| 
| Expression-bases Activities always disabled [message #331835] | Wed, 24 September 2008 11:26  |  | 
| Eclipse User  |  |  |  |  | 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 #785094 is a reply to message #331884] | Sat, 28 January 2012 07:59  |  | 
| Eclipse User  |  |  |  |  | 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
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.04303 seconds