Results 1 to 9 of 9

Thread: how to add more than one toolbar ?

Hybrid View

  1. #1

    Default how to add more than one toolbar ?

    just as title

  2. #2
    Join Date
    Sep 2004
    Location
    Ghent, Belgium
    Posts
    224

    Default

    Can't you just add commands to the existing toolbar?

    you can get the toolbar from the ApplicationWindow, and then contribute commands or commandgroups.

  3. #3
    Join Date
    Aug 2004
    Posts
    203

    Default

    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

  4. #4
    Join Date
    Sep 2004
    Location
    Ghent, Belgium
    Posts
    224

    Default

    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

  5. #5
    Join Date
    Aug 2004
    Posts
    203

    Default

    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

  6. #6
    Join Date
    Sep 2004
    Location
    Ghent, Belgium
    Posts
    224

    Default

    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

  7. #7
    Join Date
    Aug 2004
    Posts
    203

    Default

    CommandGroup toolBar = getContext().getWindow().getToolBar();
    I can't use it because I create commandGroup programatic :

    This is code :
    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

  8. #8
    Join Date
    Dec 2004
    Posts
    5

    Default

    Snpe,

    You already solve this problem ?
    If yes can you explain !!!

    Thanks

  9. #9
    Join Date
    Aug 2004
    Posts
    203

    Default

    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

Similar Threads

  1. Large Icons for ToolBar
    By afida in forum Swing
    Replies: 8
    Last Post: Feb 4th, 2010, 02:23 AM
  2. ShowViewMenu and toolbar buttons
    By lstreepy in forum Swing
    Replies: 6
    Last Post: Oct 9th, 2008, 09:55 AM
  3. toolbar buttons with dropdown menu
    By lstreepy in forum Swing
    Replies: 5
    Last Post: Aug 13th, 2007, 03:10 PM
  4. Mnemonic set on toolbar buttons
    By tdunn in forum Swing
    Replies: 0
    Last Post: Oct 5th, 2005, 01:39 PM
  5. ShowViewCommand in ToolBar
    By afida in forum Swing
    Replies: 0
    Last Post: Oct 15th, 2004, 04:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •