Ignore:
Timestamp:
2011-08-27T14:42:10+02:00 (13 years ago)
Author:
stoecker
Message:

see #6731 - reduce space required for SideButtons, moved arrow creation into SideButton class

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs
Files:
2 edited

Legend:

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

    r4223 r4354  
    55import static org.openstreetmap.josm.tools.I18n.trn;
    66
    7 import java.awt.BorderLayout;
    8 import java.awt.Color;
    97import java.awt.Component;
    10 import java.awt.GridLayout;
    118import java.awt.Rectangle;
    129import java.awt.event.ActionEvent;
     
    1613import java.awt.event.MouseEvent;
    1714import java.util.ArrayList;
     15import java.util.Arrays;
    1816import java.util.Collection;
    1917import java.util.Collections;
     
    2725import javax.swing.AbstractAction;
    2826import javax.swing.AbstractListModel;
    29 import javax.swing.BorderFactory;
    3027import javax.swing.DefaultListSelectionModel;
    3128import javax.swing.JButton;
    3229import javax.swing.JList;
    3330import javax.swing.JMenuItem;
    34 import javax.swing.JPanel;
    3531import javax.swing.JPopupMenu;
    36 import javax.swing.JScrollPane;
    3732import javax.swing.ListSelectionModel;
    38 import javax.swing.SwingConstants;
    3933import javax.swing.SwingUtilities;
    4034import javax.swing.event.ListDataEvent;
     
    4236import javax.swing.event.ListSelectionEvent;
    4337import javax.swing.event.ListSelectionListener;
    44 import javax.swing.plaf.basic.BasicArrowButton;
    4538
    4639import org.openstreetmap.josm.Main;
     
    9891
    9992    /**
    100      * Builds the panel with the list of selected OSM primitives
    101      *
    102      * @return the panel with the list of selected OSM primitives
    103      */
    104     protected JPanel buildListPanel() {
    105         JPanel pnl = new JPanel(new BorderLayout());
     93     * Builds the content panel for this dialog
     94     */
     95    protected void buildContentPanel() {
    10696        DefaultListSelectionModel selectionModel  = new DefaultListSelectionModel();
    10797        model = new SelectionListModel(selectionModel);
     
    111101        lstPrimitives.setCellRenderer(new OsmPrimitivRenderer());
    112102        lstPrimitives.setTransferHandler(null); // Fix #6290. Drag & Drop is not supported anyway and Copy/Paste is better propagated to main window
    113         pnl.add(new JScrollPane(lstPrimitives), BorderLayout.CENTER);
    114 
    115         return pnl;
    116     }
    117 
    118     /**
    119      * Builds the row of action buttons at the bottom of this dialog
    120      *
    121      * @return the panel
    122      */
    123     protected JPanel buildActionPanel() {
    124         JPanel pnl = new  JPanel(new GridLayout(1,2));
    125103
    126104        // the select action
    127         final JButton selectButton = new SideButton(actSelect = new SelectAction());
     105        final SideButton selectButton = new SideButton(actSelect = new SelectAction());
    128106        lstPrimitives.getSelectionModel().addListSelectionListener(actSelect);
    129         pnl.add(selectButton);
    130         BasicArrowButton selectionHistoryMenuButton = createArrowButton(selectButton);
    131         selectionHistoryMenuButton.addActionListener(new ActionListener() {
     107        selectButton.createArrow(new ActionListener() {
    132108            public void actionPerformed(ActionEvent e) {
    133109                SelectionHistoryPopup.launch(selectButton, model.getSelectionHistory());
     
    136112
    137113        // the search button
    138         final JButton searchButton = new SideButton(actSearch = new SearchAction());
    139         pnl.add(searchButton);
    140 
    141         BasicArrowButton searchHistoryMenuButton = createArrowButton(searchButton);
    142         searchHistoryMenuButton.addActionListener(new ActionListener() {
     114        final SideButton searchButton = new SideButton(actSearch = new SearchAction());
     115        searchButton.createArrow(new ActionListener() {
    143116            public void actionPerformed(ActionEvent e) {
    144117                SearchPopupMenu.launch(searchButton);
     
    146119        });
    147120
    148         return pnl;
    149     }
    150 
    151     /**
    152      * Builds the content panel for this dialog
    153      *
    154      * @return the content panel
    155      */
    156     protected JPanel buildContentPanel() {
    157         JPanel pnl = new JPanel(new BorderLayout());
    158         pnl.add(buildListPanel(), BorderLayout.CENTER);
    159         pnl.add(buildActionPanel(), BorderLayout.SOUTH);
    160         return pnl;
     121        createLayout(lstPrimitives, true, Arrays.asList(new SideButton[] {
     122            selectButton, searchButton
     123        }));
    161124    }
    162125
     
    168131        );
    169132
    170         add(buildContentPanel(), BorderLayout.CENTER);
     133        buildContentPanel();
    171134        model.addListDataListener(new TitleUpdater());
    172135        actZoomToJOSMSelection = new ZoomToJOSMSelectionAction();
     
    213176        DatasetEventManager.getInstance().removeDatasetListener(model);
    214177    }
    215 
    216     private BasicArrowButton createArrowButton(JButton parentButton) {
    217         BasicArrowButton arrowButton = new BasicArrowButton(SwingConstants.SOUTH, null, null, Color.BLACK, null);
    218         arrowButton.setBorder(BorderFactory.createEmptyBorder());
    219         parentButton.setLayout(new BorderLayout());
    220         parentButton.add(arrowButton, BorderLayout.EAST);
    221         return arrowButton;
    222     }
    223 
    224178
    225179    /**
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r4353 r4354  
    671671            add(data, BorderLayout.CENTER);
    672672        if(buttons != null && buttons.size() != 0) {
    673             JPanel buttonsPanel = new JPanel();
    674             buttonsPanel.setLayout(Main.pref.getBoolean("dialog.align.left", false)
     673            JPanel buttonsPanel = new JPanel(Main.pref.getBoolean("dialog.align.left", false)
    675674                ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,buttons.size()));
    676675            for(SideButton button : buttons)
Note: See TracChangeset for help on using the changeset viewer.