Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Pulldown actions in the View toolbar problem
Pulldown actions in the View toolbar problem [message #435205] Wed, 10 August 2005 08:16 Go to next message
Eclipse UserFriend
Originally posted by: golovkov.texnika.com.ua

Hello, guys!

I'm a newbie in eclipse so it maybe a little difficult for me to
understand some basic concepts. I see that declarative way of creation new
actions is very simple and nice (using org.eclipse.ui.actionSets and
org.eclipse.ui.viewActions extention points).

The only problem I met here is to create Pulldown action in the view local
toolbar (not a pulldown menu)...

Please, help me with this thing (the declarative solution if possible).
Generally, I think this feature is possible (for example - "Console View"
in the Eclipse IDE has such actions: "Display Selected Console" and "Open
Console")

Thanks:)
Re: Pulldown actions in the View toolbar problem [message #435301 is a reply to message #435205] Thu, 11 August 2005 17:58 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alexei,

Actually pretty simple. I did a simple snippet for you that should work. You
need to implement an action that implements IMenuCreator which provides the
getMenu()-method. This method provides the menu and fills it with the
content you want to show. Typically you would futhermore add ActionItems to
that. You can find a sample for that in the code of the console view (see
below).

Finally you need to initiate this by calling setMenuCreator of the class
Action in your constructor.

public class MyView extends Action implements IMenuCreator {

private Menu fMenu;

public MyView ()
{
setId("myId");
setToolTipText("myToolTip");
setImageDescriptor(ImageUtils.getImageDescriptor(ImageUtils. COLLAPSE_ALL));

// this is the first magic portion for it
setMenuCreator(this);
}

/* this is the second magic portion for it */
public Menu getMenu(Control parent) {
if (fMenu != null) {
fMenu.dispose();
}
fMenu= new Menu(parent);
MenuItem menuItem = new MenuItem (fMenu, SWT.PUSH);
menuItem.setText ("hello 1");

return fMenu;
}

// other methods like run and to empty ones that are needed for
interface
}

Here's how you can view the source code of the console-view. Open the
plugin-view. Here you will find a plugin named org.eclipse.ui.console.
Right-click, import As Source Project. Now go to Navigator or Package
Explorer and open this new project. You will find the
org.eclipse.ui.internal.console.OpenConsoleAction under source. Here you'll
see the same approach only that getMenu uses addActionToMenu() to add
actions to the Menu.

Stefan


"Alexei Golovko" <golovkov@texnika.com.ua> schrieb im Newsbeitrag
news:b732c17c5eefc72338a6efc9bf6e0302$1@www.eclipse.org...
> Hello, guys!
>
> I'm a newbie in eclipse so it maybe a little difficult for me to
> understand some basic concepts. I see that declarative way of creation new
> actions is very simple and nice (using org.eclipse.ui.actionSets and
> org.eclipse.ui.viewActions extention points).
>
> The only problem I met here is to create Pulldown action in the view local
> toolbar (not a pulldown menu)...
>
> Please, help me with this thing (the declarative solution if possible).
> Generally, I think this feature is possible (for example - "Console View"
> in the Eclipse IDE has such actions: "Display Selected Console" and "Open
> Console")
>
> Thanks:)
>
Re: Pulldown actions in the View toolbar problem [message #435306 is a reply to message #435301] Fri, 12 August 2005 01:44 Go to previous messageGo to next message
Eclipse UserFriend
Sorry, I forgot to add the call in the view to integrate into the toolbar:

IToolBarManager toolbar=
getViewSite().getActionBars().getToolBarManager();
MyViewAction menuAction = new MyViewAction ();
toolbar.add(menuAction);

and of course the class name for the Action should be called MyViewAction
not MyView

Stefan

"Stefan Hoehn" <webmail@andreaundstefanhoehn.de> schrieb im Newsbeitrag
news:ddghmf$j46$1@news.eclipse.org...
> Hi Alexei,
>
> Actually pretty simple. I did a simple snippet for you that should work.
> You need to implement an action that implements IMenuCreator which
> provides the getMenu()-method. This method provides the menu and fills it
> with the content you want to show. Typically you would futhermore add
> ActionItems to that. You can find a sample for that in the code of the
> console view (see below).
>
> Finally you need to initiate this by calling setMenuCreator of the class
> Action in your constructor.
>
> public class MyViewAction extends Action implements IMenuCreator {
>
> private Menu fMenu;
>
> public MyViewAction ()
> {
> setId("myId");
> setToolTipText("myToolTip");
>
> setImageDescriptor(ImageUtils.getImageDescriptor(ImageUtils. COLLAPSE_ALL));
>
> // this is the first magic portion for it
> setMenuCreator(this);
> }
>
> /* this is the second magic portion for it */
> public Menu getMenu(Control parent) {
> if (fMenu != null) {
> fMenu.dispose();
> }
> fMenu= new Menu(parent);
> MenuItem menuItem = new MenuItem (fMenu, SWT.PUSH);
> menuItem.setText ("hello 1");
>
> return fMenu;
> }
>
> // other methods like run and to empty ones that are needed for
> interface
> }
>
> Here's how you can view the source code of the console-view. Open the
> plugin-view. Here you will find a plugin named org.eclipse.ui.console.
> Right-click, import As Source Project. Now go to Navigator or Package
> Explorer and open this new project. You will find the
> org.eclipse.ui.internal.console.OpenConsoleAction under source. Here
> you'll see the same approach only that getMenu uses addActionToMenu() to
> add actions to the Menu.
>
> Stefan
>
>
> "Alexei Golovko" <golovkov@texnika.com.ua> schrieb im Newsbeitrag
> news:b732c17c5eefc72338a6efc9bf6e0302$1@www.eclipse.org...
>> Hello, guys!
>>
>> I'm a newbie in eclipse so it maybe a little difficult for me to
>> understand some basic concepts. I see that declarative way of creation
>> new actions is very simple and nice (using org.eclipse.ui.actionSets and
>> org.eclipse.ui.viewActions extention points).
>>
>> The only problem I met here is to create Pulldown action in the view
>> local toolbar (not a pulldown menu)...
>>
>> Please, help me with this thing (the declarative solution if possible).
>> Generally, I think this feature is possible (for example - "Console View"
>> in the Eclipse IDE has such actions: "Display Selected Console" and "Open
>> Console")
>>
>> Thanks:)
>>
>
>
Re: Pulldown actions in the View toolbar problem [message #435310 is a reply to message #435306] Fri, 12 August 2005 05:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: golovkov.texnika.com.ua

Hello, Stefan!

Thank you very much for your answer:) It is really useful for me... And
what about declarative way of the action definition (I mean plugin.xml).
Is this impossible to make the pulldown action this way?

It seems that xml-scripting eclipse abilities are restricted to make some
simple actions (actionSets) which are not accessible and reusable from
other application parts...

Am I wright?

Thank you ones more for your examples:)
Re: Pulldown actions in the View toolbar problem [message #435314 is a reply to message #435310] Fri, 12 August 2005 06:34 Go to previous messageGo to next message
Eclipse UserFriend
You are welcome :-)

I don't think that there is a way to do that because it involves much more
that pressing the button. How would you fill the entries in a declarative
way? What would the entries do (declarative-wise)? The only application I
would see is that those entries again are actions....

Stefan
Re: Pulldown actions in the View toolbar problem [message #435315 is a reply to message #435314] Fri, 12 August 2005 07:49 Go to previous message
Eclipse UserFriend
Originally posted by: golovkov.texnika.com.ua

Stefan,

Menu entries are actions. It's OK for my needs. But I spent much time
searching the web and docs for the XML instructions how to do this. It
seems the best way to make actions (even not pulldown) is to define them
in the source code.

Also I see that there is the xml instuction to make the pulldown action on
the application top-level (whole workbench) but there are no similar
instruction for the view or editor part...


> You are welcome :-)

> I don't think that there is a way to do that because it involves much more
> that pressing the button. How would you fill the entries in a declarative
> way? What would the entries do (declarative-wise)? The only application I
> would see is that those entries again are actions....

> Stefan
Previous Topic:How to get Eclipse Dialog icons
Next Topic:Changing a view without the PerspectiveFactory
Goto Forum:
  


Current Time: Sat Nov 08 23:32:28 EST 2025

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

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

Back to the top