
GUEST
글
eclipse 2010. 8. 16. 18:31eclipse command
defaultHandler="com.eclipse_tips.commandstate.BoldHandler"
id="com.eclipse-tips.commandState.boldCommand"
name="Bold">
<state
class="org.eclipse.ui.handlers.RegistryToggleState:true"
id="org.eclipse.ui.commands.toggleState">
</state>
</command>
public Object execute(ExecutionEvent event) throws ExecutionException {
Command command = event.getCommand();
boolean oldValue = HandlerUtil.toggleCommandState(command);
// use the old value and perform the operation
return null;
}
defaultHandler="com.eclipse_tips.commandstate.AlignHandler"
id="com.eclipse-tips.commandState.alignCommand"
name="Align Command">
<commandParameter
id="org.eclipse.ui.commands.radioStateParameter"
name="State"
optional="false">
</commandParameter>
<state
class="org.eclipse.ui.handlers.RadioState:left"
id="org.eclipse.ui.commands.radioState">
</state>
</command>
public Object execute(ExecutionEvent event) throws ExecutionException {
if(HandlerUtil.matchesRadioState(event))
return null; // we are already in the updated state - do nothing
String currentState = event.getParameter(RadioState.PARAMETER_ID);
// perform task for current state
if(currentState.equals("left"))
// perform left alignment
else if(currentState.equals("center"))
// perform center alignment
// and so on ...
// and finally update the current state
HandlerUtil.updateRadioState(event.getCommand(), currentState);
return null;
}
RECENT COMMENT