Bug 39455 - [ActionSets] isInitiallyVisible override (with patch)
Summary: [ActionSets] isInitiallyVisible override (with patch)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.0 RC1   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2003-06-29 11:54 EDT by Dan Rubel CLA
Modified: 2004-05-25 10:43 EDT (History)
2 users (show)

See Also:


Attachments
Patch to ActionSetDescriptor adding new setInitiallyVisible method (171 bytes, patch)
2003-06-29 11:58 EDT, Dan Rubel CLA
no flags Details | Diff
(take 2) Patch to ActionSetDescriptor adding new setInitiallyVisible method (2.58 KB, patch)
2003-06-29 17:36 EDT, Dan Rubel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Rubel CLA 2003-06-29 11:54:54 EDT
We have a top level menu that is initially visible when our plugin is loaded.  
Elipse provides a mechanism for hiding that action set on a individual 
perspective basis, but there are two issues with the current implementation:

1) To hide the menu, the user has a several step process for *each* perspective 
currently open.

2) Anytime a new perspective is opened, the user must use that same process to 
hide the actionSet.

To overcome this limitation, I have enhanced ActionSetDescriptor and 
IActionSetDescriptor to have a new #setInitiallyVisible method that overrides 
the actionSet's visible attribute specified in the plugin manifest.  The value 
is persisted in the workspace metadata using the normal perference storage 
mechanism.

This code is written against Eclipse 3.0 HEAD and thus should be fully 
compatible with the latest Eclipse 3.0 nightly build.

Please consider thes modifications for inclusion in the Eclipse 3.0 M2 build.  
If you approve of this approach and include this code in the Eclipse 3.0 build, 
I would be happy to provide a new ShowActionSetAction that would show/hide an 
action set in all of the currently open perspectives, plus call the new 
#setInitiallyVisible method so that state is remembered for any perspectives 
opened later in the workspace.  We could then provide this action as part of our 
menu so that the user could quickly hide the menu in all current and future 
perspectives.
Comment 1 Dan Rubel CLA 2003-06-29 11:58:53 EDT
Created attachment 5312 [details]
Patch to ActionSetDescriptor adding new setInitiallyVisible method
Comment 2 Dan Rubel CLA 2003-06-29 17:36:40 EDT
Created attachment 5313 [details]
(take 2) Patch to ActionSetDescriptor adding new setInitiallyVisible method

Apparently I uploaded the first patch incorrectly.
Please ignore the first patch and use this instead.
Comment 3 Nick Edgar CLA 2003-09-29 22:04:24 EDT
Comment on attachment 5312 [details]
Patch to ActionSetDescriptor adding new setInitiallyVisible method

Obsolete, according to comment #1.
Comment 4 Nick Edgar CLA 2003-09-29 22:20:17 EDT
I have the following concerns with the proposed enhancement:

1. Currently, actions sets can either be on globally, associated with specific 
perspectives, and/or associated with specific parts.  This makes it consistent 
and explainable as to when a particular set of actions appears.  Adding the 
ability to change the "initially visible" state, and/or adding API to 
show/hide actions sets, circumvents the Workbench's ability to manage the 
visibility of action sets in a consistent and explainable way. 

2. Before considering this change, I would want to know how you propose to 
present this mode switch in the UI.  Currently the user can go to one place, 
the perspective customization dialog, to effect changes in the visible action 
sets, and I would not want to introduce multiple, inconsistent ways of doing 
so.

3. If the concern is that there is no way for the user to toggle an action 
set "always on" or "always off", then we can consider enhancing the 
perspective customization dialog to allow this (without necessarily adding new 
API for arbitrary plugins to call).

It would help to have some concrete use cases illustrating what you are trying 
to accomplish with this API.  We may be able to offer some alternative ideas.


Comment 5 Eric Clayberg CLA 2003-10-30 16:29:44 EST
Our action set is a global (available accross all perspectives), top-level menu 
which gives the user quick access to a variety of services provided by our 
product. The menu is provided as a convenience to the user, but is not required 
by the product (it will work fine, if the menu is not there). We want to 
be "nice" to the user and give them an easy way to turn this global menu off 
and save the menubar real estate.

The current workbench customization options do not provide a way to globally 
enable or disable an action set across all perspectives. Our supplied patch 
provides this capability.

Currently (and for lack of any other option), we provide this mode switch via a 
preference page option. A single checkbox will make the menu appear and 
disappear as desired by the user. If there were a global Eclipse customization 
option (such as #3 above) for turning on and off global actions sets, we could 
use that instead.
Comment 6 Dan Rubel CLA 2004-01-21 16:00:31 EST
Any plans to integrate this new IActionSetDescriptor API into 3.0 ?
Comment 7 Nick Edgar CLA 2004-01-26 20:39:10 EST
Will consider it for M8.
Comment 8 Nick Edgar CLA 2004-03-15 00:02:23 EST
Patch applied.
Comment 9 Nick Edgar CLA 2004-05-25 10:35:49 EDT
The patch as provided does not work.
If setInitiallyVisible(false) is called, the preference store removes the
explicitly set value since it's the same as the default.  So the
isDefault(prefId) call returns true, causing the registered visible value (true
in the case of an always-on action set) to be returned.

Comment 10 Nick Edgar CLA 2004-05-25 10:38:07 EDT
The isDefault check in the code also prevented apps from overriding the default
value in plugin_customization.ini.
Comment 11 Nick Edgar CLA 2004-05-25 10:43:54 EDT
Fixed by flipping the logic.  It now uses the following pref prefix:
	private static final String INITIALLY_HIDDEN_PREF_ID_PREFIX =
"actionSet.initiallyHidden."; //$NON-NLS-1$

This avoids having to use isDefault checks.

The set logic is now:
public void setInitiallyVisible(boolean newValue) {
	if (id == null)
		return;
	Preferences prefs = WorkbenchPlugin.getDefault().getPluginPreferences();
	String prefId = INITIALLY_HIDDEN_PREF_ID_PREFIX + getId();
	prefs.setValue(prefId, !newValue);
}

The get logic is now:
public boolean isInitiallyVisible() {
    if (id == null)
		return visible;
	Preferences prefs = WorkbenchPlugin.getDefault().getPluginPreferences();
	String prefId = INITIALLY_HIDDEN_PREF_ID_PREFIX + getId();
	if (prefs.getBoolean(prefId))
	    return false;
	return visible;
}