|
|
|
Re: Accessing editor actionbar contribution [message #447822 is a reply to message #447809] |
Mon, 17 April 2006 18:26 |
Eclipse User |
|
|
|
Originally posted by: childress.shapetechllc.com
Paul Webster wrote:
> From your IEditorSite you can get the IActionBars and the appropriate
> manager. Then use IContributionManager#find(*) to find the
> IContributionItem that you need.
> You have to walk the hierarchy of the path you specified (toolbarPath,
> menuPath, etc).
When you do this, you get a
org.eclipse.ui.internal.PluginActionContributionItem, which doesn't give
you access to any methods to query the state of the item if it
is a TOGGLE or RADIO button.
If you can get access to the ToolBar, you should be able to access the
ToolItem, which contains the information needed. But, I can't find a way
to do that.
Ken...
|
|
|
|
Re: Accessing editor actionbar contribution [message #447838 is a reply to message #447826] |
Mon, 17 April 2006 22:35 |
Eclipse User |
|
|
|
Originally posted by: childress.shapetechllc.com
Paul Webster wrote:
> Ken Childress wrote:
>> When you do this, you get a
>> org.eclipse.ui.internal.PluginActionContributionItem, which doesn't give
>> you access to any methods to query the state of the item if it
>> is a TOGGLE or RADIO button.
> If it's a PluginActionContributionItem it's also a
> org.eclipse.jface.action.ActionContributionItem, which has getAction().
> IAction has an isChecked() method.
> But this is a hack. I'm still looking for the proper way to access the
> state of a contributed action.
Thanks. This seems to work. I would be interested in knowing if there is
a better way of doing this.
Ken...
|
|
|
|
Re: Accessing editor actionbar contribution [message #448136 is a reply to message #447942] |
Tue, 18 April 2006 22:57 |
Eclipse User |
|
|
|
Originally posted by: childress.shapetechllc.com
Paul Webster wrote:
> The way that these things are moving is to Commands, Handlers, and Bindings.
> It looks like you can use definitionId in your action declaration to
> link it to a command. Define a command in the org.eclipse.ui.commands
> extension point. Using a definitionId and a command turns the legacy
> actionSet or editorAction actions into handlers.
> Use ICommandServer#getCommand(String commandId) to get the Command.
> From Command, you can use getState(IMenuStateIds.STYLE), and then if
> your command state is an instance of ToggleState, use
> ((Boolean)state.getValue()).booleanValue().
I tried what you suggest. I created a command, and put its id as the
definitionId of the editorAction. Then, I tried to access it via,
CommandManager manager = new CommandManager();
Command command = manager.getCommand( "commandId" );
At this point, I'm not seeing any way to get at the state or other
information about the contribution. Am I missing something or doing
something wrong?
Ken...
|
|
|
|
Re: Accessing editor actionbar contribution [message #448351 is a reply to message #448221] |
Fri, 21 April 2006 15:41 |
Eclipse User |
|
|
|
Originally posted by: childress.shapetechllc.com
Paul Webster wrote:
> You need the command service.
> Object serviceObject = PlatformUI.getWorkbench()
> .getAdapter(ICommandService.class);
> if (serviceObject != null) {
> ICommandService service = (ICommandService) serviceObject;
> ..............
> }
> In 3.1.2 I think you would need the global command service, and in 3.1.2
> you use getAdapter(*) to retrieve services.
I appreciate you trying to help me, but I'm just not seeing how this
helps. Once I have the ICommandService, I still don't understand how to
get at the information I need to find out the state of the button. I can
get the Command using the command's id, but I still see no way of getting
to the state of the button.
Ken...
|
|
|
|
Re: Accessing editor actionbar contribution [message #448442 is a reply to message #448381] |
Mon, 24 April 2006 22:35 |
Eclipse User |
|
|
|
Originally posted by: childress.shapetechllc.com
Paul Webster wrote:
> Ken Childress wrote:
>>
>> I appreciate you trying to help me, but I'm just not seeing how this
>> helps. Once I have the ICommandService, I still don't understand how to
>> get at the information I need to find out the state of the button. I
>> can get the Command using the command's id, but I still see no way of
>> getting to the state of the button.
> From Command, you can use Command#getState(IMenuStateIds.STYLE), and
> then if your command state is an instance of ToggleState, use
> ((Boolean)state.getValue()).booleanValue().
Are we talking 3.1.2?
I don't see a getState method in the Command class.
Ken...
|
|
|
|
Powered by
FUDForum. Page generated in 0.07426 seconds