@Override protected Object doGetValue(Object source) { return ((CellEditor) source).getControl(); }
/** * Ensure that cell editor control shows up above the table cursor control. * Should be called whenever the table viewer makes a new call to setCellEditors * i.e. in constructor and in refreshCellEditors * * @param - array of cell editors for the StructuredViewer */ public void moveCellEditorsAbove(CellEditor[] editorArray) { for (int i = 0; i < editorArray.length ; i++) { CellEditor cEd = editorArray[i]; if (cEd != null && cEd.getControl() != null) { cEd.getControl().moveAbove(null); } } }
private void deactivateEditor(CellEditor editor) { removeListeners(editor.getControl()); fTableCursor.moveAbove(editor.getControl()); fTableCursor.setFocus(); }
protected void doSetFocus() { if (_wrapped != null && _wrapped.getControl() != null && !_wrapped.getControl().isDisposed()) { _wrapped.setFocus(); } else { _button.setFocus(); } }
public Point computeSize(Composite editor, int wHint, int hHint, boolean force) { if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) return new Point(wHint, hHint); Point contentsSize = _wrapped.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT, force); Point buttonSize = _button.computeSize(SWT.DEFAULT, SWT.DEFAULT, force); // Just return the button width to ensure the button is not clipped // if the label is long. // The label will just use whatever extra width there is Point result = new Point(buttonSize.x, Math.max(contentsSize.y, buttonSize.y)); return result; } }
@Override protected IObservableValue doCreateCellEditorObservable ( final CellEditor cellEditor ) { return WidgetProperties.text ( SWT.Modify ).observe ( cellEditor.getControl () ); }
@Override protected IObservableValue doCreateCellEditorObservable ( final CellEditor cellEditor ) { return WidgetProperties.text ( SWT.Modify ).observe ( cellEditor.getControl () ); }
/** * Returns a layout data object for this cell editor. This is called each * time the cell editor is activated and controls the layout of the SWT * table editor. * <p> * The default implementation of this method sets the minimum width to the * control's preferred width. Subclasses may extend or reimplement. * </p> * * @return the layout data object */ public LayoutData getLayoutData() { LayoutData result = new LayoutData(); Control control = getControl(); if (control != null) { result.minimumWidth = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x; } return result; }
/** * Returns a layout data object for this cell editor. This is called each * time the cell editor is activated and controls the layout of the SWT * table editor. * <p> * The default implementation of this method sets the minimum width to the * control's preferred width. Subclasses may extend or reimplement. * </p> * * @return the layout data object */ public LayoutData getLayoutData() { LayoutData result = new LayoutData(); Control control = getControl(); if (control != null) { result.minimumWidth = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x; } return result; }
/** * Returns a layout data object for this cell editor. This is called each * time the cell editor is activated and controls the layout of the SWT * table editor. * <p> * The default implementation of this method sets the minimum width to the * control's preferred width. Subclasses may extend or reimplement. * </p> * * @return the layout data object */ public LayoutData getLayoutData() { LayoutData result = new LayoutData(); Control control = getControl(); if (control != null) { result.minimumWidth = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x; } return result; }
public boolean canExecute() { IField field = (IField)getModel(); Object newValue = ((CCombo)request.getCellEditor().getControl()).getText(); if (newValue instanceof String) { return !newValue.equals(field.getTypeName()); } return true; } }
/** * Editor closed. */ private void editorClosed() { // remove cell editors from viewer to prevent auto-editing for ( int i = 0; i < viewer.getCellEditors().length; i++ ) { viewer.getCellEditors()[i] = null; } // remove listener if ( cellEditor.getControl() != null ) { cellEditor.getControl().removeFocusListener( this ); cellEditor.getControl().removeKeyListener( this ); } // reset custom value editor and set selection to notify all // actions to update their enabled state. valueEditorManager.setUserSelectedValueEditor( null ); viewer.setSelection( viewer.getSelection() ); // enable action handlers actionGroup.activateGlobalActionHandlers(); }
public void layout(Composite editor, boolean force) { Rectangle bounds = editor.getClientArea(); Point size = _button.computeSize(SWT.DEFAULT, SWT.DEFAULT, force); // if (_wrapped != null) _wrapped.getControl().setBounds(0, 0, bounds.width - size.x, bounds.height); _button.setBounds(bounds.width - size.x, 0, size.x, bounds.height); }
/** * Adds a <code>CellEditor</code> to the handler so that the * Cut, Copy, Paste, Delete, Select All, Find, Undo, and Redo * actions are redirected to it when active. * * @param editor the <code>CellEditor</code> */ public void addCellEditor(CellEditor editor) { if (editor == null) { return; } Control control = editor.getControl(); Assert.isNotNull(control); controlToEditor.put(control, editor); control.addListener(SWT.Activate, controlListener); control.addListener(SWT.Deactivate, controlListener); if (control.isFocusControl()) { activeEditor = editor; editor.addPropertyChangeListener(cellListener); updateActionsEnableState(); } }
/** * Removes a <code>CellEditor</code> from the handler * so that the Cut, Copy, Paste, Delete, Select All, Find * Undo, and Redo actions are no longer redirected to it. * * @param editor the <code>CellEditor</code> */ public void removeCellEditor(CellEditor editor) { if (editor == null) { return; } if (activeEditor == editor) { activeEditor.removePropertyChangeListener(cellListener); activeEditor = null; } Control control = editor.getControl(); if (control != null) { controlToEditor.remove(control); if (!control.isDisposed()) { control.removeListener(SWT.Activate, controlListener); control.removeListener(SWT.Deactivate, controlListener); } } }
public void relocate(CellEditor celleditor) { CCombo combo = (CCombo) celleditor.getControl(); // TODO: We're pulling a fast one here..... This is assuming we're using a // CCombo as our widget // Our eventual 'Combo' may not even use CCombo so this will most likely // get replaced. // int dropDownButtonSizeX = 16; Rectangle labelParentBounds = label.getBounds().getCopy(); label.translateToAbsolute(labelParentBounds); int x = labelParentBounds.x; int y = labelParentBounds.y; int widthK = labelParentBounds.width; int height = labelParentBounds.height; combo.setBounds(x, y + 1, widthK, height - 2); } }
private CellEditor createRefCellEditor(final Table table, final IContentProposalProvider proposalProvider) { final CellEditor cellEditor = new TextCellEditor(table); final Text text = (Text) cellEditor.getControl(); final ContentAssistCommandAdapter assist = new ContentAssistCommandAdapter( text, new TextContentAdapter(), proposalProvider, null, null, true); assist .setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); return cellEditor; }
@Override public void relocate(CellEditor celleditor) { // Obtain the location IFigure figure = OfficeFloorDirectEditPolicy.this.initialiser .getLocationFigure(); Rectangle rect = figure.getBounds().getCopy(); figure.translateToAbsolute(rect); // Obtain the preferred size Text text = (Text) celleditor.getControl(); Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); // Position the cell editor text box text.setBounds(rect.x, rect.y, pref.x, pref.y); } };
public void activateCellEditor(TreeItem treeItem, int column) { if (cellModifier instanceof ICellEditorProvider) { ICellEditorProvider cellEditorProvider = (ICellEditorProvider) cellModifier; Object data = treeItem.getData(); if (fColumnProperties.length > column) { String property = fColumnProperties[column]; if (cellModifier.canModify(data, property)) { CellEditor newCellEditor = cellEditorProvider.getCellEditor(data, column); if (newCellEditor != null) { // The control that will be the editor must be a // child of the columnPosition Control control = newCellEditor.getControl(); if (control != null) { cellEditorState = new CellEditorState(newCellEditor, control, treeItem, column, property); cellEditorState.activate(); } } } } } }
public void relocate(CellEditor celleditor) { Text text = (Text) celleditor.getControl(); Label label = namedEditPart.getNameLabelFigure(); if (text.getBounds().x <= 0) { super.relocate(celleditor); } else { org.eclipse.swt.graphics.Point sel = text.getSelection(); org.eclipse.swt.graphics.Point pref = text.computeSize(-1, -1); Rectangle rect = label.getTextBounds().getCopy(); label.translateToAbsolute(rect); text.setBounds(rect.x, rect.y-1, rect.width, pref.y+1); text.setSelection(0); text.setSelection(sel); } } }