Changeset 302 in josm


Ignore:
Timestamp:
2007-08-08T17:09:56+02:00 (17 years ago)
Author:
imi
Message:
  • added better plugin information in about dialog
Location:
src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/actions/AboutAction.java

    r298 r302  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
     1//License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.actions;
    33
     
    1414import java.io.InputStreamReader;
    1515import java.net.URL;
     16import java.util.Map.Entry;
    1617import java.util.regex.Matcher;
    1718import java.util.regex.Pattern;
    1819
     20import javax.swing.AbstractAction;
    1921import javax.swing.BorderFactory;
     22import javax.swing.Box;
     23import javax.swing.JButton;
    2024import javax.swing.JLabel;
    2125import javax.swing.JOptionPane;
     
    6771                JTextArea readme = loadFile(Main.class.getResource("/README"));
    6872                JTextArea contribution = loadFile(Main.class.getResource("/CONTRIBUTION"));
    69                 JTextArea plugins = loadFile(null);
    7073
    7174                JPanel info = new JPanel(new GridBagLayout());
     
    8184                info.add(new UrlLabel("http://www.opengeodata.org/?cat=17"), GBC.eol().fill(GBC.HORIZONTAL));
    8285
    83                 StringBuilder pluginsStr = new StringBuilder();
    84                 for (PluginProxy p : Main.plugins)
    85                         pluginsStr.append(p.info.name + "\n");
    86                 plugins.setText(pluginsStr.toString());
    87                 plugins.setCaretPosition(0);
    88 
    8986                about.addTab(tr("Info"), info);
    9087                about.addTab(tr("Readme"), createScrollPane(readme));
    9188                about.addTab(tr("Revision"), createScrollPane(revision));
    9289                about.addTab(tr("Contribution"), createScrollPane(contribution));
    93                 about.addTab(tr("Plugins"), createScrollPane(plugins));
     90
     91                JPanel pluginTab = new JPanel(new GridBagLayout());
     92                for (final PluginProxy p : Main.plugins) {
     93                        String name = p.info.name + (p.info.version != null && !p.info.version.equals("") ? " Version: "+p.info.version : "");
     94                        pluginTab.add(new JLabel(name), GBC.std());
     95                        pluginTab.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
     96                        pluginTab.add(new JButton(new AbstractAction(tr("Information")){
     97                                public void actionPerformed(ActionEvent event) {
     98                                        StringBuilder b = new StringBuilder();
     99                                        for (Entry<String,String> e : p.info.attr.entrySet()) {
     100                                                b.append(e.getKey());
     101                                                b.append(": ");
     102                                                b.append(e.getValue());
     103                                                b.append("\n");
     104                                        }
     105                                        JTextArea a = new JTextArea(10,40);
     106                                        a.setEditable(false);
     107                                        a.setText(b.toString());
     108                                        JOptionPane.showMessageDialog(Main.parent, new JScrollPane(a));
     109                                }
     110                        }), GBC.eol());
     111                        JLabel label = new JLabel("<html><i>"+(p.info.description==null?tr("no description available"):p.info.description)+"</i></html>");
     112                        label.setBorder(BorderFactory.createEmptyBorder(0,20,0,0));
     113                        label.setMaximumSize(new Dimension(450,1000));
     114                        pluginTab.add(label, GBC.eop().fill(GBC.HORIZONTAL));
     115                }
     116                about.addTab(tr("Plugins"), pluginTab);
    94117
    95118                about.setPreferredSize(new Dimension(500,300));
     
    102125                area.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    103126                area.setOpaque(false);
    104             JScrollPane sp = new JScrollPane(area);
     127                JScrollPane sp = new JScrollPane(area);
    105128                sp.setBorder(null);
    106129                sp.setOpaque(false);
    107             return sp;
    108     }
     130                return sp;
     131        }
    109132
    110133        /**
     
    114137         */
    115138        public static String checkLatestVersion() {
    116         String latest;
    117         try {
    118                 InputStream s = new URL("http://josm.openstreetmap.de/current").openStream();
    119                 latest = new BufferedReader(new InputStreamReader(s)).readLine();
    120                 s.close();
    121         } catch (IOException x) {
    122                 x.printStackTrace();
    123                 return "UNKNOWN";
    124         }
    125         return latest;
    126     }
     139                String latest;
     140                try {
     141                        InputStream s = new URL("http://josm.openstreetmap.de/current").openStream();
     142                        latest = new BufferedReader(new InputStreamReader(s)).readLine();
     143                        s.close();
     144                } catch (IOException x) {
     145                        x.printStackTrace();
     146                        return "UNKNOWN";
     147                }
     148                return latest;
     149        }
    127150
    128151        /**
  • src/org/openstreetmap/josm/gui/preferences/PluginPreference.java

    r300 r302  
    7979                plugin.add(pluginPane, GBC.eol().fill(GBC.BOTH));
    8080                plugin.add(GBC.glue(0,10), GBC.eol());
    81                 JButton morePlugins = new JButton(tr("Get more plugins"));
     81                JButton morePlugins = new JButton(tr("Check for plugins"));
    8282                morePlugins.addActionListener(new ActionListener(){
    8383                        public void actionPerformed(ActionEvent e) {
     
    201201
    202202                        pluginCheck.setToolTipText(plugin.resource != null ? plugin.resource : tr("Plugin bundled with JOSM"));
    203                         JLabel label = new JLabel("<html><i>"+(plugin.description==null?"no description available":plugin.description)+"</i></html>");
     203                        JLabel label = new JLabel("<html><i>"+(plugin.description==null?tr("no description available"):plugin.description)+"</i></html>");
    204204                        label.setBorder(BorderFactory.createEmptyBorder(0,20,0,0));
    205205                        label.setMaximumSize(new Dimension(450,1000));
Note: See TracChangeset for help on using the changeset viewer.