Changeset 3646 in josm for trunk/src/org


Ignore:
Timestamp:
2010-10-31T06:21:03+01:00 (14 years ago)
Author:
bastiK
Message:

little gui rework (move some buttons to the side so the structure is easier to grasp)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/StyleSourceEditor.java

    r3479 r3646  
    66
    77import java.awt.Component;
    8 import java.awt.FlowLayout;
    98import java.awt.GridBagConstraints;
    109import java.awt.GridBagLayout;
     
    4544import javax.swing.JPanel;
    4645import javax.swing.JScrollPane;
     46import javax.swing.JSeparator;
    4747import javax.swing.JTable;
    4848import javax.swing.JTextField;
     49import javax.swing.JToolBar;
    4950import javax.swing.KeyStroke;
    5051import javax.swing.ListCellRenderer;
     
    101102        lstAvailableStyles.setSelectionModel(selectionModel);
    102103        lstAvailableStyles.setCellRenderer(new StyleSourceCellRenderer());
    103         //availableStylesModel.setStyleSources(reloadAvailableStyles(availableStylesUrl));
    104104        this.availableStylesUrl = availableStylesUrl;
    105105
     
    107107        this.iconpref = iconsPreferenceKey;
    108108
    109         JButton iconadd = null;
    110         JButton iconedit = null;
    111         JButton icondelete = null;
    112 
     109        EditActiveStyleAction editActiveStyleAction = new EditActiveStyleAction();
     110        tblActiveStyles.getSelectionModel().addListSelectionListener(editActiveStyleAction);
     111
     112        RemoveActiveStylesAction removeActiveStylesAction = new RemoveActiveStylesAction();
     113        tblActiveStyles.getSelectionModel().addListSelectionListener(removeActiveStylesAction);
     114        tblActiveStyles.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0), "delete");
     115        tblActiveStyles.getActionMap().put("delete", removeActiveStylesAction);
     116
     117        ActivateStylesAction activateStylesAction = new ActivateStylesAction();
     118        lstAvailableStyles.addListSelectionListener(activateStylesAction);
     119        JButton activate = new JButton(activateStylesAction);
     120
     121        setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
     122        setLayout(new GridBagLayout());
     123        add(new JLabel(tr("Active styles:")), GBC.eol().insets(11, 5, 5, 0));
     124        JScrollPane sp = new JScrollPane(tblActiveStyles);
     125        add(sp, GBC.std().insets(10, 0, 3, 0).fill(GBC.BOTH));
     126        sp.setColumnHeaderView(null);
     127
     128        JToolBar sideButtonTB = new JToolBar(JToolBar.VERTICAL);
     129        sideButtonTB.setFloatable(false);
     130        sideButtonTB.setBorderPainted(false);
     131        sideButtonTB.setOpaque(false);
     132        sideButtonTB.add(new NewActiveStyleAction());
     133        sideButtonTB.add(editActiveStyleAction);
     134        sideButtonTB.add(removeActiveStylesAction);
     135        add(sideButtonTB, GBC.eol().insets(0, 0, 10, 0).fill(GBC.VERTICAL));
     136
     137        JToolBar bottomButtonTB = new JToolBar();
     138        bottomButtonTB.setFloatable(false);
     139        bottomButtonTB.setBorderPainted(false);
     140        bottomButtonTB.setOpaque(false);
     141        bottomButtonTB.add(activate);
     142        add(bottomButtonTB, GBC.eol().insets(12, 4, 5, 4).fill(GBC.HORIZONTAL));
     143
     144        add(new JLabel(tr("Available styles (from {0}):", availableStylesUrl)), GBC.eol().insets(11, 0, 5, 0));
     145        add(new JScrollPane(lstAvailableStyles), GBC.std().insets(10, 0, 3, 0).fill(GBC.BOTH));
     146
     147        sideButtonTB = new JToolBar(JToolBar.VERTICAL);
     148        sideButtonTB.setFloatable(false);
     149        sideButtonTB.setBorderPainted(false);
     150        sideButtonTB.setOpaque(false);
     151        sideButtonTB.add(new ReloadStylesAction(availableStylesUrl));
     152        add(sideButtonTB, GBC.eol().insets(0, 0, 10, 0).fill(GBC.VERTICAL));
     153       
    113154        if (iconsPreferenceKey != null) {
    114155            selectionModel = new DefaultListSelectionModel();
     
    121162            iconPathsModel.setIconPaths(Main.pref.getCollection(iconsPreferenceKey, null));
    122163
    123             iconadd = new JButton(new NewIconPathAction());
    124 
    125164            EditIconPathAction editIconPathAction = new EditIconPathAction();
    126165            tblIconPaths.getSelectionModel().addListSelectionListener(editIconPathAction);
    127             iconedit = new JButton(editIconPathAction);
    128166
    129167            RemoveIconPathAction removeIconPathAction = new RemoveIconPathAction();
    130168            tblIconPaths.getSelectionModel().addListSelectionListener(removeIconPathAction);
    131             icondelete = new JButton(removeIconPathAction);
    132169            tblIconPaths.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0), "delete");
    133170            tblIconPaths.getActionMap().put("delete", removeIconPathAction);
    134         }
    135 
    136         JButton add = new JButton(new NewActiveStyleAction());
    137 
    138         EditActiveStyleAction editActiveStyleAction = new EditActiveStyleAction();
    139         tblActiveStyles.getSelectionModel().addListSelectionListener(editActiveStyleAction);
    140         JButton edit = new JButton(editActiveStyleAction);
    141 
    142         RemoveActiveStylesAction removeActiveStylesAction = new RemoveActiveStylesAction();
    143         tblActiveStyles.getSelectionModel().addListSelectionListener(removeActiveStylesAction);
    144         tblActiveStyles.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0), "delete");
    145         tblActiveStyles.getActionMap().put("delete", removeActiveStylesAction);
    146         JButton delete = new JButton(removeActiveStylesAction);
    147 
    148         ActivateStylesAction activateStylesAction = new ActivateStylesAction();
    149         lstAvailableStyles.addListSelectionListener(activateStylesAction);
    150         JButton copy = new JButton(activateStylesAction);
    151 
    152         JButton update = new JButton(new ReloadStylesAction(availableStylesUrl));
    153 
    154         setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    155         setLayout(new GridBagLayout());
    156         add(new JLabel(tr("Active styles")), GBC.eol().insets(5, 5, 5, 0));
    157         JScrollPane sp;
    158         add(sp = new JScrollPane(tblActiveStyles), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
    159         sp.setColumnHeaderView(null);
    160         JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    161         add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
    162         buttonPanel.add(add, GBC.std().insets(0, 5, 0, 0));
    163         buttonPanel.add(edit, GBC.std().insets(5, 5, 5, 0));
    164         buttonPanel.add(delete, GBC.std().insets(0, 5, 5, 0));
    165         buttonPanel.add(copy, GBC.std().insets(0, 5, 5, 0));
    166         add(new JLabel(tr("Available styles (from {0})", availableStylesUrl)), GBC.eol().insets(5, 5, 5, 0));
    167         add(new JScrollPane(lstAvailableStyles), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
    168         buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    169         add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
    170         buttonPanel.add(update, GBC.std().insets(0, 5, 0, 0));
    171         if (tblIconPaths != null) {
    172             add(new JLabel(tr("Icon paths")), GBC.eol().insets(5, -5, 5, 0));
    173             add(sp = new JScrollPane(tblIconPaths), GBC.eol().insets(5, 0, 5, 0).fill(GBC.BOTH));
     171
     172            add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 10, 5, 10));
     173            add(new JLabel(tr("Icon paths:")), GBC.eol().insets(11, 0, 5, 0));
     174            add(sp = new JScrollPane(tblIconPaths), GBC.std().insets(10, 0, 3, 0).fill(GBC.BOTH));
    174175            sp.setColumnHeaderView(null);
    175             buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    176             add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
    177             buttonPanel.add(iconadd);
    178             buttonPanel.add(iconedit);
    179             buttonPanel.add(icondelete);
     176            sideButtonTB = new JToolBar(JToolBar.VERTICAL);
     177            sideButtonTB.setFloatable(false);
     178            sideButtonTB.setBorderPainted(false);
     179            sideButtonTB.setOpaque(false);
     180            add(sideButtonTB, GBC.eol().insets(0, 0, 10, 0).fill(GBC.VERTICAL));
     181            sideButtonTB.add(new NewIconPathAction());
     182            sideButtonTB.add(editIconPathAction);
     183            sideButtonTB.add(removeIconPathAction);
    180184        }
    181185    }
     
    530534            putValue(NAME, tr("Reload"));
    531535            putValue(SHORT_DESCRIPTION, tr("Reloads the list of available styles from ''{0}''", url));
    532             putValue(SMALL_ICON, ImageProvider.get("download"));
     536            putValue(SMALL_ICON, ImageProvider.get("dialogs/refresh"));
    533537            this.url = url;
    534538        }
Note: See TracChangeset for help on using the changeset viewer.