private void setupCellEditors(final Table table) { final ComboBoxCellEditor editor= new ComboBoxCellEditor(); editor.setStyle(SWT.READ_ONLY); fTableViewer.setCellEditors(new CellEditor[] { null, editor}); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { if (editor.getControl() == null & !table.isDisposed()) editor.create(table); final ISelection sel= event.getSelection(); if (!(sel instanceof IStructuredSelection)) return; final IStructuredSelection structured= (IStructuredSelection) sel; if (structured.size() != 1) return; final MemberActionInfo info= (MemberActionInfo) structured.getFirstElement(); editor.setItems(info.getAllowedLabels()); editor.setValue(new Integer(info.getAction())); } }); final ICellModifier cellModifier= new MemberActionCellModifier(); fTableViewer.setCellModifier(cellModifier); fTableViewer.setColumnProperties(new String[] { MEMBER_PROPERTY, ACTION_PROPERTY}); }
private void setupCellEditors(final Table table) { final ComboBoxCellEditor comboBoxCellEditor= new ComboBoxCellEditor(); comboBoxCellEditor.setStyle(SWT.READ_ONLY); fTableViewer.setCellEditors(new CellEditor[] { null, comboBoxCellEditor}); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { if (comboBoxCellEditor.getControl() == null & !table.isDisposed()) comboBoxCellEditor.create(table); Assert.isTrue(event.getSelection() instanceof IStructuredSelection); final IStructuredSelection ss= (IStructuredSelection) event.getSelection(); if (ss.size() != 1) return; final MemberActionInfo mac= (MemberActionInfo) ss.getFirstElement(); comboBoxCellEditor.setItems(MemberActionInfoLabelProvider.getAvailableActionLabels(mac)); comboBoxCellEditor.setValue(new Integer(mac.getAction())); } }); final ICellModifier cellModifier= new PushDownCellModifier(); fTableViewer.setCellModifier(cellModifier); fTableViewer.setColumnProperties(new String[] { MEMBER_PROPERTY, ACTION_PROPERTY}); }
/** * To be used by LabelProviders that whant to display a checked/unchecked icon for the CheckboxCellEditor that does * not have a Control. * * @param cellModifier * The ICellModifier for the CellEditor to provide the value * @param element * The current element * @param property * The property the cellModifier should return the value from */ public Image getCellEditorImage(ICellModifier cellModifier, Object element, String property) { Boolean value = (Boolean) cellModifier.getValue(element, property); return getCellEditorImage(value); }
protected abstract ICellModifier getCellModifier();