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 47722 Details for
Bug 149193
[Viewers] JFace Table and Tree Viewers need to handle SWT events in an extensible way
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]
Patch August 10
149193.txt (text/plain), 146.44 KB, created by
Tod Creasey
on 2006-08-10 16:29:48 EDT
(
hide
)
Description:
Patch August 10
Filename:
MIME Type:
Creator:
Tod Creasey
Created:
2006-08-10 16:29:48 EDT
Size:
146.44 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface >Index: src/org/eclipse/jface/viewers/TableViewer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java,v >retrieving revision 1.56 >diff -u -r1.56 TableViewer.java >--- src/org/eclipse/jface/viewers/TableViewer.java 15 Jun 2006 22:28:48 -0000 1.56 >+++ src/org/eclipse/jface/viewers/TableViewer.java 10 Aug 2006 20:32:27 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Tom Schindl <tom.schindl@bestsolution.at> (bug 83200) > *******************************************************************************/ > > package org.eclipse.jface.viewers; >@@ -21,6 +22,7 @@ > import org.eclipse.swt.events.MouseAdapter; > import org.eclipse.swt.events.MouseEvent; > import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >@@ -28,9 +30,11 @@ > import org.eclipse.swt.widgets.Item; > import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableColumn; > import org.eclipse.swt.widgets.TableItem; > import org.eclipse.swt.widgets.Widget; > >+ > /** > * A concrete viewer based on a SWT <code>Table</code> control. > * <p> >@@ -63,179 +67,102 @@ > * @see #doFindItem(Object) > * @see #internalRefresh(Object, boolean) > */ >-public class TableViewer extends StructuredViewer { >- >- private class VirtualManager{ >+public class TableViewer extends ColumnViewer { >+ >+ private class VirtualManager { > > /** >- * The currently invisible elements as provided >- * by the content provider or by addition. >- * This will not be populated by an ILazyStructuredContentProvider >- * as an ILazyStructuredContentProvider is only queried >- * on the virtual callback. >+ * The currently invisible elements as provided by the content provider >+ * or by addition. This will not be populated by an >+ * ILazyStructuredContentProvider as an ILazyStructuredContentProvider >+ * is only queried on the virtual callback. > */ > private Object[] cachedElements = new Object[0]; >+ > /** > * Create a new instance of the receiver. >- * >+ * > */ >- public VirtualManager(){ >+ public VirtualManager() { > addTableListener(); > } > >- > /** > * Add the listener for SetData on the table > */ > private void addTableListener() { >- table.addListener(SWT.SetData,new Listener(){ >- /* (non-Javadoc) >+ table.addListener(SWT.SetData, new Listener() { >+ /* >+ * (non-Javadoc) >+ * > * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) > */ > public void handleEvent(Event event) { > TableItem item = (TableItem) event.item; > final int index = table.indexOf(item); > Object element = resolveElement(index); >- if(element == null){ >- //Didn't find it so make a request >- //Keep looking if it is not in the cache. >+ if (element == null) { >+ // Didn't find it so make a request >+ // Keep looking if it is not in the cache. > IContentProvider contentProvider = getContentProvider(); >- //If we are building lazily then request lookup now >- if(contentProvider instanceof ILazyContentProvider){ >- ((ILazyContentProvider) contentProvider). >- updateElement(index); >+ // If we are building lazily then request lookup now >+ if (contentProvider instanceof ILazyContentProvider) { >+ ((ILazyContentProvider) contentProvider) >+ .updateElement(index); > return; >- } >+ } > } >- >- >- associate(element,item); >- updateItem(item,element); >+ >+ associate(element, item); >+ updateItem(item, element); > } > > }); > } >- >+ > /** >- * Get the element at index.Resolve it lazily if this >- * is available. >+ * Get the element at index.Resolve it lazily if this is available. >+ * > * @param index >- * @return Object or <code>null</code> if it could >- * not be found >+ * @return Object or <code>null</code> if it could not be found > */ > protected Object resolveElement(int index) { >- >+ > Object element = null; >- if(index < cachedElements.length) { >- element = cachedElements[index]; >+ if (index < cachedElements.length) { >+ element = cachedElements[index]; > } >- >+ > return element; > } > > /** > * A non visible item has been added. >+ * > * @param element > * @param index > */ > public void notVisibleAdded(Object element, int index) { >- >+ > int requiredCount = index + 1; >- >- if(requiredCount > getTable().getItemCount()){ >+ >+ if (requiredCount > getTable().getItemCount()) { > getTable().setItemCount(requiredCount); > Object[] newCache = new Object[requiredCount]; >- System.arraycopy(cachedElements, 0, newCache, 0, cachedElements.length); >+ System.arraycopy(cachedElements, 0, newCache, 0, >+ cachedElements.length); > cachedElements = newCache; > } >- >- >+ > cachedElements[index] = element; >- >+ > } >- >+ > } >- >+ > private VirtualManager virtualManager; >- >- /** >- * TableColorAndFontNoOp is an optimization for tables without >- * color and font support. >- * @see ITableColorProvider >- * @see ITableFontProvider >- */ >- private class TableColorAndFontNoOp{ >- >- /** >- * Create a new instance of the receiver. >- * >- */ >- TableColorAndFontNoOp(){ >- >- } >- >- /** >- * Set the fonts and colors for the tableItem if there is a color >- * and font provider available. >- * @param tableItem The item to update. >- * @param element The element being represented >- * @param column The column index >- */ >- public void setFontsAndColors(TableItem tableItem, Object element, int column){ >- } >- >- } > > /** >- * TableColorAndFontCollector is an helper class for color and font >- * support for tables that support the ITableFontProvider and >- * the ITableColorProvider. >- * @see ITableColorProvider >- * @see ITableFontProvider >- */ >- >- private class TableColorAndFontCollector extends TableColorAndFontNoOp{ >- >- ITableFontProvider fontProvider = null; >- ITableColorProvider colorProvider = null; >- >- /** >- * Create an instance of the receiver. Set the color and font >- * providers if provider can be cast to the correct type. >- * @param provider IBaseLabelProvider >- */ >- public TableColorAndFontCollector(IBaseLabelProvider provider){ >- if(provider instanceof ITableFontProvider) { >- fontProvider = (ITableFontProvider) provider; >- } >- if(provider instanceof ITableColorProvider) { >- colorProvider = (ITableColorProvider) provider; >- } >- } >- >- >- /** >- * Set the fonts and colors for the tableItem if there is a color >- * and font provider available. >- * @param tableItem The item to update. >- * @param element The element being represented >- * @param column The column index >- */ >- public void setFontsAndColors(TableItem tableItem, Object element, int column){ >- if (colorProvider != null) { >- tableItem.setBackground(column, colorProvider.getBackground(element, >- column)); >- tableItem.setForeground(column, colorProvider.getForeground(element, >- column)); >- } >- if(fontProvider != null) { >- tableItem.setFont(column,fontProvider.getFont(element,column)); >- } >- } >- >- } >- >- /** > * Internal table viewer implementation. > */ > private TableEditorImpl tableViewerImpl; >@@ -251,11 +178,6 @@ > private TableEditor tableEditor; > > /** >- * The color and font collector for the cells. >- */ >- private TableColorAndFontNoOp tableColorAndFont = new TableColorAndFontNoOp(); >- >- /** > * Creates a table viewer on a newly-created table control under the given > * parent. The table control is created using the SWT style bits > * <code>MULTI, H_SCROLL, V_SCROLL,</code> and <code>BORDER</code>. The >@@ -281,7 +203,7 @@ > * SWT style bits > */ > public TableViewer(Composite parent, int style) { >- this(new Table(parent, style)); >+ this(new Table(parent, style)); > } > > /** >@@ -299,19 +221,19 @@ > initTableViewerImpl(); > initializeVirtualManager(table.getStyle()); > } >- >+ > /** >- * Initialize the virtual manager to manage the virtual state >- * if the table is VIRTUAL. If not use the default no-op >- * version. >+ * Initialize the virtual manager to manage the virtual state if the table >+ * is VIRTUAL. If not use the default no-op version. >+ * > * @param style > */ > private void initializeVirtualManager(int style) { >- if((style & SWT.VIRTUAL) == 0) { >+ if ((style & SWT.VIRTUAL) == 0) { > return; > } >- >- virtualManager = new VirtualManager(); >+ >+ virtualManager = new VirtualManager(); > } > > /** >@@ -330,7 +252,7 @@ > public void add(Object[] elements) { > assertElementsNotNull(elements); > Object[] filtered = filter(elements); >- >+ > for (int i = 0; i < filtered.length; i++) { > Object element = filtered[i]; > int index = indexForElement(element); >@@ -340,17 +262,18 @@ > > /** > * Create a new TableItem at index if required. >+ * > * @param element > * @param index > * > * @since 3.1 > */ > private void createItem(Object element, int index) { >- if(virtualManager == null) { >- updateItem(new TableItem(getTable(), SWT.NONE, index), element); >- } else{ >- virtualManager.notVisibleAdded(element,index); >- >+ if (virtualManager == null) { >+ updateItem(createNewRowPart(null, SWT.NONE, index).getItem(), element); >+ } else { >+ virtualManager.notVisibleAdded(element, index); >+ > } > } > >@@ -382,7 +305,8 @@ > } > > /* >- * (non-Javadoc) >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.StructuredViewer#doFindInputItem(java.lang.Object) > */ > protected Widget doFindInputItem(Object element) { >@@ -393,11 +317,12 @@ > } > > /* >- * (non-Javadoc) >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.StructuredViewer#doFindItem(java.lang.Object) > */ > protected Widget doFindItem(Object element) { >- >+ > TableItem[] children = table.getItems(); > for (int i = 0; i < children.length; i++) { > TableItem item = children[i]; >@@ -411,8 +336,10 @@ > } > > /* >- * (non-Javadoc) >- * @see org.eclipse.jface.viewers.StructuredViewer#doUpdateItem(org.eclipse.swt.widgets.Widget, java.lang.Object, boolean) >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.StructuredViewer#doUpdateItem(org.eclipse.swt.widgets.Widget, >+ * java.lang.Object, boolean) > */ > protected void doUpdateItem(Widget widget, Object element, boolean fullMap) { > if (widget instanceof TableItem) { >@@ -422,86 +349,64 @@ > if (fullMap) { > associate(element, item); > } else { >- Object data = item.getData(); >- if (data != null) { >- unmapElement(data, item); >- } >+ Object data = item.getData(); >+ if (data != null) { >+ unmapElement(data, item); >+ } > item.setData(element); > mapElement(element, item); > } > >- IBaseLabelProvider prov = getLabelProvider(); >- ITableLabelProvider tprov = null; >- ILabelProvider lprov = null; >- IViewerLabelProvider vprov = null; >- >- if(prov instanceof ILabelProvider) { >- lprov = (ILabelProvider) prov; >- } >- >- if (prov instanceof IViewerLabelProvider) { >- vprov = (IViewerLabelProvider) prov; >- } >- >- if (prov instanceof ITableLabelProvider) { >- tprov = (ITableLabelProvider) prov; >- } >- > int columnCount = table.getColumnCount(); >- TableItem ti = item; >- getColorAndFontCollector().setFontsAndColors(element); >- >+ if(columnCount == 0) >+ columnCount = 1;//If there are no columns do the first one >+ > // Also enter loop if no columns added. See 1G9WWGZ: JFUIF:WINNT - > // TableViewer with 0 columns does not work > for (int column = 0; column < columnCount || column == 0; column++) { >- // Similar code in TreeViewer.doUpdateItem() >- String text = "";//$NON-NLS-1$ >- Image image = null; >- tableColorAndFont.setFontsAndColors(ti,element,column); >- >- if (tprov == null) { >- if (column == 0) { >- ViewerLabel updateLabel = new ViewerLabel(item >- .getText(), item.getImage()); >- >- if(vprov != null) { >- buildLabel(updateLabel,element,vprov); >- } else{ >- if(lprov != null) { >- buildLabel(updateLabel,element,lprov); >- } >- } >- >-// As it is possible for user code to run the event >- //loop check here. >- if (item.isDisposed()) { >- unmapElement(element, item); >- return; >- } >- >- text = updateLabel.getText(); >- image = updateLabel.getImage(); >- } >- } else { >- text = tprov.getColumnText(element, column); >- image = tprov.getColumnImage(element, column); >- } >+ ColumnViewerPart columnViewer = getColumnViewer(column); >+ columnViewer.refresh( getRowPartFromItem(item),column); > >- //Avoid setting text to null >- if (text == null) { >- text = ""; //$NON-NLS-1$ >- } >- ti.setText(column, text); >- if (ti.getImage(column) != image) { >- ti.setImage(column, image); >+ // As it is possible for user code to run the event >+ // loop check here. >+ if (item.isDisposed()) { >+ unmapElement(element, item); >+ return; > } >+ > } >- >- >- getColorAndFontCollector().applyFontsAndColors(ti); >+ >+ } >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getColumnViewerOwner(int) >+ */ >+ protected Widget getColumnViewerOwner(int columnIndex) { >+ if( columnIndex < 0 || columnIndex > getTable().getColumnCount() ) { >+ return null; > } >+ >+ if (getTable().getColumnCount() == 0)// Hang it off the table if it >+ return getTable(); >+ >+ >+ return getTable().getColumn(columnIndex); >+ } >+ >+ /** >+ * Set the TableColumnViewerPart at columnIndex to be viewerPart. >+ * >+ * @param viewerPart >+ * @param columnIndex >+ */ >+ public void setColumnPart(ColumnViewerPart viewerPart, int columnIndex) { >+ TableColumn column = getTable().getColumn(columnIndex); >+ column.setData(ColumnViewerPart.COLUMN_VIEWER_KEY, viewerPart); > } > >+ > /** > * Starts editing the given element. > * >@@ -514,37 +419,32 @@ > tableViewerImpl.editElement(element, column); > } > >- /** >- * Returns the cell editors of this table viewer. >- * >- * @return the list of cell editors >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getCellEditors() > */ > public CellEditor[] getCellEditors() { > return tableViewerImpl.getCellEditors(); > } > >- /** >- * Returns the cell modifier of this table viewer. >- * >- * @return the cell modifier >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getCellModifier() > */ > public ICellModifier getCellModifier() { > return tableViewerImpl.getCellModifier(); > } > >- /** >- * Returns the column properties of this table viewer. The properties must >- * correspond with the columns of the table control. They are used to >- * identify the column in a cell modifier. >- * >- * @return the list of column properties >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getColumnProperties() > */ > public Object[] getColumnProperties() { > return tableViewerImpl.getColumnProperties(); > } > > /* >- * (non-Javadoc) >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.Viewer#getControl() > */ > public Control getControl() { >@@ -588,11 +488,12 @@ > } > > /* >- * (non-Javadoc) >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.StructuredViewer#getSelectionFromWidget() > */ > protected List getSelectionFromWidget() { >- if(virtualManager != null) { >+ if (virtualManager != null) { > return getVirtualSelection(); > } > Widget[] items = table.getSelection(); >@@ -606,50 +507,49 @@ > } > return list; > } >- >+ > /** >- * Get the virtual selection. Avoid calling SWT whenever possible >- * to prevent extra widget creation. >+ * Get the virtual selection. Avoid calling SWT whenever possible to prevent >+ * extra widget creation. >+ * > * @return List of Object > */ > > private List getVirtualSelection() { >- >+ > List result = new ArrayList(); >- int[] selectionIndices = getTable().getSelectionIndices(); >- if(getContentProvider() instanceof ILazyContentProvider){ >+ int[] selectionIndices = getTable().getSelectionIndices(); >+ if (getContentProvider() instanceof ILazyContentProvider) { > ILazyContentProvider lazy = (ILazyContentProvider) getContentProvider(); > for (int i = 0; i < selectionIndices.length; i++) { > int selectionIndex = selectionIndices[i]; >- lazy.updateElement(selectionIndex);//Start the update >+ lazy.updateElement(selectionIndex);// Start the update > Object element = getTable().getItem(selectionIndex).getData(); >- //Only add the element if it got updated. >- //If this is done deferred the selection will >- //be incomplete until selection is finished. >+ // Only add the element if it got updated. >+ // If this is done deferred the selection will >+ // be incomplete until selection is finished. > if (element != null) { > result.add(element); >- } >+ } > } >- } >- else{ >+ } else { > for (int i = 0; i < selectionIndices.length; i++) { > Object element = null; >- //See if it is cached >+ // See if it is cached > int selectionIndex = selectionIndices[i]; >- if (selectionIndex < virtualManager.cachedElements.length){ >+ if (selectionIndex < virtualManager.cachedElements.length) { > element = virtualManager.cachedElements[selectionIndex]; > } >- if (element == null){ >+ if (element == null) { > // Not cached so try the item's data > TableItem item = getTable().getItem(selectionIndex); > element = item.getData(); > } > if (element != null) { > result.add(element); >- } >+ } > } >- >- >+ > } > return result; > } >@@ -664,7 +564,8 @@ > } > > /* >- * (non-Javadoc) >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.ContentViewer#hookControl(org.eclipse.swt.widgets.Control) > */ > protected void hookControl(Control control) { >@@ -757,8 +658,10 @@ > } > > /* >- * (non-Javadoc) >- * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object, java.lang.Object) >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object, >+ * java.lang.Object) > */ > protected void inputChanged(Object input, Object oldInput) { > getControl().setRedraw(false); >@@ -795,12 +698,13 @@ > if (position == -1) { > position = table.getItemCount(); > } >- >- createItem(element,position); >+ >+ createItem(element, position); > } > > /* >- * (non-Javadoc) >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.StructuredViewer#internalRefresh(java.lang.Object) > */ > protected void internalRefresh(Object element) { >@@ -808,15 +712,17 @@ > } > > /* >- * (non-Javadoc) >- * @see org.eclipse.jface.viewers.StructuredViewer#internalRefresh(java.lang.Object, boolean) >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.StructuredViewer#internalRefresh(java.lang.Object, >+ * boolean) > */ > protected void internalRefresh(Object element, boolean updateLabels) { > tableViewerImpl.applyEditorValue(); > if (element == null || equals(element, getRoot())) { >- if(virtualManager == null) { >+ if (virtualManager == null) { > internalRefreshAll(updateLabels); >- } else{ >+ } else { > internalVirtualRefreshAll(); > } > } else { >@@ -833,17 +739,17 @@ > * @since 3.1 > */ > private void internalVirtualRefreshAll() { >- >+ > Object root = getRoot(); > IContentProvider contentProvider = getContentProvider(); >- >- //Invalidate for lazy >- if(!(contentProvider instanceof ILazyContentProvider) >+ >+ // Invalidate for lazy >+ if (!(contentProvider instanceof ILazyContentProvider) > && (contentProvider instanceof IStructuredContentProvider)) { >- //Don't cache if the root is null but cache if it is not lazy. >- if(root != null){ >- virtualManager.cachedElements = >- ((IStructuredContentProvider) getContentProvider()).getElements(root); >+ // Don't cache if the root is null but cache if it is not lazy. >+ if (root != null) { >+ virtualManager.cachedElements = ((IStructuredContentProvider) getContentProvider()) >+ .getElements(root); > getTable().setItemCount(virtualManager.cachedElements.length); > } > } >@@ -851,8 +757,9 @@ > } > > /** >- * Refresh all of the elements of the table. update the >- * labels if updatLabels is true; >+ * Refresh all of the elements of the table. update the labels if >+ * updatLabels is true; >+ * > * @param updateLabels > * > * @since 3.1 >@@ -871,10 +778,9 @@ > TableItem[] items = getTable().getItems(); > int min = Math.min(children.length, items.length); > for (int i = 0; i < min; ++i) { >- >- >+ > TableItem item = items[i]; >- >+ > // if the element is unchanged, update its label if appropriate > if (equals(children[i], item.getData())) { > if (updateLabels) { >@@ -893,14 +799,16 @@ > // So, if the object associated with this item has changed, > // just disassociate it for now, and update it below. > item.setText(""); //$NON-NLS-1$ >- item.setImage(new Image[Math.max(1,table.getColumnCount())]);//Clear all images >+ item.setImage(new Image[Math.max(1, table.getColumnCount())]);// Clear >+ // all >+ // images > disassociate(item); > } > } > // dispose of all items beyond the end of the current elements > if (min < items.length) { > for (int i = items.length; --i >= min;) { >- >+ > disassociate(items[i]); > } > table.remove(min, items.length - 1); >@@ -912,7 +820,7 @@ > } > // Update items which were removed above > for (int i = 0; i < min; ++i) { >- >+ > TableItem item = items[i]; > if (item.getData() == null) { > updateItem(item, children[i]); >@@ -920,11 +828,10 @@ > } > // add any remaining elements > for (int i = min; i < children.length; ++i) { >- createItem(children[i],i); >+ createItem(children[i], i); > } > } > >- > /** > * Removes the given elements from this table viewer. > * >@@ -987,9 +894,9 @@ > */ > public void remove(final Object[] elements) { > assertElementsNotNull(elements); >- if (elements.length == 0) { >- return; >- } >+ if (elements.length == 0) { >+ return; >+ } > preservingSelection(new Runnable() { > public void run() { > internalRemove(elements); >@@ -1007,8 +914,8 @@ > * the model. Note that there is another method for efficiently processing > * the simultaneous removal of multiple elements. > * </p> >- * <strong>NOTE:</strong> removing an object from a virtual >- * table will decrement the itemCount. >+ * <strong>NOTE:</strong> removing an object from a virtual table will >+ * decrement the itemCount. > * > * @param element > * the element >@@ -1018,7 +925,8 @@ > } > > /* >- * (non-Javadoc) >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.StructuredViewer#reveal(java.lang.Object) > */ > public void reveal(Object element) { >@@ -1079,34 +987,51 @@ > * may also implement {@link IColorProvider} and/or {@link IFontProvider} to > * provide colors and/or fonts. > * </p> >+ * <p> >+ * If the label provider implements the mixin interface ITooltipProvider, it >+ * can provide custom tooltips. >+ * </p> > */ > public void setLabelProvider(IBaseLabelProvider labelProvider) { > Assert.isTrue(labelProvider instanceof ITableLabelProvider > || labelProvider instanceof ILabelProvider); >+ clearColumnParts();//Clear before refresh > super.setLabelProvider(labelProvider); >- if(labelProvider instanceof ITableFontProvider || labelProvider instanceof ITableColorProvider) { >- tableColorAndFont = new TableColorAndFontCollector(labelProvider); >- } else { >- tableColorAndFont = new TableColorAndFontNoOp(); >- } >- > } > > /** >+ * Clear the viewer parts for the columns >+ */ >+ private void clearColumnParts() { >+ TableColumn[] columns = getTable().getColumns(); >+ if(columns.length == 0) >+ getTable().setData(ColumnViewerPart.COLUMN_VIEWER_KEY,null); >+ else{ >+ for (int i = 0; i < columns.length; i++) { >+ columns[i].setData(ColumnViewerPart.COLUMN_VIEWER_KEY,null); >+ >+ } >+ } >+ >+ } >+ >+ /** > * <p> >- * Sets a new selection for this viewer and optionally makes it visible. >- * The TableViewer implmentation of this method is ineffecient for the >+ * Sets a new selection for this viewer and optionally makes it visible. The >+ * TableViewer implmentation of this method is ineffecient for the > * ILazyContentProvider as lookup is done by indices rather than elements >- * and may require population of the entire table in worse case. >+ * and may require population of the entire table in worse case. > * </p> > * <p> >- * Use Table#setSelection(int[] indices) and Table#showSelection() if >- * you wish to set selection more effeciently when using a ILazyContentProvider. >+ * Use Table#setSelection(int[] indices) and Table#showSelection() if you >+ * wish to set selection more effeciently when using a ILazyContentProvider. > * </p> > * >- * @param selection the new selection >- * @param reveal <code>true</code> if the selection is to be made >- * visible, and <code>false</code> otherwise >+ * @param selection >+ * the new selection >+ * @param reveal >+ * <code>true</code> if the selection is to be made visible, >+ * and <code>false</code> otherwise > * @see Table#setSelection(int[]) > * @see Table#showSelection() > */ >@@ -1115,21 +1040,23 @@ > } > > /* >- * (non-Javadoc) >- * @see org.eclipse.jface.viewers.StructuredViewer#setSelectionToWidget(java.util.List, boolean) >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.StructuredViewer#setSelectionToWidget(java.util.List, >+ * boolean) > */ > protected void setSelectionToWidget(List list, boolean reveal) { >- >+ > if (list == null) { > table.deselectAll(); > return; > } >- >- if(virtualManager != null){ >+ >+ if (virtualManager != null) { > virtualSetSelectionToWidget(list, reveal); > return; > } >- >+ > int size = list.size(); > TableItem[] items = new TableItem[size]; > int count = 0; >@@ -1149,22 +1076,24 @@ > if (reveal) { > table.showSelection(); > } >- >+ > } >- >- >+ > /** > * Set the selection on a virtual table >- * @param list The elements to set >- * @param reveal Whether or not reveal the first item. >+ * >+ * @param list >+ * The elements to set >+ * @param reveal >+ * Whether or not reveal the first item. > */ > private void virtualSetSelectionToWidget(List list, boolean reveal) { > int size = list.size(); > int[] indices = new int[list.size()]; >- >+ > TableItem firstItem = null; > int count = 0; >- HashSet virtualElements = new HashSet(); >+ HashSet virtualElements = new HashSet(); > for (int i = 0; i < size; ++i) { > Object o = list.get(i); > Widget w = findItem(o); >@@ -1178,37 +1107,38 @@ > virtualElements.add(o); > } > } >- >- if(getContentProvider() instanceof ILazyContentProvider){ >- ILazyContentProvider provider = >- (ILazyContentProvider) getContentProvider(); >- >- //Now go through it again until all is done or we are no longer virtual >- //This may create all items so it is not a good >- //idea in general. >- //Use #setSelection (int [] indices,boolean reveal) instead >- for (int i = 0; virtualElements.size() > 0 && i < getTable().getItemCount(); i++) { >+ >+ if (getContentProvider() instanceof ILazyContentProvider) { >+ ILazyContentProvider provider = (ILazyContentProvider) getContentProvider(); >+ >+ // Now go through it again until all is done or we are no longer >+ // virtual >+ // This may create all items so it is not a good >+ // idea in general. >+ // Use #setSelection (int [] indices,boolean reveal) instead >+ for (int i = 0; virtualElements.size() > 0 >+ && i < getTable().getItemCount(); i++) { > provider.updateElement(i); > TableItem item = getTable().getItem(i); >- if(virtualElements.contains(item.getData())){ >- indices[count++] = i; >+ if (virtualElements.contains(item.getData())) { >+ indices[count++] = i; > virtualElements.remove(item.getData()); > if (firstItem == null) { > firstItem = item; > } > } > } >- } >- else{ >- >- if(count != list.size()){//As this is expensive skip it if all have been found >- //If it is not lazy we can use the cache >+ } else { >+ >+ if (count != list.size()) {// As this is expensive skip it if all >+ // have been found >+ // If it is not lazy we can use the cache > for (int i = 0; i < virtualManager.cachedElements.length; i++) { > Object element = virtualManager.cachedElements[i]; >- if(virtualElements.contains(element)){ >+ if (virtualElements.contains(element)) { > TableItem item = getTable().getItem(i); >- item.getText();//Be sure to fire the update >- indices[count++] = i; >+ item.getText();// Be sure to fire the update >+ indices[count++] = i; > virtualElements.remove(element); > if (firstItem == null) { > firstItem = item; >@@ -1217,7 +1147,7 @@ > } > } > } >- >+ > if (count < size) { > System.arraycopy(indices, 0, indices = new int[count], 0, count); > } >@@ -1230,35 +1160,39 @@ > > /** > * Set the item count of the receiver. >- * @param count the new table size. >+ * >+ * @param count >+ * the new table size. > * > * @since 3.1 > */ >- public void setItemCount(int count){ >+ public void setItemCount(int count) { > getTable().setItemCount(count); > getTable().redraw(); > } >- >+ > /** >- * Replace the entries starting at index with elements. >- * This method assumes all of these values are correct >- * and will not call the content provider to verify. >- * <strong>Note that this method will create a TableItem >- * for all of the elements provided</strong>. >+ * Replace the entries starting at index with elements. This method assumes >+ * all of these values are correct and will not call the content provider to >+ * verify. <strong>Note that this method will create a TableItem for all of >+ * the elements provided</strong>. >+ * > * @param element > * @param index > * @see ILazyContentProvider > * > * @since 3.1 > */ >- public void replace(Object element, int index){ >+ public void replace(Object element, int index) { > TableItem item = getTable().getItem(index); > refreshItem(item, element); > } > > /** > * Clear the table item at the specified index >- * @param index the index of the table item to be cleared >+ * >+ * @param index >+ * the index of the table item to be cleared > * > * @since 3.1 > */ >@@ -1269,26 +1203,86 @@ > } > table.clear(index); > } >- >- /* (non-Javadoc) >+ >+ /* >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.StructuredViewer#getRawChildren(java.lang.Object) > */ > protected Object[] getRawChildren(Object parent) { > >- Assert.isTrue(!(getContentProvider() instanceof ILazyContentProvider),"Cannot get raw children with an ILazyContentProvider");//$NON-NLS-1$ >+ Assert.isTrue(!(getContentProvider() instanceof ILazyContentProvider), >+ "Cannot get raw children with an ILazyContentProvider");//$NON-NLS-1$ > return super.getRawChildren(parent); >- >+ > } >- >- /* (non-Javadoc) >+ >+ /* >+ * (non-Javadoc) >+ * > * @see org.eclipse.jface.viewers.StructuredViewer#assertContentProviderType(org.eclipse.jface.viewers.IContentProvider) > */ > protected void assertContentProviderType(IContentProvider provider) { >- Assert.isTrue(provider instanceof IStructuredContentProvider || >- provider instanceof ILazyContentProvider); >+ Assert.isTrue(provider instanceof IStructuredContentProvider >+ || provider instanceof ILazyContentProvider); > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.StructuredViewer#getRowPartFromItem(org.eclipse.swt.widgets.Widget) >+ */ >+ protected RowPart getRowPartFromItem(Widget item) { >+ RowPart part = (RowPart)item.getData(RowPart.ROWPART_KEY); >+ >+ if( part == null ) { >+ part = new TableRowPart(((TableItem)item)); >+ } >+ >+ return part; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.StructuredViewer#createNewRowPart(org.eclipse.jface.internal.viewers.RowPart, int, int) >+ */ >+ protected RowPart createNewRowPart(RowPart parent, int style, int rowIndex) { >+ TableItem item; >+ >+ if( rowIndex >= 0 ) { >+ item = new TableItem(table,SWT.NONE,rowIndex); >+ } else { >+ item = new TableItem(table,SWT.NONE); >+ } >+ >+ return getRowPartFromItem(item); >+ } >+ >+ /** >+ * Returns the item at the given display-relative coordinates, or >+ * <code>null</code> if there is no item at that location. >+ * <p> >+ * The default implementation of this method returns <code>null</code>. >+ * </p> >+ * >+ * @param x >+ * horizontal coordinate >+ * @param y >+ * vertical coordinate >+ * @return the item, or <code>null</code> if there is no item at the given >+ * coordinates >+ */ >+ protected Item getItem(int x, int y) { >+ return table.getItem(new Point(x,y)); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.StructuredViewer#createColumnViewer(org.eclipse.swt.widgets.Widget, org.eclipse.jface.viewers.ViewerLabelProvider) >+ */ >+ protected ColumnViewerPart createColumnViewer(Widget columnOwner, ViewerLabelProvider labelProvider) { >+ if( columnOwner instanceof TableColumn ) { >+ return new TableColumnViewerPart((TableColumn)columnOwner,labelProvider); >+ } >+ >+ return super.createColumnViewer(columnOwner, labelProvider); >+ } > > > } >- >Index: src/org/eclipse/jface/viewers/TreeViewer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java,v >retrieving revision 1.50 >diff -u -r1.50 TreeViewer.java >--- src/org/eclipse/jface/viewers/TreeViewer.java 30 May 2006 20:15:06 -0000 1.50 >+++ src/org/eclipse/jface/viewers/TreeViewer.java 10 Aug 2006 20:32:27 -0000 >@@ -22,7 +22,6 @@ > import org.eclipse.swt.events.MouseAdapter; > import org.eclipse.swt.events.MouseEvent; > import org.eclipse.swt.events.TreeListener; >-import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Composite; >@@ -55,69 +54,6 @@ > public class TreeViewer extends AbstractTreeViewer { > > /** >- * TreeColorAndFontCollector is an helper class for color and font support >- * for trees that support the ITableFontProvider and the >- * ITableColorProvider. >- * >- * @see ITableColorProvider >- * @see ITableFontProvider >- */ >- >- private class TreeColorAndFontCollector { >- >- ITableFontProvider fontProvider = null; >- >- ITableColorProvider colorProvider = null; >- >- /** >- * Create an instance of the receiver. Set the color and font providers >- * if provider can be cast to the correct type. >- * >- * @param provider >- * IBaseLabelProvider >- */ >- public TreeColorAndFontCollector(IBaseLabelProvider provider) { >- if (provider instanceof ITableFontProvider) { >- fontProvider = (ITableFontProvider) provider; >- } >- if (provider instanceof ITableColorProvider) { >- colorProvider = (ITableColorProvider) provider; >- } >- } >- >- /** >- * Create an instance of the receiver with no color and font providers. >- */ >- public TreeColorAndFontCollector() { >- } >- >- /** >- * Set the fonts and colors for the treeItem if there is a color and >- * font provider available. >- * >- * @param treeItem >- * The item to update. >- * @param element >- * The element being represented >- * @param column >- * The column index >- */ >- public void setFontsAndColors(TreeItem treeItem, Object element, >- int column) { >- if (colorProvider != null) { >- treeItem.setBackground(column, colorProvider.getBackground( >- element, column)); >- treeItem.setForeground(column, colorProvider.getForeground( >- element, column)); >- } >- if (fontProvider != null) { >- treeItem.setFont(column, fontProvider.getFont(element, column)); >- } >- } >- >- } >- >- /** > * Internal tree viewer implementation. > */ > private TreeEditorImpl treeViewerImpl; >@@ -133,11 +69,6 @@ > private TreeEditor treeEditor; > > /** >- * The color and font collector for the cells. >- */ >- private TreeColorAndFontCollector treeColorAndFont = new TreeColorAndFontCollector(); >- >- /** > * Flag for whether the tree has been disposed of. > */ > private boolean treeIsDisposed = false; >@@ -207,7 +138,7 @@ > * (non-Javadoc) Method declared in AbstractTreeViewer. > */ > protected void doUpdateItem(final Item item, Object element) { >- if (!(item instanceof TreeItem)) { >+ if (!(item instanceof TreeItem)) { > return; > } > TreeItem treeItem = (TreeItem) item; >@@ -216,116 +147,44 @@ > return; > } > >- getColorAndFontCollector().setFontsAndColors(element); >- >- IBaseLabelProvider prov = getLabelProvider(); >- ITableLabelProvider tprov = null; >- ILabelProvider lprov = null; >- IViewerLabelProvider vprov = null; >- ITreePathLabelProvider pprov = null; >- >- if(prov instanceof ILabelProvider) { >- lprov = (ILabelProvider) prov; >- } >- >- if (prov instanceof IViewerLabelProvider) { >- vprov = (IViewerLabelProvider) prov; >- } >- >- if (prov instanceof ITableLabelProvider) { >- tprov = (ITableLabelProvider) prov; >- } >- >- if (prov instanceof ITreePathLabelProvider) { >- pprov = (ITreePathLabelProvider) prov; >- } >- >- >- int columnCount = tree.getColumnCount(); >- if (columnCount == 0) {// If no columns were created use the label >- // provider >- >- ViewerLabel updateLabel = new ViewerLabel(treeItem.getText(), >- treeItem.getImage()); >- if (pprov != null) { >- TreePath path = getTreePathFromItem(item); >- buildLabel(updateLabel,path,pprov); >- } else >- if(vprov != null) { >- buildLabel(updateLabel,element,vprov); >- } else{ >- if(lprov != null) { >- buildLabel(updateLabel,element,lprov); >- } >- } >+ int columnCount = getTree().getColumnCount(); >+ if(columnCount == 0)//If no columns are created then fake one >+ columnCount = 1; >+ >+ for (int column = 0; column < columnCount; column++) { >+ ColumnViewerPart columnViewer = getColumnViewer(column); >+ columnViewer.refresh(getRowPartFromItem(treeItem),column); > > // As it is possible for user code to run the event > // loop check here. >- if (treeItem.isDisposed()) { >- unmapElement(element, treeItem); >+ if (item.isDisposed()) { >+ unmapElement(element, item); > return; > } > >- if (updateLabel.hasNewText()) { >- treeItem.setText(updateLabel.getText()); >- } >- if (updateLabel.hasNewImage()) { >- treeItem.setImage(updateLabel.getImage()); >- } >- >- if (!updateLabel.hasPendingDecorations()) >- getColorAndFontCollector().applyFontsAndColors(treeItem); >- >- } else {// Use the table based support >- for (int column = 0; column < columnCount; column++) { >- // Similar code in TableViewer.doUpdateItem() >- String text = "";//$NON-NLS-1$ >- Image image = null; >- treeColorAndFont.setFontsAndColors(treeItem, element, column); >- >- if (tprov == null) { >- if (column == 0) { >- ViewerLabel updateLabel = new ViewerLabel(treeItem >- .getText(), treeItem.getImage()); >- if(vprov != null) { >- buildLabel(updateLabel,element,vprov); >- } else{ >- if(lprov != null) { >- buildLabel(updateLabel,element,lprov); >- } >- } >- >- // As it is possible for user code to run the event >- // loop check here. >- if (treeItem.isDisposed()) { >- unmapElement(element, treeItem); >- return; >- } >+ } > >- text = updateLabel.getText(); >- image = updateLabel.getImage(); >- } >- } else { >- text = tprov.getColumnText(element, column); >- image = tprov.getColumnImage(element, column); >- } >+ } > >- // Avoid setting text to null >- if (text == null) { >- text = ""; //$NON-NLS-1$ >- } >- treeItem.setText(column, text); >- if (treeItem.getImage(column) != image) { >- treeItem.setImage(column, image); >- } >- } >- getColorAndFontCollector().applyFontsAndColors(treeItem); >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getColumnViewerOwner(int) >+ */ >+ protected Widget getColumnViewerOwner(int columnIndex) { >+ if( columnIndex < 0 || columnIndex > getTree().getColumnCount() ) { >+ return null; > } >+ >+ if (getTree().getColumnCount() == 0)// Hang it off the table if it >+ return getTree(); >+ >+ return getTree().getColumn(columnIndex); > } >- >+ > /** > * Override to handle tree paths. >- * @see org.eclipse.jface.viewers.StructuredViewer#buildLabel(org.eclipse.jface.viewers.ViewerLabel, java.lang.Object) >+ * >+ * @see org.eclipse.jface.viewers.StructuredViewer#buildLabel(org.eclipse.jface.viewers.ViewerLabel, >+ * java.lang.Object) > */ > protected void buildLabel(ViewerLabel updateLabel, Object elementOrPath) { > Object element; >@@ -357,21 +216,16 @@ > treeViewerImpl.editElement(element, column); > } > >- /** >- * Returns the cell editors of this tree viewer. >- * >- * @return the list of cell editors >- * @since 3.1 >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getCellEditors() > */ > public CellEditor[] getCellEditors() { > return treeViewerImpl.getCellEditors(); > } > >- /** >- * Returns the cell modifier of this tree viewer. >- * >- * @return the cell modifier >- * @since 3.1 >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getCellModifier() > */ > public ICellModifier getCellModifier() { > return treeViewerImpl.getCellModifier(); >@@ -390,13 +244,8 @@ > return null; > } > >- /** >- * Returns the column properties of this tree viewer. The properties must >- * correspond with the columns of the tree control. They are used to >- * identify the column in a cell modifier. >- * >- * @return the list of column properties >- * @since 3.1 >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getColumnProperties() > */ > public Object[] getColumnProperties() { > return treeViewerImpl.getColumnProperties(); >@@ -416,8 +265,19 @@ > return ((TreeItem) item).getExpanded(); > } > >- /* >- * (non-Javadoc) Method declared in StructuredViewer. >+ /** >+ * Returns the item at the given display-relative coordinates, or >+ * <code>null</code> if there is no item at that location. >+ * <p> >+ * The default implementation of this method returns <code>null</code>. >+ * </p> >+ * >+ * @param x >+ * horizontal coordinate >+ * @param y >+ * vertical coordinate >+ * @return the item, or <code>null</code> if there is no item at the given >+ * coordinates > */ > protected Item getItem(int x, int y) { > return getTree().getItem(getTree().toControl(new Point(x, y))); >@@ -463,7 +323,7 @@ > protected Item getParentItem(Item item) { > return ((TreeItem) item).getParentItem(); > } >- >+ > /* > * (non-Javadoc) Method declared in AbstractTreeViewer. > */ >@@ -494,12 +354,13 @@ > } > }); > if ((treeControl.getStyle() & SWT.VIRTUAL) != 0) { >- treeControl.addDisposeListener(new DisposeListener(){ >+ treeControl.addDisposeListener(new DisposeListener() { > public void widgetDisposed(DisposeEvent e) { > treeIsDisposed = true; > unmapAllElements(); >- }}); >- treeControl.addListener(SWT.SetData, new Listener(){ >+ } >+ }); >+ treeControl.addListener(SWT.SetData, new Listener() { > > public void handleEvent(Event event) { > if (getContentProvider() instanceof ILazyTreeContentProvider) { >@@ -582,19 +443,13 @@ > */ > protected Item newItem(Widget parent, int flags, int ix) { > TreeItem item; >- if (ix >= 0) { >- if (parent instanceof TreeItem) { >- item = new TreeItem((TreeItem) parent, flags, ix); >- } else { >- item = new TreeItem((Tree) parent, flags, ix); >- } >+ >+ if (parent instanceof TreeItem) { >+ item = (TreeItem)createNewRowPart(getRowPartFromItem(parent),flags, ix).getItem(); > } else { >- if (parent instanceof TreeItem) { >- item = new TreeItem((TreeItem) parent, flags); >- } else { >- item = new TreeItem((Tree) parent, flags); >- } >+ item = (TreeItem)createNewRowPart(null,flags, ix).getItem(); > } >+ > return item; > } > >@@ -645,7 +500,7 @@ > */ > protected void setExpanded(Item node, boolean expand) { > ((TreeItem) node).setExpanded(expand); >- if(getContentProvider() instanceof ILazyTreeContentProvider) { >+ if (getContentProvider() instanceof ILazyTreeContentProvider) { > // force repaints to happen > getControl().update(); > } >@@ -661,7 +516,7 @@ > * <code>ITableLabelProvider</code> may also implement > * {@link ITableColorProvider} and/or {@link ITableFontProvider} to provide > * colors and/or fonts. Note that the underlying {@link Tree} must be >- * configured with {@link TreeColumn} objects in this case. >+ * configured with {@link TreeColumn} objects in this case. > * </p> > * <p> > * If the label provider is an <code>ILabelProvider</code>, then it >@@ -674,8 +529,25 @@ > public void setLabelProvider(IBaseLabelProvider labelProvider) { > Assert.isTrue(labelProvider instanceof ITableLabelProvider > || labelProvider instanceof ILabelProvider); >+ clearColumnParts();//Clear before refresh > super.setLabelProvider(labelProvider); >- treeColorAndFont = new TreeColorAndFontCollector(labelProvider); >+ >+ } >+ >+ /** >+ * Clear the viewer parts for the columns >+ */ >+ private void clearColumnParts() { >+ TreeColumn[] columns = getTree().getColumns(); >+ if(columns.length == 0) >+ getTree().setData(ColumnViewerPart.COLUMN_VIEWER_KEY,null); >+ else{ >+ for (int i = 0; i < columns.length; i++) { >+ columns[i].setData(ColumnViewerPart.COLUMN_VIEWER_KEY,null); >+ >+ } >+ } >+ > } > > /* >@@ -705,7 +577,7 @@ > * the array of items > * @return <code>true</code> if the refer to the same elements, > * <code>false</code> otherwise >- * >+ * > * @since 3.1 > */ > protected boolean isSameSelection(List items, Item[] current) { >@@ -725,7 +597,8 @@ > // Go through the items of the current collection > // If there is a mismatch return false > for (int i = 0; i < current.length; i++) { >- if (current[i].getData() == null || !itemSet.containsKey(current[i].getData())) { >+ if (current[i].getData() == null >+ || !itemSet.containsKey(current[i].getData())) { > return false; > } > } >@@ -740,9 +613,11 @@ > getTree().showItem((TreeItem) item); > } > >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.AbstractTreeViewer#getChild(org.eclipse.swt.widgets.Widget, int) >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.AbstractTreeViewer#getChild(org.eclipse.swt.widgets.Widget, >+ * int) > */ > protected Item getChild(Widget widget, int index) { > if (widget instanceof TreeItem) { >@@ -753,38 +628,38 @@ > } > return null; > } >- >+ > protected void assertContentProviderType(IContentProvider provider) { >- if(provider instanceof ILazyTreeContentProvider) { >+ if (provider instanceof ILazyTreeContentProvider) { > return; > } > super.assertContentProviderType(provider); > } >- >- protected Object[] getRawChildren(Object parent) { >- if(getContentProvider() instanceof ILazyTreeContentProvider) { >- return new Object[0]; >- } >- return super.getRawChildren(parent); >- } >- >- /** >- * For a TreeViewer with a tree with the VIRTUAL style bit set, set the >- * number of children of the given element. To set the number of children >- * of the invisible root of the tree, the input object is passed as the >- * element. >- * >- * @param element >- * @param count >- * >+ >+ protected Object[] getRawChildren(Object parent) { >+ if (getContentProvider() instanceof ILazyTreeContentProvider) { >+ return new Object[0]; >+ } >+ return super.getRawChildren(parent); >+ } >+ >+ /** >+ * For a TreeViewer with a tree with the VIRTUAL style bit set, set the >+ * number of children of the given element. To set the number of children of >+ * the invisible root of the tree, the input object is passed as the >+ * element. >+ * >+ * @param element >+ * @param count >+ * > * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will remain >- * unchanged during the 3.2 release cycle. Please do not use this API without >- * consulting with the Platform/UI team. >+ * part of a work in progress. There is no guarantee that this API will >+ * remain unchanged during the 3.2 release cycle. Please do not use this API >+ * without consulting with the Platform/UI team. > * </p> >- * >- * @since 3.2 >- */ >+ * >+ * @since 3.2 >+ */ > public void setChildCount(Object element, int count) { > Tree tree = (Tree) doFindInputItem(element); > if (tree != null) { >@@ -793,9 +668,9 @@ > } > Widget[] items = findItems(element); > for (int i = 0; i < items.length; i++) { >- TreeItem treeItem = (TreeItem)items[i]; >+ TreeItem treeItem = (TreeItem) items[i]; > treeItem.setItemCount(count); >- } >+ } > } > > /** >@@ -807,23 +682,27 @@ > * This method should be called by implementers of ILazyTreeContentProvider > * to populate this viewer. > * </p> >- * @param parent the parent of the element that should be updated >- * @param index the index in the parent's children >- * @param element the new element >+ * >+ * @param parent >+ * the parent of the element that should be updated >+ * @param index >+ * the index in the parent's children >+ * @param element >+ * the new element > * > * @see #setChildCount(Object, int) > * @see ILazyTreeContentProvider >- * >+ * > * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will remain >- * unchanged during the 3.2 release cycle. Please do not use this API without >- * consulting with the Platform/UI team. >+ * part of a work in progress. There is no guarantee that this API will >+ * remain unchanged during the 3.2 release cycle. Please do not use this API >+ * without consulting with the Platform/UI team. > * </p> >- * >+ * > * @since 3.2 > */ > public void replace(Object parent, int index, Object element) { >- if(parent.equals(getInput())) { >+ if (parent.equals(getInput())) { > if (index < tree.getItemCount()) { > updateItem(tree.getItem(index), element); > } >@@ -834,81 +713,82 @@ > if (index < parentItem.getItemCount()) { > updateItem(parentItem.getItem(index), element); > } >- } >+ } > } > } >- >- public boolean isExpandable(Object element) { >- if (getContentProvider() instanceof ILazyTreeContentProvider) { >- TreeItem treeItem = (TreeItem) internalExpand(element, false); >- if (treeItem == null) { >- return false; >- } >- virtualMaterializeItem(treeItem); >- return treeItem.getItemCount() > 0; >- } >- return super.isExpandable(element); >- } >- >- protected Object getParentElement(Object element) { >- if(!(element instanceof TreePath) && (getContentProvider() instanceof ILazyTreeContentProvider)) { >- ILazyTreeContentProvider lazyTreeContentProvider = (ILazyTreeContentProvider) getContentProvider(); >- return lazyTreeContentProvider.getParent(element); >- } >- return super.getParentElement(element); >- } >- >- protected void createChildren(Widget widget) { >- if (getContentProvider() instanceof ILazyTreeContentProvider) { >- final Item[] tis = getChildren(widget); >- if (tis != null && tis.length > 0) { >- // children already there, touch them >- for (int i = 0; i < tis.length; i++) { >+ >+ public boolean isExpandable(Object element) { >+ if (getContentProvider() instanceof ILazyTreeContentProvider) { >+ TreeItem treeItem = (TreeItem) internalExpand(element, false); >+ if (treeItem == null) { >+ return false; >+ } >+ virtualMaterializeItem(treeItem); >+ return treeItem.getItemCount() > 0; >+ } >+ return super.isExpandable(element); >+ } >+ >+ protected Object getParentElement(Object element) { >+ if (!(element instanceof TreePath) >+ && (getContentProvider() instanceof ILazyTreeContentProvider)) { >+ ILazyTreeContentProvider lazyTreeContentProvider = (ILazyTreeContentProvider) getContentProvider(); >+ return lazyTreeContentProvider.getParent(element); >+ } >+ return super.getParentElement(element); >+ } >+ >+ protected void createChildren(Widget widget) { >+ if (getContentProvider() instanceof ILazyTreeContentProvider) { >+ final Item[] tis = getChildren(widget); >+ if (tis != null && tis.length > 0) { >+ // children already there, touch them >+ for (int i = 0; i < tis.length; i++) { > tis[i].getText(); > } >- return; >- } >- ILazyTreeContentProvider lazyTreeContentProvider = (ILazyTreeContentProvider) getContentProvider(); >- Object element = widget.getData(); >- if (element == null && widget instanceof TreeItem) { >- // parent has not been materialized >- virtualMaterializeItem((TreeItem) widget); >- // try getting the element now that updateElement was called >- element = widget.getData(); >- } >- TreeItem[] children; >- if (widget instanceof Tree) { >- children = ((Tree) widget).getItems(); >- } else { >- children = ((TreeItem) widget).getItems(); >- } >- if (element != null && children.length > 0) { >- for (int i = 0; i < children.length; i++) { >- lazyTreeContentProvider.updateElement(element, i); >- } >- } >- return; >- } >- super.createChildren(widget); >- } >- >- protected void internalAdd(Widget widget, Object parentElement, >- Object[] childElements) { >- if (getContentProvider() instanceof ILazyTreeContentProvider) { >- if (widget instanceof TreeItem) { >- TreeItem ti = (TreeItem) widget; >- int count = ti.getItemCount() + childElements.length; >+ return; >+ } >+ ILazyTreeContentProvider lazyTreeContentProvider = (ILazyTreeContentProvider) getContentProvider(); >+ Object element = widget.getData(); >+ if (element == null && widget instanceof TreeItem) { >+ // parent has not been materialized >+ virtualMaterializeItem((TreeItem) widget); >+ // try getting the element now that updateElement was called >+ element = widget.getData(); >+ } >+ TreeItem[] children; >+ if (widget instanceof Tree) { >+ children = ((Tree) widget).getItems(); >+ } else { >+ children = ((TreeItem) widget).getItems(); >+ } >+ if (element != null && children.length > 0) { >+ for (int i = 0; i < children.length; i++) { >+ lazyTreeContentProvider.updateElement(element, i); >+ } >+ } >+ return; >+ } >+ super.createChildren(widget); >+ } >+ >+ protected void internalAdd(Widget widget, Object parentElement, >+ Object[] childElements) { >+ if (getContentProvider() instanceof ILazyTreeContentProvider) { >+ if (widget instanceof TreeItem) { >+ TreeItem ti = (TreeItem) widget; >+ int count = ti.getItemCount() + childElements.length; > ti.setItemCount(count); >- ti.clearAll(false); >- } else { >- Tree t = (Tree) widget; >- t.setItemCount(t.getItemCount() + childElements.length); >- t.clearAll(false); >- } >- return; >- } >- super.internalAdd(widget, parentElement, childElements); >- } >+ ti.clearAll(false); >+ } else { >+ Tree t = (Tree) widget; >+ t.setItemCount(t.getItemCount() + childElements.length); >+ t.clearAll(false); >+ } >+ return; >+ } >+ super.internalAdd(widget, parentElement, childElements); >+ } > > private void virtualMaterializeItem(TreeItem treeItem) { > if (treeItem.getData() != null) { >@@ -934,47 +814,55 @@ > lazyTreeContentProvider.updateElement(parentElement, index); > } > } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.AbstractTreeViewer#internalRefreshStruct(org.eclipse.swt.widgets.Widget, java.lang.Object, boolean) >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.AbstractTreeViewer#internalRefreshStruct(org.eclipse.swt.widgets.Widget, >+ * java.lang.Object, boolean) > */ >- protected void internalRefreshStruct(Widget widget, Object element, boolean updateLabels) { >- if (getContentProvider() instanceof ILazyTreeContentProvider) { >- // first phase: update child counts >- virtualRefreshChildCounts(widget, element); >- // second phase: update labels >- if (updateLabels) { >- if (widget instanceof Tree) { >- ((Tree)widget).clearAll(true); >- } else if (widget instanceof TreeItem) { >- ((TreeItem)widget).clearAll(true); >- } >- } >- return; >- } >+ protected void internalRefreshStruct(Widget widget, Object element, >+ boolean updateLabels) { >+ if (getContentProvider() instanceof ILazyTreeContentProvider) { >+ // first phase: update child counts >+ virtualRefreshChildCounts(widget, element); >+ // second phase: update labels >+ if (updateLabels) { >+ if (widget instanceof Tree) { >+ ((Tree) widget).clearAll(true); >+ } else if (widget instanceof TreeItem) { >+ ((TreeItem) widget).clearAll(true); >+ } >+ } >+ return; >+ } > super.internalRefreshStruct(widget, element, updateLabels); > } > > /** >- * Traverses the visible (expanded) part of the tree and updates child counts. >+ * Traverses the visible (expanded) part of the tree and updates child >+ * counts. >+ * > * @param widget > * @param element > * @param updateLabels > */ > private void virtualRefreshChildCounts(Widget widget, Object element) { > ILazyTreeContentProvider lazyTreeContentProvider = (ILazyTreeContentProvider) getContentProvider(); >- if (widget instanceof Tree || ((TreeItem)widget).getExpanded()) { >+ if (widget instanceof Tree || ((TreeItem) widget).getExpanded()) { > // widget shows children - it is safe to call getChildren > if (element != null) { >- lazyTreeContentProvider.updateChildCount(element, getChildren(widget).length); >+ lazyTreeContentProvider.updateChildCount(element, >+ getChildren(widget).length); > } else { > if (widget instanceof Tree) { >- ((Tree)widget).setItemCount(0); >+ ((Tree) widget).setItemCount(0); > } else { >- ((TreeItem)widget).setItemCount(0); >+ ((TreeItem) widget).setItemCount(0); > } > } >- // need to get children again because they might have been updated through a callback to setChildCount. >+ // need to get children again because they might have been updated >+ // through a callback to setChildCount. > Item[] items = getChildren(widget); > for (int i = 0; i < items.length; i++) { > Item item = items[i]; >@@ -985,7 +873,7 @@ > } > } > } >- >+ > /* > * To unmap elements correctly, we need to register a dispose listener with > * the item if the tree is virtual. >@@ -994,7 +882,7 @@ > super.mapElement(element, item); > // make sure to unmap elements if the tree is virtual > if ((getTree().getStyle() & SWT.VIRTUAL) != 0) { >- item.addDisposeListener(new DisposeListener(){ >+ item.addDisposeListener(new DisposeListener() { > public void widgetDisposed(DisposeEvent e) { > if (!treeIsDisposed) { > Object data = item.getData(); >@@ -1002,7 +890,51 @@ > unmapElement(data, item); > } > } >- }}); >+ } >+ }); > } > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getRowPartFromItem(org.eclipse.swt.widgets.Widget) >+ */ >+ protected RowPart getRowPartFromItem(Widget item) { >+ RowPart part = (RowPart)item.getData(RowPart.ROWPART_KEY); >+ >+ if( part == null ) { >+ part = new TreeRowPart(((TreeItem)item)); >+ } >+ >+ return part; >+ } >+ >+ /** >+ * Create a new RowPart at rowIndex >+ * @param parent >+ * @param style >+ * @param rowIndex >+ * @return RowPart >+ */ >+ private RowPart createNewRowPart(RowPart parent, int style, int rowIndex) { >+ if( parent == null ) { >+ if( rowIndex >= 0 ) { >+ return getRowPartFromItem(new TreeItem(tree,style,rowIndex)); >+ } >+ return getRowPartFromItem(new TreeItem(tree,style)); >+ } >+ >+ if( rowIndex >= 0 ) { >+ return getRowPartFromItem(new TreeItem((TreeItem)parent.getItem(),SWT.NONE,rowIndex)); >+ } >+ >+ return getRowPartFromItem(new TreeItem((TreeItem)parent.getItem(),SWT.NONE)); >+ } >+ >+ protected ColumnViewerPart createColumnViewer(Widget columnOwner, ViewerLabelProvider labelProvider) { >+ if( columnOwner instanceof TreeColumn ) { >+ return new TreeColumnViewerPart((TreeColumn)columnOwner,labelProvider); >+ } >+ >+ return super.createColumnViewer(columnOwner, labelProvider); >+ } > } >Index: src/org/eclipse/jface/viewers/AbstractTreeViewer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java,v >retrieving revision 1.94 >diff -u -r1.94 AbstractTreeViewer.java >--- src/org/eclipse/jface/viewers/AbstractTreeViewer.java 31 Jul 2006 09:51:18 -0000 1.94 >+++ src/org/eclipse/jface/viewers/AbstractTreeViewer.java 10 Aug 2006 20:32:27 -0000 >@@ -54,7 +54,7 @@ > * @see TreeViewer > * @see TableTreeViewer > */ >-public abstract class AbstractTreeViewer extends StructuredViewer { >+public abstract class AbstractTreeViewer extends ColumnViewer { > > /** > * Constant indicating that all levels of the tree should be expanded or >Index: src/org/eclipse/jface/viewers/TreeEditorImpl.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeEditorImpl.java,v >retrieving revision 1.7 >diff -u -r1.7 TreeEditorImpl.java >--- src/org/eclipse/jface/viewers/TreeEditorImpl.java 8 May 2006 20:56:56 -0000 1.7 >+++ src/org/eclipse/jface/viewers/TreeEditorImpl.java 10 Aug 2006 20:32:27 -0000 >@@ -49,9 +49,9 @@ > > private int doubleClickExpirationTime; > >- private StructuredViewer viewer; >+ private ColumnViewer viewer; > >- TreeEditorImpl(StructuredViewer viewer) { >+ TreeEditorImpl(ColumnViewer viewer) { > this.viewer = viewer; > initCellEditorListener(); > } >@@ -66,52 +66,48 @@ > } > > private void activateCellEditor() { >- if (cellEditors != null) { >- if (cellEditors[columnNumber] != null && cellModifier != null) { >- Object element = treeItem.getData(); >- String property = columnProperties[columnNumber]; >- if (cellModifier.canModify(element, property)) { >- cellEditor = cellEditors[columnNumber]; >- //tree.showSelection(); >- cellEditor.addListener(cellEditorListener); >- Object value = cellModifier.getValue(element, property); >- cellEditor.setValue(value); >- // Tricky flow of control here: >- // activate() can trigger callback to cellEditorListener which will clear cellEditor >- // so must get control first, but must still call activate() even if there is no control. >- final Control control = cellEditor.getControl(); >- cellEditor.activate(); >- if (control == null) { >- return; >- } >- setLayoutData(cellEditor.getLayoutData()); >- setEditor(control, treeItem, columnNumber); >- cellEditor.setFocus(); >- if (focusListener == null) { >- focusListener = new FocusAdapter() { >- public void focusLost(FocusEvent e) { >- applyEditorValue(); >- } >- }; >+ ColumnViewerPart part = viewer.getColumnViewer(columnNumber); >+ Object element = treeItem.getData(); >+ >+ if( part != null && part.getEditingSupport() != null && part.getEditingSupport().canEdit(element) ) { >+ cellEditor = part.getEditingSupport().getCellEditor(element); >+ cellEditor.addListener(cellEditorListener); >+ Object value = part.getEditingSupport().getValue(element); >+ cellEditor.setValue(value); >+ // Tricky flow of control here: >+ // activate() can trigger callback to cellEditorListener which will clear cellEditor >+ // so must get control first, but must still call activate() even if there is no control. >+ final Control control = cellEditor.getControl(); >+ cellEditor.activate(); >+ if (control == null) { >+ return; >+ } >+ setLayoutData(cellEditor.getLayoutData()); >+ setEditor(control, treeItem, columnNumber); >+ cellEditor.setFocus(); >+ if (focusListener == null) { >+ focusListener = new FocusAdapter() { >+ public void focusLost(FocusEvent e) { >+ applyEditorValue(); > } >- control.addFocusListener(focusListener); >- mouseListener = new MouseAdapter() { >- 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); >- } >- } >- }; >- control.addMouseListener(mouseListener); >- } >+ }; > } >- } >+ control.addFocusListener(focusListener); >+ mouseListener = new MouseAdapter() { >+ 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); >+ } >+ } >+ }; >+ control.addMouseListener(mouseListener); >+ } > } > > /** >@@ -313,13 +309,10 @@ > * by delegating to the cell modifier. > */ > private void saveEditorValue(CellEditor cellEditor, Item treeItem) { >- if (cellModifier != null) { >- String property = null; >- if (columnProperties != null >- && columnNumber < columnProperties.length) { >- property = columnProperties[columnNumber]; >- } >- cellModifier.modify(treeItem, property, cellEditor.getValue()); >+ ColumnViewerPart part = (ColumnViewerPart)treeItem.getData(ColumnViewerPart.COLUMN_VIEWER_KEY); >+ >+ if( part != null && part.getEditingSupport() != null ) { >+ part.getEditingSupport().setValue(treeItem.getData(), cellEditor.getValue()); > } > } > >Index: src/org/eclipse/jface/viewers/DecoratingLabelProvider.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingLabelProvider.java,v >retrieving revision 1.20 >diff -u -r1.20 DecoratingLabelProvider.java >--- src/org/eclipse/jface/viewers/DecoratingLabelProvider.java 19 Apr 2006 21:05:56 -0000 1.20 >+++ src/org/eclipse/jface/viewers/DecoratingLabelProvider.java 10 Aug 2006 20:32:27 -0000 >@@ -22,10 +22,8 @@ > * The decorator decorates the label text, image, font and colors provided by > * the nested label provider. > */ >-public class DecoratingLabelProvider extends LabelProvider implements >- ILabelProvider, IViewerLabelProvider, IColorProvider, IFontProvider, ITreePathLabelProvider { >+public class DecoratingLabelProvider extends TreeColumnViewerLabelProvider { > >- private ILabelProvider provider; > > private ILabelDecorator decorator; > >@@ -43,8 +41,8 @@ > */ > public DecoratingLabelProvider(ILabelProvider provider, > ILabelDecorator decorator) { >+ super(provider); > Assert.isNotNull(provider); >- this.provider = provider; > this.decorator = decorator; > } > >@@ -56,7 +54,7 @@ > */ > public void addListener(ILabelProviderListener listener) { > super.addListener(listener); >- provider.addListener(listener); >+ getLabelProvider().addListener(listener); > if (decorator != null) { > decorator.addListener(listener); > } >@@ -68,7 +66,7 @@ > * disposes both the nested label provider and the label decorator. > */ > public void dispose() { >- provider.dispose(); >+ getLabelProvider().dispose(); > if (decorator != null) { > decorator.dispose(); > } >@@ -82,7 +80,7 @@ > * <code>decorateImage</code> method. > */ > public Image getImage(Object element) { >- Image image = provider.getImage(element); >+ Image image = getLabelProvider().getImage(element); > if (decorator != null) { > if (decorator instanceof LabelDecorator) { > LabelDecorator ld2 = (LabelDecorator) decorator; >@@ -110,15 +108,6 @@ > } > > /** >- * Returns the nested label provider. >- * >- * @return the nested label provider >- */ >- public ILabelProvider getLabelProvider() { >- return provider; >- } >- >- /** > * The <code>DecoratingLabelProvider</code> implementation of this > * <code>ILabelProvider</code> method returns the text label provided > * by the nested label provider's <code>getText</code> method, >@@ -126,7 +115,7 @@ > * <code>decorateText</code> method. > */ > public String getText(Object element) { >- String text = provider.getText(element); >+ String text = getLabelProvider().getText(element); > if (decorator != null) { > if (decorator instanceof LabelDecorator) { > LabelDecorator ld2 = (LabelDecorator) decorator; >@@ -151,7 +140,7 @@ > * decorator returns <code>true</code>. > */ > public boolean isLabelProperty(Object element, String property) { >- if (provider.isLabelProperty(element, property)) { >+ if (getLabelProvider().isLabelProperty(element, property)) { > return true; > } > if (decorator != null && decorator.isLabelProperty(element, property)) { >@@ -168,7 +157,7 @@ > */ > public void removeListener(ILabelProviderListener listener) { > super.removeListener(listener); >- provider.removeListener(listener); >+ getLabelProvider().removeListener(listener); > if (decorator != null) { > decorator.removeListener(listener); > } >@@ -260,36 +249,6 @@ > > } > >- /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) >- */ >- public Color getBackground(Object element) { >- if(provider instanceof IColorProvider) { >- return ((IColorProvider) provider).getBackground(element); >- } >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) >- */ >- public Font getFont(Object element) { >- if(provider instanceof IFontProvider) { >- return ((IFontProvider) provider).getFont(element); >- } >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) >- */ >- public Color getForeground(Object element) { >- if(provider instanceof IColorProvider) { >- return ((IColorProvider) provider).getForeground(element); >- } >- return null; >- } >- > /** > * Return the decoration context associated with this label provider. > * It will be passed to the decorator if the decorator is an >@@ -314,8 +273,10 @@ > this.decorationContext = decorationContext; > } > >+ >+ > /* (non-Javadoc) >- * @see org.eclipse.jface.viewers.ITreePathLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel, org.eclipse.jface.viewers.TreePath) >+ * @see org.eclipse.jface.viewers.TreeViewerLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel, org.eclipse.jface.viewers.TreePath) > */ > public void updateLabel(ViewerLabel settings, TreePath elementPath) { > ILabelDecorator currentDecorator = getLabelDecorator(); >@@ -338,8 +299,8 @@ > settings.setHasPendingDecorations(!decorationReady); > // update icon and label > >- if (provider instanceof ITreePathLabelProvider) { >- ITreePathLabelProvider pprov = (ITreePathLabelProvider) provider; >+ if (getTreePathProvider() == null) { >+ ITreePathLabelProvider pprov = (ITreePathLabelProvider) getLabelProvider(); > if (decorationReady || oldText == null > || settings.getText().length() == 0) { > pprov.updateLabel(settings, elementPath); >Index: src/org/eclipse/jface/viewers/TableEditorImpl.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/TableEditorImpl.java,v >retrieving revision 1.7 >diff -u -r1.7 TableEditorImpl.java >--- src/org/eclipse/jface/viewers/TableEditorImpl.java 8 May 2006 20:56:57 -0000 1.7 >+++ src/org/eclipse/jface/viewers/TableEditorImpl.java 10 Aug 2006 20:32:27 -0000 >@@ -49,9 +49,9 @@ > > private int doubleClickExpirationTime; > >- private StructuredViewer viewer; >+ private ColumnViewer viewer; > >- TableEditorImpl(StructuredViewer viewer) { >+ TableEditorImpl(ColumnViewer viewer) { > this.viewer = viewer; > initCellEditorListener(); > } >@@ -61,57 +61,53 @@ > * > * @return the viewer > */ >- public StructuredViewer getViewer() { >+ public ColumnViewer getViewer() { > return viewer; > } > > private void activateCellEditor() { >- if (cellEditors != null) { >- if (cellEditors[columnNumber] != null && cellModifier != null) { >- Object element = tableItem.getData(); >- String property = columnProperties[columnNumber]; >- if (cellModifier.canModify(element, property)) { >- cellEditor = cellEditors[columnNumber]; >- //table.showSelection(); >- cellEditor.addListener(cellEditorListener); >- Object value = cellModifier.getValue(element, property); >- cellEditor.setValue(value); >- // Tricky flow of control here: >- // activate() can trigger callback to cellEditorListener which will clear cellEditor >- // so must get control first, but must still call activate() even if there is no control. >- final Control control = cellEditor.getControl(); >- cellEditor.activate(); >- if (control == null) { >- return; >- } >- setLayoutData(cellEditor.getLayoutData()); >- setEditor(control, tableItem, columnNumber); >- cellEditor.setFocus(); >- if (focusListener == null) { >- focusListener = new FocusAdapter() { >- public void focusLost(FocusEvent e) { >- applyEditorValue(); >- } >- }; >+ ColumnViewerPart part = viewer.getColumnViewer(columnNumber); >+ Object element = tableItem.getData(); >+ >+ if( part != null && part.getEditingSupport() != null && part.getEditingSupport().canEdit(element) ) { >+ cellEditor = part.getEditingSupport().getCellEditor(element); >+ cellEditor.addListener(cellEditorListener); >+ Object value = part.getEditingSupport().getValue(element); >+ cellEditor.setValue(value); >+ // Tricky flow of control here: >+ // activate() can trigger callback to cellEditorListener which will clear cellEditor >+ // so must get control first, but must still call activate() even if there is no control. >+ final Control control = cellEditor.getControl(); >+ cellEditor.activate(); >+ if (control == null) { >+ return; >+ } >+ setLayoutData(cellEditor.getLayoutData()); >+ setEditor(control, tableItem, columnNumber); >+ cellEditor.setFocus(); >+ if (focusListener == null) { >+ focusListener = new FocusAdapter() { >+ public void focusLost(FocusEvent e) { >+ applyEditorValue(); > } >- control.addFocusListener(focusListener); >- mouseListener = new MouseAdapter() { >- 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); >- } >- } >- }; >- control.addMouseListener(mouseListener); >- } >+ }; > } >- } >+ control.addFocusListener(focusListener); >+ mouseListener = new MouseAdapter() { >+ 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); >+ } >+ } >+ }; >+ control.addMouseListener(mouseListener); >+ } > } > > /** >@@ -217,7 +213,7 @@ > > abstract Rectangle getBounds(Item item, int columnNumber); > >- /** >+/** > * Return the array of CellEditors used in the viewer > * @return the cell editors > */ >@@ -235,14 +231,14 @@ > > abstract int getColumnCount(); > >- /** >+ /** > * Return the properties for the column > * @return the array of column properties > */ > public Object[] getColumnProperties() { > return columnProperties; > } >- >+ > abstract Item[] getSelection(); > > /** >@@ -308,17 +304,11 @@ > * by delegating to the cell modifier. > */ > private void saveEditorValue(CellEditor cellEditor, Item tableItem) { >- if (cellModifier != null) { >- if (!cellEditor.isValueValid()) { >- ///Do what ??? >- } >- String property = null; >- if (columnProperties != null >- && columnNumber < columnProperties.length) { >- property = columnProperties[columnNumber]; >- } >- cellModifier.modify(tableItem, property, cellEditor.getValue()); >- } >+ ColumnViewerPart part = (ColumnViewerPart)tableItem.getData(ColumnViewerPart.COLUMN_VIEWER_KEY); >+ >+ if( part != null && part.getEditingSupport() != null ) { >+ part.getEditingSupport().setValue(tableItem.getData(), cellEditor.getValue()); >+ } > } > > /** >@@ -344,7 +334,7 @@ > public void setColumnProperties(String[] columnProperties) { > this.columnProperties = columnProperties; > } >- >+ > abstract void setEditor(Control w, Item item, int fColumnNumber); > > abstract void setLayoutData(CellEditor.LayoutData layoutData); >Index: src/org/eclipse/jface/viewers/TableTreeViewer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/TableTreeViewer.java,v >retrieving revision 1.21 >diff -u -r1.21 TableTreeViewer.java >--- src/org/eclipse/jface/viewers/TableTreeViewer.java 8 May 2006 20:56:57 -0000 1.21 >+++ src/org/eclipse/jface/viewers/TableTreeViewer.java 10 Aug 2006 20:32:27 -0000 >@@ -519,4 +519,11 @@ > protected void showItem(Item item) { > getTableTree().showItem((TableTreeItem) item); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ColumnViewer#getColumnViewerOwner(int) >+ */ >+ protected Widget getColumnViewerOwner(int columnIndex) { >+ return null; >+ } > } >Index: src/org/eclipse/jface/viewers/ViewerLabel.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerLabel.java,v >retrieving revision 1.11 >diff -u -r1.11 ViewerLabel.java >--- src/org/eclipse/jface/viewers/ViewerLabel.java 8 May 2006 20:56:57 -0000 1.11 >+++ src/org/eclipse/jface/viewers/ViewerLabel.java 10 Aug 2006 20:32:27 -0000 >@@ -13,6 +13,7 @@ > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; > import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; > > /** > * The ViewerLabel is the class that is passed to a viewer to handle updates of >@@ -43,6 +44,14 @@ > private Image startImage; > > private boolean hasPendingDecorations; >+ >+ private String tooltipText; >+ >+ private Color tooltipForegroundColor; >+ >+ private Color tooltipBackgroundColor; >+ >+ private Point tooltipShift; > > /** > * Create a new instance of the receiver with the supplied >@@ -241,4 +250,88 @@ > /* public */ boolean hasPendingDecorations() { > return hasPendingDecorations; > } >+ >+ /** >+ * @return Returns the tooltipText. >+ */ >+ public String getTooltipText() { >+ return tooltipText; >+ } >+ >+ /** >+ * @param tooltipText The tooltipText to set. >+ */ >+ public void setTooltipText(String tooltipText) { >+ this.tooltipText = tooltipText; >+ } >+ >+ /** >+ * @return Return whether or not the tooltip text has been set. >+ */ >+ public boolean hasNewTooltipText() { >+ return this.tooltipText != null; >+ } >+ >+ /** >+ * @return Returns the tooltipBackgroundColor. >+ */ >+ public Color getTooltipBackgroundColor() { >+ return tooltipBackgroundColor; >+ } >+ >+ /** >+ * @param tooltipBackgroundColor The tooltipBackgroundColor to set. >+ */ >+ public void setTooltipBackgroundColor(Color tooltipBackgroundColor) { >+ this.tooltipBackgroundColor = tooltipBackgroundColor; >+ } >+ >+ /** >+ * @return Return whether or not the tooltip background color has been set. >+ */ >+ public boolean hasNewTooltipBackgroundColor() { >+ return tooltipBackgroundColor != null; >+ } >+ >+ /** >+ * @return Returns the tooltipForegroundColor. >+ */ >+ public Color getTooltipForegroundColor() { >+ return tooltipForegroundColor; >+ } >+ >+ /** >+ * @param tooltipForegroundColor The tooltipForegroundColor to set. >+ */ >+ public void setTooltipForegroundColor(Color tooltipForegroundColor) { >+ this.tooltipForegroundColor = tooltipForegroundColor; >+ } >+ >+ /** >+ * @return Return whether or not the tooltip foreground color has been set. >+ */ >+ public boolean hasNewTooltipForegroundColor() { >+ return tooltipForegroundColor != null; >+ } >+ >+ /** >+ * @return Returns the tooltipShift. >+ */ >+ public Point getTooltipShift() { >+ return tooltipShift; >+ } >+ >+ /** >+ * @param tooltipShift The tooltipShift to set. >+ */ >+ public void setTooltipShift(Point tooltipShift) { >+ this.tooltipShift = tooltipShift; >+ } >+ >+ /** >+ * @return Return whether or not the tooltip shift has been set. >+ */ >+ public boolean hasTooltipShift() { >+ return this.tooltipShift != null; >+ } > } >Index: src/org/eclipse/jface/viewers/ColumnViewerPart.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/ColumnViewerPart.java >diff -N src/org/eclipse/jface/viewers/ColumnViewerPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/ColumnViewerPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,158 @@ >+/******************************************************************************* >+ * 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 >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import org.eclipse.jface.util.Policy; >+import org.eclipse.swt.widgets.Widget; >+ >+/** >+ * The ColumnViewerPart is abstract implementation of the column parts. >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * >+ * @since 3.3 >+ * >+ */ >+public class ColumnViewerPart { >+ >+ private ViewerLabelProvider labelProvider; >+ >+ static String COLUMN_VIEWER_KEY = Policy.JFACE + ".columnViewer";//$NON-NLS-1$ >+ >+ private EditingSupport editingSupport; >+ >+ >+ >+ >+ /** >+ * Create a new instance of the receiver at columnIndex. >+ * >+ * @param columnOwner >+ * @param provider >+ */ >+ public ColumnViewerPart(Widget columnOwner, ViewerLabelProvider provider) { >+ labelProvider = provider; >+ columnOwner.setData(ColumnViewerPart.COLUMN_VIEWER_KEY, this); >+ } >+ >+ /** >+ * Return the label provider for the receiver. >+ * >+ * @return ViewerLabelProvider >+ */ >+ public ViewerLabelProvider getLabelProvider() { >+ return labelProvider; >+ } >+ >+ /** >+ * @param labelProvider >+ * the new label-provider >+ */ >+ public void setLabelProvider(ViewerLabelProvider labelProvider) { >+ this.labelProvider = labelProvider; >+ } >+ >+ /** >+ * @return Returns the editingSupport. >+ */ >+ EditingSupport getEditingSupport() { >+ return editingSupport; >+ } >+ >+ /** >+ * @param editingSupport >+ * The editingSupport to set. >+ */ >+ void setEditingSupport(EditingSupport editingSupport) { >+ this.editingSupport = editingSupport; >+ } >+ >+ /** >+ * Refresh the row for the given columnIndex >+ * >+ * @param row >+ * @param element >+ * @param columnIndex >+ */ >+ public void refresh(RowPart row, int columnIndex) { >+ ViewerLabel label = new ViewerLabel(row.getText(columnIndex), row >+ .getImage(columnIndex)); >+ getLabelProvider().updateLabel(label, row.getItem().getData(), columnIndex); >+ >+ row.setBackground(columnIndex, label.getBackground()); >+ row.setForeground(columnIndex, label.getForeground()); >+ row.setFont(columnIndex, label.getFont()); >+ >+ if (label.hasNewText()) >+ row.setText(columnIndex, label.getText()); >+ >+ if (label.hasNewImage()) >+ row.setImage(columnIndex, label.getImage()); >+ } >+ >+ /** >+ * Refresh the TreeItem for element. >+ * >+ * @param item >+ * @param element >+ * @param columnIndex >+ */ >+/* public void refresh(TreeItem item, Object element, int columnIndex) { >+ >+ ViewerLabel label = new ViewerLabel(item.getText(columnIndex), item >+ .getImage(columnIndex)); >+ getLabelProvider().updateLabel(label, element, columnIndex); >+ >+ // We can not make a null check because then we could not >+ // set the items back to default state >+ item.setBackground(columnIndex, label.getBackground()); >+ item.setForeground(columnIndex, label.getForeground()); >+ item.setFont(columnIndex, label.getFont()); >+ >+ if (label.hasNewText()) >+ item.setText(columnIndex, label.getText()); >+ >+ if (label.hasNewImage()) >+ item.setImage(columnIndex, label.getImage()); >+ } >+*/ >+ /** >+ * Refresh the TableItem for element. >+ * >+ * @param item >+ * @param element >+ * @param columnIndex >+ */ >+/* public void refresh(TableItem item, Object element, int columnIndex) { >+ >+ ViewerLabel label = new ViewerLabel(item.getText(columnIndex), item >+ .getImage(columnIndex)); >+ getLabelProvider().updateLabel(label, element, columnIndex); >+ >+ if (label.hasNewBackground()) >+ item.setBackground(columnIndex, label.getBackground()); >+ >+ if (label.hasNewForeground()) >+ item.setForeground(columnIndex, label.getForeground()); >+ >+ if (label.hasNewFont()) >+ item.setFont(columnIndex, label.getFont()); >+ >+ if (label.hasNewText()) >+ item.setText(columnIndex, label.getText()); >+ >+ if (label.hasNewImage()) >+ item.setImage(columnIndex, label.getImage()); >+ }*/ >+} >Index: src/org/eclipse/jface/viewers/ColumnViewer.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/ColumnViewer.java >diff -N src/org/eclipse/jface/viewers/ColumnViewer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/ColumnViewer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,218 @@ >+/******************************************************************************* >+ * 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 >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.widgets.Item; >+import org.eclipse.swt.widgets.Widget; >+ >+/** >+ * The ColumnViewer is the abstract superclass of viewers that jave columns >+ * (TreeViewer and TableViewer). >+ * >+ * @since 3.3 <strong>EXPERIMENTAL</strong> This class or interface has been >+ * added as part of a work in progress. This API may change at any given >+ * time. Please do not use this API without consulting with the >+ * Platform/UI team. >+ * >+ */ >+abstract class ColumnViewer extends StructuredViewer { >+ >+ private TooltipSupport tooltipSupport; >+ >+ /** >+ * Create a new instance of the receiver. >+ */ >+ public ColumnViewer() { >+ super(); >+ tooltipSupport = new TooltipSupport(this); >+ } >+ >+ /** >+ * Get the cell at this point. >+ * <p> >+ * <i>Subclasses should overwrite this method and provide a meaningful >+ * implementation</i> >+ * </p> >+ * >+ * @param point >+ * the point in the viewer where you need to corresponding cell >+ * from >+ * @param onlyInSelection >+ * search only in selection >+ * @return the cell or if no cell is found at this point >+ */ >+ Cell getCell(Point point) { >+ RowPart row = getRowPart(point); >+ if (row != null) { >+ return row.getCell(point); >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Get the RowPart at point. >+ * >+ * @param point >+ * @return RowPart >+ */ >+ protected RowPart getRowPart(Point point) { >+ Item item = getItem(point.x, point.y); >+ >+ if (item != null) { >+ return getRowPartFromItem(item); >+ } >+ >+ return null; >+ } >+ >+ protected RowPart getRowPartFromItem(Widget item) { >+ return (RowPart) item.getData(RowPart.ROWPART_KEY); >+ } >+ >+ /** >+ * Get the widget for the column at columnIndex. >+ * >+ * @param columnIndex >+ * @return Widget >+ */ >+ protected abstract Widget getColumnViewerOwner(int columnIndex); >+ >+ /** >+ * Returns the cell modifier of this viewer. >+ * >+ * @return the cell modifier >+ * @since 3.1 (in subclasses, added in 3.3 to abstract class) >+ */ >+ public abstract ICellModifier getCellModifier(); >+ >+ /** >+ * Return the CellEditors for the receiver. >+ * >+ * @return CellEditor[] >+ * @since 3.1 (in subclasses, added in 3.3 to abstract class) >+ */ >+ public abstract CellEditor[] getCellEditors(); >+ >+ /** >+ * Returns the column properties of this table viewer. The properties must >+ * correspond with the columns of the table control. They are used to >+ * identify the column in a cell modifier. >+ * >+ * @return the list of column properties >+ * @since 3.1 (in subclasses, added in 3.3 to abstract class) >+ */ >+ public abstract Object[] getColumnProperties(); >+ >+ /** >+ * Return the TableColumnViewer at columnIndex >+ * >+ * @param columnIndex >+ * @return TableColumnViewer >+ */ >+ public ColumnViewerPart getColumnViewer(final int columnIndex) { >+ >+ ColumnViewerPart viewer; >+ Widget columnOwner = getColumnViewerOwner(columnIndex); >+ >+ if (columnOwner == null) { >+ return null; >+ } >+ >+ viewer = (ColumnViewerPart) columnOwner >+ .getData(ColumnViewerPart.COLUMN_VIEWER_KEY); >+ >+ if (viewer == null) { >+ viewer = createColumnViewer(columnOwner, ViewerLabelProvider >+ .createViewerLabelProvider(getLabelProvider())); >+ if (getCellModifier() != null) { >+ viewer.setEditingSupport(new EditingSupport() { >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.EditingSupport#canEdit(java.lang.Object) >+ */ >+ public boolean canEdit(Object element) { >+ return getCellModifier().canModify(element, >+ (String) getColumnProperties()[columnIndex]); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.EditingSupport#getCellEditor(java.lang.Object) >+ */ >+ public CellEditor getCellEditor(Object element) { >+ return getCellEditors()[columnIndex]; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object) >+ */ >+ public Object getValue(Object element) { >+ return getCellModifier().getValue(element, >+ (String) getColumnProperties()[columnIndex]); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, >+ * java.lang.Object) >+ */ >+ public void setValue(Object element, Object value) { >+ getCellModifier().modify(findItem(element), >+ (String) getColumnProperties()[columnIndex], >+ value); >+ } >+ }); >+ } >+ } >+ >+ // Reset the colum-index because maybe it changed from the last time >+ viewer.getLabelProvider().setColumnIndex(columnIndex); >+ >+ return viewer; >+ } >+ >+ /** >+ * Create a ColumnViewerPart for the columnOwner. >+ * >+ * @param columnOwner >+ * @param labelProvider >+ * @return ColumnViewerPart >+ */ >+ protected ColumnViewerPart createColumnViewer(Widget columnOwner, >+ ViewerLabelProvider labelProvider) { >+ return new ColumnViewerPart(columnOwner, labelProvider); >+ } >+ >+ /** >+ * Activate the tooltip support. >+ */ >+ public void activateCustomTooltips() { >+ tooltipSupport.activate(); >+ } >+ >+ /** >+ * Deactivate the tooltip support. >+ */ >+ public void deactivateCustomTooltips() { >+ tooltipSupport.deactivate(); >+ } >+ >+} >Index: src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java >diff -N src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/******************************************************************************* >+ * 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 >+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+ >+/** >+ * TreeViewerLabelProvider is the ViewerLabelProvider that handles >+ * TreePaths. >+ * @since 3.3 >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * >+ */ >+public class TreeColumnViewerLabelProvider extends TableColumnViewerLabelProvider { >+ private ITreePathLabelProvider treePathProvider; >+ >+ >+ /** >+ * Create a new instance of the receiver with the supplied labelProvider. >+ * @param labelProvider >+ */ >+ public TreeColumnViewerLabelProvider(IBaseLabelProvider labelProvider) { >+ super(labelProvider); >+ } >+ >+ /** >+ * Update the label for the element with TreePath. >+ * @param label >+ * @param elementPath >+ */ >+ public void updateLabel(ViewerLabel label, TreePath elementPath) { >+ treePathProvider.updateLabel(label, elementPath); >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ViewerLabelProvider#setProviders(java.lang.Object) >+ */ >+ public void setProviders(Object provider) { >+ super.setProviders(provider); >+ if(provider instanceof ITreePathLabelProvider) >+ treePathProvider = (ITreePathLabelProvider) provider; >+ } >+ >+ /** >+ * Return the ITreePathLabelProvider for the receiver. >+ * @return Returns the treePathProvider. >+ */ >+ public ITreePathLabelProvider getTreePathProvider() { >+ return treePathProvider; >+ } >+ >+} >Index: src/org/eclipse/jface/viewers/TableRowPart.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/TableRowPart.java >diff -N src/org/eclipse/jface/viewers/TableRowPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/TableRowPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,141 @@ >+/******************************************************************************* >+ * 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 >+ * >+ * @since 3.3 >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Item; >+import org.eclipse.swt.widgets.TableItem; >+ >+/** >+ * TableRowPart is the Table specific implementation of RowPart >+ * @since 3.3 >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * >+ */ >+public class TableRowPart extends RowPart { >+ private TableItem item; >+ >+ /** >+ * Create a new instance of the receiver from item. >+ * @param item >+ */ >+ TableRowPart(TableItem item) { >+ super(item); >+ this.item = item; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getBounds(int) >+ */ >+ public Rectangle getBounds(int columnIndex) { >+ return item.getBounds(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getBounds() >+ */ >+ public Rectangle getBounds() { >+ return item.getBounds(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getItem() >+ */ >+ public Item getItem() { >+ return item; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getColumnCount() >+ */ >+ public int getColumnCount() { >+ return item.getParent().getColumnCount(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getBackground(int) >+ */ >+ public Color getBackground(int columnIndex) { >+ return item.getBackground(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getFont(int) >+ */ >+ public Font getFont(int columnIndex) { >+ return item.getFont(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getForeground(int) >+ */ >+ public Color getForeground(int columnIndex) { >+ return item.getForeground(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getImage(int) >+ */ >+ public Image getImage(int columnIndex) { >+ return item.getImage(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getText(int) >+ */ >+ public String getText(int columnIndex) { >+ return item.getText(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setBackground(int, org.eclipse.swt.graphics.Color) >+ */ >+ public void setBackground(int columnIndex, Color color) { >+ item.setBackground(columnIndex, color); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setFont(int, org.eclipse.swt.graphics.Font) >+ */ >+ public void setFont(int columnIndex, Font font) { >+ item.setFont(columnIndex, font); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setForeground(int, org.eclipse.swt.graphics.Color) >+ */ >+ public void setForeground(int columnIndex, Color color) { >+ item.setForeground(columnIndex, color); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setImage(int, org.eclipse.swt.graphics.Image) >+ */ >+ public void setImage(int columnIndex, Image image) { >+ item.setImage(columnIndex,image); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setText(int, java.lang.String) >+ */ >+ public void setText(int columnIndex, String text) { >+ item.setText(columnIndex, text); >+ } >+ >+} >Index: src/org/eclipse/jface/viewers/TableColumnViewerLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/TableColumnViewerLabelProvider.java >diff -N src/org/eclipse/jface/viewers/TableColumnViewerLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/TableColumnViewerLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,139 @@ >+/******************************************************************************* >+ * 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; >+ >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * TableColumnViewerLabelProvider is the mapping from the table based providers >+ * to the ViewerLabelProvider. >+ * >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * @since 3.3 >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ * @see ITableLabelProvider >+ * @see ITableColorProvider >+ * @see ITableFontProvider >+ * >+ */ >+class TableColumnViewerLabelProvider extends ViewerLabelProvider { >+ >+ /** >+ * Create a new instance of the receiver. >+ * >+ * @param labelProvider >+ * instance of a table based label provider >+ * @param columnIndex >+ * the index into the table for this column >+ * @see ITableLabelProvider >+ * @see ITableColorProvider >+ * @see ITableFontProvider >+ */ >+ public TableColumnViewerLabelProvider(IBaseLabelProvider labelProvider) { >+ super(labelProvider); >+ >+ if (labelProvider instanceof ITableLabelProvider) >+ setLabelProvider(labelProviderFor((ITableLabelProvider) labelProvider)); >+ >+ if (labelProvider instanceof ITableColorProvider) >+ setColorProvider(colorProviderFor((ITableColorProvider) labelProvider)); >+ >+ if (labelProvider instanceof ITableFontProvider) >+ setFontProvider(fontProviderFor((ITableFontProvider) labelProvider)); >+ } >+ >+ >+ /** >+ * Return the IFontProvider based on provider at columnIndex. >+ * >+ * @param provider >+ * @param columnIndex >+ * @return IFontProvider >+ */ >+ private IFontProvider fontProviderFor(final ITableFontProvider provider) { >+ return new IFontProvider() { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) >+ */ >+ public Font getFont(Object element) { >+ return provider.getFont(element, getColumnIndex()); >+ } >+ }; >+ } >+ >+ /** >+ * Return the ILabelProvider based on provider at columnIndex. >+ * >+ * @param provider >+ * @param columnIndex >+ * @return ILabelProvider >+ */ >+ private ILabelProvider labelProviderFor(final ITableLabelProvider provider) { >+ return new LabelProvider() { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) { >+ return provider.getColumnText(element, getColumnIndex()); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) >+ */ >+ public Image getImage(Object element) { >+ return provider.getColumnImage(element, getColumnIndex()); >+ } >+ }; >+ } >+ >+ /** >+ * Create an IColorProvider from the ITableColorProvider at columnIndex. >+ * >+ * @param provider >+ * @param columnIndex >+ * @return IColorProvider >+ */ >+ private IColorProvider colorProviderFor(final ITableColorProvider provider) { >+ return new IColorProvider() { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) >+ */ >+ public Color getBackground(Object element) { >+ return provider.getBackground(element, getColumnIndex()); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) >+ */ >+ public Color getForeground(Object element) { >+ return provider.getForeground(element, getColumnIndex()); >+ } >+ }; >+ } >+ >+} >Index: src/org/eclipse/jface/viewers/ViewerLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/ViewerLabelProvider.java >diff -N src/org/eclipse/jface/viewers/ViewerLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/ViewerLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,424 @@ >+/******************************************************************************* >+ * 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 >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+ >+/** >+ * The ViewerLabelProvider is an abstract implementation of a >+ * label provider for structured viewers. >+ * @since 3.3 >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ */ >+public class ViewerLabelProvider extends LabelProvider implements >+ ILabelProvider, IColorProvider, IFontProvider { >+ >+ private static ILabelProvider defaultLabelProvider = new LabelProvider() { >+ >+ }; >+ >+ private ILabelProvider labelProvider = defaultLabelProvider; >+ >+ private IColorProvider colorProvider; >+ >+ private IFontProvider fontProvider; >+ >+ private int columnIndex; >+ >+ /** >+ * Create a new instance of the receiver. >+ */ >+ public ViewerLabelProvider() { >+ super(); >+ } >+ >+ /** >+ * Create a new instance of the receiver based on labelProvider. >+ * >+ * @param labelProvider >+ */ >+ public ViewerLabelProvider(IBaseLabelProvider labelProvider) { >+ super(); >+ setProviders(labelProvider); >+ } >+ >+ /** >+ * Create a ViewerLabelProvider for the column at index >+ * >+ * @param columnIndex >+ * @param labelProvider >+ * The labelProvider to convert >+ * @return ViewerLabelProvider >+ */ >+ static ViewerLabelProvider createViewerLabelProvider( >+ IBaseLabelProvider labelProvider) { >+ >+ if (labelProvider instanceof ITableLabelProvider >+ || labelProvider instanceof ITableColorProvider >+ || labelProvider instanceof ITableFontProvider) >+ return new TableColumnViewerLabelProvider(labelProvider); >+ return new ViewerLabelProvider(labelProvider); >+ >+ } >+ >+ private void updateLabel(ViewerLabel label, Object element) { >+ label.setText(labelProvider.getText(element)); >+ label.setImage(labelProvider.getImage(element)); >+ >+ if (colorProvider != null) { >+ label.setBackground(colorProvider.getBackground(element)); >+ label.setForeground(colorProvider.getForeground(element)); >+ } >+ >+ if (fontProvider != null) { >+ label.setFont(fontProvider.getFont(element)); >+ } >+ } >+ >+ /** >+ * Updates the label for the given element and the given index >+ * >+ * @param label >+ * the label to update >+ * @param element >+ * the element >+ * @param columnIndex >+ * the column index >+ */ >+ public void updateLabel(ViewerLabel label, Object element, int columnIndex) { >+ setColumnIndex(columnIndex); >+ updateLabel(label, element); >+ } >+ >+ /** >+ * @param columnIndex >+ * the column-index >+ */ >+ public void setColumnIndex(int columnIndex) { >+ this.columnIndex = columnIndex; >+ } >+ >+ /** >+ * @return Returns the column index >+ */ >+ public int getColumnIndex() { >+ return columnIndex; >+ } >+ >+ /** >+ * Set the colorProvider to use for the receiver. >+ * >+ * @param colorProvider >+ * The colorProvider to set. >+ */ >+ public void setColorProvider(IColorProvider colorProvider) { >+ this.colorProvider = colorProvider; >+ } >+ >+ /** >+ * Set the fontProvider to fontProvider. >+ * >+ * @param fontProvider >+ * The fontProvider to set. >+ */ >+ public void setFontProvider(IFontProvider fontProvider) { >+ this.fontProvider = fontProvider; >+ } >+ >+ /** >+ * Set the labelProvider to be provider. >+ * >+ * @param provider >+ * ILabelProvider provider to set. >+ */ >+ public void setLabelProvider(ILabelProvider provider) { >+ this.labelProvider = provider; >+ } >+ >+ /** >+ * Set the any providers for the receiver that can be adapted from provider. >+ * >+ * @param provider >+ */ >+ public void setProviders(Object provider) { >+ if (provider instanceof ILabelProvider) >+ setLabelProvider((ILabelProvider) provider); >+ >+ if (provider instanceof IColorProvider) >+ colorProvider = (IColorProvider) provider; >+ >+ if (provider instanceof IFontProvider) >+ fontProvider = (IFontProvider) provider; >+ >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) >+ */ >+ public Font getFont(Object element) { >+ if (fontProvider == null) { >+ return null; >+ } >+ >+ return fontProvider.getFont(element); >+ >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) >+ */ >+ public Color getBackground(Object element) { >+ if (colorProvider == null) { >+ return null; >+ } >+ >+ return colorProvider.getBackground(element); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) >+ */ >+ public Color getForeground(Object element) { >+ if (colorProvider == null) { >+ return null; >+ } >+ >+ return colorProvider.getForeground(element); >+ } >+ >+ /** >+ * Get the IColorProvider for the receiver. >+ * >+ * @return IColorProvider >+ */ >+ public IColorProvider getColorProvider() { >+ return colorProvider; >+ } >+ >+ /** >+ * Get the IFontProvider for the receiver. >+ * >+ * @return IFontProvider >+ */ >+ public IFontProvider getFontProvider() { >+ return fontProvider; >+ } >+ >+ /** >+ * @return Returns the labelProvider. >+ */ >+ public ILabelProvider getLabelProvider() { >+ return labelProvider; >+ } >+ >+ /** >+ * The image displayed in the tooltip >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @return the image displayed if null no image is displayed >+ */ >+ >+ public Image getTooltipImage(Object object) { >+ return null; >+ } >+ >+ /** >+ * Returns the tooltip text for the given element and column index, or >+ * <code>null</code> if a custom tooltip should not be displayed. >+ * >+ * @param element >+ * the element for which the tooltip is shown >+ * @return the text to be displayed in the tooltip, or <code>null</code> >+ * if a custom tooltip should not be displayed >+ */ >+ public String getTooltipText(Object element) { >+ return null; >+ } >+ >+ /** >+ * The background color used for the tooltip >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * >+ * @return the color used or <code>null</code> if you want to use the >+ */ >+ public Color getTooltipBackgroundColor(Object object) { >+ return null; >+ } >+ >+ /** >+ * The foreground color used to display the the text in the tooltip >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @return the color used or <code>null</code> if you want to use the >+ * default color {@link SWT#COLOR_INFO_FOREGROUND} >+ */ >+ public Color getTooltipForegroundColor(Object object) { >+ return null; >+ } >+ >+ /** >+ * The font used to display the tooltip >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @return the font if null default font is used >+ */ >+ public Font getTooltipFont(Object object) { >+ return null; >+ } >+ >+ /** >+ * This is the amount the used to control how much the tooltip is shifted >+ * from the current mouse position >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @param columnIndex >+ * the column-index >+ * @return shift of the tooltip >+ */ >+ public Point getTooltipShift(Object object, int columnIndex) { >+ return null; >+ } >+ >+ /** >+ * If you want your tooltip to be using the native Tooltip you can force >+ * this by returning true from this method. If native tooltips are used only >+ * the text-value is used all other feature are of custom tooltips are not >+ * supported. >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @param columnIndex >+ * the column-index >+ * @return true if native tooltips should be used >+ */ >+ public boolean useNativeTooltip(Object object, int columnIndex) { >+ return false; >+ } >+ >+ /** >+ * The time in milliseconds after the tooltip is hidden >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @param columnIndex >+ * the column-index >+ * @return milliseconds >+ */ >+ public int getTooltipTimeDisplayed(Object object, int columnIndex) { >+ return 0; >+ } >+ >+ /** >+ * The time in milliseconds until the tooltip pops up >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @param columnIndex >+ * the column-index >+ * @return milliseconds >+ */ >+ public int getTooltipDisplayDelayTime(Object object, int columnIndex) { >+ return 0; >+ } >+ >+ /** >+ * The style used to create the label >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @param columnIndex >+ * the column-index >+ * @return style mask >+ */ >+ public int getTooltipImageStyle(Object object, int columnIndex) { >+ return SWT.SHADOW_NONE; >+ } >+ >+ /** >+ * This is the amount the used to control how much the tooltip is shifted >+ * from the current mouse position >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @return shift of the tooltip >+ */ >+ public Point getTooltipShift(Object object) { >+ return null; >+ } >+ >+ /** >+ * If you want your tooltip to be using the native Tooltip you can force >+ * this by returning true from this method. If native tooltips are used only >+ * the text-value is used all other feature are of custom tooltips are not >+ * supported. >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @return true if native tooltips should be used >+ */ >+ public boolean useNativeTooltip(Object object) { >+ return false; >+ } >+ >+ /** >+ * The time in milliseconds after the tooltip is hidden >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @return milliseconds >+ */ >+ public int getTooltipTimeDisplayed(Object object) { >+ return 0; >+ } >+ >+ /** >+ * The time in milliseconds until the tooltip pops up >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @return milliseconds >+ */ >+ public int getTooltipDisplayDelayTime(Object object) { >+ return 0; >+ } >+ >+ /** >+ * The style used to create the label >+ * >+ * @param object >+ * the element for which the tooltip is shown >+ * @return style mask >+ */ >+ public int getTooltipImageStyle(Object object) { >+ return SWT.SHADOW_NONE; >+ } >+ >+} >Index: src/org/eclipse/jface/viewers/TooltipSupport.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/TooltipSupport.java >diff -N src/org/eclipse/jface/viewers/TooltipSupport.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/TooltipSupport.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,212 @@ >+/******************************************************************************* >+ * 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 >+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import java.util.Timer; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CLabel; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * The TooltipSupport is the class that provides tooltips for >+ * ColumnViewers. >+ * @since 3.3 >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * >+ */ >+class TooltipSupport { >+ private ColumnViewer viewer; >+ private Listener listener = new MouseListener(); >+ private static final int DEFAULT_SHIFT_X = 10; >+ private static final int DEFAULT_SHIFT_Y = 0; >+ >+ TooltipSupport(ColumnViewer viewer) { >+ this.viewer = viewer; >+ } >+ >+ /** >+ * activate tooltip support for this viewer >+ */ >+ public void activate() { >+ deactivate(); >+ viewer.getControl().addListener(SWT.Dispose, listener); >+ viewer.getControl().addListener(SWT.MouseHover, listener); >+ viewer.getControl().addListener(SWT.MouseMove, listener); >+ viewer.getControl().addListener(SWT.MouseExit, listener); >+ viewer.getControl().addListener(SWT.MouseDown, listener); >+ } >+ >+ /** >+ * deactivate tooltip support for this viewer >+ */ >+ public void deactivate() { >+ viewer.getControl().removeListener(SWT.Dispose, listener); >+ viewer.getControl().removeListener(SWT.MouseHover, listener); >+ viewer.getControl().removeListener(SWT.MouseMove, listener); >+ viewer.getControl().removeListener(SWT.MouseExit, listener); >+ viewer.getControl().removeListener(SWT.MouseDown, listener); >+ } >+ >+ private class MouseListener implements Listener { >+ private Shell tip; >+ private TooltipHideListener hideListener = new TooltipHideListener(); >+ private Timer timer = new Timer(); >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) >+ */ >+ public void handleEvent(Event event) { >+ switch (event.type) { >+ case SWT.Dispose: >+ if( timer != null ) { >+ timer.cancel(); >+ } >+ case SWT.KeyDown: >+ case SWT.MouseMove: >+ case SWT.MouseDown: >+ disposeTooltip(tip); >+ break; >+ case SWT.MouseHover: >+ Point p = new Point(event.x, event.y); >+ RowPart row = viewer.getRowPart(p); >+ viewer.getControl().setToolTipText(""); //$NON-NLS-1$ >+ >+ if (row != null) { >+ popupTooltip(row, p); >+ } >+ >+ break; >+ } >+ } >+ >+ /** >+ * Popup a tooltip for the row at Point p. >+ * @param row >+ * @param p >+ */ >+ private void popupTooltip(RowPart row, Point p) { >+ Object element = row.getItem().getData(); >+ disposeTooltip(tip); >+ >+ ColumnViewerPart viewPart = viewer.getColumnViewer(row.getColumnIndex(p)); >+ >+ if( viewPart == null ) { >+ return; >+ } >+ >+ ViewerLabelProvider labelProvider = viewPart.getLabelProvider(); >+ >+ String text = labelProvider.getTooltipText(element); >+ >+ if( text != null ) { >+ >+ if( labelProvider.useNativeTooltip(element) ) { >+ viewer.getControl().setToolTipText(text); >+ return; >+ } >+ >+ tip = new Shell(viewer.getControl().getShell(), SWT.ON_TOP | SWT.TOOL); >+ tip.setLayout(new FillLayout()); >+ CLabel label = new CLabel(tip, labelProvider.getTooltipImageStyle(element)); >+ label.setText(text); >+ label.addListener(SWT.MouseExit, hideListener); >+ label.addListener(SWT.MouseDown, hideListener); >+ >+ Image img = labelProvider.getTooltipImage(element); >+ >+ if( img != null) { >+ label.setImage(img); >+ } >+ >+ Color color = labelProvider.getTooltipForegroundColor(element); >+ if( color == null ) { >+ color = viewer.getControl().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND); >+ } >+ label.setForeground(color); >+ >+ color = labelProvider.getTooltipBackgroundColor(element); >+ if( color == null ) { >+ color = viewer.getControl().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND); >+ } >+ label.setBackground(color); >+ >+ Font font = labelProvider.getTooltipFont(element); >+ >+ if( font != null ) { >+ label.setFont(font); >+ } >+ >+ Point pt = viewer.getControl().toDisplay(p); >+ Point shift = labelProvider.getTooltipShift(element); >+ >+ if( shift == null ) { >+ pt.x += DEFAULT_SHIFT_X; >+ pt.y += DEFAULT_SHIFT_Y; >+ } else { >+ pt.x += shift.x; >+ pt.y += shift.y; >+ } >+ >+ tip.pack(); >+ tip.setLocation(pt); >+ tip.setVisible(true); >+ } >+ } >+ >+ /** >+ * Dispose the tooltip. >+ * @param tip >+ */ >+ private void disposeTooltip(Shell tip) { >+ if (tip != null && !tip.isDisposed()) { >+ tip.dispose(); >+ } >+ >+ tip = null; >+ } >+ } >+ >+ /** >+ * TooltipHideListener is a listener for tooltip removal. >+ * @since 3.3 >+ * >+ */ >+ private class TooltipHideListener implements Listener { >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) >+ */ >+ public void handleEvent(Event event) { >+ CLabel label = (CLabel) event.widget; >+ Shell shell = label.getShell(); >+ switch (event.type) { >+ case SWT.MouseDown: >+ viewer.setSelection(new StructuredSelection()); >+ // fall through >+ case SWT.MouseExit: >+ viewer.getControl().setFocus(); >+ shell.dispose(); >+ break; >+ } >+ } >+ } >+} >Index: src/org/eclipse/jface/viewers/EditingSupport.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/EditingSupport.java >diff -N src/org/eclipse/jface/viewers/EditingSupport.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/EditingSupport.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,62 @@ >+/******************************************************************************* >+ * 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; >+ >+/** >+ * EditingSupport is the abstract superclass of the support for cell editing. >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * @since 3.3 >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ * >+ */ >+abstract class EditingSupport { >+ /** >+ * The editor to be shown >+ * >+ * @param element >+ * the model element >+ * @return the CellEditor >+ */ >+ abstract CellEditor getCellEditor(Object element); >+ >+ /** >+ * Is the cell editable >+ * >+ * @param element >+ * the model element >+ * @return true if editable >+ */ >+ abstract boolean canEdit(Object element); >+ >+ /** >+ * Get the value to set to the editor >+ * >+ * @param element >+ * the model element >+ * @return the value shown >+ */ >+ abstract Object getValue(Object element); >+ >+ /** >+ * Restore the value from the CellEditor >+ * >+ * @param element >+ * the model element >+ * @param value >+ * the new value >+ */ >+ abstract void setValue(Object element, Object value); >+} >Index: src/org/eclipse/jface/viewers/TreeColumnViewerPart.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/TreeColumnViewerPart.java >diff -N src/org/eclipse/jface/viewers/TreeColumnViewerPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/TreeColumnViewerPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/******************************************************************************* >+ * 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; >+ >+import org.eclipse.swt.widgets.TreeColumn; >+ >+/** >+ * Wrapper class for {@link TreeColumn} >+ * @since 3.3 >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ >+ * >+ */ >+public class TreeColumnViewerPart extends ColumnViewerPart { >+ private TreeColumn column; >+ >+ /** >+ * Create new TableColumnViewerPart. This simply wrapps up a new >+ * {@link TreeColumn#TableColumn(org.eclipse.swt.widgets.Table, int)}. >+ * Before calling {@link TreeViewer#setInput(Object)}} you need to set the >+ * label-provider using >+ * {@link ColumnViewerPart#setLabelProvider(ViewerLabelProvider)} >+ * >+ * @param parent >+ * the table-viewer >+ * @param style >+ * style bits used to create TableColumn {@link TreeColumn} >+ */ >+ public TreeColumnViewerPart(TreeViewer parent, int style) { >+ this(new TreeColumn(parent.getTree(), style),null); >+ } >+ >+ /** >+ * Create new TableColumnViewerPart. This simply wrapps up a new >+ * {@link TableColumn#TableColumn(org.eclipse.swt.widgets.Table, int, int)} >+ * >+ * @param parent >+ * the table-viewer >+ * @param style >+ * style style bits used to create TableColumn >+ * {@link TableColumn} >+ * @param index >+ * the index of the column >+ */ >+ public TreeColumnViewerPart(TreeViewer parent, int style, int index) { >+ this(new TreeColumn(parent.getTree(), style, index),null); >+ } >+ >+ /** >+ * Wrap an existing TableColumn >+ * >+ * @param column >+ * the existing table-column >+ * @param labelProvider >+ * the label provider >+ */ >+ public TreeColumnViewerPart(TreeColumn column, >+ ViewerLabelProvider labelProvider) { >+ super(column,labelProvider); >+ this.column = column; >+ } >+ >+ /** >+ * @return access the underlying tree-column >+ */ >+ public TreeColumn getColumn() { >+ return column; >+ } >+} >Index: src/org/eclipse/jface/viewers/TreeRowPart.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/TreeRowPart.java >diff -N src/org/eclipse/jface/viewers/TreeRowPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/TreeRowPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,139 @@ >+/******************************************************************************* >+ * 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 >+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Item; >+import org.eclipse.swt.widgets.TreeItem; >+ >+/** >+ * TreeRowPart is the Tree implementation of RowPart. >+ * @since 3.3 >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * >+ */ >+public class TreeRowPart extends RowPart { >+ private TreeItem item; >+ >+ /** >+ * Create a new instance of the receiver. >+ * @param item >+ */ >+ TreeRowPart(TreeItem item) { >+ super(item); >+ this.item = item; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getBounds(int) >+ */ >+ public Rectangle getBounds(int columnIndex) { >+ return item.getBounds(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getBounds() >+ */ >+ public Rectangle getBounds() { >+ return item.getBounds(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getColumnCount() >+ */ >+ public int getColumnCount() { >+ return item.getParent().getItemCount(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getItem() >+ */ >+ public Item getItem() { >+ return item; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getBackground(int) >+ */ >+ public Color getBackground(int columnIndex) { >+ return item.getBackground(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getFont(int) >+ */ >+ public Font getFont(int columnIndex) { >+ return item.getFont(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getForeground(int) >+ */ >+ public Color getForeground(int columnIndex) { >+ return item.getForeground(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getImage(int) >+ */ >+ public Image getImage(int columnIndex) { >+ return item.getImage(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#getText(int) >+ */ >+ public String getText(int columnIndex) { >+ return item.getText(columnIndex); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setBackground(int, org.eclipse.swt.graphics.Color) >+ */ >+ public void setBackground(int columnIndex, Color color) { >+ item.setBackground(columnIndex, color); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setFont(int, org.eclipse.swt.graphics.Font) >+ */ >+ public void setFont(int columnIndex, Font font) { >+ item.setFont(columnIndex, font); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setForeground(int, org.eclipse.swt.graphics.Color) >+ */ >+ public void setForeground(int columnIndex, Color color) { >+ item.setForeground(columnIndex, color); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setImage(int, org.eclipse.swt.graphics.Image) >+ */ >+ public void setImage(int columnIndex, Image image) { >+ item.setImage(columnIndex,image); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.RowPart#setText(int, java.lang.String) >+ */ >+ public void setText(int columnIndex, String text) { >+ item.setText(columnIndex, text); >+ } >+} >Index: src/org/eclipse/jface/viewers/RowPart.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/RowPart.java >diff -N src/org/eclipse/jface/viewers/RowPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/RowPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,186 @@ >+/******************************************************************************* >+ * 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 >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import org.eclipse.jface.util.Policy; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Item; >+ >+/** >+ * RowPart is the abstract superclass of the part that represents items in a >+ * Table or Tree. >+ * @since 3.3 >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * >+ */ >+public abstract class RowPart { >+ /** >+ * Key used to reference RowPart in the widgets data-map >+ */ >+ public static final String ROWPART_KEY = Policy.JFACE + ".ROWPART"; //$NON-NLS-1$ >+ >+ /** >+ * Create a new instance of the receiver. >+ * @param item >+ */ >+ RowPart(final Item item) { >+ item.setData(RowPart.ROWPART_KEY, this); >+ item.addDisposeListener(new DisposeListener() { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) >+ */ >+ public void widgetDisposed(DisposeEvent e) { >+ item.setData(ROWPART_KEY, null); >+ } >+ >+ }); >+ } >+ >+ /** >+ * Get the bounds of the entry at the columnIndex, >+ * @param columnIndex >+ * @return Rectangle >+ */ >+ public abstract Rectangle getBounds(int columnIndex); >+ >+ /** >+ * Return the bounds for the whole item. >+ * @return Rectangle >+ */ >+ public abstract Rectangle getBounds(); >+ >+ /** >+ * Return the item for the receiver. >+ * @return Item >+ */ >+ public abstract Item getItem(); >+ >+ /** >+ * Return the number of columns for the receiver. >+ * @return int >+ */ >+ public abstract int getColumnCount(); >+ >+ /** >+ * Return the image at the columnIndex. >+ * @param columnIndex >+ * @return Image >+ */ >+ public abstract Image getImage(int columnIndex); >+ >+ /** >+ * Set the image at the columnIndex >+ * @param columnIndex >+ * @param image >+ */ >+ public abstract void setImage(int columnIndex,Image image); >+ >+ /** >+ * Get the text at the columnIndex. >+ * @param columnIndex >+ * @return String >+ */ >+ public abstract String getText(int columnIndex); >+ >+ /** >+ * Set the text at the columnIndex >+ * @param columnIndex >+ * @param text >+ */ >+ public abstract void setText(int columnIndex,String text); >+ >+ /** >+ * Get the background at the columnIndex, >+ * @param columnIndex >+ * @return Color >+ */ >+ public abstract Color getBackground(int columnIndex); >+ >+ /** >+ * Set the background at the columnIndex. >+ * @param columnIndex >+ * @param color >+ */ >+ public abstract void setBackground(int columnIndex, Color color); >+ >+ /** >+ * Get the foreground at the columnIndex. >+ * @param columnIndex >+ * @return Color >+ */ >+ public abstract Color getForeground(int columnIndex); >+ >+ /** >+ * Set the foreground at the columnIndex. >+ * @param columnIndex >+ * @param color >+ */ >+ public abstract void setForeground(int columnIndex, Color color); >+ >+ /** >+ * Get the font at the columnIndex. >+ * @param columnIndex >+ * @return Font >+ */ >+ public abstract Font getFont(int columnIndex); >+ >+ /** >+ * Set the font at the columnIndex. >+ * @param columnIndex >+ * @param font >+ */ >+ public abstract void setFont(int columnIndex,Font font); >+ >+ >+ /** >+ * Get the Cell at point. >+ * @param point >+ * @return Cell >+ */ >+ public Cell getCell(Point point) { >+ int index = getColumnIndex(point); >+ >+ if( index >= 0 ) { >+ return new Cell(this,index); >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Get the columnIndex of the point. >+ * @param point >+ * @return the column index or -1 if it cannot be found. >+ */ >+ public int getColumnIndex(Point point) { >+ int count = getColumnCount(); >+ >+ for(int i = 0; i < count; i++ ) { >+ if( getBounds(i).contains(point) ) { >+ return i; >+ } >+ } >+ >+ return -1; >+ } >+ >+} >Index: src/org/eclipse/jface/viewers/Cell.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/Cell.java >diff -N src/org/eclipse/jface/viewers/Cell.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/Cell.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,62 @@ >+/******************************************************************************* >+ * 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 >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.jface.viewers; >+ >+import org.eclipse.swt.graphics.Rectangle; >+ >+/** >+ * The Cell is the JFace representation of a cell entry in a RowPart. >+ * @since 3.3 >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * >+ */ >+public class Cell { >+ private int columnIndex; >+ private RowPart row; >+ >+ /** >+ * Create a new instance of the receiver on the row. >+ * @param row >+ * @param columnIndex >+ */ >+ public Cell(RowPart row, int columnIndex) { >+ this.row = row; >+ this.columnIndex = columnIndex; >+ } >+ >+ /** >+ * Get the index of the cell. >+ * @return int >+ */ >+ public int getColumnIndex() { >+ return columnIndex; >+ } >+ >+ /** >+ * Get the bounds of the cell. >+ * @return Rectangle >+ */ >+ public Rectangle getBounds() { >+ return row.getBounds(columnIndex); >+ } >+ >+ /** >+ * Get the element this row represents. >+ * @return Object >+ */ >+ public Object getElement() { >+ return row.getItem().getData(); >+ } >+} >Index: src/org/eclipse/jface/viewers/TableColumnViewerPart.java >=================================================================== >RCS file: src/org/eclipse/jface/viewers/TableColumnViewerPart.java >diff -N src/org/eclipse/jface/viewers/TableColumnViewerPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/viewers/TableColumnViewerPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/******************************************************************************* >+ * 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; >+ >+import org.eclipse.swt.widgets.TableColumn; >+ >+/** >+ * Wrapper class for {@link TableColumn} >+ * <strong>EXPERIMENTAL</strong> This class or interface has been added as >+ * part of a work in progress. This API may change at any given time. Please >+ * do not use this API without consulting with the Platform/UI team. >+ * @since 3.3 >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation >+ * >+ */ >+public class TableColumnViewerPart extends ColumnViewerPart { >+ private TableColumn column; >+ >+ /** >+ * Create new TableColumnViewerPart. This simply wrapps up a new >+ * {@link TableColumn#TableColumn(org.eclipse.swt.widgets.Table, int)}. >+ * Before calling {@link TableViewer#setInput(Object)}} you need to set the >+ * label-provider using >+ * {@link ColumnViewerPart#setLabelProvider(ViewerLabelProvider)} >+ * >+ * @param parent >+ * the table-viewer >+ * @param style >+ * style bits used to create TableColumn {@link TableColumn} >+ */ >+ public TableColumnViewerPart(TableViewer parent, int style) { >+ this(new TableColumn(parent.getTable(), style),null); >+ } >+ >+ /** >+ * Create new TableColumnViewerPart. This simply wrapps up a new >+ * {@link TableColumn#TableColumn(org.eclipse.swt.widgets.Table, int, int)} >+ * >+ * @param parent >+ * the table-viewer >+ * @param style >+ * style style bits used to create TableColumn >+ * {@link TableColumn} >+ * @param index >+ * the index of the column >+ */ >+ public TableColumnViewerPart(TableViewer parent, int style, int index) { >+ this(new TableColumn(parent.getTable(), style, index),null); >+ } >+ >+ /** >+ * Wrap an existing TableColumn >+ * >+ * @param column >+ * the existing table-column >+ * @param labelProvider >+ * the label provider >+ */ >+ public TableColumnViewerPart(TableColumn column, >+ ViewerLabelProvider labelProvider) { >+ super(column,labelProvider); >+ this.column = column; >+ } >+ >+ /** >+ * @return access the underlying table-column >+ */ >+ public TableColumn getColumn() { >+ return column; >+ } >+}
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 149193
:
46241
|
46254
|
46263
|
46677
|
46686
|
47008
|
47350
|
47453
|
47454
|
47472
| 47722 |
47944
|
48028
|
48089