/* * (non-Javadoc) * * @see org.eclipse.jface.viewers.CellEditor#activate(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent) */ public void activate(ColumnViewerEditorActivationEvent activationEvent) { super.activate(activationEvent); if (activationStyle != SWT.NONE) { boolean dropDown = false; if ((activationEvent.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION || activationEvent.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION) && (activationStyle & DROP_DOWN_ON_MOUSE_ACTIVATION) != 0) { dropDown = true; } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && (activationStyle & DROP_DOWN_ON_KEY_ACTIVATION) != 0) { dropDown = true; } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC && (activationStyle & DROP_DOWN_ON_PROGRAMMATIC_ACTIVATION) != 0) { dropDown = true; } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL && (activationStyle & DROP_DOWN_ON_TRAVERSE_ACTIVATION) != 0) { dropDown = true; } if (dropDown) { getControl() .getDisplay() .asyncExec( new Runnable() { public void run() { ((CCombo) getControl()).setListVisible(true); } }); } } }
@Override public boolean editCellAt(final int row, final int column, final EventObject event) { final boolean editingStarted = super.editCellAt(row, column, event); if (editingStarted) { final CellEditor cellEditor = getCellEditor(); try { final Object o = cellEditor.getClass().getMethod("getComponent").invoke(cellEditor); if (o instanceof Component) { ((Component) o).requestFocusInWindow(); } } catch (final Exception e) { // ignore } } return editingStarted; }
public void actionPerformed(ActionEvent e) { JGrid grid = (JGrid) e.getSource(); if (!grid.hasFocus()) { CellEditor cellEditor = grid.getCurrentCellEditor(); if (cellEditor != null && !cellEditor.stopCellEditing()) { return; } grid.requestFocus(); } SelectionModel selectionModel = grid.getSelectionModel(); int anchorRow = selectionModel.getAnchorRow(); int anchorColumn = selectionModel.getAnchorColumn(); grid.editCellAt(anchorRow, anchorColumn, null); Component editorComp = grid.getEditorComponent(); if (editorComp != null) { editorComp.requestFocus(); } }
public void actionPerformed(ActionEvent e) { JListMutable list = (JListMutable) e.getSource(); if (!list.hasFocus()) { CellEditor cellEditor = list.getListCellEditor(); if (cellEditor != null && !cellEditor.stopCellEditing()) { return; } list.requestFocus(); return; } ListSelectionModel rsm = list.getSelectionModel(); int anchorRow = rsm.getAnchorSelectionIndex(); list.editCellAt(anchorRow, null); Component editorComp = list.getEditorComponent(); if (editorComp != null) { editorComp.requestFocus(); } }
public void actionPerformed(ActionEvent e) { JTable table = (JTable) e.getSource(); if (!table.hasFocus()) { CellEditor cellEditor = table.getCellEditor(); if (cellEditor != null && !cellEditor.stopCellEditing()) { return; } table.requestFocus(); return; } ListSelectionModel rsm = table.getSelectionModel(); int anchorRow = rsm.getAnchorSelectionIndex(); table.editCellAt(anchorRow, PropertySheetTableModel.VALUE_COLUMN); Component editorComp = table.getEditorComponent(); if (editorComp != null) { editorComp.requestFocus(); } }
public void actionPerformed(ActionEvent event) { JGrid grid = (JGrid) event.getSource(); if (!grid.hasFocus()) { CellEditor cellEditor = grid.getCurrentCellEditor(); if ((cellEditor != null) && !cellEditor.stopCellEditing()) { return; } grid.requestFocus(); } SelectionModel selectionModel = grid.getSelectionModel(); Cell selectedCell = selectionModel.getSelectedCell(); int row = selectedCell.getRow(); int column = selectedCell.getColumn(); grid.editCellAt(row, column, null); Component editorComponent = grid.getEditorComponent(); if (editorComponent != null) { editorComponent.requestFocus(); } }
public void mouseDragged(MouseEvent e) { if (shouldIgnore(e)) { return; } repostEvent(e); CellEditor editor = grid.getCurrentCellEditor(); if (editor == null || editor.shouldSelectCell(e)) { Point p = e.getPoint(); int row = grid.rowAtPoint(p); int column = grid.columnAtPoint(p); // The autoscroller can generate drag events outside the Table's range. if ((column == -1) || (row == -1)) { return; } grid.changeSelection(row, column, false, true); } }
public void mouseDragged(MouseEvent event) { // System.out.println("MouseInputHandler.mouseDragged()"); if (shouldIgnore(event)) { return; } // if CTRL is pressed we are not interested in mouse drag events if (event.isControlDown()) { return; } repostEvent(event); CellEditor editor = grid.getCurrentCellEditor(); if (editor == null || editor.shouldSelectCell(event)) { Point p = event.getPoint(); if (startPoint == null) { startPoint = p; } if (previousPoint == null) { previousPoint = p; } int row = grid.rowAtPoint(p); int column = grid.columnAtPoint(p); // The autoscroller can generate drag events outside the Grid's range. if ((column == -1) || (row == -1)) { return; } // update selectionRegion if (selectionAlgorithm == null) { // for grid headers selectionAlgorithm = new GridSelectionAlgorithm(grid); } selectionAlgorithm.update(p, startPoint, previousPoint, selectionRegion); selectionRegionChanged(grid, selectionRegion, false); previousPoint = p; } }
@Override public void focusLost(FocusEvent e) { editor.stopCellEditing(); }
@Override public TableCellEditor getValueEditor(PropertiesPanel propertiesPanel) { editor.formatterFactory = formatterFactory; return editor; }
/** @see javax.swing.CellEditor#getCellEditorValue() */ public Object getCellEditorValue() { if (lastEditor != null) { return lastEditor.getCellEditorValue(); } return null; }