Bug 149719 - [MPE] Allow tab style changes to MultiPageEditorPart
Summary: [MPE] Allow tab style changes to MultiPageEditorPart
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P5 enhancement with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
: 251736 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-07-05 14:21 EDT by J Aaron Farr CLA
Modified: 2015-01-21 10:58 EST (History)
6 users (show)

See Also:


Attachments
Patch to allow tabs to show at the top of the editor (1.76 KB, patch)
2008-10-23 12:48 EDT, Antoine Toulmé CLA
no flags Details | Diff
Patch adding containerStyle field to MPEP (2.83 KB, patch)
2011-01-15 15:34 EST, Michal Tkacz CLA
no flags Details | Diff
Add getContainerStyle v03 (7.52 KB, patch)
2011-02-25 13:53 EST, Paul Webster CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description J Aaron Farr CLA 2006-07-05 14:21:21 EDT
Use case:

User wants multi-page tabs to be on the top, instead of the bottom.

This is trivially possible if one could override createContainer.  However, the method is currently private.  Moreover, the createPartControl is final, so one cannot override that either.  I believe the preferred solution would be to make createContainer protected instead of private.  Or at least allow a style bit to be passed into the part.
Comment 1 Paul Webster CLA 2006-09-28 11:01:46 EDT
There are currently no plans to work on this feature.

PW
Comment 2 Denis Roy CLA 2007-06-22 09:33:28 EDT
Changes requested on bug 193523
Comment 3 Paul Webster CLA 2008-10-23 09:09:17 EDT
*** Bug 251736 has been marked as a duplicate of this bug. ***
Comment 4 Antoine Toulmé CLA 2008-10-23 12:48:13 EDT
Created attachment 115958 [details]
Patch to allow tabs to show at the top of the editor

Here is a patch that does the job by adding a new constructor.

Please review.
Comment 5 Michal Tkacz CLA 2010-12-23 10:21:24 EST
This sounds like a simple change, could someone please have a look at it?
BTW bug 257767 has some more suggestions on how to allow different kinds of customizations for MPE.
Comment 6 Paul Webster CLA 2011-01-04 10:51:35 EST
(In reply to comment #5)
> This sounds like a simple change, could someone please have a look at it?
> BTW bug 257767 has some more suggestions on how to allow different kinds of
> customizations for MPE.

I wouldn't add a new constructor, although it is probably semantically correct.

The general concern with this bug is how to customize the editor, given that we don't expose the MPEP container (and don't want to expose that it's a CTabFolder).

Even it we add something like:
protected void setStyle(int style) where you can set TOP or BOTTOM, I'm not sure that adding a method where we then say "This will only work until we change the implementation, and then it won't work any more" is a good idea.

PW
Comment 7 Michal Tkacz CLA 2011-01-05 05:21:06 EST
Would making createContainer protected be considered exposing the implementation?
Comment 8 Paul Webster CLA 2011-01-05 07:43:34 EST
(In reply to comment #7)
> Would making createContainer protected be considered exposing the
> implementation?

Yes ... as soon as it is protected, it becomes part of the API which means (in theory) it cannot change and must always work.

PW
Comment 9 Michal Tkacz CLA 2011-01-05 08:38:55 EST
Sure, it becomes part of the API, but I wouldn't consider that as a bad thing.
What I wondered is if we could change the return type from CTabFolder to Composite along the way. This would hide the implementation (the fact that MPEP uses CTabFolder) but MPEP would continue to work. Of course, overriding getContainer and returning something different than CTabFolder without overriding other methods will not work but I thought there're such cases present in the API already (e.g. StructuredViewer.getSelection() is supposed to return an instance of IStructuredSelection, AbstractTreeViewer.setContentProvider() expects an instance of ITreeContentProvider, etc.).
Comment 10 Paul Webster CLA 2011-01-05 09:59:08 EST
(In reply to comment #9)
> Sure, it becomes part of the API, but I wouldn't consider that as a bad thing.
> What I wondered is if we could change the return type from CTabFolder to
> Composite along the way. This would hide the implementation (the fact that MPEP
> uses CTabFolder) but MPEP would continue to work. Of course, overriding
> getContainer and returning something different than CTabFolder without
> overriding other methods will not work

There-in lies the problem.  Anyone that used this would still be required to know that the internal implementation is a CTabFolder and if that changes, they would be broken.  To be able to plug in a new "Container" the work would have to be done to turn the entire container into API in some extendable way ... that's design work as opposed to simply making a method protected.

> but I thought there're such cases
> present in the API already (e.g. StructuredViewer.getSelection() is supposed to
> return an instance of IStructuredSelection,
> AbstractTreeViewer.setContentProvider() expects an instance of
> ITreeContentProvider, etc.).

This is a little different, as they're all API and the classes involved are specializations of the base classes/interfaces.  ex: IViewer sets an IContentProvider, and ITreeViewer sets an ITreeContentProvider (both extensions of the base API).  The API doesn't expose internal implementation details.

PW
Comment 11 Michal Tkacz CLA 2011-01-05 10:32:24 EST
OK then, let's go back to the idea of setStyle (or getStyle, called directly from createContainer?). Assuming that allowing people to use any style constants may lead to problems you described, why not at least allow them to choose whether the tabs should be at the top or at the bottom? Both existing implementations of tab folder (TabFolder and CTabFolder) allow it and any custom implementation could probably easily support it as well. As a last resort, the javadoc could say that this is just a hint and doesn't have to be respected by implementation (as it is often case with style flags in SWT). We could have a method like setTabsOnTop (or isTabsOnTop called directly from createContainer?) but personally I think that setStyle (getStyle?) would be better in case we want to support more flags in future.
Comment 12 Paul Webster CLA 2011-01-05 10:35:43 EST
(In reply to comment #11)
> OK then, let's go back to the idea of setStyle (or getStyle, called directly
> from createContainer?). Assuming that allowing people to use any style

I'd consider a patch + test for this.

PW
Comment 13 Michal Tkacz CLA 2011-01-15 15:34:51 EST
Created attachment 186879 [details]
Patch adding containerStyle field to MPEP

The patch also adds two protected methods: getContainerStyle() and setContainerStyle(). Currently setContainerStyle() filters out all style flags but SWT.BOTTOM and SWT.TOP, although this can be easily changed in future. When both are specified, only SWT.BOTTOM is kept. createContainer() still adds SWT.FLAT to the flag specified.

Change the patch to your liking or let me know if you think it can be improved.

I wasn't sure about the nature or location of the test you asked for. Can you point me to an existing similar test?
Comment 14 Paul Webster CLA 2011-02-02 15:09:26 EST
(In reply to comment #13)
> 
> I wasn't sure about the nature or location of the test you asked for. Can you
> point me to an existing similar test?

org.eclipse.ui.tests.multipageeditor.MultiVariablePageTest (and other classes in that package) in org.eclipse.ui.tests

PW
Comment 15 Paul Webster CLA 2011-02-25 13:53:41 EST
Created attachment 189841 [details]
Add getContainerStyle v03

This follows the same pattern as ContentOutlinePage.  Subclasses can override a getContainerStyle() to provide SWT.TOP|SWT.FLAT.

Michal, could you please check this out and make sure it meets your requirements?  M6 is a week away, and that's API freeze :-)

PW
Comment 16 Paul Webster CLA 2011-03-09 10:46:06 EST
This'll have to wait until I get a 3.8 milestone.
PW