| Summary: | [Viewers] IViewerLabelProvider isn't supported by the TreeViewer anymore | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Frank Lyner <frank_lyner> | ||||||||||||||||||||
| Component: | UI | Assignee: | Thomas Schindl <tom.schindl> | ||||||||||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||||||||||||
| Severity: | blocker | ||||||||||||||||||||||
| Priority: | P3 | CC: | andre_weinand, bokowski, bpasero, daniel_megert, Darin_Swanson, Mike_Wilson, nicolas.bros, tom.schindl | ||||||||||||||||||||
| Version: | 3.3 | ||||||||||||||||||||||
| Target Milestone: | 3.3 M6 | ||||||||||||||||||||||
| Hardware: | PC | ||||||||||||||||||||||
| OS: | Linux | ||||||||||||||||||||||
| Whiteboard: | |||||||||||||||||||||||
| Attachments: |
|
||||||||||||||||||||||
Tom, is this related to your work ?? Eric I'm working on a fix with Boris I expect a solution within the next hour ;-) Created attachment 59101 [details]
patch
internals have changed a bit, standard providers now use ViewerLabel to pass information may we can make the new CellLabelProvider#update(ViewerCell,ViewerLabel) protected? A strange thing I noticed in our test suite, I think there's a failure in tests, I need to recheck that. When I fix the test code all test are OK.
Ok now it's clear the new implementation in TableColumnViewerLabelProvider unrevealed a bug in our test suite Created attachment 59103 [details]
one more time
same than before but a test for trees is also included now
There is still at least one interface that isn't supported anymore: ITreePathLabelProvider you are right Frank, I'll workout a fix. Does the IViewerLabelProvider stuff now work for you? Yes, the IViewerLabelProvider is working now. Created attachment 59158 [details]
fix the treepath problem
fix the problem and add test case
Created attachment 59165 [details]
small fix after talking to Boris
the two mentionned interfaces are not support when using the new label support because they can be worked around easily by providing ones own CellLabelProvider e.g. derived from ColumnLabelProvider and overloading buildLabel and using ViewerRow#getTreePath()
Which of the 4 attached patches is blessed by the UI team to make M5 work? Bug 174701 is marked as blocking this one - does it mean I also need the patches that are attached there. Please advice what someone who wants to patch M5 has to do - or even better: provide a patched M5 JFace plug-in. sorry but Mylar didn't let me to mark patches obsolet. You only need the patch from here to make it work. To get this patch in to CVS we need to PMC approval. I also removed the dependency because #174701 is not a must before we fix this. Thanks Tom. Please consider to include this fix in a M5 rebuild. Thanks The fix that Tom has come up with changes a lot of files. I am uncomfortable with slipping that into an M5a without a milestone test pass. I was under the impression that Dani had created a replacement jar file for you as a temporary solution until M6. Is this not good enough? Created attachment 59535 [details]
patch for M5a
Single-file patch for 3.3M5a.
(In reply to comment #16) > Created an attachment (id=59535) [details] > patch for M5a > > Single-file patch for 3.3M5a. Tom, Andre, Tod, could you please review the patch? There a big difference between what you are doing in update and what my code was doing. I use
----------------8<----------------
if() {
//ITreePathLabelProvider
}
if() {
// IViewerLabelProvider
}
super.update()
----------------8<----------------
Your code is:
----------------8<----------------
if() {
// IViewerLabelProvider
} else if() {
// ITreePathLabelProvider
} else {
super.update();
}
----------------8<----------------
If you now look at buildLabel() the order of calls is:
TreeViewer#buildLabel():
1. Checks for ITreePathLabelProvider
2. calls super
StructuredViewer#buildLabel():
1. Checks for IViewerLabelProvider
2. Checks for ILabelProvider
By the way Boris you only fix the providers using WrappedLabelProvider but not the TableColumnViewerLabelProvider. Although it might be unlikely that one implements the IViewerLabelProvider interface together with ITable*-Interfaces this can happen. Created attachment 59551 [details]
patch for M5a
corrects bugs from Boris patch (e.g. foreground tests didn't pass) and provides implementation for TableColumnViewerLabelProvider
(In reply to comment #18) > There a big difference between what you are doing in update and what my code > was doing. Yes. I did it this way to bring back the 3.2 behaviour: if a label provider implemented IViewerLabelProvider, *only* its #updateLabel method was called, not its #get(Text|Image|...) methods. Still waiting for a response from Andre. After discussing with Boris and browsing 3.2 code we came to the conclusion: That Boris' patch is the right one and I'm the one to blame for making noise for nothing. The problem in Boris' patch was that he had a c&p error when setting the foreground the rest is OK. Created attachment 59557 [details]
patch without the background/foreground error
I would recommend using this patch going forward, or for anyone needing to run a modified M5.
Created attachment 59578 [details]
Patch incooperating ViewerRow#getTreePath() into Boris M5a solution
A couple of questions about patch 59578:
1) I'm confused by this...
+ public TreePath getTreePath() {
+ ArrayList path = new ArrayList();
+ path.add(item.getData());
+
+ TreeItem tItem = item;
+ LinkedList segments = new LinkedList();
+ while (tItem != null) {
+ Object segment = tItem.getData();
+ Assert.isNotNull(segment);
+ segments.addFirst(segment);
+ tItem = tItem.getParentItem();
+ }
+
+ return new TreePath(segments.toArray());
+ }
... Specifically, the variable "path" doesn't appear to do anything useful.
2) "getTreePath" for tables is set to return null because they don't support paths. Would it be better to think of tables as "trees with nothing but roots"?
Created attachment 60281 [details]
Revised patch
ad 1. you are right this is a left over from former days
ad 2. I've never thought about it this way but I like the idea of not return null
and updated the patch in this way
The updated patch looks good to me. +1 Released > 20070313 Verified by code inspection in I20070321-1800 When I try to give a TreeViewer an IViewerLabelProvider as label provider, I get an AssertionFailedException.
setLabelProvider doesn't seem to accept IViewerLabelProvider :
public void setLabelProvider(IBaseLabelProvider labelProvider) {
Assert.isTrue(labelProvider instanceof ITableLabelProvider
|| labelProvider instanceof ILabelProvider
|| labelProvider instanceof CellLabelProvider);
...
}
Is this a regression?
I'm using Helios (I20100608-0911)
Nicolas, this bug got fixed in 3.3. If you experience a problem in Helios then please open a new bug report. |
Build ID: I20070209-1006 Steps To Reproduce: 1. Register following label provider to a TreeViewer: private class TestLabelProvider extends LabelProvider implements IViewerLabelProvider { @Override public String getText(Object element) { return super.getText(element); } public void updateLabel(ViewerLabel label, Object element) { ... // update the label } } 2. If you set a breakpoint in both methods, you see that updateLabel() is never called but getText() is. More information: Here is the stacktrace on the getText() breakpoint: Thread [main] (Suspended (breakpoint at line 283 in EditCategoriesView$TestLabelProvider)) EditCategoriesView$TestLabelProvider.getText(Object) line: 283 WrappedViewerLabelProvider.getText(Object) line: 95 WrappedViewerLabelProvider(ColumnLabelProvider).update(ViewerCell) line: 35 ColumnViewer$3(ViewerColumn).refresh(ViewerCell) line: 139 TreeViewer(AbstractTreeViewer).doUpdateItem(Item, Object) line: 887 AbstractTreeViewer$UpdateItemSafeRunnable.run() line: 97 SafeRunner.run(ISafeRunnable) line: 37 Platform.run(ISafeRunnable) line: 850 JFaceUtil$1.run(ISafeRunnable) line: 52 SafeRunnable.run(ISafeRunnable) line: 153 TreeViewer(AbstractTreeViewer).doUpdateItem(Widget, Object, boolean) line: 962 StructuredViewer$UpdateItemSafeRunnable.run() line: 465 SafeRunner.run(ISafeRunnable) line: 37 Platform.run(ISafeRunnable) line: 850 JFaceUtil$1.run(ISafeRunnable) line: 52 SafeRunnable.run(ISafeRunnable) line: 153 TreeViewer(StructuredViewer).updateItem(Widget, Object) line: 1983 TreeViewer(AbstractTreeViewer).createTreeItem(Widget, Object, int) line: 799 AbstractTreeViewer$1.run() line: 777 BusyIndicator.showWhile(Display, Runnable) line: 67 TreeViewer(AbstractTreeViewer).createChildren(Widget) line: 751 TreeViewer.createChildren(Widget) line: 526 TreeViewer(AbstractTreeViewer).internalInitializeTree(Control) line: 1419 TreeViewer.internalInitializeTree(Control) line: 705 AbstractTreeViewer$5.run() line: 1406 TreeViewer(StructuredViewer).preservingSelection(Runnable) line: 1332 TreeViewer(AbstractTreeViewer).inputChanged(Object, Object) line: 1395 TreeViewer(ContentViewer).setInput(Object) line: 251 TreeViewer(StructuredViewer).setInput(Object) line: 1570 EditCategoriesView.create(Composite) line: 235 EditCategoriesDialog.createDialogArea(Composite) line: 38 EditCategoriesDialog(Dialog).createContents(Composite) line: 780 EditCategoriesDialog(Window).create() line: 426 EditCategoriesDialog(Dialog).create() line: 1111 EditCategoriesDialog(Window).open() line: 785 EditCategoriesAction$1.runInUI(IProgressMonitor) line: 77 UIUpdateManager$ForegroundJob.runInUIThread(IProgressMonitor) line: 94 UIJob$1.run() line: 94 RunnableLock.run() line: 35 UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 123 Display.runAsyncMessages(boolean) line: 3215 Display.readAndDispatch() line: 2908 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2264 Workbench.runUI() line: 2228 Workbench.access$4(Workbench) line: 2103 Workbench$4.run() line: 457 Realm.runWithDefault(Realm, Runnable) line: 289 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 452 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 IDEApplication.start(IApplicationContext) line: 101 EclipseAppHandle.run(Object) line: 146 EclipseAppLauncher.runApplication(Object) line: 106 EclipseAppLauncher.start(Object) line: 76 EclipseStarter.run(Object) line: 354 EclipseStarter.run(String[], Runnable) line: 169 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 585 Main.invokeFramework(String[], URL[]) line: 339 Main.basicRun(String[]) line: 283 Main.run(String[]) line: 984 Main.main(String[]) line: 959 The culprit seems to be ColumnLabelProvider.update(ViewerCell cell) and CellLabelProvider.createViewerLabelProvider() which simply are not considering the IViewerLabelProvider interface. This is a blocker for us since we are using this interface for most of our label providers.