just as title
Printable View
just as title
Can't you just add commands to the existing toolbar?
you can get the toolbar from the ApplicationWindow, and then contribute commands or commandgroups.
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
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
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
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
I can't use it because I create commandGroup programatic :Quote:
CommandGroup toolBar = getContext().getWindow().getToolBar();
This is code :
I have CommandGroup group (id DATABASE_COMMAND) and toolbar toolbarCode:...
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();
How I can add and remove command from group or toolbar. I try with group.add and remove
and it doesn't work
I have views in tabs (idw docking window) and listener is called when view open, but don'tQuote:
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,
when view selected/deselected
Thanks
Snpe,
You already solve this problem ?
If yes can you explain !!!
Thanks
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