Bug 165951 - [TabbedProperties] Provide extensibility for removing tab/section
Summary: [TabbedProperties] Provide extensibility for removing tab/section
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Anthony Hunter CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-27 13:40 EST by Adam Neal CLA
Modified: 2019-09-06 15:36 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Neal CLA 2006-11-27 13:40:05 EST
Build ID: M20060921-0945

Steps To Reproduce:
1. Try to remove a preexisting tab from an existing property section.

More information:
We would like to be able to override a preexisting tab for a given properties section.  Currently there is no way to remove an existing tab.  One way to solve this problem could be to provide an extension point that allows a user to specify a property tab/section's ids to be removed.
Comment 1 Antoine Toulmé CLA 2006-12-15 14:29:25 EST
Hi, there is a workaround to do that.

You need to override or wrap the content provider of the property page,
then filter the object array returned by getElements by testing them on the toString method. The TabDescriptor toString method returns the id of the tabDescriptor.
Comment 2 Antoine Toulmé CLA 2006-12-15 14:31:04 EST
One more comment:

As the toString method of TabDescriptor may change without notice, this workaround is quite dangerous on the long run. So the best thing would be to move TabDescriptor to an exported pakage, so that we can rely on it.

Comment 3 Anthony Hunter CLA 2006-12-15 14:40:09 EST
(In reply to comment #2)
> One more comment:
> [...] toString method [...] is quite dangerous on the long run.

toString was added for debugginging, it cannot be used for filtering.
How can you use the tab label for filtering once it is translated?
Comment 4 Antoine Toulmé CLA 2006-12-15 14:57:04 EST
I am not suer I understand your question.

So here what I do as of today :

I override the content provider
@Override
protected IStructuredContentProvider getTabListContentProvider() {
	return new DelegateFilteringContentProvider(
			super.getTabListContentProvider());
}

Then I delegate all methods to the real content provider, except for getElements, in which I do :

public Object[] getElements(Object inputElement) {
			Object[] elements = _contentProvider.getElements(inputElement);
			List<Object> result = new LinkedList<Object>();
			for (Object desc : elements) {
				if (desc.toString().equals(ADVANCED)) {
					// add or not
				} else if (desc.toString().equals(ANNOTATIONS)){
                                        // add or not
				} else if (desc.toString().equals(PROCESS_EXECUTION)) {
// here I expressly say that I want this tab to be the first one.
					result.add(0,desc);
				} else {
// by default
					result.add(desc);
				}
			}
			return result.toArray();
		}

So the comparison entirely relies on the toString method.
It looks like this in TaqbDescriptor :
        /**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return getId();
	}

Ideally I would like to be able to cast the objects returned by the getElements method into TabDescriptors, and get the Id from there.

This approach happens to work, but I am quite sure that there are better ways to do it.
Comment 5 Anthony Hunter CLA 2006-12-15 15:10:27 EST
(In reply to comment #4)
> if (desc.toString().equals(ADVANCED)) {
Assuming Static final String ADVANCED = "Advanced";
What do you do when the UI is translated to various languages and the tab label is no longer advanced.


Comment 6 Antoine Toulmé CLA 2006-12-15 15:18:33 EST
Well:
public static final String ADVANCED = 
			"property.tab.AdvancedPropertySection";
This is the Id of the tab, not its label.

Hopefully it should not be changed during the translation operation.

Comment 7 Anthony Hunter CLA 2006-12-15 15:28:43 EST
(In reply to comment #4)
>         public String toString() {
>                 return getId();
>         }
OK, I get it, agreed we would remove by ID matching and not by tab label.
Comment 8 Antoine Toulmé CLA 2006-12-15 15:46:27 EST
ok Anthony, 
do you agree moving the TabDescriptor class to a public package ?
Comment 9 Antoine Toulmé CLA 2006-12-15 17:53:10 EST
Actually, would it be possible to add the getId() method to ITabItem ?

That would be all I need. :)
Comment 10 Anthony Hunter CLA 2006-12-18 10:20:49 EST
(In reply to comment #9)
> Actually, would it be possible to add the getId() method to ITabItem ?
> That would be all I need. :)

Ok.
Comment 11 Mike Wilson CLA 2008-06-09 14:58:40 EDT
If this was fixed, please mark it so, if not, please set the target milestone appropriately.
Comment 12 Eclipse Webmaster CLA 2019-09-06 15:36:12 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.