Ignore:
Timestamp:
2009-01-09T22:11:24+01:00 (15 years ago)
Author:
ulfl
Message:

Improve panels on the right side:
a) add a normal/minimized display mechanism, with "triangle icon"
b) display number of active items in title
c) show title bold if panel has "active items"
d) add close "X" button

(b and c currently not implemented in the various plugins - but easy to do so)

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

Legend:

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

    r1169 r1228  
    6060
    6161    private void buildList() {
     62        if(Main.main.undoRedo.commands.size() != 0) {
     63            setTitle(tr("Command Stack: {0}", Main.main.undoRedo.commands.size()), true);
     64        } else {
     65            setTitle(tr("Command Stack"), false);
     66        }
    6267        if (Main.map == null || Main.map.mapView == null || Main.map.mapView.editLayer == null)
    6368            return;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r1221 r1228  
    130130            if (osm instanceof Relation)
    131131                model.addElement(osm);
     132
     133        if(model.size() != 0) {
     134            setTitle(tr("Conflicts: {0}", model.size()), true);
     135        } else {
     136            setTitle(tr("Conflicts"), false);
     137        }
    132138    }
    133139
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r1213 r1228  
    286286        downButton.setEnabled(sel >= 0 && sel < model.getSize()-1);
    287287        deleteAction.setEnabled(!model.isEmpty());
     288       
     289        if(model.getSize() != 0) {
     290            setTitle(tr("Layers: {0}", model.getSize()), true);
     291        } else {
     292            setTitle(tr("Layers"), false);
     293        }
    288294    }
    289295
  • trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r1169 r1228  
    695695
    696696        membershipTable.getTableHeader().setVisible(membershipData.getRowCount() > 0);
    697     }
     697
     698        if(propertyData.getRowCount() != 0 || membershipData.getRowCount() != 0) {
     699            setTitle(tr("Properties: {0} / Memberships: {1}",
     700                propertyData.getRowCount(), membershipData.getRowCount()), true);
     701        } else {
     702            setTitle(tr("Properties / Memberships"), false);
     703        }
     704
     705        }
    698706}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r1169 r1228  
    122122        }
    123123        list.setSize(i);
     124
     125        if(Main.ds.relations.size() != 0) {
     126            setTitle(tr("Relations: {0}", Main.ds.relations.size()), true);
     127        } else {
     128            setTitle(tr("Relations"), false);
     129        }
    124130    }
    125131
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r1195 r1228  
    262262                selectionHistory.removeLast();
    263263        }
     264       
     265        int ways = 0;
     266        int nodes = 0;
     267        int relations = 0;
     268        for (OsmPrimitive o : newSelection) {
     269            if (o instanceof Way)
     270                ways++;
     271            else if (o instanceof Node)
     272                nodes++;
     273            else if (o instanceof Relation)
     274                relations++;
     275        }
     276
     277        if( (nodes+ways+relations) != 0) {
     278            setTitle(tr("Selection: Rel.: {0} / Ways: {1} / Nodes: {2}", relations, ways, nodes), true);
     279        } else {
     280            setTitle(tr("Selection"), false);
     281        }
    264282    }
    265283
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r1180 r1228  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.gui.dialogs;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.awt.BorderLayout;
     
    68import java.awt.EventQueue;
    79import java.awt.GridBagLayout;
     10import java.awt.Component;
     11import java.awt.Image;
    812import java.awt.event.ActionEvent;
    913import java.awt.event.ActionListener;
    1014import java.awt.event.ComponentAdapter;
    1115import java.awt.event.ComponentEvent;
     16import java.awt.event.MouseEvent;
     17import java.awt.event.MouseListener;
    1218import java.awt.event.WindowAdapter;
    1319import java.awt.event.WindowEvent;
     
    2026import javax.swing.JLabel;
    2127import javax.swing.JPanel;
     28import javax.swing.ImageIcon;
    2229
    2330import org.openstreetmap.josm.Main;
     
    6168    public JPanel parent;
    6269    private final JPanel titleBar = new JPanel(new GridBagLayout());
     70    public JLabel label = new JLabel();
    6371
    6472    public ToggleDialog(final String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight) {
     
    6876    }
    6977
    70     private void ToggleDialogInit(final String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight) {
     78    private void ToggleDialogInit(final String name, String iconName, String tooltip, Shortcut shortcut, final int preferredHeight) {
    7179        setPreferredSize(new Dimension(330,preferredHeight));
    7280        action = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, shortcut, iconName);
     
    7583        setLayout(new BorderLayout());
    7684
    77         titleBar.add(new JLabel(name), GBC.std());
     85        // show the minimize button
     86        final JLabel minimize = new JLabel(ImageProvider.get("misc", "normal"));
     87        titleBar.add(minimize);
     88       
     89        // scale down the dialog icon
     90        ImageIcon inIcon = ImageProvider.get("dialogs", iconName);
     91        ImageIcon smallIcon = new ImageIcon(inIcon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH));
     92        JLabel labelSmallIcon = new JLabel(smallIcon);
     93        titleBar.add(labelSmallIcon);
     94
     95        final ActionListener hideActionListener = new ActionListener(){
     96            public void actionPerformed(ActionEvent e) {
     97                boolean nowVisible = false;
     98                Component comps[] = getComponents();
     99                for(int i=0; i<comps.length; i++)
     100                {
     101                    if(comps[i] != titleBar)
     102                    {
     103                        if(comps[i].isVisible()) {
     104                            comps[i].setVisible(false);
     105                        } else {
     106                            comps[i].setVisible(true);
     107                            nowVisible = true;
     108                        }
     109                    }
     110                }
     111               
     112                Main.pref.put(action.prefname+".minimized", !nowVisible);
     113                if(nowVisible == true) {
     114                    setPreferredSize(new Dimension(330,preferredHeight));
     115                    setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
     116                    minimize.setIcon(ImageProvider.get("misc", "normal"));
     117                } else {
     118                    setPreferredSize(new Dimension(330,20));
     119                    setMaximumSize(new Dimension(330,20));
     120                    minimize.setIcon(ImageProvider.get("misc", "minimized"));
     121                }
     122                // doLayout() - workaround
     123                parent.setVisible(false);
     124                parent.setVisible(true);
     125            }
     126        };
     127        //hide.addActionListener(hideActionListener);
     128
     129        final MouseListener titleMouseListener = new MouseListener(){
     130            public void mouseClicked(MouseEvent e) {
     131                hideActionListener.actionPerformed(null);
     132            }
     133            public void mouseEntered(MouseEvent e) {}
     134            public void mouseExited(MouseEvent e) {}
     135            public void mousePressed(MouseEvent e) {}
     136        public void mouseReleased(MouseEvent e) {}
     137        };
     138        titleBar.addMouseListener(titleMouseListener);
     139
     140        // add some padding space (there must be a better way to do this!)
     141        JLabel padding = new JLabel(" ");
     142        titleBar.add(padding);
     143
     144        // show the title label
     145        label.setText(name);
     146        titleBar.add(label, GBC.std());
    78147        titleBar.add(Box.createHorizontalGlue(),GBC.std().fill(GBC.HORIZONTAL));
    79148
     149        // show the sticky button
    80150        JButton sticky = new JButton(ImageProvider.get("misc", "sticky"));
     151        sticky.setToolTipText(tr("Undock the panel"));
    81152        sticky.setBorder(BorderFactory.createEmptyBorder());
    82153        final ActionListener stickyActionListener = new ActionListener(){
     
    121192        };
    122193        sticky.addActionListener(stickyActionListener);
    123 
    124194        titleBar.add(sticky);
     195
     196        // show the close button
     197        JButton close = new JButton(ImageProvider.get("misc", "close"));
     198        close.setToolTipText(tr("Close this panel. You can reopen it with the buttons in the left toolbar"));
     199        close.setBorder(BorderFactory.createEmptyBorder());
     200        final ActionListener closeActionListener = new ActionListener(){
     201            public void actionPerformed(ActionEvent e) {
     202                // fake an event to toggle dialog
     203                action.actionPerformed(new ActionEvent(titleBar, 0, ""));
     204            }
     205        };
     206        close.addActionListener(closeActionListener);
     207        titleBar.add(close);
     208
    125209        add(titleBar, BorderLayout.NORTH);
     210        titleBar.setToolTipText(tr("Click to minimize/maximize the panel content"));
    126211
    127212        setVisible(false);
     
    135220            });
    136221        }
     222        if (Main.pref.getBoolean(action.prefname+".minimized", false)) {
     223            EventQueue.invokeLater(new Runnable(){
     224                public void run() {
     225                    titleMouseListener.mouseClicked(null);
     226                }
     227            });
     228        }
     229    }
     230
     231    public void setTitle(String title, boolean active) {
     232        if(active) {
     233            label.setText("<html><b>" + title + "</b>");
     234        } else {
     235            label.setText(title);
     236        }
    137237    }
    138238
  • trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java

    r1169 r1228  
    109109            data.addRow(new Object[] { uc.user.name, uc.count, uc.count * 100 / all });
    110110        }
     111
     112        if(ucArr.length != 0) {
     113            setTitle(tr("Authors: {0}", ucArr.length), true);
     114        } else {
     115            setTitle(tr("Authors"), false);
     116        }
    111117    }
    112118
Note: See TracChangeset for help on using the changeset viewer.