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,6 +23,7 @@
23 23
 package com.dmdirc.addons.ui_swing.components.addonpanel;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26
+import com.dmdirc.ui.IconManager;
26 27
 
27 28
 import java.awt.Color;
28 29
 import java.awt.Font;
@@ -54,21 +55,26 @@ public class AddonCell extends JPanel implements AddonToggleListener {
54 55
     private final TextLabel status;
55 56
     /** Addon icon. */
56 57
     private final JLabel icon;
58
+    /** Icon manager to retrieve icons from. */
59
+    private final IconManager iconManager;
57 60
 
58 61
     /**
59 62
      * Creates a new addon cell representing the specified addon info.
60 63
      *
61 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 68
         super();
65 69
 
70
+        this.iconManager = iconManager;
71
+        this.info = info;
72
+
66 73
         name = new TextLabel(false);
67 74
         status = new TextLabel(false);
68 75
         status.setAlignment(StyleConstants.ALIGN_RIGHT);
69 76
         icon = new JLabel();
70 77
 
71
-        this.info = info;
72 78
         info.addListener(this);
73 79
         init();
74 80
     }
@@ -77,11 +83,12 @@ public class AddonCell extends JPanel implements AddonToggleListener {
77 83
      * Initialises the addon cell.
78 84
      */
79 85
     private void init() {
80
-        setLayout(new MigLayout("fill, ins 0, debug"));
86
+        setLayout(new MigLayout("fill, ins 0"));
81 87
         Color foreground = UIManager.getColor("Table.foreground");
82 88
         if (!info.getState()) {
83 89
             foreground = foreground.brighter().brighter().brighter();
84 90
         }
91
+        icon.setIcon(iconManager.getIcon("addon"));
85 92
         name.setText(info.getName());
86 93
         status.setText(info.getState() ? "Enabled" : "Disabled");
87 94
         name.setForeground(foreground);
@@ -95,7 +102,7 @@ public class AddonCell extends JPanel implements AddonToggleListener {
95 102
             initialPadding = 30;
96 103
         }
97 104
         add(icon, "gaptop rel, gapbottom rel, gapleft rel, "
98
-                    + "wmin " + initialPadding + ", wmax " + initialPadding);
105
+                    + ", wmax " + initialPadding + ", right");
99 106
         add(name, "gaptop rel, gapbottom rel, " + "wmin 50% - "
100 107
                 + initialPadding + ", wmax 50% - " + initialPadding);
101 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,7 +28,9 @@ import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28 28
 import com.dmdirc.addons.ui_swing.components.addonbrowser.BrowserWindow;
29 29
 import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
30 30
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
31
+import com.dmdirc.config.IdentityManager;
31 32
 import com.dmdirc.config.prefs.PreferencesInterface;
33
+import com.dmdirc.ui.IconManager;
32 34
 
33 35
 import java.awt.Window;
34 36
 
@@ -64,6 +66,8 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
64 66
     private final Window parentWindow;
65 67
     /** Swing Controller. */
66 68
     private final SwingController controller;
69
+    /** The icon manager used to retrieve icons. */
70
+    private final IconManager iconManager;
67 71
     /** Addon list scroll pane. */
68 72
     private JScrollPane scrollPane;
69 73
     /** Blurb label. */
@@ -87,6 +91,7 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
87 91
 
88 92
         this.parentWindow = parentWindow;
89 93
         this.controller = controller;
94
+        this.iconManager = new IconManager(IdentityManager.getGlobalConfig());
90 95
 
91 96
         initComponents();
92 97
         layoutComponents();
@@ -229,4 +234,13 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
229 234
     public void addonToggled() {
230 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,8 +95,8 @@ public class PluginPanel extends AddonPanel implements ActionListener {
95 95
                 ((DefaultTableModel) table.getModel()).setNumRows(0);
96 96
                 for (PluginInfo plugin : sortedList) {
97 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 101
                 table.repaint();
102 102
             }

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

@@ -74,8 +74,8 @@ public class ThemePanel extends AddonPanel {
74 74
                 ((DefaultTableModel) addonList.getModel()).setRowCount(0);
75 75
                 for (Theme theme : list) {
76 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 81
                 addonList.repaint();

Loading…
Cancel
Save