Browse Source

fixes issue 1326: Info pane redesign

git-svn-id: http://svn.dmdirc.com/trunk@4177 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Gregory Holmes 16 years ago
parent
commit
7be64e82a4
1 changed files with 38 additions and 79 deletions
  1. 38
    79
      src/com/dmdirc/ui/swing/dialogs/about/InfoPanel.java

+ 38
- 79
src/com/dmdirc/ui/swing/dialogs/about/InfoPanel.java View File

@@ -24,49 +24,51 @@ package com.dmdirc.ui.swing.dialogs.about;
24 24
 
25 25
 import com.dmdirc.Main;
26 26
 
27
-import java.awt.Font;
28
-import java.awt.Toolkit;
29
-import java.awt.datatransfer.StringSelection;
30
-import java.awt.event.ActionEvent;
31
-import java.awt.event.ActionListener;
32 27
 import java.util.Locale;
33 28
 
34
-import javax.swing.JButton;
35
-import javax.swing.JLabel;
29
+import javax.swing.JEditorPane;
36 30
 import javax.swing.JPanel;
37 31
 import javax.swing.JScrollPane;
38 32
 import javax.swing.SwingUtilities;
39 33
 
40 34
 import net.miginfocom.swing.MigLayout;
41 35
 
42
-/**
43
- * Info panel.
44
- */
45
-public final class InfoPanel extends JPanel implements ActionListener {
46
-    
36
+/** Info panel. */
37
+public final class InfoPanel extends JPanel {
38
+
47 39
     /**
48 40
      * A version number for this class. It should be changed whenever the class
49 41
      * structure is changed (or anything else that would prevent serialized
50 42
      * objects being unserialized with the new class).
51 43
      */
52 44
     private static final long serialVersionUID = 1;
53
-    
45
+
54 46
     /** Creates a new instance of InfoPanel. */
55 47
     public InfoPanel() {
56 48
         super();
57
-        
49
+
58 50
         initComponents();
59 51
     }
60 52
 
53
+    /**
54
+     * Returns the DMDirc version info
55
+     * 
56
+     * @return DMDirc version string
57
+     */
58
+    private String getDMDircVersion() {
59
+        return Main.VERSION + " (" + Main.SVN_REVISION + "; " +
60
+                Main.UPDATE_CHANNEL + ")";
61
+    }
62
+
61 63
     /**
62 64
      * Returns the systems java version
63 65
      * 
64 66
      * @return Java version string
65 67
      */
66 68
     private String getJavaVersion() {
67
-        return System.getProperty("java.vm.name", "unknown") + " " 
68
-                + System.getProperty("java.vm.version", "unknown") + " ["
69
-                + System.getProperty("java.vm.vendor", "uknown") + "]";
69
+        return System.getProperty("java.vm.name", "unknown") + " " +
70
+                System.getProperty("java.vm.version", "unknown") + 
71
+                " [" + System.getProperty("java.vm.vendor", "uknown") + "]";
70 72
     }
71 73
 
72 74
     /**
@@ -75,78 +77,35 @@ public final class InfoPanel extends JPanel implements ActionListener {
75 77
      * @return OS version string
76 78
      */
77 79
     private String getOSVersion() {
78
-        return System.getProperty("os.name", "unknown") + " " 
79
-                + System.getProperty("os.version", "unknown") + " "
80
-                + System.getProperty("os.arch", "unknown") + "; "
81
-                + System.getProperty("file.encoding", "unknown") + "; "
82
-                + Locale.getDefault().toString();
80
+        return System.getProperty("os.name", "unknown") + " " +
81
+                System.getProperty("os.version", "unknown") + " " +
82
+                System.getProperty("os.arch", "unknown") + "; " +
83
+                System.getProperty("file.encoding", "unknown") + "; " + Locale.getDefault().
84
+                toString();
83 85
     }
84
-    
86
+
85 87
     /** Initialises the components. */
86 88
     private void initComponents() {
87
-        final JButton copy;
88
-        final JPanel info;
89
-        final JScrollPane scrollPane;
90
-        JLabel label;
91
-        
92
-        copy = new JButton("Copy to clipboard");
93
-        copy.addActionListener(this);
94
-        
95
-        info = new JPanel(new MigLayout("fillx, wrap 2"));
96
-        label = new JLabel("DMDirc version: ");
97
-        label.setFont(label.getFont().deriveFont(Font.BOLD));
98
-        info.add(label);
99
-        info.add(new JLabel(Main.VERSION + " (" + Main.SVN_REVISION + "; "
100
-                + Main.UPDATE_CHANNEL + ")"), "growx, pushx");
101
-        label = new JLabel("Profile directory: ");
102
-        label.setFont(label.getFont().deriveFont(Font.BOLD));
103
-        info.add(label);
104
-        info.add(new JLabel(Main.getConfigDir()), "growx, pushx");
105
-        label = new JLabel("Java version: ");
106
-        label.setFont(label.getFont().deriveFont(Font.BOLD));
107
-        info.add(label);
108
-        info.add(new JLabel(getJavaVersion()), "growx, pushx");
109
-        label = new JLabel("OS Version: ");
110
-        label.setFont(label.getFont().deriveFont(Font.BOLD));
111
-        info.add(label);
112
-        info.add(new JLabel(getOSVersion()), "growx, pushx");
113
-        
114
-        scrollPane = new JScrollPane(info);
89
+        final JScrollPane scrollPane = new JScrollPane();
90
+        final JEditorPane infoPane = new JEditorPane("text/html", "<html>" +
91
+                "<b>DMDirc version: </b>" + getDMDircVersion() + "<br>" +
92
+                "<b>Profile directory: </b>" + Main.getConfigDir() + "<br>" +
93
+                "<b>Java version: </b>" + getJavaVersion() + "<br>" +
94
+                "<b>OS Version: </b>" + getOSVersion() + "<br>" +
95
+                "</html>");
96
+        infoPane.setEditable(false);
97
+        scrollPane.setViewportView(infoPane);
98
+
115 99
         SwingUtilities.invokeLater(new Runnable() {
100
+
116 101
             /** {@inheritDoc} */
117 102
             @Override
118 103
             public void run() {
119 104
                 scrollPane.getVerticalScrollBar().setValue(0);
120 105
             }
121
-        }
122
-        );
123
-        
106
+        });
107
+
124 108
         setLayout(new MigLayout("ins rel, fill"));
125 109
         add(scrollPane, "grow, wrap");
126
-        add(copy, "right");
127
-    }
128
-
129
-    /** 
130
-     * {@inheritDoc}
131
-     * 
132
-     * @param e action event
133
-     */
134
-    @Override
135
-    public void actionPerformed(final ActionEvent e) {
136
-        final StringBuilder b = new StringBuilder();
137
-        b.append("DMDirc version: ");
138
-        b.append(Main.VERSION);
139
-        b.append(System.getProperty("line.separator", "\n"));
140
-        b.append("Profile directory: ");
141
-        b.append(Main.getConfigDir());
142
-        b.append(System.getProperty("line.separator", "\n"));
143
-        b.append("Java version: ");
144
-        b.append(getJavaVersion());
145
-        b.append(System.getProperty("line.separator", "\n"));
146
-        b.append("OS Version: ");
147
-        b.append(getOSVersion());
148
-        
149
-        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
150
-                new StringSelection(b.toString()), null);
151 110
     }
152 111
 }

Loading…
Cancel
Save