Java Code Examples for org.eclipse.jface.viewers.TableViewer#addDoubleClickListener()

The following examples show how to use org.eclipse.jface.viewers.TableViewer#addDoubleClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValidateableConstantSectionPart.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * create the viewer
 */
@Override
protected TableViewer createTableViewer(Table table)
{
    // create
    TableViewer tableViewer = new TableViewer(table);
    // represent formulas in the view
    tableViewer.setContentProvider(new AssignmentContentProvider());
    // on changed selection change button enablement
    tableViewer.addSelectionChangedListener(fSelectionChangedListener);
    // edit on double-click
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event)
        {
            doEdit();
        }
    });

    return tableViewer;
}
 
Example 2
Source File: ConnectorSection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createConnectorComposite(final Composite parent) {
    final Composite buttonsComposite = getWidgetFactory()
            .createComposite(parent);
    buttonsComposite.setLayoutData(GridDataFactory.fillDefaults()
            .grab(false, true).create());
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults()
            .numColumns(1).margins(5, 0).spacing(0, 3).create());

    createAddConnectorButton(buttonsComposite);
    updateConnectorButton = createUpdateConnectorButton(buttonsComposite);
    removeConnectorButton = createRemoveConnectorButton(buttonsComposite);
    upConnectorButton = createUpConnectorButton(buttonsComposite);
    downConnectorButton = createDownConnectorButton(buttonsComposite);
    moveButton = createMoveConnectorButton(buttonsComposite);

    tableViewer = new TableViewer(parent, GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.MULTI
            | SWT.NO_FOCUS));
    getWidgetFactory().adapt(tableViewer.getTable(), false, false);
    tableViewer.getTable().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true)
                    .hint(SWT.DEFAULT, 120).create());

    tableViewer.addDoubleClickListener(this);
    tableViewer.addSelectionChangedListener(this);
    tableViewer.getTable().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                e.doit = false;
                removeSelectedConnectors();
            }
        }
    });
    tableViewer.setContentProvider(new EMFListFeatureTreeContentProvider(
            getConnectorFeature()));
    tableViewer.setLabelProvider(new StyledConnectorLabelProvider());
    tableViewer.addFilter(getViewerFilter());

}
 
Example 3
Source File: ParameterPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createParameterComposite(final Composite parent) {
    final Composite parameterComposite = getWidgetFactory().createComposite(parent);
    parameterComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    parameterComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());

    final Composite buttonsComposite = getWidgetFactory().createComposite(parameterComposite, SWT.NONE);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 3).create());
    buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).create());

    createAddParameterButton(buttonsComposite);
    updateButton = createUpdateParameterButton(buttonsComposite);
    createRemoveParameterButton(buttonsComposite);

    parameterTableViewer = new TableViewer(widgetFactory.createTable(parameterComposite,
            GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.MULTI | SWT.NO_FOCUS | SWT.H_SCROLL | SWT.V_SCROLL)));
    parameterTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create());
    getWidgetFactory().adapt(parameterTableViewer.getTable(), false, false);
    parameterTableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    parameterTableViewer.setSorter(new ViewerSorter());
    parameterTableViewer.addDoubleClickListener(this);
    parameterTableViewer.addSelectionChangedListener(this);
    parameterTableViewer.getTable().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                e.doit = false;
                remove();
            }
        }
    });

    parameterTableViewer.setContentProvider(new ArrayContentProvider());
    parameterTableViewer.setLabelProvider(new ParameterStyledLabelProvider());
    ColumnViewerToolTipSupport.enableFor(parameterTableViewer, ToolTip.RECREATE);
}
 
Example 4
Source File: SelectBestellungDialog.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
protected Control createDialogArea(Composite container){
	Composite parent = (Composite) super.createDialogArea(container);
	createMessageArea(parent);
	fTableViewer = new TableViewer(parent, getTableStyle());
	fTableViewer.setContentProvider(ArrayContentProvider.getInstance());
	
	addColumns();
	
	setComparator();
	
	fTableViewer.setInput(this);
	
	fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event){
			if (fAddCancelButton) {
				okPressed();
			}
		}
	});
	List initialSelection = getInitialElementSelections();
	if (initialSelection != null) {
		fTableViewer.setSelection(new StructuredSelection(initialSelection));
	}
	GridData gd = new GridData(GridData.FILL_BOTH);
	gd.heightHint = convertHeightInCharsToPixels(heightInChars);
	gd.widthHint = convertWidthInCharsToPixels(widthInChars);
	Table table = fTableViewer.getTable();
	table.setLayoutData(gd);
	table.setFont(container.getFont());
	table.setHeaderVisible(true);
	
	IQuery<IOrder> query = CoreModelServiceHolder.get().getQuery(IOrder.class);
	fTableViewer.setInput(query.execute());
	
	return parent;
}
 
Example 5
Source File: StatisticsView.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
private void createViewer(Composite parent) {
	viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.READ_ONLY | SWT.PUSH);
	createColumns(parent, viewer);
	final Table table = viewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

	viewer.setContentProvider(new ArrayContentProvider());
	getSite().setSelectionProvider(viewer);

	GridData gridData = new GridData();
	gridData.verticalAlignment = GridData.FILL;
	gridData.horizontalSpan = 3;
	gridData.grabExcessHorizontalSpace = true;
	gridData.grabExcessVerticalSpace = true;
	gridData.horizontalAlignment = GridData.FILL;
	viewer.getControl().setLayoutData(gridData);

	viewer.addDoubleClickListener(new IDoubleClickListener() {

		@Override
		public void doubleClick(DoubleClickEvent event) {
			ResultsUnit clickedRow = (ResultsUnit) ((IStructuredSelection) event.getSelection()).getFirstElement();
			int lineNumber = -1;
			AbstractError error = clickedRow.getError();

			if (error != null) {
				lineNumber = error.getErrorLocation().getUnit().get().getJavaSourceStartLineNumber();
			} else {
				lineNumber = clickedRow.getSeed().stmt().getUnit().get().getJavaSourceStartLineNumber();
			}

			try {
				String className = clickedRow.getClassName();
				if (className.endsWith(".java")) {
					className = className.substring(0, className.lastIndexOf("."));
				}
				ITextEditor activeEditor =
						(ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), Utils.findFileInProject(lastProject, className));
				IDocument activeDocument = activeEditor.getDocumentProvider().getDocument(activeEditor.getEditorInput());
				if (activeDocument != null) {
					IRegion lineInfo = activeDocument.getLineInformation(lineNumber - 1);
					activeEditor.selectAndReveal(lineInfo.getOffset(), lineInfo.getLength());
				}
			}
			catch (BadLocationException | CoreException e) {
				Activator.getDefault().logError(e);
			}
		}
	});
}
 
Example 6
Source File: AddOrEditSrxConfigDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建语言规则配置
 * @param tparent
 *            ;
 */
private void createLanguageGroup(Composite tparent, GridData groupData, GridLayout groupLayout) {
	Group group = new Group(tparent, SWT.BORDER);
	group.setLayoutData(groupData);
	group.setLayout(groupLayout);
	group.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.groupLang"));

	langTableViewer = new TableViewer(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
			| SWT.MULTI);
	langTable = langTableViewer.getTable();
	langTable.setLinesVisible(true);
	langTable.setHeaderVisible(true);

	GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(langTable);
	langTableViewer.setLabelProvider(new TableViewerLabelProvider());
	langTableViewer.setContentProvider(new ArrayContentProvider());

	String[] columnNames = new String[] { Messages.getString("srx.AddOrEditSrxConfigDialog.langColumnNames1"),
			Messages.getString("srx.AddOrEditSrxConfigDialog.langColumnNames2") };
	int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
	for (int i = 0; i < columnNames.length; i++) {
		TableColumn tableColumn = new TableColumn(langTable, columnAlignments[i]);
		tableColumn.setText(columnNames[i]);
		tableColumn.setWidth(50);
	}
	refreshTableWidth(langTable);

	langAddBtn = new Button(group, SWT.NONE);
	langAddBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langAddBtn"));
	setButtonLayoutData(langAddBtn);

	langEditBtn = new Button(group, SWT.NONE);
	langEditBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langEditBtn"));
	setButtonLayoutData(langEditBtn);

	langDeleteBtn = new Button(group, SWT.NONE);
	langDeleteBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langDeleteBtn"));
	setButtonLayoutData(langDeleteBtn);

	new Label(group, SWT.NONE);

	langTableViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			editLangRules();
		}
	});
}
 
Example 7
Source File: AddOrEditSrxConfigDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建映身
 * @param tparent
 *            ;
 */
private void createMapGroup(Composite tparent, GridData groupData, GridLayout groupLayout) {
	Group group = new Group(tparent, SWT.BORDER);
	group.setLayoutData(groupData);
	group.setLayout(groupLayout);
	group.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.group"));

	mapTableViewer = new TableViewer(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
			| SWT.MULTI);
	mapTable = mapTableViewer.getTable();
	mapTable.setLinesVisible(true);
	mapTable.setHeaderVisible(true);

	GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(mapTable);
	mapTableViewer.setLabelProvider(new TableViewerLabelProvider());
	mapTableViewer.setContentProvider(new ArrayContentProvider());

	String[] columnNames = new String[] { Messages.getString("srx.AddOrEditSrxConfigDialog.columnNames1"),
			Messages.getString("srx.AddOrEditSrxConfigDialog.columnNames2") };
	int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
	for (int i = 0; i < columnNames.length; i++) {
		TableColumn tableColumn = new TableColumn(mapTable, columnAlignments[i]);
		tableColumn.setText(columnNames[i]);
		tableColumn.setWidth(50);
	}
	refreshTableWidth(mapTable);

	mapAddBtn = new Button(group, SWT.NONE);
	mapAddBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapAddBtn"));
	setButtonLayoutData(mapAddBtn);

	mapEditBtn = new Button(group, SWT.NONE);
	mapEditBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapEditBtn"));
	setButtonLayoutData(mapEditBtn);

	mapDeleteBtn = new Button(group, SWT.NONE);
	mapDeleteBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapDeleteBtn"));
	setButtonLayoutData(mapDeleteBtn);

	new Label(group, SWT.NONE);

	mapTableViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			editMapRules();
		}
	});
}
 
Example 8
Source File: AddOrEditSrxConfigDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建语言规则配置
 * @param tparent
 *            ;
 */
private void createLanguageGroup(Composite tparent, GridData groupData, GridLayout groupLayout) {
	Group group = new Group(tparent, SWT.BORDER);
	group.setLayoutData(groupData);
	group.setLayout(groupLayout);
	group.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.groupLang"));

	langTableViewer = new TableViewer(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
			| SWT.MULTI);
	langTable = langTableViewer.getTable();
	langTable.setLinesVisible(true);
	langTable.setHeaderVisible(true);

	GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(langTable);
	langTableViewer.setLabelProvider(new TableViewerLabelProvider());
	langTableViewer.setContentProvider(new ArrayContentProvider());

	String[] columnNames = new String[] { Messages.getString("srx.AddOrEditSrxConfigDialog.langColumnNames1"),
			Messages.getString("srx.AddOrEditSrxConfigDialog.langColumnNames2") };
	int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
	for (int i = 0; i < columnNames.length; i++) {
		TableColumn tableColumn = new TableColumn(langTable, columnAlignments[i]);
		tableColumn.setText(columnNames[i]);
		tableColumn.setWidth(50);
	}
	refreshTableWidth(langTable);

	langAddBtn = new Button(group, SWT.NONE);
	langAddBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langAddBtn"));
	setButtonLayoutData(langAddBtn);

	langEditBtn = new Button(group, SWT.NONE);
	langEditBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langEditBtn"));
	setButtonLayoutData(langEditBtn);

	langDeleteBtn = new Button(group, SWT.NONE);
	langDeleteBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langDeleteBtn"));
	setButtonLayoutData(langDeleteBtn);

	new Label(group, SWT.NONE);

	langTableViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			editLangRules();
		}
	});
}
 
Example 9
Source File: AddOrEditSrxConfigDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建映身
 * @param tparent
 *            ;
 */
private void createMapGroup(Composite tparent, GridData groupData, GridLayout groupLayout) {
	Group group = new Group(tparent, SWT.BORDER);
	group.setLayoutData(groupData);
	group.setLayout(groupLayout);
	group.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.group"));

	mapTableViewer = new TableViewer(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
			| SWT.MULTI);
	mapTable = mapTableViewer.getTable();
	mapTable.setLinesVisible(true);
	mapTable.setHeaderVisible(true);

	GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(mapTable);
	mapTableViewer.setLabelProvider(new TableViewerLabelProvider());
	mapTableViewer.setContentProvider(new ArrayContentProvider());

	String[] columnNames = new String[] { Messages.getString("srx.AddOrEditSrxConfigDialog.columnNames1"),
			Messages.getString("srx.AddOrEditSrxConfigDialog.columnNames2") };
	int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
	for (int i = 0; i < columnNames.length; i++) {
		TableColumn tableColumn = new TableColumn(mapTable, columnAlignments[i]);
		tableColumn.setText(columnNames[i]);
		tableColumn.setWidth(50);
	}
	refreshTableWidth(mapTable);

	mapAddBtn = new Button(group, SWT.NONE);
	mapAddBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapAddBtn"));
	setButtonLayoutData(mapAddBtn);

	mapEditBtn = new Button(group, SWT.NONE);
	mapEditBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapEditBtn"));
	setButtonLayoutData(mapEditBtn);

	mapDeleteBtn = new Button(group, SWT.NONE);
	mapDeleteBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapDeleteBtn"));
	setButtonLayoutData(mapDeleteBtn);

	new Label(group, SWT.NONE);

	mapTableViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			editMapRules();
		}
	});
}
 
Example 10
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void initTable( TableViewer tableViewer, boolean leafOnly )
{
	final Table table = tableViewer.getTable( );

	GridData gd = new GridData( GridData.FILL_BOTH );
	gd.heightHint = 150;
	table.setLayoutData( gd );
	table.setToolTipText( null );

	final TableColumn column = new TableColumn( table, SWT.NONE );
	column.setWidth( 200 );
	table.getShell( ).addControlListener( new ControlAdapter( ) {

		public void controlResized( ControlEvent e )
		{
			Display.getCurrent( ).asyncExec( new Runnable( ) {

				public void run( )
				{
					if ( column != null && !column.isDisposed( ) )
					{
						column.setWidth( table.getSize( ).x > 204 ? table.getSize( ).x - 4
								: 200 );
					}
				}
			} );

		}

	} );

	table.addMouseTrackListener( new MouseTrackAdapter( ) {

		public void mouseHover( MouseEvent event )
		{
			Widget widget = event.widget;
			if ( widget == table )
			{
				Point pt = new Point( event.x, event.y );
				TableItem item = table.getItem( pt );
				if ( item == null )
				{

					table.setToolTipText( null );
				}
				else
				{
					table.setToolTipText( provider.getTooltipText( item.getData( ) ) );
				}
			}
		}
	} );

	tableViewer.setLabelProvider( new ExpressionLabelProvider( ) );
	tableViewer.setContentProvider( new TableContentProvider( tableViewer, leafOnly ) );
	tableViewer.addSelectionChangedListener( selectionListener );
	tableViewer.addDoubleClickListener( doubleClickListener );
}
 
Example 11
Source File: SelectConnectorImplementationWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(10, 10, 10, 0).create());
    table = new TableViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    table.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
    table.setContentProvider(contentProvider);
    table.setLabelProvider(labelProvider);
    table.addSelectionChangedListener(this);
    table.addDoubleClickListener(this);

    table.setInput(new Object());

    context = new EMFDataBindingContext();

    IValidator selectionValidator = value -> {
        if (value == null) {
            return ValidationStatus.error(Messages.selectAImplWarning);
        }
        return Status.OK_STATUS;
    };

    UpdateValueStrategy selectionStrategy = new UpdateValueStrategy();
    selectionStrategy.setBeforeSetValidator(selectionValidator);

    context.bindValue(ViewersObservables.observeSingleSelection(table),
            PojoProperties.value(SelectConnectorImplementationWizardPage.class, "selectedImplementation").observe(this),
            selectionStrategy, null);

    removeButton = new Button(composite, SWT.PUSH);
    removeButton.setText(Messages.remove);
    removeButton.setLayoutData(GridDataFactory.swtDefaults().hint(85, SWT.DEFAULT).create());
    removeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (selectedImplementation != null) {
                String fileName = URI.decode(selectedImplementation.eResource().getURI().lastSegment());
                IRepositoryFileStore file = implStore.getChild(fileName, true);
                file.delete();
                refresh();
            }
        }
    });
    removeButton.setEnabled(false);

    pageSupport = WizardPageSupport.create(this, context);
    setControl(composite);
}
 
Example 12
Source File: ImportFileWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected Composite doCreateControls(Composite parent, DataBindingContext dbc) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 0).extendedMargins(10, 10, 10, 0).create());

    final Group transfoGroup = new Group(mainComposite, SWT.NONE);
    transfoGroup.setText(Messages.fileFormat);
    transfoGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create());
    transfoGroup.setLayout(new GridLayout(2, true));

    final TableViewer importList = new TableViewer(transfoGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    importList.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    importList.setContentProvider(ArrayContentProvider.getInstance());
    importList.setComparator(new ImporterPriorityDisplayComparator());
    importList.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object item) {
            return ((ImporterFactory) item).getName();
        }
    });

    final List<ImporterFactory> allAvailableImports = ImporterRegistry.getInstance().getAllAvailableImports();
    importList.setInput(allAvailableImports);

    final IObservableValue importerFactoryObservable = PojoObservables.observeValue(importFileData, "importerFactory");
    importerFactoryObservable.setValue(importList.getElementAt(0));

    dbc.bindValue(ViewersObservables.observeSingleSelection(importList), importerFactoryObservable,
            updateValueStrategy().withValidator(mandatoryValidator(Messages.fileFormat)).create(),
            updateValueStrategy().create());

    final Composite descComposite = new Composite(transfoGroup, SWT.NONE);
    descComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).spacing(5, 3).create());
    descComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());

    final Label importDescriptionLabel = new Label(descComposite, SWT.NONE);
    importDescriptionLabel.setText(Messages.importDescriptionLabel);

    final Label descriptionImage = new Label(descComposite, SWT.NONE);
    descriptionImage.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.FILL).create());

    final Label separator = new Label(descComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final Label descriptionLabel = new Label(descComposite, SWT.WRAP);
    descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().hint(230, SWT.DEFAULT).grab(false, true).create());

    updatePanel(importFileData.getImporterFactory(), descriptionImage, descriptionLabel);

    doCreateAdditionalControls(mainComposite, dbc);

    final Label fileLabel = new Label(mainComposite, SWT.NONE);
    fileLabel.setText(Messages.selectFileToImport);

    final Text text = new Text(mainComposite, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final IObservableValue filePathObservable = PojoObservables.observeValue(importFileData, "filePath");
    dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), filePathObservable,
            updateValueStrategy().withValidator(pathValidator(Messages.selectFileToImport).overrideMessage(Messages.invalidFilePath)).create(),
            updateValueStrategy().create());

    final Button browseButton = new Button(mainComposite, SWT.PUSH);
    browseButton.setText(Messages.browseButton_label);
    browseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final String file = openFileDialog();
            if (file != null) {
                text.setText(file);
                if (new File(file).exists()) {
                    savePath(new File(file).getParentFile().getAbsolutePath());
                }
            }
        }
    });

    importList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updatePanel((ImporterFactory) importerFactoryObservable.getValue(), descriptionImage, descriptionLabel);
        }

    });
    importList.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent arg0) {
            updatePanel((ImporterFactory) importerFactoryObservable.getValue(), descriptionImage, descriptionLabel);
            browseButton.notifyListeners(SWT.Selection, null);
        }
    });

    return mainComposite;
}
 
Example 13
Source File: AbstractDataSection.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void createDataComposite(final Composite parent) {
    createViewerHeaderLabel(parent);

    final Composite buttonsComposite = getWidgetFactory().createComposite(parent, SWT.NONE);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 3).create());
    buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).create());

    createAddDataButton(buttonsComposite);
    updateDataButton = createEditDataButton(buttonsComposite);
    removeDataButton = createRemoveDataButton(buttonsComposite);
    promoteDataButton = createMoveDataButton(buttonsComposite);

    dataTableViewer = new TableViewer(
            getWidgetFactory().createTable(parent, GTKStyleHandler
                    .removeBorderFlag(SWT.BORDER | SWT.MULTI | SWT.NO_FOCUS | SWT.H_SCROLL | SWT.V_SCROLL)));
    dataTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create());
    dataTableViewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_PROCESS_DATA_LIST);
    dataTableViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    dataTableViewer.setSorter(new ViewerSorter());
    dataTableViewer.addDoubleClickListener(this);
    dataTableViewer.getTable().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                e.doit = false;
                removeData((IStructuredSelection) dataTableViewer.getSelection());
            }
        }
    });
    final ObservableListContentProvider contentProvider = new ObservableListContentProvider();
    dataTableViewer.setContentProvider(contentProvider);
    dataTableViewer.addFilter(hideBusinessObjectData());
    // create the label provider including monitoring
    // of the changes of the labels
    final IObservableSet knownElements = contentProvider.getKnownElements();
    final IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements, new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME,
            ProcessPackage.Literals.DATA__DATA_TYPE });
    dataTableViewer.setLabelProvider(new DataStyledTreeLabelProvider(labelMaps));

}
 
Example 14
Source File: CodeElementStatisticsComposite.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
private void createContent(){
	setLayout(new GridLayout(1, false));
	
	title = new Label(this, SWT.NONE);
	title.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
	
	viewer = new TableViewer(this,
		SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
	viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element){
			if (element instanceof PersistentObject) {
				return ((PersistentObject) element).getLabel();
			} else if (element instanceof Identifiable) {
				return ((Identifiable) element).getLabel();
			}
			return super.getText(element);
		}
	});
	
	MenuManager menu = new MenuManager();
	menu.setRemoveAllWhenShown(true);
	menu.addMenuListener(new IMenuListener() {
		public void menuAboutToShow(IMenuManager manager){
			manager.add(new ClearStatisticAction());
		}
	});
	viewer.getControl().setMenu(menu.createContextMenu(viewer.getControl()));
	viewer.addDoubleClickListener(new IDoubleClickListener() {
		@Override
		public void doubleClick(DoubleClickEvent event){
			IStructuredSelection selection = viewer.getStructuredSelection();
			if (selection != null && !selection.isEmpty()) {
				ICodeSelectorTarget target =
					CodeSelectorHandler.getInstance().getCodeSelectorTarget();
				if (target != null) {
					for (Object selected : selection.toList()) {
						target.codeSelected(selected);
					}
				}
			}
		}
	});
	new GenericObjectDragSource(viewer);
}
 
Example 15
Source File: DocumentSelectDialog.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	ret.setLayout(new GridLayout());
	if ((type & TEMPLATE) != 0) {
		new Label(ret, SWT.NONE).setText(Messages.DocumentSelectDialog_subject); //$NON-NLS-1$
		tBetreff = SWTHelper.createText(ret, 1, SWT.NONE);
		new Label(ret, SWT.SEPARATOR | SWT.HORIZONTAL);
	}
	tv = new TableViewer(ret, SWT.V_SCROLL);
	tv.setContentProvider(new IStructuredContentProvider() {
		
		public Object[] getElements(Object inputElement){
			Query<Brief> qbe = new Query<Brief>(Brief.class);
			if (type == TYPE_LOAD_DOCUMENT) {
				qbe.add(Brief.FLD_TYPE, Query.NOT_EQUAL, Brief.TEMPLATE);
			} else {
				String sys = type == TYPE_LOAD_SYSTEMPLATE ? Query.EQUALS : Query.NOT_EQUAL;
				qbe.add(Brief.FLD_TYPE, Query.EQUALS, Brief.TEMPLATE);
				qbe.add(Brief.FLD_KONSULTATION_ID, sys, "SYS"); //$NON-NLS-1$
				qbe.startGroup();
				qbe.add(Brief.FLD_DESTINATION_ID, Query.EQUALS, CoreHub.actMandant.getId());
				qbe.or();
				qbe.add(Brief.FLD_DESTINATION_ID, Query.EQUALS, StringTool.leer);
				qbe.endGroup();
			}
			qbe.and();
			qbe.add("deleted", Query.NOT_EQUAL, StringConstants.ONE); //$NON-NLS-1$
			
			if (type != TYPE_LOAD_DOCUMENT) {
				qbe.orderBy(false, Brief.FLD_SUBJECT);
			} else {
				qbe.orderBy(false, Brief.FLD_DATE);
			}
			List<Brief> l = qbe.execute();
			return l.toArray();
		}
		
		public void dispose(){}
		
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput){}
	});
	tv.setLabelProvider(new MyLabelProvider());
	makeActions();
	menu = new MenuManager();
	menu.setRemoveAllWhenShown(true);
	menu.addMenuListener(new IMenuListener() {
		public void menuAboutToShow(IMenuManager manager){
			menu.add(editNameAction);
			if (type == TYPE_LOAD_TEMPLATE) {
				// only show in load template dialog
				Brief sel =
					(Brief) ((IStructuredSelection) tv.getSelection()).getFirstElement();
				if (getDontAskForAddresseeForThisTemplate(sel)) {
					menu.add(editDontAskForAddressee);
					editDontAskForAddressee.setChecked(false);
				} else {
					menu.add(editDontAskForAddressee);
					editDontAskForAddressee.setChecked(true);
				}
			}
			menu.add((type & TEMPLATE) != 0 ? deleteTemplateAction : deleteTextAction);
		}
	});
	tv.getControl().setMenu(menu.createContextMenu(tv.getControl()));
	tv.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	tv.setInput(this);
	tv.addDoubleClickListener(new IDoubleClickListener() {
		@Override
		public void doubleClick(DoubleClickEvent event){
			okPressed();
		}
	});
	return ret;
}