List of usage examples for org.eclipse.jface.viewers ComboBoxViewerCellEditor ComboBoxViewerCellEditor
public ComboBoxViewerCellEditor(Composite parent, int style)
From source file:com.amitinside.e4.rcp.todo.parts.EMFTableViewerBindingPart.java
License:Apache License
@PostConstruct public void createControl(Composite parent) { final FormToolkit toolkit = new FormToolkit(parent.getDisplay()); final Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setText("Section 1 for demonstration"); //$NON-NLS-1$ section.setDescription("This demonstrates the usage of section"); final Composite client = toolkit.createComposite(section, SWT.WRAP); t = new TableViewerBuilder(client); t.createColumn("Summary").bindToProperty(TodoPackage.Literals.TODO__SUMMARY.getName()).makeEditable() .build();/*from ww w . j a v a 2s.co m*/ t.createColumn("Description").makeEditable().setPixelWidth(300).useAsDefaultSortColumn() .bindToProperty(TodoPackage.Literals.TODO__DESCRIPTION.getName()).build(); t.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) t.getTableViewer().getSelection(); selectionService.setSelection(selection.getFirstElement()); } }); final ComboBoxViewerCellEditor cityComboEditor = new ComboBoxViewerCellEditor(t.getTable(), SWT.READ_ONLY); cityComboEditor.setContentProvider(ArrayContentProvider.getInstance()); cityComboEditor.setInput(RandomData.CITIES); t.createColumn("Cities").makeEditable(cityComboEditor) .bindToProperty(TodoPackage.Literals.TODO__NOTE.getName()).build(); toolkit.adapt(t.getTable(), true, true); t.getTableViewer().setContentProvider(new AdapterFactoryContentProvider(composedFactory)); t.getTableViewer().setLabelProvider(new AdapterFactoryLabelProvider(composedFactory)); t.getTableViewer().setInput(service.getTodos()); section.setClient(client); }
From source file:com.amitinside.e4.rcp.todo.parts.SampleUIAdapt.java
License:Apache License
@PostConstruct public void createControl(Composite parent) { System.out.println("NAME=====>" + name); System.out.println(context.get("test")); final FormToolkit toolkit = new FormToolkit(parent.getDisplay()); // Creating the Screen final Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setText("Section 1 for demonstration"); //$NON-NLS-1$ section.setDescription("This demonstrates the usage of section"); // Composite for storing the data final Composite client = toolkit.createComposite(section, SWT.WRAP); t = new TableViewerBuilder(client); t.createColumn("Summary").bindToProperty(TodoPackage.Literals.TODO__SUMMARY.getName()).makeEditable() .build();//from w ww. jav a 2s . c o m t.createColumn("Description").makeEditable().setPixelWidth(300).useAsDefaultSortColumn() .bindToProperty(TodoPackage.Literals.TODO__DESCRIPTION.getName()).build(); t.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) t.getTableViewer().getSelection(); selectionService.setSelection(selection.getFirstElement()); } }); final ComboBoxViewerCellEditor cityComboEditor = new ComboBoxViewerCellEditor(t.getTable(), SWT.READ_ONLY); cityComboEditor.setContentProvider(ArrayContentProvider.getInstance()); cityComboEditor.setLabelProvider(new LabelProvider()); cityComboEditor.setInput(RandomData.CITIES); t.createColumn("Notes").makeEditable(cityComboEditor) .bindToProperty(TodoPackage.Literals.TODO__NOTE.getName()).build(); toolkit.adapt(t.getTable(), true, true); t.getTableViewer().setContentProvider(ArrayContentProvider.getInstance()); list.addAll(service.getTodos()); list.addListChangeListener(listener); t.getTableViewer().setInput(list); section.setClient(client); }
From source file:com.ecfeed.ui.common.TestDataValueEditingSupport.java
License:Open Source License
public TestDataValueEditingSupport(MethodNode method, TableViewer viewer, ITestDataEditorListener setValueListener) { super(viewer); fViewer = viewer;//from www.jav a2 s. co m fSetValueListener = setValueListener; fMethod = method; fComboCellEditor = new ComboBoxViewerCellEditor(fViewer.getTable(), SWT.TRAIL); fComboCellEditor.setLabelProvider(new LabelProvider()); fComboCellEditor.setContentProvider(new ArrayContentProvider()); }
From source file:com.netxforge.netxstudio.callflow.screens.referenceNetwork.ComboBoxCellEditingSupport.java
License:Open Source License
public ComboBoxCellEditingSupport(ColumnViewer viewer, DataBindingContext dbc, Composite control, EditingDomain domain, FeaturePath path) { super(viewer, dbc); this.editingDomain = domain; this.path = path; cellEditor = new ComboBoxViewerCellEditor(control, SWT.READ_ONLY); // TODO, In a better version, use the editing service adapterfactory for // naming.// ww w . j av a2 s . c o m cellEditor.setLabelProvider(new LabelProvider() { /* * (non-Javadoc) * * @see * org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) */ @Override public String getText(Object element) { if (element instanceof NodeType) { return ((NodeType) element).getName(); } else if (element instanceof Protocol) { return ((Protocol) element).getName(); } else if (element instanceof ReferenceRelationship) { ReferenceRelationship rel = (ReferenceRelationship) element; NodeType nt1 = rel.getRefInterface1Ref(); NodeType nt2 = rel.getRefInterface2Ref(); StringBuffer buf = new StringBuffer(); buf.append(" ("); buf.append(nt1 != null ? nt1.getName() : " ?"); buf.append(" <--> "); buf.append(nt2 != null ? nt2.getName() : " ?"); buf.append(")"); String name = rel.getName(); return name != null ? name : buf.toString(); } else if (element instanceof ServiceFlowDirection) { switch (((ServiceFlowDirection) element).getValue()) { case ServiceFlowDirection.LEFTTORIGHT_VALUE: { return "-->"; } case ServiceFlowDirection.RIGHTTOLEFT_VALUE: { return "<--"; } } } else if (element instanceof Message) { Message m = (Message) element; String name = m.getName(); return name; } return super.getText(element); } }); ObservableListContentProvider listContentProvider = new ObservableListContentProvider(); cellEditor.setContentProvider(listContentProvider); }
From source file:com.subgraph.vega.ui.http.intercept.config.BreakpointMatchTypeEditingSupport.java
License:Open Source License
@Override protected CellEditor getCellEditor(Object element) { ComboBoxViewerCellEditor editor = new ComboBoxViewerCellEditor(viewer.getTable(), SWT.READ_ONLY); editor.setContenProvider(new ArrayContentProvider()); editor.setLabelProvider(new LabelProvider() { public String getText(Object element) { return ((IHttpConditionMatchAction) element).getLabel(); }/*from w ww .j a va 2s . c o m*/ }); final IHttpCondition condition = (IHttpCondition) element; final List<IHttpConditionMatchAction> matchActions = condition.getType().getMatchActions(); editor.setInput(matchActions); for (IHttpConditionMatchAction ma : matchActions) { if (ma.getLabel().equals(condition.getMatchAction().getLabel())) editor.getViewer().setSelection(new StructuredSelection(ma)); } return editor; }
From source file:com.testify.ecfeed.ui.common.TestDataValueEditingSupport.java
License:Open Source License
public TestDataValueEditingSupport(MethodNode method, TableViewer viewer, List<ChoiceNode> testData, ITestDataEditorListener setValueListener) { super(viewer); fViewer = viewer;// www. jav a 2s.com fSetValueListener = setValueListener; fMethod = method; fComboCellEditor = new ComboBoxViewerCellEditor(fViewer.getTable(), SWT.TRAIL); fComboCellEditor.setLabelProvider(new LabelProvider()); fComboCellEditor.setContentProvider(new ArrayContentProvider()); }
From source file:com.xse.optstack.persconftool.ui.applications.ApplicationsTree.java
License:Open Source License
@Override protected TableColumn[] getColumns() { final ComboBoxViewerCellEditor comboBoxViewerCellEditor = new ComboBoxViewerCellEditor(this.getTree(), SWT.READ_ONLY);//w ww . j av a 2 s . c o m comboBoxViewerCellEditor.setContentProvider(new IStructuredContentProvider() { @Override public void inputChanged(final Viewer viewerRef, final Object oldInput, final Object newInput) { // do nothing } @Override public void dispose() { // do nothing } @Override public Object[] getElements(final Object inputElement) { return EInstallRule.values(); } }); comboBoxViewerCellEditor.setLabelProvider(new AbstractBaseLabelProvider() { @Override public String getText(final Object element) { if (element instanceof EInstallRule) { return ((EInstallRule) element).getName(); } return ""; } @Override public Image getImage(final Object element) { return null; } }); comboBoxViewerCellEditor.setInput(new Object()); final TableColumn installationRuleColumn = new TableColumn("Installation Rule", 140); installationRuleColumn.setEditingSupport(new EditingSupport(this.getViewer()) { @Override protected void setValue(final Object element, final Object value) { if ((element instanceof EApplication) && (value instanceof EInstallRule)) { ((EApplication) element).setInstallRule((EInstallRule) value); } } @Override protected Object getValue(final Object element) { if (element instanceof EApplication) { return ((EApplication) element).getInstallRule(); } return null; } @Override protected CellEditor getCellEditor(final Object element) { return comboBoxViewerCellEditor; } @Override protected boolean canEdit(final Object element) { return element instanceof EApplication; } }); final TextCellEditor textCellEditor = new TextCellEditor(this.getTree(), SWT.NONE); final TableColumn sizeColumn = new TableColumn("Size (kB)", 100); sizeColumn.setEditingSupport(new EditingSupport(this.getViewer()) { @Override protected void setValue(final Object element, final Object value) { if ((element instanceof EApplication) && (value instanceof String)) { if (!StringUtils.isEmpty(value.toString())) { try { ((EApplication) element).setSize(Integer.valueOf(value.toString())); } catch (final NumberFormatException e) { // do nothing } } else { ((EApplication) element).setSize(null); } } } @Override protected Object getValue(final Object element) { if (element instanceof EApplication) { final EApplication app = (EApplication) element; return app.getSize() != null ? app.getSize().toString() : ""; } return ""; } @Override protected CellEditor getCellEditor(final Object element) { return textCellEditor; } @Override protected boolean canEdit(final Object element) { return element instanceof EApplication; } }); final TableColumn userNameColumn = new TableColumn("User", 100); userNameColumn.setEditingSupport(new EditingSupport(this.getViewer()) { @Override protected void setValue(final Object element, final Object value) { if ((element instanceof EApplication) && (value instanceof String)) { ((EApplication) element).setUserName(String.valueOf(value)); } } @Override protected Object getValue(final Object element) { if (element instanceof EApplication) { final EApplication app = (EApplication) element; return app.getUserName(); } return "?"; } @Override protected CellEditor getCellEditor(final Object element) { return textCellEditor; } @Override protected boolean canEdit(final Object element) { return element instanceof EApplication; } }); final TableColumn groupNameColumn = new TableColumn("Group", 100); groupNameColumn.setEditingSupport(new EditingSupport(this.getViewer()) { @Override protected void setValue(final Object element, final Object value) { if ((element instanceof EApplication) && (value instanceof String)) { String stringVal = String.valueOf(value); ((EApplication) element).setGroupName(stringVal); } } @Override protected Object getValue(final Object element) { if (element instanceof EApplication) { final EApplication app = (EApplication) element; String groupName = app.getGroupName(); return groupName; } return "?"; } @Override protected CellEditor getCellEditor(final Object element) { return textCellEditor; } @Override protected boolean canEdit(final Object element) { return element instanceof EApplication; } }); final TableColumn userIdColumn = new TableColumn("User ID", 100); userIdColumn.setEditingSupport(new EditingSupport(this.getViewer()) { @Override protected void setValue(final Object element, final Object value) { if ((element instanceof EApplication) && (value instanceof String)) { if (!StringUtils.isEmpty(value.toString())) { try { ((EApplication) element).setUserId(Integer.valueOf(value.toString())); } catch (final NumberFormatException e) { // do nothing } } else { ((EApplication) element).setUserId(null); } } } @Override protected Object getValue(final Object element) { if (element instanceof EApplication) { final EApplication app = (EApplication) element; return app.getUserId() != null ? app.getUserId().toString() : ""; } return ""; } @Override protected CellEditor getCellEditor(final Object element) { return textCellEditor; } @Override protected boolean canEdit(final Object element) { return element instanceof EApplication; } }); final TableColumn groupIdColumn = new TableColumn("Group ID", 100); groupIdColumn.setEditingSupport(new EditingSupport(this.getViewer()) { @Override protected void setValue(final Object element, final Object value) { if ((element instanceof EApplication) && (value instanceof String)) { if (!StringUtils.isEmpty(value.toString())) { try { ((EApplication) element).setGroupId(Integer.valueOf(value.toString())); } catch (final NumberFormatException e) { // do nothing } } else { ((EApplication) element).setGroupId(null); } } } @Override protected Object getValue(final Object element) { if (element instanceof EApplication) { final EApplication app = (EApplication) element; return app.getGroupId() != null ? app.getGroupId().toString() : ""; } return ""; } @Override protected CellEditor getCellEditor(final Object element) { return textCellEditor; } @Override protected boolean canEdit(final Object element) { return element instanceof EApplication; } }); return new TableColumn[] { new TableColumn("Name", 220), installationRuleColumn, sizeColumn, userNameColumn, groupNameColumn, userIdColumn, groupIdColumn }; }
From source file:com.xse.optstack.persconftool.ui.resources.ResourcesTable.java
License:Open Source License
@Override protected TableColumn[] getColumns() { final ComboBoxViewerCellEditor comboBoxViewerCellEditor = new ComboBoxViewerCellEditor(this.getTable(), SWT.READ_ONLY);// ww w .ja v a 2 s.c om comboBoxViewerCellEditor.setContentProvider(new IStructuredContentProvider() { @Override public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { } @Override public void dispose() { } @Override public Object[] getElements(final Object inputElement) { final Object[] vals = new Object[EInstallException.values().length + 1]; int i = 0; for (final EInstallException eInstallException : EInstallException.values()) { vals[i++] = eInstallException; } vals[i] = StructuredSelection.EMPTY; return vals; } }); comboBoxViewerCellEditor.setLabelProvider(new AbstractBaseLabelProvider() { @Override public String getText(final Object element) { if (element instanceof EInstallException) { return ((EInstallException) element).getName(); } else { return ""; } } @Override public Image getImage(final Object element) { return null; } }); comboBoxViewerCellEditor.setInput(new Object()); final TableColumn installationRuleColumn = new TableColumn("Installation Exception", 140); installationRuleColumn.setEditingSupport(new EditingSupport(this.getViewer()) { @Override protected void setValue(final Object element, final Object value) { if (element instanceof EResource) { if (value instanceof EInstallException) { ((EResource) element).setInstallException((EInstallException) value); } else { ((EResource) element).setInstallException(null); } this.getViewer().refresh(element); } } @Override protected Object getValue(final Object element) { if (element instanceof EResource) { final EResource res = (EResource) element; if (res.getInstallException() != null) { return res.getInstallException(); } else { return StructuredSelection.EMPTY; } } return null; } @Override protected CellEditor getCellEditor(final Object element) { return comboBoxViewerCellEditor; } @Override protected boolean canEdit(final Object element) { return element instanceof EResource; } }); return new TableColumn[] { new TableColumn("Name", 180), installationRuleColumn }; }
From source file:eu.esdihumboldt.hale.ui.views.tasks.TaskStatusEditingSupport.java
License:Open Source License
/** * @see EditingSupport#getCellEditor(Object) *///from w w w . j a v a2 s . c om @Override protected CellEditor getCellEditor(Object element) { ComboBoxViewerCellEditor editor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl(), SWT.READ_ONLY); editor.setContenProvider(ArrayContentProvider.getInstance()); editor.setLabelProvider(new LabelProvider()); editor.setInput( new Object[] { TaskStatus.NEW, TaskStatus.ACTIVE, TaskStatus.COMPLETED, TaskStatus.IGNORED }); return editor; }
From source file:gov.redhawk.ide.debug.ui.tabs.ImplementationTab.java
License:Open Source License
/** * {@inheritDoc}/* w w w. jav a 2 s .co m*/ */ @Override public void createControl(final Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); setControl(composite); composite.setFont(parent.getFont()); composite.setLayout(new FillLayout()); final TableLayout layout = new TableLayout(); this.viewer = new TableViewer(composite, SWT.BORDER); this.viewer.getTable().setLayout(layout); this.viewer.getTable().setHeaderVisible(true); this.viewer.getTable().setLinesVisible(true); this.viewer.setContentProvider(new IStructuredContentProvider() { @Override public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { } @Override public void dispose() { } @Override public Object[] getElements(final Object inputElement) { if (inputElement instanceof SoftwareAssembly) { final SoftwareAssembly localSad = (SoftwareAssembly) inputElement; final List<SadComponentInstantiation> retVal = new ArrayList<SadComponentInstantiation>(); for (final HostCollocation hc : localSad.getPartitioning().getHostCollocation()) { for (final SadComponentPlacement cp : hc.getComponentPlacement()) { retVal.addAll(cp.getComponentInstantiation()); } } for (final SadComponentPlacement cp : localSad.getPartitioning().getComponentPlacement()) { retVal.addAll(cp.getComponentInstantiation()); } return retVal.toArray(); } return new Object[0]; } }); this.viewer.setInput(this.sad); final TableViewerColumn componentColumn = new TableViewerColumn(this.viewer, SWT.CENTER); componentColumn.getColumn().setText("Instantiation"); componentColumn.setLabelProvider(new TreeColumnViewerLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { final SadComponentInstantiation ci = (SadComponentInstantiation) element; return ci.getUsageName(); } })); layout.addColumnData(new ColumnWeightData(20, 20, true)); //SUPPRESS CHECKSTYLE MagicNumber final TableViewerColumn implColumn = new TableViewerColumn(this.viewer, SWT.CENTER); implColumn.getColumn().setText("Implementation"); implColumn.setLabelProvider(new TreeColumnViewerLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { final SadComponentInstantiation ci = (SadComponentInstantiation) element; final String implId = ImplementationTab.this.implMap.get(ci.getId()); final SoftPkg softPkg = ScaEcoreUtils.getFeature(ci, ImplementationTab.SPD_PATH); Implementation impl = null; if (implId != null) { return implId; } else if (softPkg != null && !softPkg.getImplementation().isEmpty()) { impl = softPkg.getImplementation().get(0); } if (impl == null) { return ""; } else { return impl.getId(); } } })); implColumn.setEditingSupport(new EditingSupport(this.viewer) { @Override protected void setValue(final Object element, final Object value) { final SadComponentInstantiation ci = (SadComponentInstantiation) element; if (value == null) { ImplementationTab.this.implMap.remove(ci.getId()); } else if (value instanceof String) { ImplementationTab.this.implMap.put(ci.getId(), value.toString()); } else if (value instanceof Implementation) { ImplementationTab.this.implMap.put(ci.getId(), ((Implementation) value).getId()); } else { ImplementationTab.this.implMap.remove(ci.getId()); } ImplementationTab.this.viewer.refresh(element); updateLaunchConfigurationDialog(); } @Override protected Object getValue(final Object element) { final SadComponentInstantiation ci = (SadComponentInstantiation) element; return getImplementation(ci); } @Override protected CellEditor getCellEditor(final Object element) { final SadComponentInstantiation ci = (SadComponentInstantiation) element; final SoftPkg spd = ScaEcoreUtils.getFeature(ci, ImplementationTab.SPD_PATH); final ComboBoxViewerCellEditor editor = new ComboBoxViewerCellEditor( ImplementationTab.this.viewer.getTable(), SWT.READ_ONLY); editor.setContentProvider(new ArrayContentProvider()); editor.setLabelProvider(new AdapterFactoryLabelProvider(ImplementationTab.this.adapterFactory)); if (spd != null) { editor.setInput(spd.getImplementation()); } return editor; } @Override protected boolean canEdit(final Object element) { return true; } }); layout.addColumnData(new ColumnWeightData(100, 20, true)); //SUPPRESS CHECKSTYLE MagicNumber }