Browse Source

Adds icons to new plugins prefs panel.

Plugin icons are now shown in the plugins panel, this will need to be
changed at a later date when CLIENT-221 is finished and themes are
integrated into this panel.

Issue CLIENT-33

Change-Id: I102920e35ec1a5aa7c49da36894f143458e21331
Reviewed-on: http://gerrit.dmdirc.com/2154
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.7rc1
Greg Holmes 13 years ago
parent
commit
903516fe3b

+ 11
- 4
src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonCell.java View File

23
 package com.dmdirc.addons.ui_swing.components.addonpanel;
23
 package com.dmdirc.addons.ui_swing.components.addonpanel;
24
 
24
 
25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26
+import com.dmdirc.ui.IconManager;
26
 
27
 
27
 import java.awt.Color;
28
 import java.awt.Color;
28
 import java.awt.Font;
29
 import java.awt.Font;
54
     private final TextLabel status;
55
     private final TextLabel status;
55
     /** Addon icon. */
56
     /** Addon icon. */
56
     private final JLabel icon;
57
     private final JLabel icon;
58
+    /** Icon manager to retrieve icons from. */
59
+    private final IconManager iconManager;
57
 
60
 
58
     /**
61
     /**
59
      * Creates a new addon cell representing the specified addon info.
62
      * Creates a new addon cell representing the specified addon info.
60
      *
63
      *
61
      * @param info PluginInfoToggle or ThemeToggle
64
      * @param info PluginInfoToggle or ThemeToggle
65
+     * @param iconManager Icon manager to retrieve icons from
62
      */
66
      */
63
-    public AddonCell(final AddonToggle info) {
67
+    public AddonCell(final AddonToggle info, final IconManager iconManager) {
64
         super();
68
         super();
65
 
69
 
70
+        this.iconManager = iconManager;
71
+        this.info = info;
72
+
66
         name = new TextLabel(false);
73
         name = new TextLabel(false);
67
         status = new TextLabel(false);
74
         status = new TextLabel(false);
68
         status.setAlignment(StyleConstants.ALIGN_RIGHT);
75
         status.setAlignment(StyleConstants.ALIGN_RIGHT);
69
         icon = new JLabel();
76
         icon = new JLabel();
70
 
77
 
71
-        this.info = info;
72
         info.addListener(this);
78
         info.addListener(this);
73
         init();
79
         init();
74
     }
80
     }
77
      * Initialises the addon cell.
83
      * Initialises the addon cell.
78
      */
84
      */
79
     private void init() {
85
     private void init() {
80
-        setLayout(new MigLayout("fill, ins 0, debug"));
86
+        setLayout(new MigLayout("fill, ins 0"));
81
         Color foreground = UIManager.getColor("Table.foreground");
87
         Color foreground = UIManager.getColor("Table.foreground");
82
         if (!info.getState()) {
88
         if (!info.getState()) {
83
             foreground = foreground.brighter().brighter().brighter();
89
             foreground = foreground.brighter().brighter().brighter();
84
         }
90
         }
91
+        icon.setIcon(iconManager.getIcon("addon"));
85
         name.setText(info.getName());
92
         name.setText(info.getName());
86
         status.setText(info.getState() ? "Enabled" : "Disabled");
93
         status.setText(info.getState() ? "Enabled" : "Disabled");
87
         name.setForeground(foreground);
94
         name.setForeground(foreground);
95
             initialPadding = 30;
102
             initialPadding = 30;
96
         }
103
         }
97
         add(icon, "gaptop rel, gapbottom rel, gapleft rel, "
104
         add(icon, "gaptop rel, gapbottom rel, gapleft rel, "
98
-                    + "wmin " + initialPadding + ", wmax " + initialPadding);
105
+                    + ", wmax " + initialPadding + ", right");
99
         add(name, "gaptop rel, gapbottom rel, " + "wmin 50% - "
106
         add(name, "gaptop rel, gapbottom rel, " + "wmin 50% - "
100
                 + initialPadding + ", wmax 50% - " + initialPadding);
107
                 + initialPadding + ", wmax 50% - " + initialPadding);
101
         add(status, "gaptop rel, gapbottom rel, gapright rel, " + "wmin 50% - "
108
         add(status, "gaptop rel, gapbottom rel, gapright rel, " + "wmin 50% - "

+ 14
- 0
src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonPanel.java View File

28
 import com.dmdirc.addons.ui_swing.components.addonbrowser.BrowserWindow;
28
 import com.dmdirc.addons.ui_swing.components.addonbrowser.BrowserWindow;
29
 import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
29
 import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
30
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
30
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
31
+import com.dmdirc.config.IdentityManager;
31
 import com.dmdirc.config.prefs.PreferencesInterface;
32
 import com.dmdirc.config.prefs.PreferencesInterface;
33
+import com.dmdirc.ui.IconManager;
32
 
34
 
33
 import java.awt.Window;
35
 import java.awt.Window;
34
 
36
 
64
     private final Window parentWindow;
66
     private final Window parentWindow;
65
     /** Swing Controller. */
67
     /** Swing Controller. */
66
     private final SwingController controller;
68
     private final SwingController controller;
69
+    /** The icon manager used to retrieve icons. */
70
+    private final IconManager iconManager;
67
     /** Addon list scroll pane. */
71
     /** Addon list scroll pane. */
68
     private JScrollPane scrollPane;
72
     private JScrollPane scrollPane;
69
     /** Blurb label. */
73
     /** Blurb label. */
87
 
91
 
88
         this.parentWindow = parentWindow;
92
         this.parentWindow = parentWindow;
89
         this.controller = controller;
93
         this.controller = controller;
94
+        this.iconManager = new IconManager(IdentityManager.getGlobalConfig());
90
 
95
 
91
         initComponents();
96
         initComponents();
92
         layoutComponents();
97
         layoutComponents();
229
     public void addonToggled() {
234
     public void addonToggled() {
230
         addonList.repaint();
235
         addonList.repaint();
231
     }
236
     }
237
+
238
+    /**
239
+     * Returns the icon manager for this panel.
240
+     *
241
+     * @return Icon manager instance
242
+     */
243
+    public IconManager getIconManager() {
244
+        return iconManager;
245
+    }
232
 }
246
 }

+ 2
- 2
src/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java View File

95
                 ((DefaultTableModel) table.getModel()).setNumRows(0);
95
                 ((DefaultTableModel) table.getModel()).setNumRows(0);
96
                 for (PluginInfo plugin : sortedList) {
96
                 for (PluginInfo plugin : sortedList) {
97
                     ((DefaultTableModel) table.getModel()).addRow(
97
                     ((DefaultTableModel) table.getModel()).addRow(
98
-                            new AddonCell[]{
99
-                        new AddonCell(new AddonToggle(plugin, null)), });
98
+                            new AddonCell[]{ new AddonCell(new AddonToggle(
99
+                            plugin, null), getIconManager()), });
100
                 }
100
                 }
101
                 table.repaint();
101
                 table.repaint();
102
             }
102
             }

+ 2
- 2
src/com/dmdirc/addons/ui_swing/components/addonpanel/ThemePanel.java View File

74
                 ((DefaultTableModel) addonList.getModel()).setRowCount(0);
74
                 ((DefaultTableModel) addonList.getModel()).setRowCount(0);
75
                 for (Theme theme : list) {
75
                 for (Theme theme : list) {
76
                     ((DefaultTableModel) addonList.getModel()).addRow(
76
                     ((DefaultTableModel) addonList.getModel()).addRow(
77
-                            new AddonCell[]{
78
-                        new AddonCell(new AddonToggle(null, theme)), });
77
+                    new AddonCell[]{ new AddonCell(new AddonToggle(
78
+                            null, theme), getIconManager()), });
79
                 }
79
                 }
80
 
80
 
81
                 addonList.repaint();
81
                 addonList.repaint();

Loading…
Cancel
Save