Bug 174689 - [Contributions] Commands not appearing in Customize Perspective dialog
Summary: [Contributions] Commands not appearing in Customize Perspective dialog
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug candidate43
Keywords:
: 181591 325411 (view as bug list)
Depends on:
Blocks: 414612 543572
  Show dependency tree
 
Reported: 2007-02-19 15:59 EST by Curtis d'Entremont CLA
Modified: 2021-07-17 08:01 EDT (History)
8 users (show)

See Also:


Attachments
Rough cut (11.06 KB, patch)
2009-10-19 13:32 EDT, Prakash Rangaraj CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Curtis d'Entremont CLA 2007-02-19 15:59:12 EST
Tried to migrate away from the now-deprecated actionSets ext point for the forms examples. We used to have an actionSet we can manually add to any perspective via customize perspective dialog for testing. With the new org.eclipse.ui.menus ext point, I can't get my command category or menu to show up.

For example, see the org.eclipse.ui.forms.examples plug-in in CVS.
Comment 1 Paul Webster CLA 2007-02-19 19:20:28 EST
We are still finalizing the actionSet replacement.

It looks like it will be contexts, children of org.eclipse.ui.contexts.actionSets.  They will be listed in the Customize Perspective dialog, and menu contributions that are declaratively tagged for those contexts will be displayed.  Originally, probably in the same kind of dialog, eventually in more like a filtered tree of the main menu/main toolbar.

PW
Comment 2 Paul Webster CLA 2007-04-24 08:13:45 EDT
*** Bug 181591 has been marked as a duplicate of this bug. ***
Comment 3 Prakash Rangaraj CLA 2009-10-19 13:32:03 EDT
Created attachment 149898 [details]
Rough cut

Paul,
   This is a very rough cut. Just to make sure I'm not going in a different direction.
Comment 4 Prakash Rangaraj CLA 2009-10-22 08:17:23 EDT
Updating target to M4
Comment 5 Paul Webster CLA 2009-10-22 09:06:41 EDT
(In reply to comment #3)
> Created an attachment (id=149898) [details]
> Rough cut

I think this is heading in the right direction.  Comments:

"actionSetID = ((ToolBarContributionItem2) item).getId();" - Some toolbars are contributed programmatically ... is this there ID?  Also, in theory the toolbar ID can be created by an action with toolbarPath="Normal/additions" which would imply the toolbar ID is Normal, but not related to the actionSet

"getActionSetID(ComandContributionItem)" I don't think you need that second clause ... if there's no visibleWhen, then we won't consider it part of an actionSet.

"getActionSetID(IConfigurationElement element)" we'll have to make sure this algorithm can handle different levels: for example:
<visibleWhen>
  <or>
    <with variable="activeContexts">
      <iterate>
        <equals .../>
      </iterate>
    </with>
  </or>
</visibleWhen>

Technically, something like this is also valid:
<with variable="selection">
  <and>
    <instanceof value="com.example.my.Selection"/>
    <with variable="activeContexts">
      ...
    </with>
  </and>
</with>

"public IConfigurationElement configurationElement;" in CCI.  This should be a get method (since it's immutable, more or less) and should say @noreference and be final.  Also a note that it might be null.

The public member variable in the CCIP is fine.

PW
Comment 6 Prakash Rangaraj CLA 2009-11-23 02:16:29 EST
Will try to push this into 3.6, if only time permits
Comment 7 Chris Gross CLA 2010-01-06 14:32:05 EST
This is causing me some grief.  Like the original poster, I moved everything to commands only later to realize they don't show up in the Customize Perspective dialog.  And know I don't see any other solution then to rework all my code/extensions back to actions.

But then I'm looking to add key bindings which adds another problem.  Key bindings appear to only be associated with commands (and then to actions via definitionId).  

So... to have commands, keybindings, and have them show on the Customize Perspective dialog I think I need:

-My set of commands
-Keybindings associated with commands
-Set actions which duplicate my commands

I think I need to move my actual code back into the actions, put those actions/actionSets into the menus and use the commands only as empty shells for the key bindings... and associated via definitionId?

Is that right?
Comment 8 Paul Webster CLA 2010-01-11 09:08:33 EST
(In reply to comment #7)
> This is causing me some grief.  Like the original poster, I moved everything to
> commands only later to realize they don't show up in the Customize Perspective
> dialog.  And know I don't see any other solution then to rework all my
> code/extensions back to actions.

Commands will show up in the CustomizePerspectiveDialog as of 3.5, in the Toolbar Visibility and Menu Visibility tabs.  But not in the mislabled "Command Groups Availability" tab.

If having them appear in that tab is what you need from your action functionality, then the only way to get that is to switch back to actionSets.  They are in maintenance mode (they won't disappear from 3.x) but they are not actively fixed or enhanced (only regressions are fixed).

Because of the flexibility of commands visibleWhen (an expression with access to many variables) they are not directly associated and are not contained (it's not like actionSets where it belongs to an actionSet and has the actionSet lifecycle).

The new way for commands is to simply display them all in Toolbar and Menu Visibility and turn them off individually.

The only possibility that I can see either something similar to what Prakash already tried (but I don't want IConfigurationElements in CommandContributionItems) or an Expression hack in org.eclipse.ui.internal.dialogs.CustomizePerspectiveDialog.getActionSetID(IContributionItem)

EvaluationContext defaultContext = new EvaluationContext(null, Collections.EMPTY_LIST);
if (visibleWhen.evaluate(defaultContext) == true) return null;

foreach (key in idToActionSet) {
EvaluationContext c1 = new EvalutionContext(null, Collections.EMPTY_LIST);
Set s = new HashSet();
s.add(key1 from idToActionSet);
v1.addVariable("activeContexts", s);
if (visibleWhen.evaluate(c1)==true) return key1;
}

This will work for commands that have tied themselves to an actionSet with a simple expression:
<visibleWhen><with variable="activeContext"><iterate...><equals value="actionSet.id"/></iterate></with></visibleWhen>


PW
Comment 9 Chris Gross CLA 2010-01-11 09:22:56 EST
Thanks Paul for the detailed response.  I'll take a look at what you suggest.
Comment 10 Paul Webster CLA 2010-01-11 10:48:40 EST
(In reply to comment #9)
> Thanks Paul for the detailed response.  I'll take a look at what you suggest.

You'd probably have to expose org.eclipse.ui.internal.menus.WorkbenchMenuService.evaluationsByItem in some way to get the EvaluationReference for an IContributionItem, which would allow you to get the core expression for that ICI (you don't want to use the EvalRef itself, that's kindof a live cache for a real item).  It's OK to go all internal on this.

PW
Comment 11 Paul Webster CLA 2010-01-19 11:08:24 EST
(In reply to comment #9)
> Thanks Paul for the detailed response.  I'll take a look at what you suggest.

Chris, if you're interested in contributing a patch in this direction we'll take a look at it.

PW
Comment 12 Paul Webster CLA 2010-11-09 08:24:21 EST
*** Bug 325411 has been marked as a duplicate of this bug. ***
Comment 13 Andrey Loskutov CLA 2015-01-27 09:18:59 EST
The commands added via code (like "Pin Editor" in bug 445538) should be already shown since 4.5 M5.

They visibility *can* be controlled via CPD *but* only if they initial visibility state is "visible".

Activating initially "invisible" commands is currently impossible, I've spend half a day experimenting but with no luck. One of the reasons is that to maintain the visibility state we need an instance of the Perspective, but command contributions are instantiated at the time where window don't yet have perspective set at all.
Comment 14 Eclipse Genie CLA 2021-07-17 08:01:54 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.

--
The automated Eclipse Genie.