/** * Creates a table tree viewer on the given table tree control. The viewer * has no input, no content provider, a default label provider, no sorter, * and no filters. * * @param tree * the table tree control */ @Deprecated public TableTreeViewer(TableTree tree) { super(); tableTree = tree; hookControl(tree); tableTreeEditor = new TableTreeEditor(tableTree); tableEditorImpl = new TableTreeEditorImpl(this); }
@Override @Deprecated public void cancelEditing() { tableEditorImpl.cancelEditing(); }
@Override @Deprecated public void editElement(Object element, int column) { tableEditorImpl.editElement(element, column); }
/** * Activate a cell editor for the given mouse position. */ private void activateCellEditor(MouseEvent event) { if (tableItem == null || tableItem.isDisposed()) { // item no longer exists return; } int columnToEdit; int columns = getColumnCount(); if (columns == 0) { // If no TableColumn, Table acts as if it has a single column // which takes the whole width. columnToEdit = 0; } else { columnToEdit = -1; for (int i = 0; i < columns; i++) { Rectangle bounds = getBounds(tableItem, i); if (bounds.contains(event.x, event.y)) { columnToEdit = i; break; } } if (columnToEdit == -1) { return; } } columnNumber = columnToEdit; activateCellEditor(); }
/** * Handles the mouse down event; activates the cell editor. * * @param event * the mouse event that should be handled */ public void handleMouseDown(MouseEvent event) { if (event.button != 1) { return; } if (cellEditor != null) { applyEditorValue(); } // activate the cell editor immediately. If a second mouseDown // is received prior to the expiration of the doubleClick time then // the cell editor will be deactivated and a doubleClick event will // be processed. // doubleClickExpirationTime = event.time + Display.getCurrent().getDoubleClickTime(); Item[] items = getSelection(); // Do not edit if more than one row is selected. if (items.length != 1) { tableItem = null; return; } tableItem = items[0]; activateCellEditor(event); }
/** * Start editing the given element. * * @param element * @param column */ public void editElement(Object element, int column) { if (cellEditor != null) { applyEditorValue(); } setSelection(new StructuredSelection(element), true); Item[] selection = getSelection(); if (selection.length != 1) { return; } tableItem = selection[0]; // Make sure selection is visible showSelection(); columnNumber = column; activateCellEditor(); }
@Override public void mouseDown(MouseEvent e) { // time wrap? // check for expiration of doubleClickTime if (e.time <= doubleClickExpirationTime) { control.removeMouseListener(mouseListener); cancelEditing(); handleDoubleClickEvent(); } else if (mouseListener != null) { control.removeMouseListener(mouseListener); } } };
@Override @Deprecated public ICellModifier getCellModifier() { return tableEditorImpl.getCellModifier(); }
@Override public void applyEditorValue() { TableTreeEditorImpl.this.applyEditorValue(); } };
@Override public void cancelEditor() { TableTreeEditorImpl.this.cancelEditing(); }
@Override public void focusLost(FocusEvent e) { applyEditorValue(); } };
@Override @Deprecated public Object[] getColumnProperties() { return tableEditorImpl.getColumnProperties(); }
@Override @Deprecated public CellEditor[] getCellEditors() { return tableEditorImpl.getCellEditors(); }