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 { if (element instanceof ControlNode) { return factory.getDeviceEditor(DeviceType.SCANNABLE, (Composite)getViewer().getControl()); } } catch (Exception ne) { logger.error("Cannot get a proper scannable editor!", ne); } return new TextCellEditor((Composite)getViewer().getControl()) { @Override protected void doSetValue(Object value) { if (value instanceof INamedNode) value = ((INamedNode)value).getDisplayName(); String string = value!=null ? value.toString() : ""; super.doSetValue(string); } }; }
@Override protected CellEditor getCellEditor(Object element) { if (editor==null) { try { editor = new AxesCellEditor((Composite)getViewer().getControl(), delegatingSelectionProvider, cservice); } catch (ScanningException e) { logger.error("Problem reading scannable names", e); return new TextCellEditor((Composite)getViewer().getControl()) { @Override protected void doSetValue(Object value) { super.doSetValue("Problem reading scannable names"); } }; } } return editor; }
@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()); } }
/** * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#addChildVisual(org.eclipse.gef.EditPart, int) */ @Override protected void addChildVisual(EditPart childEditPart, int index) { super.addChildVisual(childEditPart, index); if (!isCreated()) { if (((AbstractNode) childEditPart.getModel()).getUmlModel().equals(getAdded())) { DirectEditorManager dem = new DirectEditorManager((GraphicalEditPart) childEditPart, TextCellEditor.class, new DirectEditCellEditorLocator(((GraphicalEditPart) childEditPart).getFigure())); dem.show(); setCreated(true); } } }
/** * performDirectEdit void */ protected void performDirectEdit(Request req) { if (getParent() != null && getParent() instanceof ScrollableEditPart) { AbstractNode node = (AbstractNode) getParent().getModel(); Label label = (Label) getFigure(); if (((AbstractNode) node).getNodeType().equals(NodeType.PROVIDED_INTERFACES)) { return; } else if (((AbstractNode) node).getNodeType().equals(NodeType.REQUIRED_INTERFACES)) { return; } setFigureLayout(label, GridData.BEGINNING); } else if (getParent() != null && getParent() instanceof AbstractChildCompartmentEditPart) { return; } if (directManager == null) { directManager = new DirectEditorManager(this, TextCellEditor.class, new DirectEditCellEditorLocator(getFigure())); } directManager.show(); }
/** * * void */ private void getChildFigure(EditPart currentEditPart) { List<EditPart> childrenEditPart = currentEditPart.getChildren(); for( EditPart child : childrenEditPart ) { if( child instanceof NotationNameEditPart ) { if( ((NotationNameEditPart)child).getFigure() instanceof org.eclipse.draw2d.Label ) { GraphicalEditPart gEdit = (GraphicalEditPart) child; setDirectManager(new DirectEditorManager((GraphicalEditPart) child, TextCellEditor.class, new DirectEditCellEditorLocator(gEdit.getFigure()))); directManager.show(); break; } else { getChildFigure(child); } } } }
/** * 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; }
@Override public CellEditor getCellEditor(Object element) { TextCellEditor textCellEditor = new TextCellEditor((Composite) getViewer().getControl()); textCellEditor.setValidator(new ICellEditorValidator() { public String isValid(Object value) { try { Long.parseLong((String) value); } catch (NumberFormatException e) { return "No valid integer value!"; } return null; } }); return textCellEditor; }
@Override public CellEditor getCellEditor(Object element) { TextCellEditor textCellEditor = new TextCellEditor((Composite) getViewer().getControl()); textCellEditor.setValidator(new ICellEditorValidator() { public String isValid(Object value) { String stringValue = (String) value; try { Double.parseDouble(stringValue); } catch (NumberFormatException e) { return "No valid real value!"; } return null; } }); return textCellEditor; }
/** * */ void defineCellEditing() { final String[] columnProperties = new String[model.getColumnCount()]; final CellEditor[] cellEditors = new CellEditor[model.getColumnCount()]; for (int i = 0; i < model.getColumnCount(); i++) { columnProperties[i] = Integer.toString(i); cellEditors[i] = new TextCellEditor(tableViewer.getTable()); } tableViewer.setColumnProperties(columnProperties); // XXX can be replaced by tableViewer.setEditingSupport() tableViewer.setCellEditors(cellEditors); tableViewer.setCellModifier(new CSVEditorCellModifier()); }
private TableViewer createTableViewer(Table table) { TableViewer viewer = new TableViewer(table); viewer.setUseHashlookup(true); viewer.setColumnProperties(tableColumnNames); CellEditor[] editors = new CellEditor[tableColumnNames.length]; // Column 1 : Name (Free text) TextCellEditor textEditor = new TextCellEditor(table); editors[0] = textEditor; // Assign the cell editors to the viewer viewer.setCellEditors(editors); // Set the cell modifier for the viewer viewer.setCellModifier(new CellModifier()); return viewer; }
private CellEditor[] getCellEditors( Table table ) { CellEditor[] editors = new CellEditor[COLUMNS.length]; editors[0] = new TextCellEditor( table ) { @Override protected void keyReleaseOccured( KeyEvent keyEvent ) { super.keyReleaseOccured( keyEvent ); if ( keyEvent.character == '\r' ) { fTableViewer.editElement( fTableViewer.getElementAt( fTable.getSelectionIndex( ) ), 1 ); } } }; editors[1] = new TextCellEditor( table ); return editors; }
/** * Creates an editing support for the given operating viewer. * * @param operatingViewer * the viewer this editing support works for * @param editor * the editor which is operated in * @param propertiesViewer * the properties group viewer that contains the operating viewer */ public PropertiesEditingSupport(ColumnViewer operatingViewer, AbstractSpotterEditor editor, PropertiesGroupViewer propertiesViewer) { super(operatingViewer); this.editor = editor; this.propertiesViewer = propertiesViewer; Composite parent = (Composite) getViewer().getControl(); cellDefaultTextEditor = new TextCellEditor(parent); cellDefaultTextEditor.getControl().addTraverseListener(new ActivationTraverser(cellDefaultTextEditor)); cellNumberEditor = new TextCellEditor(parent); ControlDecoration decor = new ControlDecoration(cellNumberEditor.getControl(), SWT.LEFT | SWT.TOP); cellNumberEditor.addListener(new TextEditorErrorListener(cellNumberEditor, decor)); cellNumberEditor.getControl().addTraverseListener(new ActivationTraverser(cellNumberEditor)); cellBooleanEditor = new CustomComboBoxCellEditor(parent, BOOLEAN_VALUES, SWT.DROP_DOWN | SWT.READ_ONLY); cellBooleanEditor.setActivationStyle(COMBO_ACTIVATION_STYLE); cellBooleanEditor.getControl().addTraverseListener(new ComboActivationTraverser(cellBooleanEditor)); cellComboBoxEditor = new CustomComboBoxCellEditor(parent, new String[0], SWT.DROP_DOWN | SWT.READ_ONLY); cellComboBoxEditor.setActivationStyle(COMBO_ACTIVATION_STYLE); cellComboBoxEditor.getControl().addTraverseListener(new ComboActivationTraverser(cellComboBoxEditor)); cellCustomDialogEditor = new CustomDialogCellEditor(parent); cellCustomDialogEditor.getControl().addTraverseListener(new ActivationTraverser(cellCustomDialogEditor)); }
@Override public CellEditor createPropertyEditor(Composite parent) { final Class type = getter.getReturnType(); if (!type.isPrimitive() && type != String.class) return null; if (type == boolean.class) return new CheckboxCellEditor(parent); TextCellEditor editor = new TextCellEditor(parent); if (type == String.class) return editor; if (isNumeric(type)) { editor.setValidator(new NumberValidator(type)); } return editor; }
private void setEditor(ICellModifier<T> modifier, int index) { switch (modifier.getCellEditingType()) { case TEXTBOX: if (modifier.getStyle() != SWT.NONE) editors[index] = new TextCellEditor(getComponent(), modifier.getStyle()); else editors[index] = new TextCellEditor(getComponent()); break; case COMBOBOX: editors[index] = new ComboEditor(getComponent(), new String[0]); break; case CHECKBOX: if (modifier.getStyle() != SWT.NONE) editors[index] = new CheckboxCellEditor(getComponent(), modifier.getStyle()); else editors[index] = new CheckboxCellEditor(getComponent()); break; default: break; } }
public ReplacementsEditor(Composite parent) { super(parent); dialogTitle = "String replacements"; templateData = new Object[] { "mime/type", "regex", "replaced by", "comment" }; columnNames = new String[] { "Mime type", "Find", "Replaced by", "Comment" }; columnSizes = new int[] { 200, 200, 200, 200 }; columnEditors = new CellEditor[] { new TextCellEditor(), new TextCellEditor(), new TextCellEditor(), new TextCellEditor() }; }
public CellEditor[] getColumnEditors(Composite parent) { columnEditors = new CellEditor[columnNames.length]; for (int i = 0 ; i < columnNames.length ; i++) { columnEditors[i] = new TextCellEditor(parent, getStyle()); } return columnEditors; }
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 CellEditor[] getColumnEditors(Composite parent) { columnEditors = new CellEditor[columnNames.length]; for (int i = 0 ; i < columnNames.length ; i++) { columnEditors[i] = new TextCellEditor(parent); } return columnEditors; }
public BrowserDefinitionEditor(Composite parent) { super(parent); dialogTitle = "Browsers definition"; templateData = new Object[] { "label", "keyword" }; columnNames = new String[] { "Label", "Keyword" }; columnSizes = new int[] { 200, 100 }; columnEditors = new CellEditor[] { new TextCellEditor(), new TextCellEditor() }; }
public CellEditor[] getColumnEditors(Composite parent) { columnEditors = new CellEditor[3]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new TextCellEditor(parent); columnEditors[2] = new XMLTableColumnEditor(parent); return columnEditors; }
public RemovableHeadersEditor(Composite parent) { super(parent); dialogTitle = "Removable headers"; templateData = new Object[] { "header name", "comment" }; columnNames = new String[] { "HEADER_TO_REMOVE", "Comment" }; columnSizes = new int[] { 200, 200}; columnEditors = new CellEditor[] { new TextCellEditor(), new TextCellEditor() }; }
public CellEditor createPropertyEditor(Composite parent) { CellEditor editor = new TextCellEditor(parent, SWT.READ_ONLY); editor.getControl().setEnabled(false); if (getValidator() != null) { editor.setValidator(getValidator()); } return editor; }
public CellEditor createPropertyEditor(Composite parent) { CellEditor editor = new TextCellEditor(parent); editor.getControl().setEnabled(false); if (getValidator() != null) { editor.setValidator(getValidator()); } return editor; }
static public CellEditor[] getColumnEditor(Composite parent) { CellEditor[] columnEditors = new CellEditor[4]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new TextCellEditor(parent); columnEditors[2] = new StepSourceEditor(parent); columnEditors[3] = new TextCellEditor(parent); return columnEditors; }
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[3]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new StepSourceEditor(parent); columnEditors[2] = 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; }
static public CellEditor[] getColumnEditor(Composite parent) { CellEditor[] columnEditors = new CellEditor[3]; columnEditors[0] = new TextCellEditor(parent); columnEditors[1] = new TextCellEditor(parent); columnEditors[2] = new TextCellEditor(parent); return columnEditors; }