List of usage examples for org.eclipse.jface.viewers TableViewer setContentProvider
@Override public void setContentProvider(IContentProvider provider)
AbstractTableViewer
. From source file:io.aos.jface.expl.explorer03.Explorer.java
License:Apache License
protected Control createContents(Composite parent) { getShell().setText("JFace File Explorer"); SashForm sash_form = new SashForm(parent, SWT.HORIZONTAL | SWT.NULL); TreeViewer tv = new TreeViewer(sash_form); tv.setContentProvider(new FileTreeContentProvider()); tv.setLabelProvider(new FileTreeLabelProvider()); tv.setInput(new File("C:\\")); tv.addFilter(new AllowOnlyFoldersFilter()); final TableViewer tbv = new TableViewer(sash_form, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); tbv.setContentProvider(new FileTableContentProvider()); tbv.setLabelProvider(new FileTableLabelProvider()); tbv.setSorter(new FileSorter()); TableColumn column = new TableColumn(tbv.getTable(), SWT.LEFT); column.setText("Name"); column.setWidth(200);//from ww w. jav a2 s.c om column = new TableColumn(tbv.getTable(), SWT.RIGHT); column.setText("Size"); column.setWidth(100); tbv.getTable().setHeaderVisible(true); tv.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); Object selected_file = selection.getFirstElement(); tbv.setInput(selected_file); } }); tbv.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); setStatus("Number of items selected is " + selection.size()); } }); return sash_form; }
From source file:it.eng.spagobi.meta.editor.physical.wizards.inline.NewColumnsWizardPage.java
License:Mozilla Public License
@Override public void createControl(Composite parent) { // Main composite Composite composite = new Composite(parent, SWT.FILL); GridLayout gl = new GridLayout(); gl.numColumns = 1;/* www .ja v a2s .com*/ gl.makeColumnsEqualWidth = true; composite.setLayout(gl); // Columns Group Group columnsGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); columnsGroup.setText(RL.getString("physical.editor.wizard.update.newcolumns.tables.label")); FillLayout flColumns = new FillLayout(); GridData gd2 = new GridData(GridData.FILL_BOTH); columnsGroup.setLayout(flColumns); columnsGroup.setLayoutData(gd2); final TableViewer tableViewer = new TableViewer(columnsGroup); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setLabelProvider(new ArrayLabelProvider()); tableViewer.setInput(missingColumnsNames); // Important: Setting page control setControl(composite); }
From source file:it.eng.spagobi.meta.editor.physical.wizards.inline.RemovedElementsWizardPage.java
License:Mozilla Public License
@Override public void createControl(Composite parent) { // Main composite Composite composite = new Composite(parent, SWT.FILL); GridLayout gl = new GridLayout(); gl.numColumns = 1;//from www . ja va2s .com gl.makeColumnsEqualWidth = true; composite.setLayout(gl); // Columns Group Group columnsGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); columnsGroup.setText(RL.getString("physical.editor.wizard.update.removedelements.group.label")); FillLayout flColumns = new FillLayout(); GridData gd2 = new GridData(GridData.FILL_BOTH); columnsGroup.setLayout(flColumns); columnsGroup.setLayoutData(gd2); TableViewer tableViewer = new TableViewer(columnsGroup); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setLabelProvider(new ArrayLabelProvider()); tableViewer.setInput(removedElementsNames); Button automaticDeleteCheck = new Button(composite, SWT.CHECK); automaticDeleteCheck .setText(RL.getString("physical.editor.wizard.update.removedelements.autodelete.label")); automaticDeleteCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (((Button) event.widget).getSelection()) { // checked automaticDelete = true; } else { // unchecked automaticDelete = false; } } }); if (removedElementsNames.isEmpty()) { // disable checkbox automaticDeleteCheck.setEnabled(false); } // Important: Setting page control setControl(composite); }
From source file:monolipse.ui.views.ReferenceContainerPropertyPage.java
License:Open Source License
private TableViewer createSelectedLibrariesViewer(Composite control) { final TableViewer viewer = new TableViewer(control, SWT.BORDER); Table table = viewer.getTable();/*from w ww .j ava 2 s. c o m*/ addColumn(table, "Assembly", 250); addColumn(table, "Type", 150); table.setHeaderVisible(true); viewer.setContentProvider(new SelectedReferencesContentProvider()); viewer.setLabelProvider(new SelectedReferencesLabelProvider()); viewer.setInput(getAssemblySource()); table.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.DEL) { List<?> selected = ((IStructuredSelection) _selectedViewer.getSelection()).toList(); _references.removeAll(selected); _selectedViewer.refresh(); } } }); return viewer; }
From source file:monolipse.ui.views.ReferenceContainerPropertyPage.java
License:Open Source License
private TableViewer createGACBrowser(Composite tabFolder) { TableViewer viewer = new TableViewer(tabFolder, SWT.FULL_SELECTION); Table table = viewer.getTable();/*from ww w .j a va 2s . c om*/ addColumn(table, "Name", 150); addColumn(table, "Version", 150); addColumn(table, "Public Key", 100); table.setHeaderVisible(true); viewer.setContentProvider(new GACContentProvider()); viewer.setLabelProvider(new GACLabelProvider()); viewer.addDoubleClickListener(_doubleClickListener); return viewer; }
From source file:name.neilbartlett.eclipse.bundlemonitor.views.bundle.BundlePropertiesDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); setTitle("Bundle Properties"); Table table = new Table(dialogArea, SWT.FULL_SELECTION); table.setLinesVisible(true);//from w w w .ja v a2 s .co m table.setHeaderVisible(true); TableColumn col; col = new TableColumn(table, SWT.NONE); col.setWidth(300); col.setText("Name"); col = new TableColumn(table, SWT.NONE); col.setWidth(400); col.setText("Value"); TableViewer viewer = new TableViewer(table); viewer.setContentProvider(new DictionaryContentProvider()); viewer.setLabelProvider(new DictionaryEntryTableLabelProvider()); viewer.setInput(bundle.getHeaders()); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); return dialogArea; }
From source file:net.bioclipse.qsar.ui.editors.InformationPage.java
License:Open Source License
private void createReferenceTab(FormToolkit toolkit) { CTabItem item = new CTabItem(tabFolder, SWT.NULL); item.setText("References"); Composite tabContent = toolkit.createComposite(tabFolder); item.setControl(tabContent);//ww w . j a v a2 s. co m tabContent.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(); tabContent.setLayout(layout); layout.numColumns = 2; layout.marginWidth = 0; TableViewer refViewer = new TableViewer(tabContent, SWT.BORDER | SWT.MULTI); Table refTable = refViewer.getTable(); toolkit.adapt(refTable, true, true); GridData gd = new GridData(GridData.FILL_BOTH); gd.verticalSpan = 2; refTable.setLayoutData(gd); refTable.setHeaderVisible(true); // molTable.setLinesVisible(true); toolkit.adapt(refTable, true, true); //Add name columns TableLayout tableLayout = new TableLayout(); refTable.setLayout(tableLayout); TableViewerColumn ixcol = new TableViewerColumn(refViewer, SWT.BORDER); ixcol.getColumn().setText("Title"); tableLayout.addColumnData(new ColumnPixelData(150)); TableViewerColumn col = new TableViewerColumn(refViewer, SWT.BORDER); col.getColumn().setText("Authors"); tableLayout.addColumnData(new ColumnPixelData(100)); col = new TableViewerColumn(refViewer, SWT.BORDER); col.getColumn().setText("journal"); tableLayout.addColumnData(new ColumnPixelData(100)); col = new TableViewerColumn(refViewer, SWT.BORDER); col.getColumn().setText("Year"); tableLayout.addColumnData(new ColumnPixelData(50)); col = new TableViewerColumn(refViewer, SWT.BORDER); col.getColumn().setText("URL"); tableLayout.addColumnData(new ColumnPixelData(100)); Button btnAdd = toolkit.createButton(tabContent, "Add...", SWT.PUSH); btnAdd.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { // addRef(); } }); GridData gd2 = new GridData(); gd2.verticalAlignment = SWT.BEGINNING; gd2.widthHint = 60; btnAdd.setLayoutData(gd2); Button btnDel = toolkit.createButton(tabContent, "Remove", SWT.PUSH); btnDel.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { // deleteRef(); } }); gd2 = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd2.widthHint = 60; btnDel.setLayoutData(gd2); // The content provider is responsible to handle add and // remove notification for the Person#address EList ObservableListContentProvider provider = new ObservableListContentProvider(); refViewer.setContentProvider(provider); // The label provider in turn handles the addresses // The EStructuralFeature[] defines which fields get shown // in the TableViewer columns IObservableSet knownElements = provider.getKnownElements(); IObservableMap[] observeMaps = EMFEditObservables.observeMaps(editingDomain, knownElements, new EStructuralFeature[] { BibtexmlPackage.Literals.ARTICLE_TYPE__AUTHOR, BibtexmlPackage.Literals.BIB_TE_XML_ENTRIES_CLASS__ARTICLE, BibtexmlPackage.Literals.BIB_TE_XML_ENTRY_TYPE__ID, BibtexmlPackage.Literals.ARTICLE_TYPE__YEAR, BibtexmlPackage.Literals.ARTICLE_TYPE__URL }); ObservableMapLabelProvider labelProvider = new ObservableQSARLabelProvider(observeMaps); refViewer.setLabelProvider(labelProvider); QsarType qsarModel = ((QsarEditor) getEditor()).getQsarModel(); EObject entryList = qsarModel.getMetadata(); // Set the Viewer's input refViewer.setInput(EMFEditObservables.observeList(Realm.getDefault(), editingDomain, entryList, QsarPackage.Literals.METADATA_TYPE__REFERENCE)); }
From source file:net.bioclipse.ui.dialogs.SearchDialog.java
License:Open Source License
private void createWhereToSearchGroup(final Group outerGroup, final String[] names) { final Group group = new Group(outerGroup, SWT.SHADOW_NONE); group.setText("Where to Search"); group.setLayout(new RowLayout(SWT.VERTICAL)); TableViewer table = new TableViewer(group, SWT.CHECK); table.setContentProvider(new IStructuredContentProvider() { String[] content;/* www . ja va 2s.co m*/ public Object[] getElements(Object inputElement) { return content; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { content = (String[]) newInput; } }); table.setInput(names); }
From source file:net.efano.sandbox.jface.snippets.TableViewerColors.java
License:Open Source License
/** * @param args//from ww w. j a v a 2 s .c om */ public static void main(String[] args) { final List<Person> persons = new ArrayList<Person>(); persons.add(new Person("Fiona Apple", Person.FEMALE)); persons.add(new Person("Elliot Smith", Person.MALE)); persons.add(new Person("Diana Krall", Person.FEMALE)); persons.add(new Person("David Gilmour", Person.MALE)); final Display display = new Display(); Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { public void run() { Shell shell = new Shell(display); shell.setText("Gender Bender"); shell.setLayout(new GridLayout()); Table table = new Table(shell, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, false); gd_table.heightHint = 352; table.setLayoutData(gd_table); table.setHeaderVisible(true); table.setLinesVisible(true); TableColumn column = new TableColumn(table, SWT.NONE); column.setText("No"); column.setWidth(20); column = new TableColumn(table, SWT.NONE); column.setText("Name"); column.setWidth(100); final TableViewer viewer = new TableViewer(table); IObservableList observableList = Observables.staticObservableList(persons); ObservableListContentProvider contentProvider = new ObservableListContentProvider(); viewer.setContentProvider(contentProvider); // this does not have to correspond to the columns in the table, // we just list all attributes that affect the table content. IObservableSet oset = contentProvider.getKnownElements(); IObservableMap[] attributes = BeansObservables.observeMaps(contentProvider.getKnownElements(), Person.class, new String[] { "name", "gender" }); class ColorLabelProvider extends ObservableMapLabelProvider implements ITableColorProvider { Color male = display.getSystemColor(SWT.COLOR_BLUE); Color female = new Color(display, 255, 192, 203); ColorLabelProvider(IObservableMap[] attributes) { super(attributes); } // to drive home the point that attributes does not have to // match // the columns // in the table, we change the column text as follows: @Override public String getColumnText(Object element, int index) { if (index == 0) { return Integer.toString(persons.indexOf(element) + 1); } return ((Person) element).getName(); } @Override public Color getBackground(Object element, int index) { return null; } @Override public Color getForeground(Object element, int index) { if (index == 0) return null; Person person = (Person) element; return (person.getGender() == Person.MALE) ? male : female; } @Override public void dispose() { super.dispose(); female.dispose(); } } viewer.setLabelProvider(new ColorLabelProvider(attributes)); viewer.setInput(observableList); table.getColumn(0).pack(); Button button = new Button(shell, SWT.PUSH); button.setText("Toggle Gender"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if (selection != null && !selection.isEmpty()) { Person person = (Person) selection.getFirstElement(); person.setGender((person.getGender() == Person.MALE) ? Person.FEMALE : Person.MALE); } } }); shell.setSize(380, 713); Button btnAddRow = new Button(shell, SWT.NONE); btnAddRow.setText("Add Row"); newRowNameText = new Text(shell, SWT.BORDER); newRowNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Composite composite = new Composite(shell, SWT.NONE); composite.setLayout(new FillLayout(SWT.HORIZONTAL)); GridData gd_composite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_composite.widthHint = 129; gd_composite.heightHint = 26; composite.setLayoutData(gd_composite); Button maleRadioButton = new Button(composite, SWT.RADIO); maleRadioButton.setText("Male"); Button femaleRadioButton = new Button(composite, SWT.RADIO); femaleRadioButton.setText("Female"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }); display.dispose(); }
From source file:net.enilink.komma.edit.ui.celleditor.PropertyEditorDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite contents = (Composite) super.createDialogArea(parent); GridLayout contentsGridLayout = (GridLayout) contents.getLayout(); contentsGridLayout.numColumns = 3;//from w w w .j a va2 s . c o m GridData contentsGridData = (GridData) contents.getLayoutData(); contentsGridData.horizontalAlignment = SWT.FILL; contentsGridData.verticalAlignment = SWT.FILL; Text patternText = null; if (choiceOfValues != null) { Group filterGroupComposite = new Group(contents, SWT.NONE); filterGroupComposite.setText(KommaEditUIPlugin.INSTANCE.getString("_UI_Choices_pattern_group")); filterGroupComposite.setLayout(new GridLayout(2, false)); filterGroupComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 3, 1)); Label label = new Label(filterGroupComposite, SWT.NONE); label.setText(KommaEditUIPlugin.INSTANCE.getString("_UI_Choices_pattern_label")); patternText = new Text(filterGroupComposite, SWT.BORDER); patternText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); } Composite choiceComposite = new Composite(contents, SWT.NONE); { GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.horizontalAlignment = SWT.END; choiceComposite.setLayoutData(data); GridLayout layout = new GridLayout(); data.horizontalAlignment = SWT.FILL; layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 1; choiceComposite.setLayout(layout); } Label choiceLabel = new Label(choiceComposite, SWT.NONE); choiceLabel.setText(choiceOfValues == null ? KommaEditUIPlugin.INSTANCE.getString("_UI_Value_label") : KommaEditUIPlugin.INSTANCE.getString("_UI_Choices_label")); GridData choiceLabelGridData = new GridData(); choiceLabelGridData.verticalAlignment = SWT.FILL; choiceLabelGridData.horizontalAlignment = SWT.FILL; choiceLabel.setLayoutData(choiceLabelGridData); final Table choiceTable = choiceOfValues == null ? null : new Table(choiceComposite, SWT.MULTI | SWT.BORDER); if (choiceTable != null) { GridData choiceTableGridData = new GridData(); choiceTableGridData.widthHint = Display.getCurrent().getBounds().width / 5; choiceTableGridData.heightHint = Display.getCurrent().getBounds().height / 3; choiceTableGridData.verticalAlignment = SWT.FILL; choiceTableGridData.horizontalAlignment = SWT.FILL; choiceTableGridData.grabExcessHorizontalSpace = true; choiceTableGridData.grabExcessVerticalSpace = true; choiceTable.setLayoutData(choiceTableGridData); } final TableViewer choiceTableViewer = choiceOfValues == null ? null : new TableViewer(choiceTable); if (choiceTableViewer != null) { choiceTableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); choiceTableViewer.setLabelProvider(labelProvider); final PatternFilter filter = new PatternFilter() { @Override protected boolean isParentMatch(Viewer viewer, Object element) { return viewer instanceof AbstractTreeViewer && super.isParentMatch(viewer, element); } }; choiceTableViewer.addFilter(filter); assert patternText != null; patternText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { filter.setPattern(((Text) e.widget).getText()); choiceTableViewer.refresh(); } }); choiceTableViewer.setInput(new ItemProvider(choiceOfValues)); } // We use multi even for a single line because we want to respond to the // enter key. int style = multiLine ? SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER : SWT.MULTI | SWT.BORDER; final Text choiceText = choiceOfValues == null ? new Text(choiceComposite, style) : null; if (choiceText != null) { GridData choiceTextGridData = new GridData(); choiceTextGridData.widthHint = Display.getCurrent().getBounds().width / 5; choiceTextGridData.verticalAlignment = SWT.BEGINNING; choiceTextGridData.horizontalAlignment = SWT.FILL; choiceTextGridData.grabExcessHorizontalSpace = true; if (multiLine) { choiceTextGridData.verticalAlignment = SWT.FILL; choiceTextGridData.grabExcessVerticalSpace = true; } choiceText.setLayoutData(choiceTextGridData); } Composite controlButtons = new Composite(contents, SWT.NONE); GridData controlButtonsGridData = new GridData(); controlButtonsGridData.verticalAlignment = SWT.FILL; controlButtonsGridData.horizontalAlignment = SWT.FILL; controlButtons.setLayoutData(controlButtonsGridData); GridLayout controlsButtonGridLayout = new GridLayout(); controlButtons.setLayout(controlsButtonGridLayout); new Label(controlButtons, SWT.NONE); final Button addButton = new Button(controlButtons, SWT.PUSH); addButton.setText(KommaEditUIPlugin.INSTANCE.getString("_UI_Add_label")); GridData addButtonGridData = new GridData(); addButtonGridData.verticalAlignment = SWT.FILL; addButtonGridData.horizontalAlignment = SWT.FILL; addButton.setLayoutData(addButtonGridData); final Button removeButton = new Button(controlButtons, SWT.PUSH); removeButton.setText(KommaEditUIPlugin.INSTANCE.getString("_UI_Remove_label")); GridData removeButtonGridData = new GridData(); removeButtonGridData.verticalAlignment = SWT.FILL; removeButtonGridData.horizontalAlignment = SWT.FILL; removeButton.setLayoutData(removeButtonGridData); Label spaceLabel = new Label(controlButtons, SWT.NONE); GridData spaceLabelGridData = new GridData(); spaceLabelGridData.verticalSpan = 2; spaceLabel.setLayoutData(spaceLabelGridData); final Button upButton = new Button(controlButtons, SWT.PUSH); upButton.setText(KommaEditUIPlugin.INSTANCE.getString("_UI_Up_label")); GridData upButtonGridData = new GridData(); upButtonGridData.verticalAlignment = SWT.FILL; upButtonGridData.horizontalAlignment = SWT.FILL; upButton.setLayoutData(upButtonGridData); final Button downButton = new Button(controlButtons, SWT.PUSH); downButton.setText(KommaEditUIPlugin.INSTANCE.getString("_UI_Down_label")); GridData downButtonGridData = new GridData(); downButtonGridData.verticalAlignment = SWT.FILL; downButtonGridData.horizontalAlignment = SWT.FILL; downButton.setLayoutData(downButtonGridData); Composite propertyComposite = new Composite(contents, SWT.NONE); { GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.horizontalAlignment = SWT.END; propertyComposite.setLayoutData(data); GridLayout layout = new GridLayout(); data.horizontalAlignment = SWT.FILL; layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 1; propertyComposite.setLayout(layout); } Label propertyLabel = new Label(propertyComposite, SWT.NONE); propertyLabel.setText(KommaEditUIPlugin.INSTANCE.getString("_UI_Feature_label")); GridData propertyLabelGridData = new GridData(); propertyLabelGridData.horizontalSpan = 2; propertyLabelGridData.horizontalAlignment = SWT.FILL; propertyLabelGridData.verticalAlignment = SWT.FILL; propertyLabel.setLayoutData(propertyLabelGridData); final Table propertyTable = new Table(propertyComposite, SWT.MULTI | SWT.BORDER); GridData propertyTableGridData = new GridData(); propertyTableGridData.widthHint = Display.getCurrent().getBounds().width / 5; propertyTableGridData.heightHint = Display.getCurrent().getBounds().height / 3; propertyTableGridData.verticalAlignment = SWT.FILL; propertyTableGridData.horizontalAlignment = SWT.FILL; propertyTableGridData.grabExcessHorizontalSpace = true; propertyTableGridData.grabExcessVerticalSpace = true; propertyTable.setLayoutData(propertyTableGridData); final TableViewer propertyTableViewer = new TableViewer(propertyTable); propertyTableViewer.setContentProvider(contentProvider); propertyTableViewer.setLabelProvider(labelProvider); propertyTableViewer.setInput(values); if (!values.getChildren().isEmpty()) { propertyTableViewer.setSelection(new StructuredSelection(values.getChildren().get(0))); } if (choiceTableViewer != null) { choiceTableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (addButton.isEnabled()) { addButton.notifyListeners(SWT.Selection, null); } } }); propertyTableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (removeButton.isEnabled()) { removeButton.notifyListeners(SWT.Selection, null); } } }); } if (choiceText != null) { choiceText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { if (!multiLine && (event.character == '\r' || event.character == '\n')) { try { Object value = KommaUtil.convertToRange(object.getEntityManager(), classes, choiceText.getText()); values.getChildren().add(value); choiceText.setText(""); propertyTableViewer.setSelection(new StructuredSelection(value)); event.doit = false; } catch (RuntimeException exception) { // Ignore } } else if (event.character == '\33') { choiceText.setText(""); event.doit = false; } } }); } upButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { IStructuredSelection selection = (IStructuredSelection) propertyTableViewer.getSelection(); int minIndex = 0; for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object value = i.next(); int index = values.getChildren().indexOf(value); values.getChildren().move(Math.max(index - 1, minIndex++), value); } } }); downButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { IStructuredSelection selection = (IStructuredSelection) propertyTableViewer.getSelection(); int maxIndex = values.getChildren().size() - selection.size(); for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object value = i.next(); int index = values.getChildren().indexOf(value); values.getChildren().move(Math.min(index + 1, maxIndex++), value); } } }); addButton.addSelectionListener(new SelectionAdapter() { // event is null when choiceTableViewer is double clicked @Override public void widgetSelected(SelectionEvent event) { if (choiceTableViewer != null) { IStructuredSelection selection = (IStructuredSelection) choiceTableViewer.getSelection(); for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object value = i.next(); if (!values.getChildren().contains(value)) { values.getChildren().add(value); } } propertyTableViewer.setSelection(selection); } else if (choiceText != null) { try { Object value = KommaUtil.convertToRange(object.getEntityManager(), classes, choiceText.getText()); values.getChildren().add(value); choiceText.setText(""); propertyTableViewer.setSelection(new StructuredSelection(value)); } catch (RuntimeException exception) { // Ignore } } } }); removeButton.addSelectionListener(new SelectionAdapter() { // event is null when featureTableViewer is double clicked @Override public void widgetSelected(SelectionEvent event) { IStructuredSelection selection = (IStructuredSelection) propertyTableViewer.getSelection(); Object firstValue = null; for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object value = i.next(); if (firstValue == null) { firstValue = value; } values.getChildren().remove(value); } if (!values.getChildren().isEmpty()) { propertyTableViewer.setSelection(new StructuredSelection(values.getChildren().get(0))); } if (choiceTableViewer != null) { choiceTableViewer.setSelection(selection); } else if (choiceText != null) { if (firstValue != null) { String value = ModelUtil.getLabel(firstValue); choiceText.setText(value); } } } }); return contents; }