Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Expression-bases Activities always disabled
Expression-bases Activities always disabled [message #331835] Wed, 24 September 2008 15:26 Go to next message
Adam Lucarz is currently offline Adam LucarzFriend
Messages: 518
Registered: July 2009
Senior Member
Hi,

I am testing expression-based activities within a simple rcp application.
I oriented myself at the eclipse help section for activities. My problem
is, that the activity is always disabled. The expression seems not to be
evaluated as true.

My Plugin.xml (PluginA) looks like this:

<plugin>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="de.cenit.play.rcp.commands.ShowQuestionCommand "
id="de.cenit.play.rcp.commands.ShowQuestionCommand"
name="Show Question">
</command>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:actions">
<command
commandId="de.cenit.play.rcp.commands.ShowQuestionCommand"
style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.activities">
<activity
id="de.cenit.play.rcp.commands.activities.ShowQuestionCommand "
name="ShowQuestionCommand">
<enabledWhen>
<with
variable="de.cenit.play.rcp.rights">
<iterate
ifEmpty="false"
operator="or">
<equals

value="de.cenit.play.rcp.commands.ShowQuestionCommand">
</equals>
</iterate>
</with>
</enabledWhen>
</activity>
<activityPatternBinding

activityId="de.cenit.play.rcp.commands.activities.ShowQuestionCommand "
isEqualityPattern="true"

pattern=" de.cenit.play.rcp.commands/de.cenit.play.rcp.commands.ShowQu estionCommand ">
</activityPatternBinding>
</extension>
</plugin>

The SourceProvider is registered in another plugin (Plugin B <- RCP
Plugin):

<plugin>
<extension
point="org.eclipse.ui.services">
<sourceProvider
provider="de.cenit.play.rcp.SourceProvider">
<variable
name="de.cenit.play.rcp.rights"
priorityLevel="workbench">
</variable>
</sourceProvider>
</extension>
</plugin>

And here is the source code of the SourceProvider:

public class SourceProvider extends AbstractSourceProvider {

private final static String SOURCENAME_RIGHTS =
"de.cenit.play.rcp.rights";

public Map getCurrentState() {
LinkedList<String> ids = new LinkedList<String>();
ids.add("de.cenit.play.rcp.commands.ShowQuestionCommand");

HashMap<String, List<String>> stateMap = new HashMap<String,
List<String>>();
stateMap.put(SOURCENAME_RIGHTS, ids);
return stateMap;
}

public String[] getProvidedSourceNames() {
return new String[] { SOURCENAME_RIGHTS };
}

}

My opinion is, that the activity should be enabled, but it is not. What
did I oversight?

Does anyone has an idea?

Best Regards
Adam
Re: Expression-bases Activities always disabled [message #331868 is a reply to message #331835] Thu, 25 September 2008 18:33 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Is it that you can see your actions menu, but you can't see the "Show
Question" menu item?

Is your getCurrentState() ever called? Is the code in the
EvaluationAuthority re-evaluating any expressions against your
de.cenit.play.rcp.rights variable? There doesn't appear to be anything
obviously wrong with your example.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Expression-bases Activities always disabled [message #331882 is a reply to message #331868] Fri, 26 September 2008 12:02 Go to previous messageGo to next message
Adam Lucarz is currently offline Adam LucarzFriend
Messages: 518
Registered: July 2009
Senior Member
Alright I have got it partly.

At first some answers to the questions:

The "Commands" Menu is visible, but the "Show Question" menue item is not.
But it should be visible because of the provided source value.

ISourceProvider.getCurrentState() is called twice. But the concerning
variable is not reevaulated at startup automatically. Everythings seems to
be okay, when
IEvaluationService.requestEvaluation("de.cenit.play.rcp.rights ") is called
after ISourceProvider.getCurrentState() was called. The other possibility
is to force an evaluation with ISourceProvider.fireSourceChanged(0,
getCurrentState()).

My questions are now:
1. Why do I have to force the evaluation manually at startup?
2. What is the best practice to do 1.?
3. Is there a good way to get the instance of my ISourceProvider which is
declared in the plugin.xml?

Thank you for your replay. That already helps me a lot!

Best Regards
Adam
Re: Expression-bases Activities always disabled [message #331884 is a reply to message #331882] Fri, 26 September 2008 13:05 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Adam Lucarz wrote:
> Alright I have got it partly.
>
> At first some answers to the questions:
>
> The "Commands" Menu is visible, but the "Show Question" menue item is
> not. But it should be visible because of the provided source value.
>
> ISourceProvider.getCurrentState() is called twice. But the concerning
> variable is not reevaulated at startup automatically. Everythings seems
> to be okay, when
> IEvaluationService.requestEvaluation("de.cenit.play.rcp.rights ") is
> called after ISourceProvider.getCurrentState() was called. The other
> possibility is to force an evaluation with
> ISourceProvider.fireSourceChanged(0, getCurrentState()).

Adam, this might be a bug in eclipse (if we're filling in expressions
but then not updating them when we instantiate the source provider.
Please enter a bug at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=UI&short_desc=[Services]

It won't hurt anything to do the
IEvaluationService.requestEvaluation("de.cenit.play.rcp.rights "),
AFAICT, it just forces an extra evaluation.

Thanx,
PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Expression-bases Activities always disabled [message #785094 is a reply to message #331884] Sat, 28 January 2012 12:59 Go to previous message
Guenther Mahr is currently offline Guenther MahrFriend
Messages: 36
Registered: September 2011
Member
Hello!

I'm facing the same issue as the one described in this old post. Using a source provider and a variable for enabling/disabling a view or preferences, when debugging I see that reevalution is not done after MySourceProvider.getCurrentState()has been called.

What I see is that in ContextAuthority.sourceChanged() my activity is not in the Collection activationsBySourcePriority and moreover the program never gets into the branch if ((sourcePriority & (1 << i)) != 0) , so that even if it were there it would never be added to activationsToRecompute.

Evaluation is only done BEFORE the source provider is added and this has the consequence that the activity is not enabled and that I never see my view/preferences.

Can you help me please?

Thanks
Guenther Mahr
Previous Topic:Can I have problem marks in the Resource Navigator icons?
Next Topic:programmatically call source format (CTRL+SHIFT+F)
Goto Forum:
  


Current Time: Thu Apr 25 03:42:51 GMT 2024

Powered by FUDForum. Page generated in 0.03161 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top