Bug 198443 - [Presentation] [API] Make Part label creation configurable from the outside
Summary: [Presentation] [API] Make Part label creation configurable from the outside
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-31 14:34 EDT by Thomas Schindl CLA
Modified: 2019-09-06 16:10 EDT (History)
5 users (show)

See Also:


Attachments
A first draft to kick off discussion (24.78 KB, patch)
2007-08-23 13:24 EDT, Thomas Schindl CLA
no flags Details | Diff
mylyn/context/zip (1.31 KB, application/octet-stream)
2007-08-23 13:24 EDT, Thomas Schindl CLA
no flags Details
Example (3.57 KB, application/octet-stream)
2007-08-23 13:27 EDT, Thomas Schindl CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schindl CLA 2007-07-31 14:34:57 EDT
Currently the creation of the Label (e.g. to mark it dirty) is hard wired into the Presentation API (org.eclipse.ui.internal.presentations.r33.DefaultTabItem). It would be a nice thing to allow people to customize the creation of the:
- label text
- label image
Comment 1 Thomas Schindl CLA 2007-07-31 15:06:22 EDT
More information on the background. I have a View which holds editable data bound to a database and I'd like to show the dirty state showing a decorated image. 

Showing the image can be worked around but setting removing the * from the title is not possible. I could of course write my own presentation but maybe the platform can provide a cleaner solution to the problem.
Comment 2 Eric Moffatt CLA 2007-07-31 16:02:04 EDT
In this case the culprit is DefaultTabItem#computeLongName which prepends the given text with "DIRTY_PREFIX". Perhaps the most surgical fix is to add 'setDirtyPrefixText' to one of the configurers or change it to a pref; either would allow Tom to get what he needs I think.
Comment 3 Thomas Schindl CLA 2007-07-31 16:17:55 EDT
Well what would be if you let the user use a message format like and define some constants like this:

PlatformUI.getPreferenceStore().setValue
(
    IWorkbenchPreferenceConstants.DIRTY_PATTERN,
    "{0} (modified)"
);

The bigger problem is the image decoration. Maybe something like the ui.decorations extension point for the viewers?

Comment 4 Thomas Schindl CLA 2007-07-31 17:30:46 EDT
I've now implemented my own presentation which allows me the following things:
- define a pattern for the label
- contribute an AbstractImageDecorator using an extension point

Both things are controled using Preferences (I missused )

So the setup looks like this:

@Override
public void initialize(IWorkbenchConfigurer configurer) {
    super.initialize(configurer);
    configurer.setSaveAndRestore(true);
    PlatformUI.getPreferenceStore().setValue(
        IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID, 
        "at.bestsolution.core.ui.presentation.decorateable"
    );

    PlatformUI.getPreferenceStore().setValue(
        IDecoratableConstants.LABEL_PATTERN_ID, 
        "${title}"
    );

    PlatformUI.getPreferenceStore().setValue(
        IDecoratableConstants.IMAGE_DECORATOR_ID,
        "com.madreiter.ingenium.core.ui.dirtyViewPartImageDecorator"
    );
}

The presentation is simply a copy from the 33-Presentation with a customized DefaultTabItem. Because this was that simple I not sure whether it make sense that the platform provides this feature. On the other hand my current presentation relies on many internal APIs (which I don't mind because when currently) which is not as nice as it could be.
Comment 5 Boris Bokowski CLA 2007-08-23 11:07:38 EDT
(In reply to comment #4)
Tom, I would be interested in a patch that makes view and editor titles decoratable. What I would like to have is a decorator (turned off by default) that shows the implementing plug-in for every view and editor.  Is what you have close to this?
Comment 6 Thomas Schindl CLA 2007-08-23 11:30:12 EDT
Well not really at the moment I'm only decorating the Icon with a Dirty-Marker
Comment 7 Thomas Schindl CLA 2007-08-23 13:24:17 EDT
Created attachment 76794 [details]
A first draft to kick off discussion

This is just a kick off to get started with an proof-of-concept implementation
Comment 8 Thomas Schindl CLA 2007-08-23 13:24:22 EDT
Created attachment 76795 [details]
mylyn/context/zip
Comment 9 Thomas Schindl CLA 2007-08-23 13:27:59 EDT
Created attachment 76796 [details]
Example

decorates dirty resources using an image and appends (modified) to the end
Comment 10 Tracy Hodges CLA 2009-03-04 13:19:49 EST
Is this issue going to be dealt with?   I would like to see it resolved.  
Just to add my senario to the mix, here it is.
We basically have an RCP that connects to databases/models in the backend.  The connection is conceptually 'bigger' than just a view/editor or even a perspective.   For all practical purposes, it is 'global' to the tool.  Think of it closer to the Workspace concept in Eclipse, except you can have multiple open and they have their own save lifecyle.  Meaning they can each be opened, closed, dirtied, and saved.

In that senario, the labels of the items within the views and editors tend to show the dirty/clean state.   There is no need for the view tab or editor tabs to do that.  In fact it is really annoying as it is virtually meaningless to the user.

What I would like to see is some way to turn off at least the dirty asterisk from showing.   I would assume it should be configurable by view/editor.  So perhaps an overridable method or the ability to specify a LabelProvider or some kind of decorator would be nice.
Comment 11 Boris Bokowski CLA 2009-03-04 16:06:22 EST
No, this was not on our plan for 3.5, and unfortunately we are now too close (<1 week) to API freeze for 3.5.

If you wanted to push this forward for 3.6, feel free to take Tom's patch and make it better!

(moved as per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009)
Comment 12 Tracy Hodges CLA 2009-03-04 16:12:02 EST
Fortunately we found an acceptable workaround (short of writing our own Presentation layer).

Early during the RCP startup we add the line:

DefaultTabItem.DIRTY_PREFIX = "";

The class is 'internal', so not the greatest approach.  The prefix happened to be public, static and non-final.  The drawback of this approach is that it affects all views/editors the same.   But that appears to be able to work for us right now.
Comment 13 Eclipse Webmaster CLA 2019-09-06 16:10:05 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.