Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » What is that drop-down Coolbar button widget?
What is that drop-down Coolbar button widget? [message #447637] Wed, 15 December 2004 16:35 Go to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
Hi, can anyone tell me what the widget is that allows menu sub-buttons to be
added to a parent coolbar button - looks like a combo box, and is used for
the New Project button in the IDE.

Thanks!

Phil
Re: What is that drop-down Coolbar button widget? [message #447639 is a reply to message #447637] Wed, 15 December 2004 18:07 Go to previous messageGo to next message
Stefan Zeiger is currently offline Stefan ZeigerFriend
Messages: 102
Registered: July 2009
Senior Member
Phillip Beauvoir wrote:

> Hi, can anyone tell me what the widget is that allows menu sub-buttons to be
> added to a parent coolbar button - looks like a combo box, and is used for
> the New Project button in the IDE.

It's a ToolItem with style SWT.DROP_DOWN.

--
Stefan Zeiger http://www.szeiger.de http://www.novocode.com
My SWT controls: http://www.novocode.com/swt
Re: What is that drop-down Coolbar button widget? [message #447642 is a reply to message #447639] Wed, 15 December 2004 20:05 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
Thanks for pointing me in the right direction. I'm trying to build a
Toolbar in a Coolbar:

public void fillCoolBar(ICoolBarManager coolBar) {
ToolBarManager toolBar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
coolBar.add(new ToolBarContributionItem(toolBar, "file"));

Action actionNew = new Action("New", SWT.DROP_DOWN) {
};

toolBar.add(actionNew);
}

This adds a drop-down ToolItem to the toolbar, but how do I now add actions
to this ToolItem?

Many thanks,

Phil


"Stefan Zeiger" <szeiger@novocode.com> wrote in message
news:cppuge$dml$1@www.eclipse.org...
> Phillip Beauvoir wrote:
>
>> Hi, can anyone tell me what the widget is that allows menu sub-buttons to
>> be added to a parent coolbar button - looks like a combo box, and is used
>> for the New Project button in the IDE.
>
> It's a ToolItem with style SWT.DROP_DOWN.
>
> --
> Stefan Zeiger http://www.szeiger.de http://www.novocode.com
> My SWT controls: http://www.novocode.com/swt
Re: What is that drop-down Coolbar button widget? [message #447644 is a reply to message #447642] Wed, 15 December 2004 21:13 Go to previous messageGo to next message
Mani Ghamari is currently offline Mani GhamariFriend
Messages: 33
Registered: July 2009
Member
See:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet140.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup

regards,

Mani

"Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> wrote in message
news:cpq5dh$4q7$1@www.eclipse.org...
> Thanks for pointing me in the right direction. I'm trying to build a
> Toolbar in a Coolbar:
>
> public void fillCoolBar(ICoolBarManager coolBar) {
> ToolBarManager toolBar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
> coolBar.add(new ToolBarContributionItem(toolBar, "file"));
>
> Action actionNew = new Action("New", SWT.DROP_DOWN) {
> };
>
> toolBar.add(actionNew);
> }
>
> This adds a drop-down ToolItem to the toolbar, but how do I now add
> actions to this ToolItem?
>
> Many thanks,
>
> Phil
>
>
> "Stefan Zeiger" <szeiger@novocode.com> wrote in message
> news:cppuge$dml$1@www.eclipse.org...
>> Phillip Beauvoir wrote:
>>
>>> Hi, can anyone tell me what the widget is that allows menu sub-buttons
>>> to be added to a parent coolbar button - looks like a combo box, and is
>>> used for the New Project button in the IDE.
>>
>> It's a ToolItem with style SWT.DROP_DOWN.
>>
>> --
>> Stefan Zeiger http://www.szeiger.de http://www.novocode.com
>> My SWT controls: http://www.novocode.com/swt
>
>
Re: What is that drop-down Coolbar button widget? [message #447646 is a reply to message #447644] Wed, 15 December 2004 21:23 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
Thnaks for the link but it doesn't help.

I'm trying to set up a Coolbar and toolbars when creating a View. All I
have is a ICoolBarManager.

Phil
Re: What is that drop-down Coolbar button widget? - The answer... [message #447653 is a reply to message #447637] Thu, 16 December 2004 00:43 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
For anyone who's interested I found out how to do it with the following
class (replace your own actions). I don't know if this is the best way to
do it, but it works:

public class NewDropDownAction extends Action implements IMenuCreator {
private Menu _menu;

public NewDropDownAction() {
super("New", SWT.DROP_DOWN);
setToolTipText("New");
setMenuCreator(this);
}

public void dispose() {
if(_menu != null) {
_menu.dispose();
_menu = null;
}
}

public Menu getMenu(Control parent) {
if(_menu != null) {
_menu.dispose();
}
_menu = new Menu(parent);
ActionContributionItem item = new
ActionContributionItem(yourAction);
item.fill(_menu, -1);
item = new ActionContributionItem(anotherAction);
item.fill(_menu, -1);
return _menu;
}

public Menu getMenu(Menu parent) {
return null;
}
}


"Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> wrote in message
news:cppp50$sa2$1@www.eclipse.org...
> Hi, can anyone tell me what the widget is that allows menu sub-buttons to
> be added to a parent coolbar button - looks like a combo box, and is used
> for the New Project button in the IDE.
>
> Thanks!
>
> Phil
>
>
Re: What is that drop-down Coolbar button widget? - The answer... [message #447656 is a reply to message #447653] Thu, 16 December 2004 07:43 Go to previous messageGo to next message
Stefan Pietsch is currently offline Stefan PietschFriend
Messages: 68
Registered: July 2009
Member
Hi Phillip,

thanks for your example. I came to the same solution.

But your method getMenu(Menu) returns null. Have you an idea how I can fill
this method, without construvting the same menu like getMenu(Control) twice?

Bye Stefan

"Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> schrieb im Newsbeitrag
news:cpqlpd$n2p$1@www.eclipse.org...
> For anyone who's interested I found out how to do it with the following
> class (replace your own actions). I don't know if this is the best way to
> do it, but it works:
>
> public class NewDropDownAction extends Action implements IMenuCreator {
> private Menu _menu;
>
> public NewDropDownAction() {
> super("New", SWT.DROP_DOWN);
> setToolTipText("New");
> setMenuCreator(this);
> }
>
> public void dispose() {
> if(_menu != null) {
> _menu.dispose();
> _menu = null;
> }
> }
>
> public Menu getMenu(Control parent) {
> if(_menu != null) {
> _menu.dispose();
> }
> _menu = new Menu(parent);
> ActionContributionItem item = new
> ActionContributionItem(yourAction);
> item.fill(_menu, -1);
> item = new ActionContributionItem(anotherAction);
> item.fill(_menu, -1);
> return _menu;
> }
>
> public Menu getMenu(Menu parent) {
> return null;
> }
> }
>
>
> "Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> wrote in message
> news:cppp50$sa2$1@www.eclipse.org...
> > Hi, can anyone tell me what the widget is that allows menu sub-buttons
to
> > be added to a parent coolbar button - looks like a combo box, and is
used
> > for the New Project button in the IDE.
> >
> > Thanks!
> >
> > Phil
> >
> >
>
>
Re: What is that drop-down Coolbar button widget? - The answer... [message #447703 is a reply to message #447656] Thu, 16 December 2004 10:27 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
I based mine on
org.eclipse.team.internal.ui.synchronize.actions.Synchronize PageDropDownAction
where they do the same, return null. I put a breakpoint there and found
that getMenu(Menu) is never called.

Now all I need to do is figure out how to get the menu to drop down when I
click the actual button (as well as the little arrow.)

Phil


"Stefan Pietsch" <pietsch@multichart.de> wrote in message
news:cprebq$tci$1@www.eclipse.org...
> Hi Phillip,
>
> thanks for your example. I came to the same solution.
>
> But your method getMenu(Menu) returns null. Have you an idea how I can
> fill
> this method, without construvting the same menu like getMenu(Control)
> twice?
>
> Bye Stefan
>
> "Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> schrieb im Newsbeitrag
> news:cpqlpd$n2p$1@www.eclipse.org...
>> For anyone who's interested I found out how to do it with the following
>> class (replace your own actions). I don't know if this is the best way
>> to
>> do it, but it works:
>>
>> public class NewDropDownAction extends Action implements IMenuCreator {
>> private Menu _menu;
>>
>> public NewDropDownAction() {
>> super("New", SWT.DROP_DOWN);
>> setToolTipText("New");
>> setMenuCreator(this);
>> }
>>
>> public void dispose() {
>> if(_menu != null) {
>> _menu.dispose();
>> _menu = null;
>> }
>> }
>>
>> public Menu getMenu(Control parent) {
>> if(_menu != null) {
>> _menu.dispose();
>> }
>> _menu = new Menu(parent);
>> ActionContributionItem item = new
>> ActionContributionItem(yourAction);
>> item.fill(_menu, -1);
>> item = new ActionContributionItem(anotherAction);
>> item.fill(_menu, -1);
>> return _menu;
>> }
>>
>> public Menu getMenu(Menu parent) {
>> return null;
>> }
>> }
>>
>>
>> "Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> wrote in message
>> news:cppp50$sa2$1@www.eclipse.org...
>> > Hi, can anyone tell me what the widget is that allows menu sub-buttons
> to
>> > be added to a parent coolbar button - looks like a combo box, and is
> used
>> > for the New Project button in the IDE.
>> >
>> > Thanks!
>> >
>> > Phil
>> >
>> >
>>
>>
>
>
Re: What is that drop-down Coolbar button widget? - The answer... [message #447704 is a reply to message #447703] Thu, 16 December 2004 12:47 Go to previous messageGo to next message
Stefan Pietsch is currently offline Stefan PietschFriend
Messages: 68
Registered: July 2009
Member
Hi Phil,

you need getMenu(Menu) if you insert the same action a menubar and a
toolbar! With my toolbar everything works fine, but the menu does not.

Bye Stefan

"Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> schrieb im Newsbeitrag
news:cpro7g$uvh$1@www.eclipse.org...
> I based mine on
>
org.eclipse.team.internal.ui.synchronize.actions.Synchronize PageDropDownActi
on
> where they do the same, return null. I put a breakpoint there and found
> that getMenu(Menu) is never called.
>
> Now all I need to do is figure out how to get the menu to drop down when I
> click the actual button (as well as the little arrow.)
>
> Phil
>
>
> "Stefan Pietsch" <pietsch@multichart.de> wrote in message
> news:cprebq$tci$1@www.eclipse.org...
> > Hi Phillip,
> >
> > thanks for your example. I came to the same solution.
> >
> > But your method getMenu(Menu) returns null. Have you an idea how I can
> > fill
> > this method, without construvting the same menu like getMenu(Control)
> > twice?
> >
> > Bye Stefan
> >
> > "Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> schrieb im Newsbeitrag
> > news:cpqlpd$n2p$1@www.eclipse.org...
> >> For anyone who's interested I found out how to do it with the following
> >> class (replace your own actions). I don't know if this is the best way
> >> to
> >> do it, but it works:
> >>
> >> public class NewDropDownAction extends Action implements IMenuCreator {
> >> private Menu _menu;
> >>
> >> public NewDropDownAction() {
> >> super("New", SWT.DROP_DOWN);
> >> setToolTipText("New");
> >> setMenuCreator(this);
> >> }
> >>
> >> public void dispose() {
> >> if(_menu != null) {
> >> _menu.dispose();
> >> _menu = null;
> >> }
> >> }
> >>
> >> public Menu getMenu(Control parent) {
> >> if(_menu != null) {
> >> _menu.dispose();
> >> }
> >> _menu = new Menu(parent);
> >> ActionContributionItem item = new
> >> ActionContributionItem(yourAction);
> >> item.fill(_menu, -1);
> >> item = new ActionContributionItem(anotherAction);
> >> item.fill(_menu, -1);
> >> return _menu;
> >> }
> >>
> >> public Menu getMenu(Menu parent) {
> >> return null;
> >> }
> >> }
> >>
> >>
> >> "Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> wrote in message
> >> news:cppp50$sa2$1@www.eclipse.org...
> >> > Hi, can anyone tell me what the widget is that allows menu
sub-buttons
> > to
> >> > be added to a parent coolbar button - looks like a combo box, and is
> > used
> >> > for the New Project button in the IDE.
> >> >
> >> > Thanks!
> >> >
> >> > Phil
> >> >
> >> >
> >>
> >>
> >
> >
>
>
Re: What is that drop-down Coolbar button widget? - The answer... [message #447706 is a reply to message #447704] Thu, 16 December 2004 13:24 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
Can you just copy the code from getMenu(Control parent)?

Phil


"Stefan Pietsch" <pietsch@multichart.de> wrote in message
news:cps04h$pmb$1@www.eclipse.org...
> Hi Phil,
>
> you need getMenu(Menu) if you insert the same action a menubar and a
> toolbar! With my toolbar everything works fine, but the menu does not.
>
> Bye Stefan
>
> "Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> schrieb im Newsbeitrag
> news:cpro7g$uvh$1@www.eclipse.org...
>> I based mine on
>>
> org.eclipse.team.internal.ui.synchronize.actions.Synchronize PageDropDownActi
> on
>> where they do the same, return null. I put a breakpoint there and found
>> that getMenu(Menu) is never called.
>>
>> Now all I need to do is figure out how to get the menu to drop down when
>> I
>> click the actual button (as well as the little arrow.)
>>
>> Phil
>>
>>
>> "Stefan Pietsch" <pietsch@multichart.de> wrote in message
>> news:cprebq$tci$1@www.eclipse.org...
>> > Hi Phillip,
>> >
>> > thanks for your example. I came to the same solution.
>> >
>> > But your method getMenu(Menu) returns null. Have you an idea how I can
>> > fill
>> > this method, without construvting the same menu like getMenu(Control)
>> > twice?
>> >
>> > Bye Stefan
>> >
>> > "Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> schrieb im Newsbeitrag
>> > news:cpqlpd$n2p$1@www.eclipse.org...
>> >> For anyone who's interested I found out how to do it with the
>> >> following
>> >> class (replace your own actions). I don't know if this is the best
>> >> way
>> >> to
>> >> do it, but it works:
>> >>
>> >> public class NewDropDownAction extends Action implements IMenuCreator
>> >> {
>> >> private Menu _menu;
>> >>
>> >> public NewDropDownAction() {
>> >> super("New", SWT.DROP_DOWN);
>> >> setToolTipText("New");
>> >> setMenuCreator(this);
>> >> }
>> >>
>> >> public void dispose() {
>> >> if(_menu != null) {
>> >> _menu.dispose();
>> >> _menu = null;
>> >> }
>> >> }
>> >>
>> >> public Menu getMenu(Control parent) {
>> >> if(_menu != null) {
>> >> _menu.dispose();
>> >> }
>> >> _menu = new Menu(parent);
>> >> ActionContributionItem item = new
>> >> ActionContributionItem(yourAction);
>> >> item.fill(_menu, -1);
>> >> item = new ActionContributionItem(anotherAction);
>> >> item.fill(_menu, -1);
>> >> return _menu;
>> >> }
>> >>
>> >> public Menu getMenu(Menu parent) {
>> >> return null;
>> >> }
>> >> }
>> >>
>> >>
>> >> "Phillip Beauvoir" <p.beauvoir@bolton.ac.uk> wrote in message
>> >> news:cppp50$sa2$1@www.eclipse.org...
>> >> > Hi, can anyone tell me what the widget is that allows menu
> sub-buttons
>> > to
>> >> > be added to a parent coolbar button - looks like a combo box, and is
>> > used
>> >> > for the New Project button in the IDE.
>> >> >
>> >> > Thanks!
>> >> >
>> >> > Phil
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Re: What is that drop-down Coolbar button widget? - The answer... [message #447709 is a reply to message #447706] Thu, 16 December 2004 14:14 Go to previous message
Stefan Pietsch is currently offline Stefan PietschFriend
Messages: 68
Registered: July 2009
Member
Hi Phil,

I think I can
Previous Topic:WizardSelectionPage example?
Next Topic:SWT & GEF
Goto Forum:
  


Current Time: Sun Nov 01 02:33:13 GMT 2020

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

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

Back to the top