Update command handlers [message #331702] |
Wed, 17 September 2008 11:10  |
Eclipse User |
|
|
|
Hello,
I'm using org.eclipse.handlers together with <enabledWhen> syntax to keep
my commands updated.
My problem is, that when executing a command the handler service seems not
to update the toolbar and other controls that are slways shown on the
workbench.
My command implementations look like this:
public class MyCommand extends org.eclipse.core.commands.AbstractHandler{
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Command execution code
return null;
}
}
I've tried to call a update of the Commands manually but this had no
effect at all.
ICommandService service = (ICommandService)
PlatformUI.getWorkbench().getService(ICommandService.class);
service.refreshElements("my.procect.commands.MyCommand", null);
How can I get a update of my handlers to get correctly enabled and
disabled commands?
Thank,
Jan
|
|
|
Re: Update command handlers [message #331717 is a reply to message #331702] |
Thu, 18 September 2008 08:20   |
Eclipse User |
|
|
|
Hello,
Further investigation brought me to the insight that my handlers work just
fine. The enableWhen (and also activeWhen when using it instead)
syntax keeps the handlers updated in my UI.
The problem is, that the handler state is not getting verified when
pressing a button such as a toolbar item.
In my case I have a start and a stop button belonging to a UI plug-in that
mirrors the activity of another plug-in performing cron jobs. The cron job
plug-in knows nothing about the UI. When pressing 'start' for instance the
cron job plug-in gets started and the UI plug-in starts display its
activities.
Just after pressing the start button I want this button to get disabled
and the stop button get enabled instead. Right now the enabled states of
the handlers are only checked when selecting something connected with the
selection service, or when pressing another button.
How can I force the handlers performing a verify of their conditions?
Thanks,
Jan
|
|
|
|
Re: Update command handlers [message #331742 is a reply to message #331726] |
Fri, 19 September 2008 06:46   |
Eclipse User |
|
|
|
Paul,
I'm usingthe following configuration:
<handler
class=" com.swisslab.xslprocessor.ui.commands.StartAllProcessorsComm and "
commandId="com.swisslab.xslprocessor.ui.startAllProcessorsCommand ">
<activeWhen>
<reference
definitionId="com.swisslab.xslprocessor.ui.defenitions.processorsStopped ">
</reference>
</activeWhen>
</handler>
<definition
id="com.swisslab.xslprocessor.ui.defenitions.processorsStopped ">
<not>
<test forcePluginActivation="false"
property="com.swisslab.xslprocessor.ui.test.processors.running ">
</test>
</not>
</definition>
<propertyTester class="com.swisslab.xslprocessor.ui.tests.ProcessorsTester"
id="com.swisslab.xslprocessor.ui.test.processors"
namespace="com.swisslab.xslprocessor.ui.test.processors"
properties="running" type="java.lang.Object"> </propertyTester>
And a PropertyTester Class that checks my cron job plug-in:
public class ProcessorsTester extends PropertyTester {
private final static String RUNNING = "running";
@Override
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue) {
// check processors
if (property.equals(RUNNING)){
// check running
for (XSLProcessor processor
:XslProcessorPlugin.getDefault().getProcessors()){
if (processor.isRunning()){
// One is running
return true;
}
}
//no processor running
return false;
}
return false;
}
}
The PropertyTester class returns the correct values.
Jan
|
|
|
|
Powered by
FUDForum. Page generated in 0.03785 seconds