|
Re: howto add a new button to toolbar [message #1047715 is a reply to message #1047666] |
Tue, 23 April 2013 14:57 |
Urs Beeli Messages: 573 Registered: October 2012 Location: Bern, Switzerland |
Senior Member |
|
|
Just add the proper classes to your client's Desktop class.
You can add classes that extend AbstractToolButton to add buttons to the right of the back/forward/refresh buttons (marked green in my screenshot below).
@Order(10.0)
public class DrawLineTool extends AbstractToolButton {
@Override
protected String getConfiguredIconId() {
return Icons.DrawLine;
}
@Override
protected String getConfiguredText() {
return TEXTS.get("DrawLine");
}
@Override
protected String getConfiguredTooltipText() {
return TEXTS.get("DrawLineTooltip");
}
@Override
protected void execAction() throws ProcessingException {
new DrawLineForm().startModify();
}
}
You can add classes that extend AbstractFormToolButton to add buttons to a bar on the right hand side of your window (marked blue in my screenshot below).
@Order(40.0)
public class GruppenFormTool extends AbstractFormToolButton {
@Override
protected String getConfiguredIconId() {
return Icons.Gruppe;
}
@Override
protected String getConfiguredText() {
return TEXTS.get("Gruppen");
}
@Override
protected String getConfiguredTooltipText() {
return TEXTS.get("GruppenTooltip");
}
@Override
protected void execAction() throws ProcessingException {
new GruppenForm().startDisplay();
}
}
Any class that extends AbstractOutlineViewButton will add a button to the outline toolbar (this is intended to switch outlines, but you can abuse this by overwriting the execAction method to do something else than switch outlines (though you need to create an associated outline and add it to the list of outlines to make the button shown) (marked in red in my screenshot below).
public class DrawLineOutlineViewButton extends AbstractOutlineViewButton {
public DrawLineOutlineViewButton() {
// dirty nasty hack: we're attaching our button to a dummy outline (which needs to be added to the result in Desktop.getConfiguredOutlines(), otherwise our button won't be shown)
super(Desktop.this, DummyOutline.class);
}
@Override
protected String getConfiguredIconId() {
return Icons.DrawLine;
}
@Override
protected String getConfiguredText() {
return TEXTS.get("DrawLine");
}
@Override
protected String getConfiguredTooltipText() {
return TEXTS.get("DrawLineTooltip");
}
@Override
protected void execAction() throws ProcessingException {
// dirty nasty hack part 2: we stop AbstractOutlineViewButton.execAction (which would switch the outline) from being called and do "our thing" instead
new DrawLineForm().startModify();
}
}
Note that the above works 1:1 using the Swing client without Rayo Look and Feel. Apparently Rayo does not support ToolButtons (but it does support FormToolButtons), so using the Swing client with Rayo, you'll only see the red and blue buttons, not the green ones. With the SWT client, none of these buttons will be shown out of the box and you'll need to add some code of your own to show them on the SWT Coolbar.
Buttons in Swing client without Rayo LnF:
Buttons in Swing client with Rayo LnF:
[Updated on: Tue, 23 April 2013 14:58] Report message to a moderator
|
|
|
|
|
Re: howto add a new button to toolbar [message #1048151 is a reply to message #1047845] |
Wed, 24 April 2013 05:27 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
Wolfgang Strunk wrote on Tue, 23 April 2013 20:31Hi Urs,
that's an excellent answer and I totally agree with Jeremie: your examples should be added to the wiki and included into the book.
For wiki: yes, the wiki is open (it is a wiki). We have no limitations, and our vision is that everybody should write in the wiki. More information here: wiki contributions.
For the book: Matthias is responsible for the content of the book (which is already defined). The space is limited (current version is already ~200 pages without all content). Contributions are more than welcome, but you should check with Matthias first if this is material for the book or not. (see also: book contributions).
Wolfgang Strunk wrote on Tue, 23 April 2013 20:31
I still have some questions
- I am happy to see that the team is working on better support of Toolbars, but I wonder what the rationale behind missing support in Rayo is.
Beat provided a good answer in an other topic from Urs, where he pointed discrepancies when using Rayo. Only the requested items were ported to rayo. I think additions like Toolbuttons could be added (there is space for a toolbar on top of the Rayo main window). As long as is does not break the choices made until now, it should be possible (Rayo is the widely used).
If you have interest let us know.
Wolfgang Strunk wrote on Tue, 23 April 2013 20:31
- is there any proposal what to use the AbstractFormToolButton for? I did not it used in any example.
In the project I am working on, we use the form tool button to open "side forms" on the right of the table (search forms, list of bookmarks, list of tasks...).
I think there is a demo of such behavior in the Scout widgets demo application.
Wolfgang Strunk wrote on Tue, 23 April 2013 20:31
- why is the AbstractToolButton not mapped to an SWT Coolbar by default?
In the SWT use cases I know sometimes the whole Scout application is represented in one perspective (using a SnapBox to switch between the outlines), sometimes each scout outline is a RCP-Perspective.
We discussed it in this thread: How to switch outlines with SWT
It might as changed in Kepler: see bug 383580 (I need to verify what changed exactly).
We are open for discussions.
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03464 seconds