Changeset 5322 in josm


Ignore:
Timestamp:
Jul 11, 2012 7:00:17 PM (11 months ago)
Author:
simon04
Message:

Permit multiple rows of SideButtons in toggle dialogs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r5266 r5322  
    755755    } 
    756756 
     757    @SuppressWarnings("unchecked") 
    757758    protected Component createLayout(Component data, boolean scroll, Collection<SideButton> buttons) { 
    758         if(scroll) { 
     759        return createLayout(data, scroll, new Collection[]{buttons}); 
     760    } 
     761 
     762    protected Component createLayout(Component data, boolean scroll, Collection<SideButton>... buttons) { 
     763        if (scroll) { 
    759764            data = new JScrollPane(data); 
    760765        } 
    761766        add(data, BorderLayout.CENTER); 
    762         if(buttons != null && buttons.size() != 0) { 
    763             buttonsPanel = new JPanel(Main.pref.getBoolean("dialog.align.left", false) 
    764                     ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,buttons.size())); 
    765             for(SideButton button : buttons) { 
    766                 buttonsPanel.add(button); 
    767                 javax.swing.Action action = button.getAction(); 
    768                 if (action != null) { 
    769                     buttonActions.add(action); 
    770                 } else { 
    771                     System.err.println("Button " + button + " doesn't have action defined"); 
    772                     new Exception().printStackTrace(); 
     767        if (buttons != null && buttons.length > 0 && !buttons[0].isEmpty()) { 
     768            buttonsPanel = new JPanel(new GridLayout(buttons.length, 1)); 
     769            for (Collection<SideButton> buttonRow : buttons) { 
     770                final JPanel buttonRowPanel = new JPanel(Main.pref.getBoolean("dialog.align.left", false) 
     771                        ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1, buttonRow.size())); 
     772                buttonsPanel.add(buttonRowPanel); 
     773                for (SideButton button : buttonRow) { 
     774                    buttonRowPanel.add(button); 
     775                    javax.swing.Action action = button.getAction(); 
     776                    if (action != null) { 
     777                        buttonActions.add(action); 
     778                    } else { 
     779                        System.err.println("Button " + button + " doesn't have action defined"); 
     780                        new Exception().printStackTrace(); 
     781                    } 
    773782                } 
    774783            } 
    775784            add(buttonsPanel, BorderLayout.SOUTH); 
    776             if(Main.pref.getBoolean("dialog.dynamic.buttons", true)) { 
     785            if (Main.pref.getBoolean("dialog.dynamic.buttons", true)) { 
    777786                Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_MOTION_EVENT_MASK); 
    778787                buttonsPanel.setVisible(buttonHiding == ButtonHiddingType.ALWAYS_SHOWN || !isDocked); 
    779788            } 
    780         } else if(buttonsHide != null) { 
     789        } else if (buttonsHide != null) { 
    781790            buttonsHide.setVisible(false); 
    782791        } 
Note: See TracChangeset for help on using the changeset viewer.