/** * The <code>ComboBoxPropertyDescriptor</code> implementation of this * <code>IPropertyDescriptor</code> method creates and returns a new * <code>ComboBoxCellEditor</code>. * <p> * The editor is configured with the current validator if there is one. * </p> */ public CellEditor createPropertyEditor(Composite parent) { String[] tags = getTags(); editor = new ComboBoxCellEditor(parent, tags, SWT.READ_ONLY); if (getValidator() != null) { editor.setValidator(getValidator()); } editor.addListener(new ICellEditorListener() { @Override public void editorValueChanged(boolean oldValidState, boolean newValidState) { } @Override public void cancelEditor() { } @Override public void applyEditorValue() { last.set(editor); } }); return editor; }
public Object getValue(Object element, String property) { int columnIndex = Arrays.asList(tableViewer.getColumnProperties()).indexOf(property); CellEditor[] cellEditors = tableViewer.getCellEditors(); CellEditor cellEditor = cellEditors[columnIndex]; boolean isComboBoxEditor = cellEditor instanceof ComboBoxCellEditor; if (element instanceof Item) { element = ((Item) element).getData(); } ArrayEditorRow row = (ArrayEditorRow) element; Object object = row.getValue(columnIndex); if (isComboBoxEditor) { int index = Arrays.asList(((ComboBoxCellEditor)cellEditor).getItems()).indexOf(object.toString()); object = new Integer(index); } return object; }
public Object getValue(Object element, String property) { int columnIndex = Arrays.asList(tableViewer.getColumnProperties()).indexOf(property); CellEditor[] cellEditors = tableViewer.getCellEditors(); CellEditor cellEditor = cellEditors[columnIndex]; boolean isComboBoxEditor = cellEditor instanceof ComboBoxCellEditor; boolean isTextCellEditor = cellEditor instanceof TextCellEditor; if (element instanceof Item) { element = ((Item) element).getData(); } TableEditorRow row = (TableEditorRow) element; Object object = row.getValue(columnIndex); if (isComboBoxEditor) { int index = Arrays.asList(((ComboBoxCellEditor)cellEditor).getItems()).indexOf(object.toString()); object = new Integer(index); } if (isTextCellEditor && (!(object instanceof String))) { object = object.toString(); } return object; }
static public CellEditor[] getColumnEditor(Composite parent) { CellEditor[] columnEditors = new CellEditor[9]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new TextCellEditor(parent); columnEditors[2] = new TextCellEditor(parent); columnEditors[3] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); columnEditors[4] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); columnEditors[5] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); columnEditors[6] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); columnEditors[7] = new ComboBoxCellEditor(parent, new String[]{"","GET","POST"}); columnEditors[8] = new TextCellEditor(parent); return columnEditors; }
@Override protected CellEditor getCellEditor(Object element) { try { util.setContainerName(containerName); util.setFileName(""); types = util.getAllTypes(); String[] opts = new String[types.size()]; int i = 0; for (String type : types) { opts[i] = type; i++; } return new ComboBoxCellEditor(viewer.getTable(), opts); } catch (IOException | JAXBException e) { return new TextCellEditor(viewer.getTable()); } }
/** * Computes an Integer value to give to a ComboBoxCellEditor. The value * corresponds to an index into the cell editor's array of items. The item * at that index is equal to the current value held in the model. */ private Integer getValueForComboBoxCellEditor(final String objectModelValue, final String property) { propertyNameToComboText.remove(property); if (objectModelValue == null) { return new Integer(-1); } final ComboBoxCellEditor comboBoxCellEditor = (ComboBoxCellEditor) getCellEditorForProperty(property); final String[] items = comboBoxCellEditor.getItems(); for (int i = 0; i < items.length; i++) { if (objectModelValue.equalsIgnoreCase(items[i])) { return new Integer(i); } } return new Integer(-1); }
public CellEditor createPropertyEditor(Composite parent) { if (!this.editable){ return null; } final ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(parent, new String[]{DEFAULT, Boolean.TRUE.toString(),Boolean.FALSE.toString()}, SWT.READ_ONLY); Control control = cellEditor.getControl(); control.addMouseListener(new MouseAdapter() { private final Integer ONE = new Integer(1); private final Integer TWO = new Integer(2); @Override public void mouseDoubleClick(MouseEvent e) { if (ONE.equals(cellEditor.getValue())){//true cellEditor.setValue(2);//false } else if (TWO.equals(cellEditor.getValue())){//false cellEditor.setValue(1);//true } super.mouseDoubleClick(e); } }); if (getValidator() != null) { cellEditor.setValidator(getValidator()); } return cellEditor; }
/** * The default constructor. * * @param viewer * The viewer that is using this <code>EditingSupport</code>. * <code>Control</code>s required by this class will be * constructed under this viewer's <code>Control</code> (usually * a <code>Table</code>). * @param contentProvider * The content provider. The methods required as an * <code>EditingSupport</code> are passed to this content * provider. */ public EntryCellEditingSupport(ColumnViewer viewer, EntryCellContentProvider contentProvider) { super(viewer); this.contentProvider = contentProvider; // Get the viewer's Composite so we can create the CellEditors. Composite parent = (Composite) viewer.getControl(); // Create the TextCellEditor. textCell = new TextCellEditor(parent, SWT.LEFT); // Create the ComboBoxCellEditor. comboCell = new ComboBoxCellEditor(parent, new String[] {}, SWT.DROP_DOWN | SWT.READ_ONLY); comboCell.getControl().setBackground(parent.getBackground()); // Create a HashMap to contain values for discrete Entry values. valueMap = new HashMap<String, Integer>(); return; }
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}); }
public CellEditor[] getCellEditors( ) { if ( cellEditor != null ) { return cellEditor; } ComboBoxCellEditor comboCell = new ComboBoxCellEditor( viewer.getTable( ), new String[0], SWT.READ_ONLY ); ComboBoxCellEditor positionCell = new ComboBoxCellEditor( viewer.getTable( ), positionItems, SWT.READ_ONLY ); cellEditor = new CellEditor[]{ null, null, comboCell, positionCell }; return cellEditor; }
public CellEditor[] getColumnEditors(Composite parent) { columnEditors = new CellEditor[7]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new TextCellEditor(parent); columnEditors[2] = new TextCellEditor(parent); columnEditors[3] = new TextCellEditor(parent); columnEditors[4] = new ComboBoxCellEditor(parent, new String[]{"","COMP","COMP-1","COMP-2","COMP-3","COMP-5","DISPLAY","POINTER"}); columnEditors[5] = new TextCellEditor(parent); columnEditors[6] = new TextCellEditor(parent); return columnEditors; }
@Override public CellEditor[] getColumnEditors(Composite parent) { columnEditors = new CellEditor[2]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new ComboBoxCellEditor(parent, new String[]{Boolean.FALSE.toString(), Boolean.TRUE.toString()}); return columnEditors; }
public CellEditor[] getColumnEditors(Composite parent) { columnEditors = new CellEditor[3]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new TextCellEditor(parent); columnEditors[2] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); return columnEditors; }
@Override public CellEditor[] getColumnEditors(Composite parent) { columnEditors = new CellEditor[2]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new ComboBoxCellEditor(parent, new String[] { HttpConnector.HTTP_HEADER_FORWARD_POLICY_MERGE, HttpConnector.HTTP_HEADER_FORWARD_POLICY_IGNORE, HttpConnector.HTTP_HEADER_FORWARD_POLICY_REPLACE }); return columnEditors; }
public void modify(Object element, String property, Object value) { int columnIndex = Arrays.asList(tableViewer.getColumnProperties()).indexOf(property); CellEditor[] cellEditors = tableViewer.getCellEditors(); CellEditor cellEditor = cellEditors[columnIndex]; boolean isComboBoxEditor = cellEditor instanceof ComboBoxCellEditor; if (element instanceof Item) { element = ((Item) element).getData(); } ArrayEditorRow row = (ArrayEditorRow) element; Object object = row.getValue(columnIndex); if (isComboBoxEditor) { String text = ((ComboBoxCellEditor)cellEditor).getItems()[((Integer)value).intValue()]; Class<?> objectClass = object.getClass(); try { Constructor<?> constructor = objectClass.getConstructor(new Class[]{String.class}); value = constructor.newInstance(new Object[]{text}); } catch (Exception e) { value = new String(text); } } row.setValue(value, columnIndex); arrayEditorComposite.getRowList().rowChanged(row); }
static public CellEditor[] getColumnEditor(Composite parent) { CellEditor[] columnEditors = new CellEditor[6]; columnEditors[0] = new ScriptCellEditor(parent); columnEditors[1] = new TextCellEditor(parent); columnEditors[2] = new TextCellEditor(parent); columnEditors[3] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); columnEditors[4] = new ComboBoxCellEditor(parent, new String[]{"","GET","POST"}); columnEditors[5] = new TextCellEditor(parent); return columnEditors; }
static public CellEditor[] getColumnEditor(Composite parent) { CellEditor[] columnEditors = new CellEditor[7]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new TextCellEditor(parent); columnEditors[2] = new TextCellEditor(parent); columnEditors[3] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); columnEditors[4] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); columnEditors[5] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); columnEditors[6] = new ComboBoxCellEditor(parent, new String[]{"true","false"}); return columnEditors; }
@Override protected CellEditor getCellEditor(Object element) { try { types = util.getAllTypes(); String[] opts = new String[types.size()]; int i = 0; for (String type : types) { opts[i] = type; i++; } return new ComboBoxCellEditor(viewer.getTable(), opts); } catch (IOException | JAXBException e) { return new TextCellEditor(viewer.getTable()); } }
@Override protected CellEditor getCellEditor(Object element) { try { types = TypesUtil.getInstance(containerName).getAllTypesForSimpleWizard(); String[] opts = new String[types.size()]; int i = 0; for (String type : types) { opts[i] = type; i++; } return new ComboBoxCellEditor(viewer.getTable(), opts); } catch (IOException | JAXBException e) { return new TextCellEditor(viewer.getTable()); } }
@Override protected CellEditor getCellEditor(Object element) { try { types = TypesUtil.getInstance(containerName).getAllTypes(); String[] opts = new String[types.size()]; int i = 0; for (String type : types) { opts[i] = type; i++; } return new ComboBoxCellEditor(viewer.getTable(), opts); } catch (IOException | JAXBException e) { return new TextCellEditor(viewer.getTable()); } }
@Override protected CellEditor getCellEditor(Object element) { try { properties = Optional.ofNullable(getModelPropertyNames()).orElse(new ArrayList<String>()).stream() .toArray(String[]::new); } catch (CoreException | IOException e) { ResourceManager.logException(e); } return new ComboBoxCellEditor(viewer.getTable(), properties); }
private void hookComboBoxCellEditor(final String property) { final ComboBoxCellEditor comboBoxCellEditor = (ComboBoxCellEditor) getCellEditorForProperty(property); ((CCombo) comboBoxCellEditor.getControl()).addModifyListener(new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { final String text = ((CCombo) e.widget).getText(); propertyNameToComboText.put(property, text); } }); }
/** * Called to translated from a value supplied by a ComboBoxCellEditor into a * value suitable for setting into the model. This method makes use of the * modify listener that we hook onto the CCombo to retrieve typed text. */ private String getStringFromModifyComboBoxCellEditor( final Object value, final String property, final boolean mustBeItemInList) { final ComboBoxCellEditor comboBoxCellEditor = (ComboBoxCellEditor) getCellEditorForProperty(property); final String[] items = comboBoxCellEditor.getItems(); final int index = ((Integer) value).intValue(); /* * When you tab-away from a field, modify gets called with the index of * the currently selected item. If the user has entered text into the * cell then we should use the user-entered value instead of the value * at the specified index. Otherwise, pressing 'tab' would clear what * the user just typed */ if (index == -1 || propertyNameToComboText.containsKey(property)) { if (propertyNameToComboText.containsKey(property)) { final String text = propertyNameToComboText.get(property); if (!mustBeItemInList) { return text; } for (int i = 0; i < items.length; i++) { if (items[i].equalsIgnoreCase(text)) { return items[i]; } } } } else { return items[index]; } return null; }
private SeverityEditingSupport(TableViewer viewer) { super(viewer); this.viewer = viewer; displayValues = ArrayUtils.toArray("Any", "Style", "Low", "Medium", "High", "Critical"); severityValues = ArrayUtils.toArray(Severity.ANY, Severity.STYLE, Severity.LOW, Severity.MEDIUM, Severity.HIGH, Severity.CRITICAL); this.editor = new ComboBoxCellEditor(viewer.getTable(), displayValues, SWT.DROP_DOWN | SWT.READ_ONLY); }
public CellEditor createPropertyEditor(Composite parent) { CellEditor editor = new ComboBoxCellEditor(parent, labels, SWT.READ_ONLY); if (getValidator() != null) { editor.setValidator(getValidator()); } return editor; }
private CellEditor newComboEditor(ArgumentInfo arg) { List<String> enumValues = new ArrayList<String>(); for (EnumValue ev : arg.getType().getEnumValueList()) { enumValues.add(ev.getLabel()); } ComboBoxCellEditor comboBox = new ComboBoxCellEditor(viewer.getTable(), enumValues.toArray(new String[enumValues.size()]), SWT.READ_ONLY); return comboBox; }
@Override public CellEditor getCellEditor(Object element) { if (element instanceof ExecutionSlot) { EnumerationType e = getEnumerationType((ExecutionSlot) element); List<String> enumeratorNames = new ArrayList<String>(); for (Enumerator enumerator : e.getEnumerator()) { enumeratorNames.add(enumerator.getName()); } return new ComboBoxCellEditor((Composite) getViewer().getControl(), enumeratorNames.toArray(new String[] {}), SWT.READ_ONLY); } return null; }
@Override protected TreeViewer createTreeViewer(Composite parent) { TreeViewer result = super.createTreeViewer(parent); // Initialize the table. Tree tree = result.getTree(); tree.setHeaderVisible(true); tree.setToolTipText("Node Display Properties"); EditColTableDef.setupTree(TABLE_DEF, tree); // Configure cell editing. CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_SELECTED] = new CheckboxCellEditor(tree); cellEditors[INDEX_XPOS] = new TextCellEditor(tree); cellEditors[INDEX_YPOS] = new TextCellEditor(tree); cellEditors[INDEX_VISIBLE] = new CheckboxCellEditor(tree); cellEditors[INDEX_SIZE] = new ComboBoxCellEditor( tree, buildSizeOptions()); cellEditors[INDEX_COLOR] = new ColorCellEditor(tree); result.setCellEditors(cellEditors); result.setLabelProvider(new PartLabelProvider()); result.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); result.setCellModifier(new PartCellModifier()); return result; }
public EdgeDisplayTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Layout embedded table Table propTable = propViewer.getTable(); propTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table propTable.setHeaderVisible(true); propTable.setToolTipText("Edge Display Properties"); EditColTableDef.setupTable(TABLE_DEF, propTable); // Configure cell editing CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_HEAD] = null; cellEditors[INDEX_TAIL] = null; cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable); cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.LineStyle.values(), true)); cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.ArrowheadStyle.values(), true)); propViewer.setCellEditors(cellEditors); propViewer.setLabelProvider(new EdgeDisplayLabelProvider()); propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); propViewer.setCellModifier(new EdgeDisplayCellModifier()); propViewer.setContentProvider(ArrayContentProvider.getInstance()); configSorters(propTable); }
public RelationDisplayTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Layout embedded table Table propTable = propViewer.getTable(); propTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table propTable.setHeaderVisible(true); propTable.setToolTipText("Relations Display Properties"); EditColTableDef.setupTable(TABLE_DEF, propTable); // Configure cell editing CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_SOURCE] = null; cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable); cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.LineStyle.values(), true)); cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.ArrowheadStyle.values(), true)); propViewer.setCellEditors(cellEditors); propViewer.setLabelProvider(new EdgeDisplayLabelProvider()); propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); propViewer.setCellModifier(new EdgeDisplayCellModifier()); // TODO: Add column sorters, filters? configSorters(propTable); // Configure content last: use updateTable() to render relations propViewer.setContentProvider(ArrayContentProvider.getInstance()); }
@Override protected CellEditor getCellEditor(Object element) { DataVariable var = (DataVariable) element; switch(m_forItem) { case VALUE: return new TextCellEditor(m_viewer.getTable()); case CONFIRM: if (var.isTyped()) { String[] confirm = new String[2]; confirm[0] = "True"; confirm[1] = "False"; ComboBoxCellEditor editor = new ComboBoxCellEditor(m_viewer.getTable(), confirm); editor.setStyle( SWT.READ_ONLY ); if (var.getConfirmGet().equals("True")) { editor.setValue(0); } else { editor.setValue(1); } return editor; } } return null; }