Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 55412 Details for
Bug 151377
[CellEditors] Listeners for CellSelections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
And finally the fully customizable editor activation for Mouse selections
151377.patch (text/plain), 28.05 KB, created by
Thomas Schindl
on 2006-12-11 12:19:06 EST
(
hide
)
Description:
And finally the fully customizable editor activation for Mouse selections
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2006-12-11 12:19:06 EST
Size:
28.05 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface >Index: src/org/eclipse/jface/viewers/TableViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java,v >retrieving revision 1.73 >diff -u -r1.73 TableViewer.java >--- src/org/eclipse/jface/viewers/TableViewer.java 8 Dec 2006 22:51:09 -0000 1.73 >+++ src/org/eclipse/jface/viewers/TableViewer.java 11 Dec 2006 17:07:06 -0000 >@@ -137,10 +137,6 @@ > return table.getSelection(); > } > >- protected void setEditor(Control w, Item item, int fColumnNumber) { >- tableEditor.setEditor(w, (TableItem) item, fColumnNumber); >- } >- > protected void setLayoutData(LayoutData layoutData) { > tableEditor.grabHorizontal = layoutData.grabHorizontal; > tableEditor.horizontalAlignment = layoutData.horizontalAlignment; >@@ -151,6 +147,15 @@ > table.showSelection(); > } > >+ protected void setEditor(Control w, ViewerCell cell) { >+ if( cell == null ) { >+ tableEditor.setEditor(w, null, 0); >+ } else { >+ tableEditor.setEditor(w, (TableItem) cell.getItem(), cell.getColumnIndex()); >+ } >+ >+ } >+ > }; > } > >Index: src/org/eclipse/jface/viewers/TreeViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java,v >retrieving revision 1.73 >diff -u -r1.73 TreeViewer.java >--- src/org/eclipse/jface/viewers/TreeViewer.java 24 Nov 2006 13:09:35 -0000 1.73 >+++ src/org/eclipse/jface/viewers/TreeViewer.java 11 Dec 2006 17:07:06 -0000 >@@ -345,8 +345,13 @@ > return tree.getSelection(); > } > >- protected void setEditor(Control w, Item item, int fColumnNumber) { >- treeEditor.setEditor(w, (TreeItem) item, fColumnNumber); >+ protected void setEditor(Control w, ViewerCell cell) { >+ if( cell == null ) { >+ treeEditor.setEditor(w, null, 0); >+ } else { >+ treeEditor.setEditor(w, (TreeItem)cell.getItem(), cell.getColumnIndex()); >+ } >+ > } > > protected void setLayoutData(LayoutData layoutData) { >Index: src/org/eclipse/jface/viewers/EditingSupport.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/EditingSupport.java,v >retrieving revision 1.4 >diff -u -r1.4 EditingSupport.java >--- src/org/eclipse/jface/viewers/EditingSupport.java 30 Nov 2006 18:53:06 -0000 1.4 >+++ src/org/eclipse/jface/viewers/EditingSupport.java 11 Dec 2006 17:07:06 -0000 >@@ -63,7 +63,7 @@ > * a new viewer > */ > public EditingSupport(ColumnViewer viewer) { >- Assert.isNotNull(viewer,"Viewer is not allowed to be null"); //$NON-NLS-1$ >+ Assert.isNotNull(viewer, "Viewer is not allowed to be null"); //$NON-NLS-1$ > this.viewer = viewer; > } > >@@ -97,7 +97,9 @@ > /** > * Restore the value from the CellEditor > * >- * <p><b>Subclasses should overwrite!</b></p> >+ * <p> >+ * <b>Subclasses should overwrite!</b> >+ * </p> > * > * @param element > * the model element >@@ -143,9 +145,9 @@ > * @param event > * the travers event > */ >- protected void processTraversEvent(int columnIndex, >- ViewerRow row, TraverseEvent event) { >- >+ protected void processTraversEvent(int columnIndex, ViewerRow row, >+ TraverseEvent event) { >+ > ViewerCell cell2edit = null; > > if (event.detail == SWT.TRAVERSE_TAB_PREVIOUS) { >@@ -284,10 +286,9 @@ > // API in ViewerColumn > // to find row above/below itself? > Rectangle r = row.getBounds(); >- return viewer.getViewerRow(new Point(r.x, >- r.y + r.height + 2)); >+ return viewer.getViewerRow(new Point(r.x, r.y + r.height + 2)); > } >- >+ > /** > * @return the viewer this editing support works for > */ >Index: src/org/eclipse/jface/viewers/ColumnViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewer.java,v >retrieving revision 1.20 >diff -u -r1.20 ColumnViewer.java >--- src/org/eclipse/jface/viewers/ColumnViewer.java 30 Nov 2006 18:53:06 -0000 1.20 >+++ src/org/eclipse/jface/viewers/ColumnViewer.java 11 Dec 2006 17:07:06 -0000 >@@ -15,11 +15,13 @@ > package org.eclipse.jface.viewers; > > import org.eclipse.core.runtime.Assert; >-import org.eclipse.swt.events.MouseAdapter; >-import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Item; >+import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Widget; > > /** >@@ -49,7 +51,19 @@ > private AbstractViewerEditor viewerEditor; > > private int tabEditingStyle = EditingSupport.TABING_NONE; >- >+ >+ private ListenerList cellSelectionListeners; >+ >+ private static EditorActivationStrategy defaultStrategy = new EditorActivationStrategy() { >+ >+ protected boolean isEditorActivationEvent(CellSelectionEvent event) { >+ return event.swtEvent.type == SWT.MouseDown; >+ } >+ >+ }; >+ >+ private EditorActivationStrategy editorActivationStrategy = defaultStrategy; >+ > /** > * Create a new instance of the receiver. > */ >@@ -74,18 +88,27 @@ > // their > // own impl > if (viewerEditor != null) { >- control.addMouseListener(new MouseAdapter() { >- public void mouseDown(MouseEvent e) { >- viewerEditor.handleMouseDown(e); >+ Listener l = new Listener() { >+ >+ public void handleEvent(Event event) { >+ handleMouseDown(event); > } >- }); >+ >+ }; >+ >+ control.addListener(SWT.MouseDown, l); >+ control.addListener(SWT.MouseDoubleClick, l); >+ >+ addCellSelectionListener(new EditingListener()); > } > } > > /** >- * Creates the viewer editor used for editing cell contents. To be implemented by subclasses. >+ * Creates the viewer editor used for editing cell contents. To be >+ * implemented by subclasses. > * >- * @return the editor, or <code>null</code> if this viewer does not support editing cell contents. >+ * @return the editor, or <code>null</code> if this viewer does not >+ * support editing cell contents. > */ > protected abstract AbstractViewerEditor createViewerEditor(); > >@@ -95,7 +118,8 @@ > * > * @param point > * the widget-relative coordinates >- * @return the cell or <code>null</code> if no cell is found at the given point >+ * @return the cell or <code>null</code> if no cell is found at the given >+ * point > */ > ViewerCell getCell(Point point) { > ViewerRow row = getViewerRow(point); >@@ -127,7 +151,8 @@ > /** > * Returns the viewer row associated with the given row widget. > * >- * @param item the row widget >+ * @param item >+ * the row widget > * @return ViewerRow the associated viewer row > */ > protected ViewerRow getViewerRowFromItem(Widget item) { >@@ -137,7 +162,8 @@ > /** > * Returns the column widget at the given column index. > * >- * @param columnIndex the column index >+ * @param columnIndex >+ * the column index > * @return Widget the column widget > */ > protected abstract Widget getColumnViewerOwner(int columnIndex); >@@ -150,7 +176,7 @@ > * @return the viewer column at the given index, or <code>null</code> if > * there is none for the given index > */ >- /* package */ ViewerColumn getViewerColumn(final int columnIndex) { >+ /* package */ViewerColumn getViewerColumn(final int columnIndex) { > > ViewerColumn viewer; > Widget columnOwner = getColumnViewerOwner(columnIndex); >@@ -176,7 +202,8 @@ > } > > /** >- * Sets up editing support for the given column based on the "old" cell editor API. >+ * Sets up editing support for the given column based on the "old" cell >+ * editor API. > * > * @param columnIndex > * @param viewer >@@ -229,15 +256,19 @@ > } > > /** >- * Creates a generic viewer column for the given column widget, based on the given label provider. >+ * Creates a generic viewer column for the given column widget, based on the >+ * given label provider. > * >- * @param columnOwner the column widget >- * @param labelProvider the label provider to use for the column >+ * @param columnOwner >+ * the column widget >+ * @param labelProvider >+ * the label provider to use for the column > * @return ViewerColumn the viewer column > */ > private ViewerColumn createViewerColumn(Widget columnOwner, > CellLabelProvider labelProvider) { >- ViewerColumn column = new ViewerColumn(this,columnOwner) {}; >+ ViewerColumn column = new ViewerColumn(this, columnOwner) { >+ }; > column.setLabelProvider(labelProvider, false); > return column; > } >@@ -269,19 +300,19 @@ > * @param column > * @return ViewerCell > */ >- /* package */ ViewerCell updateCell(ViewerRow rowItem, int column) { >+ /* package */ViewerCell updateCell(ViewerRow rowItem, int column) { > cell.update(rowItem, column); > return cell; > } > > /** > * Returns the {@link Item} at the given widget-relative coordinates, or >- * <code>null</code> if there is no item at the given coordinates. >+ * <code>null</code> if there is no item at the given coordinates. > * > * @param point > * the widget-relative coordinates >- * @return the {@link Item} at the coordinates or <code>null</code> if there >- * is no item at the given coordinates >+ * @return the {@link Item} at the coordinates or <code>null</code> if >+ * there is no item at the given coordinates > */ > protected abstract Item getItemAt(Point point); > >@@ -339,7 +370,7 @@ > > /** > * Cancels a currently active cell editor if one is active. All changes >- * already done in the cell editor are lost. >+ * already done in the cell editor are lost. > * > * @since 3.1 (in subclasses, added in 3.3 to abstract class) > */ >@@ -371,17 +402,24 @@ > */ > public void editElement(Object element, int column) { > if (viewerEditor != null) { >- viewerEditor.editElement(element, column); >+ Widget item = findItem(element); >+ if (item != null) { >+ ViewerRow row = (ViewerRow) item.getData(ViewerRow.ROWPART_KEY); >+ ViewerCell cell = row.getCell(column); >+ if (cell != null) { >+ viewerEditor.editCell(cell); >+ } >+ } > } > } > > /** > * Return the CellEditors for the receiver, or <code>null</code> if no >- * cell editors are set. >+ * cell editors are set. > * <p> > * Since 3.3, an alternative API is available, see >- * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible >- * way of editing values in a column viewer. >+ * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more >+ * flexible way of editing values in a column viewer. > * </p> > * > * @return CellEditor[] >@@ -398,12 +436,12 @@ > > /** > * Returns the cell modifier of this viewer, or <code>null</code> if none >- * has been set. >+ * has been set. > * > * <p> > * Since 3.3, an alternative API is available, see >- * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible >- * way of editing values in a column viewer. >+ * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more >+ * flexible way of editing values in a column viewer. > * </p> > * > * @return the cell modifier, or <code>null</code> >@@ -425,8 +463,8 @@ > * > * <p> > * Since 3.3, an alternative API is available, see >- * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible >- * way of editing values in a column viewer. >+ * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more >+ * flexible way of editing values in a column viewer. > * </p> > * > * @return the list of column properties >@@ -446,8 +484,8 @@ > * > * <p> > * Since 3.3, an alternative API is available, see >- * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible >- * way of editing values in a column viewer. >+ * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more >+ * flexible way of editing values in a column viewer. > * </p> > * > * @return <code>true</code> if there is an active cell editor, and >@@ -469,8 +507,8 @@ > * > * <p> > * Since 3.3, an alternative API is available, see >- * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible >- * way of editing values in a column viewer. >+ * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more >+ * flexible way of editing values in a column viewer. > * </p> > * > * @param editors >@@ -486,13 +524,13 @@ > } > > /** >- * Sets the cell modifier for this column viewer. This method does nothing if editing >- * is not supported by this viewer. >+ * Sets the cell modifier for this column viewer. This method does nothing >+ * if editing is not supported by this viewer. > * > * <p> > * Since 3.3, an alternative API is available, see >- * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible >- * way of editing values in a column viewer. >+ * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more >+ * flexible way of editing values in a column viewer. > * </p> > * > * @param modifier >@@ -515,8 +553,8 @@ > * > * <p> > * Since 3.3, an alternative API is available, see >- * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible >- * way of editing values in a column viewer. >+ * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more >+ * flexible way of editing values in a column viewer. > * </p> > * > * @param columnProperties >@@ -530,7 +568,7 @@ > viewerEditor.setColumnProperties(columnProperties); > } > } >- >+ > /** > * The tab-editing style used if the default implementation is used > * >@@ -544,4 +582,74 @@ > int getTabEditingStyle() { > return this.tabEditingStyle; > } >+ >+ /** >+ * Adding a cell selection listener >+ * >+ * @param listener >+ * listener for cell selections >+ */ >+ public void addCellSelectionListener(ICellSelectionListener listener) { >+ if (cellSelectionListeners == null) { >+ cellSelectionListeners = new ListenerList(); >+ } >+ this.cellSelectionListeners.add(listener); >+ } >+ >+ /** >+ * Remove the cell selection listener >+ * >+ * @param listener >+ * listener for cell selections >+ */ >+ public void removeCellSelectionListener(ICellSelectionListener listener) { >+ this.cellSelectionListeners.remove(listener); >+ } >+ >+ private void handleMouseDown(Event event) { >+ Point p = new Point(event.x, event.y); >+ >+ ViewerRow row = getViewerRow(p); >+ >+ if (row != null) { >+ ViewerCell cell = row.getCell(p); >+ >+ if (cell != null) { >+ fireCellSelectionEvent(new CellSelectionEvent(this, cell, event)); >+ } >+ } >+ } >+ >+ private void fireCellSelectionEvent(CellSelectionEvent event) { >+ if (!cellSelectionListeners.isEmpty()) { >+ Object[] listeners = cellSelectionListeners.getListeners(); >+ for (int i = 0; i < listeners.length; i++) { >+ ((ICellSelectionListener) listeners[i]).cellSelected(event); >+ } >+ } >+ } >+ >+ /** >+ * Set the strategy used to determine if the editor should be activated >+ * because of a {@link CellSelectionEvent} >+ * >+ * @param editorActivationStrategy >+ * the new strategy to activate an editor. <code>null</code> is >+ * allowed and will but the viewer in a none-editable mode >+ */ >+ public void setEditorActivationStrategy( >+ EditorActivationStrategy editorActivationStrategy) { >+ this.editorActivationStrategy = editorActivationStrategy; >+ } >+ >+ private class EditingListener implements ICellSelectionListener { >+ >+ public void cellSelected(CellSelectionEvent event) { >+ if (event != null && event.cell != null && event.swtEvent != null && viewerEditor != null >+ && editorActivationStrategy != null >+ && editorActivationStrategy.isEditorActivationEvent(event)) { >+ viewerEditor.handleCellSelectionEvent(event); >+ } >+ } >+ } > } >Index: src/org/eclipse/jface/viewers/ViewerCell.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerCell.java,v >retrieving revision 1.4 >diff -u -r1.4 ViewerCell.java >--- src/org/eclipse/jface/viewers/ViewerCell.java 6 Sep 2006 19:16:09 -0000 1.4 >+++ src/org/eclipse/jface/viewers/ViewerCell.java 11 Dec 2006 17:07:06 -0000 >@@ -177,4 +177,8 @@ > public Control getControl() { > return row.getControl(); > } >+ >+ ViewerRow getViewerRow() { >+ return row; >+ } > } >Index: src/org/eclipse/jface/viewers/AbstractViewerEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractViewerEditor.java,v >retrieving revision 1.3 >diff -u -r1.3 AbstractViewerEditor.java >--- src/org/eclipse/jface/viewers/AbstractViewerEditor.java 1 Dec 2006 16:30:31 -0000 1.3 >+++ src/org/eclipse/jface/viewers/AbstractViewerEditor.java 11 Dec 2006 17:07:06 -0000 >@@ -22,7 +22,6 @@ > import org.eclipse.swt.events.MouseListener; > import org.eclipse.swt.events.TraverseEvent; > import org.eclipse.swt.events.TraverseListener; >-import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Item; >@@ -46,21 +45,19 @@ > > private String[] columnProperties; > >- private int columnNumber; >- > private ICellEditorListener cellEditorListener; > > private FocusListener focusListener; > > private MouseListener mouseListener; > >- private int doubleClickExpirationTime; >- > private ColumnViewer viewer; > >- private Item item; >- > private TraverseListener tabeditingListener; >+ >+ private int activationTime; >+ >+ private ViewerCell cell; > > /** > * Create a new editor implementation for the viewer >@@ -92,8 +89,8 @@ > > void activateCellEditor() { > >- ViewerColumn part = viewer.getViewerColumn(columnNumber); >- Object element = item.getData(); >+ ViewerColumn part = viewer.getViewerColumn(cell.getColumnIndex()); >+ Object element = cell.getElement(); > > if (part != null && part.getEditingSupport() != null > && part.getEditingSupport().canEdit(element)) { >@@ -113,7 +110,7 @@ > return; > } > setLayoutData(cellEditor.getLayoutData()); >- setEditor(control, item, columnNumber); >+ setEditor(control, cell); > cellEditor.setFocus(); > if (focusListener == null) { > focusListener = new FocusAdapter() { >@@ -128,7 +125,7 @@ > public void mouseDown(MouseEvent e) { > // time wrap? > // check for expiration of doubleClickTime >- if (e.time <= doubleClickExpirationTime) { >+ if (e.time <= activationTime) { > control.removeMouseListener(mouseListener); > cancelEditing(); > handleDoubleClickEvent(); >@@ -143,11 +140,11 @@ > tabeditingListener = new TraverseListener() { > > public void keyTraversed(TraverseEvent e) { >- ViewerColumn col = viewer.getViewerColumn(columnNumber); >+ ViewerColumn col = viewer.getViewerColumn(cell.getColumnIndex()); > if ( col != null && col.getEditingSupport().isTabingSupported() ) { > col.getEditingSupport().processTraversEvent( >- columnNumber, >- viewer.getViewerRowFromItem(item), e); >+ cell.getColumnIndex(), >+ cell.getViewerRow(), e); > } > } > }; >@@ -159,38 +156,6 @@ > } > } > >- /** >- * Activate a cell editor for the given mouse position. >- */ >- private void activateCellEditor(MouseEvent event) { >- if (item == null || item.isDisposed()) { >- // item no longer exists >- return; >- } >- int columnToEdit; >- ViewerRow row = viewer.getViewerRowFromItem(item); >- int columns = row.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 = row.getBounds(i); >- if (bounds.contains(event.x, event.y)) { >- columnToEdit = i; >- break; >- } >- } >- if (columnToEdit == -1) { >- return; >- } >- } >- >- columnNumber = columnToEdit; >- activateCellEditor(); >- } > > /** > * Applies the current value and deactivates the currently active cell >@@ -204,12 +169,13 @@ > // see 1GAHI8Z: ITPUI:ALL - How to code event notification when > // using cell editor ? > this.cellEditor = null; >- Item t = this.item; >+ Item t = this.cell.getItem(); >+ > // don't null out table item -- same item is still selected > if (t != null && !t.isDisposed()) { > saveEditorValue(c, t); > } >- setEditor(null, null, 0); >+ setEditor(null, null); > c.removeListener(cellEditorListener); > Control control = c.getControl(); > if (control != null) { >@@ -235,7 +201,7 @@ > */ > void cancelEditing() { > if (cellEditor != null) { >- setEditor(null, null, 0); >+ setEditor(null, null); > cellEditor.removeListener(cellEditorListener); > > Control control = cellEditor.getControl(); >@@ -265,11 +231,8 @@ > * > * @param event > */ >- void handleMouseDown(MouseEvent event) { >- if (event.button != 1) { >- return; >- } >- >+ void handleCellSelectionEvent(CellSelectionEvent event) { >+ > if (cellEditor != null) { > applyEditorValue(); > } >@@ -279,47 +242,40 @@ > // 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) { >- item = null; >- return; >+ if( event.swtEvent != null ) { >+ activationTime = event.swtEvent.time + Display.getCurrent().getDoubleClickTime(); > } >- item = items[0]; >- activateCellEditor(event); >+ >+ >+ this.cell = event.cell; >+ activateCellEditor(); > } > > /** > * Start editing the given element. > * >- * @param element >- * @param column >+ * @param cell the cell to edit > */ >- void editElement(Object element, int column) { >+ void editCell(ViewerCell cell) { > if (cellEditor != null) { > applyEditorValue(); > } > >- setSelection(createSelection(element), true); >+ setSelection(createSelection(cell.getElement()), true); > Item[] selection = getSelection(); > if (selection.length != 1) { > return; > } > >- item = selection[0]; >- > // Make sure selection is visible > showSelection(); >- columnNumber = column; >+ > activateCellEditor(); > > } > > private void saveEditorValue(CellEditor cellEditor, Item tableItem) { >- ViewerColumn part = viewer.getViewerColumn(columnNumber); >+ ViewerColumn part = viewer.getViewerColumn(cell.getColumnIndex()); > > if (part != null && part.getEditingSupport() != null) { > part.getEditingSupport().setValue(tableItem.getData(), >@@ -414,13 +370,11 @@ > * Position the editor inside the control > * > * @param w >- * the editor control >- * @param item >- * the item (row) in which the editor is drawn in >- * @param fColumnNumber >- * the column number in which the editor is shown >+ * the editor control or <code>null</code> if the editor has to be reset >+ * @param cell the cell in which the editor should be displayed or <code>null</code> if the editor has to be reset >+ * > */ >- protected abstract void setEditor(Control w, Item item, int fColumnNumber); >+ protected abstract void setEditor(Control w, ViewerCell cell); > > /** > * set the layout data for the editor >Index: src/org/eclipse/jface/viewers/CellSelectionEvent.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/CellSelectionEvent.java >diff -N src/org/eclipse/jface/viewers/CellSelectionEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/CellSelectionEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,57 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 Tom Schindl and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation (bug 151377) >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import java.util.EventObject; >+ >+import org.eclipse.jface.viewers.ColumnViewer; >+import org.eclipse.jface.viewers.ViewerCell; >+import org.eclipse.swt.widgets.Event; >+ >+/** >+ * This event is trigger when a cell is selected through key board or any other >+ * action >+ * >+ * @since 3.3 >+ * >+ */ >+public class CellSelectionEvent extends EventObject { >+ /** >+ * The real SWT-Event which triggered the action >+ */ >+ public Event swtEvent; >+ >+ /** >+ * The cell selected >+ */ >+ public ViewerCell cell; >+ >+ private static final long serialVersionUID = 1L; >+ >+ /** >+ * A new event object holding all data to decide what was the event that has >+ * been triggered >+ * >+ * @param viewer >+ * the viewer which is the source of the event >+ * @param cell >+ * the cell selected >+ * @param swtEvent >+ * the real swt event >+ */ >+ CellSelectionEvent(ColumnViewer viewer, ViewerCell cell, Event swtEvent) { >+ super(viewer); >+ this.cell = cell; >+ this.swtEvent = swtEvent; >+ } >+ >+} >Index: src/org/eclipse/jface/viewers/EditorActivationStrategy.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/EditorActivationStrategy.java >diff -N src/org/eclipse/jface/viewers/EditorActivationStrategy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/EditorActivationStrategy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+/** >+ * This class is used to define a general editor activation strategy for all >+ * cells in a {@link ColumnViewer}. >+ * >+ * @since 3.3 >+ * >+ */ >+public abstract class EditorActivationStrategy { >+ /** >+ * The method is consulted to decide whether an editor should be activated >+ * because of this event >+ * >+ * @param event >+ * the selection event >+ * @return <code>true</code> if event triggers editor activation >+ */ >+ protected abstract boolean isEditorActivationEvent(CellSelectionEvent event); >+} >Index: src/org/eclipse/jface/viewers/ICellSelectionListener.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/ICellSelectionListener.java >diff -N src/org/eclipse/jface/viewers/ICellSelectionListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/ICellSelectionListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+package org.eclipse.jface.viewers; >+ >+/** >+ * Classes interested when cell-selections occur in a table/tree control have to >+ * implement this interface >+ * >+ * @since 3.3 >+ * >+ */ >+public interface ICellSelectionListener { >+ /** >+ * This method is called when a cell is selected >+ * >+ * @param event >+ * the selection event >+ */ >+ public void cellSelected(CellSelectionEvent event); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 151377
:
46627
|
54784
|
54904
|
55407
|
55408
| 55412