View Full Version : how to add more than one toolbar ?
lin_xd
Nov 28th, 2004, 09:14 PM
just as title
pdbruycker
Dec 2nd, 2004, 01:05 AM
Can't you just add commands to the existing toolbar?
you can get the toolbar from the ApplicationWindow, and then contribute commands or commandgroups.
snpe
Dec 2nd, 2004, 04:09 AM
I try add and remove commands from/to toolbar and it doesn't work
I create toolbar and commands programatic like :
ActionCommand com = new ActionCommand ...
CommandGroup group = getActiveWindow().getCommandManager()
.createCommandGroup ...
JToolbar toolbar = group.createToolBar ()
When I try group.add(..) or group.remove ... nothing happen
regards
pdbruycker
Dec 2nd, 2004, 05:17 AM
By calling the createToolBar method on the CommandGroup you created, you create a JToolBar instance, but it never gets added to the gui.
Do the following instead (in your view):
// first get the CommandGroup that forms the ToolBar
CommandGroup toolBar = getContext().getWindow().getToolBar();
// add a command
ActionCommand cmd = ...;
toolBar.add(cmd);
toolBar.addSeparator();
// add a CommandGroup
CommandGroup group = ...;
toolBar.add(group);
Hope this helps,
Peter
snpe
Dec 2nd, 2004, 06:47 AM
Peter,
I can't use spring RCP commands from command-context.xml because I have more views on
screen in the same time and I create command group and commands "manual" with new operator
toolbar is created fine, but I want that add or remove any command depend from context
I try group.add and group.remove and it don't work
Thanks
pdbruycker
Dec 2nd, 2004, 08:47 AM
Do you add the commandgroup you created to the toolbar as I suggested? I tried it, and it works.
I'm also working with multiple views per page, and everything works fine.
I added a PageComponentListener to the ApplicationPage that adds the commands when the view is opened or gains focus, and removes them when the view is closed or loses focus.
Everything works fine,
Peter
snpe
Dec 2nd, 2004, 10:58 AM
CommandGroup toolBar = getContext().getWindow().getToolBar();
I can't use it because I create commandGroup programatic :
This is code :
...
dbRefresh = new ActionCommand("dbRefresh") {
protected void doExecuteCommand() {
dbForm.getDbModel().refresh();
}
};
searchPreferencesPopupMenu = new SearchPopupMenuMouseListener(
createSearchPreferencesPopupMenu());
dbSearchPreferences = new ActionCommand("dbSearchPreferences") {
public AbstractButton createButton(String faceDescriptorId,
ButtonFactory buttonFactory,
CommandButtonConfigurer buttonConfigurer) {
AbstractButton button = buttonFactory.createButton();
attach(button, buttonConfigurer);
button.addMouseListener(searchPreferencesPopupMenu );
return button;
}
protected void doExecuteCommand() {
//dbForm.searchPreferencesPopupMenu.
}
};
String CommandGroupName = dbForm.getFormName() + "." + DATABASE_COMMAND;
CommandGroup group = getActiveWindow().getCommandManager()
.createCommandGroup(
CommandGroupName,
new Object[] { dbNewRow, dbSearchMode,
dbCancelSearchMode, dbRefresh, "separator",
dbSave, dbRollback, dbDelete, "separator",
dbFirst, dbPreviousPage, dbPrevious,
"separator", dbNext, dbNextPage, dbLast,
dbSearchPreferences });
return group.createToolBar();
I have CommandGroup group (id DATABASE_COMMAND) and toolbar toolbar
How I can add and remove command from group or toolbar. I try with group.add and remove
and it doesn't work
I'm also working with multiple views per page, and everything works fine.
I added a PageComponentListener to the ApplicationPage that adds the commands when the view is opened or gains focus, and removes them when the view is closed or loses focus.
Everything works fine,
I have views in tabs (idw docking window) and listener is called when view open, but don't
when view selected/deselected
Thanks
peter
Dec 28th, 2004, 09:51 AM
Snpe,
You already solve this problem ?
If yes can you explain !!!
Thanks
snpe
Dec 28th, 2004, 11:19 AM
I don't add/remove commands - I set disable/enable only (for now)
I try resolve problem with database logistic first and then I will add visual details
regards
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.