Bladeren bron

Fixes issue 2383: Prefs dialog is too tall for a 600 high display (most netbooks)

Fixes the cleint being broken

Change-Id: I7d43d97e505077556fa62648610bd464493631dc
Reviewed-on: http://gerrit.dmdirc.com/269
Tested-by: Gregory Holmes <greboid@dmdirc.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3
Gregory Holmes 14 jaren geleden
bovenliggende
commit
b44fd4dab5

+ 5
- 4
src/com/dmdirc/addons/nickcolours/NickColourPanel.java Bestand weergeven

@@ -22,7 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.nickcolours;
24 24
 
25
-import com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog;
25
+import com.dmdirc.Main;
26
+import com.dmdirc.addons.ui_swing.SwingController;
26 27
 import com.dmdirc.config.IdentityManager;
27 28
 import com.dmdirc.config.prefs.PreferencesInterface;
28 29
 
@@ -117,9 +118,9 @@ public class NickColourPanel extends JPanel implements ActionListener,
117 118
         table.setFillsViewportHeight(true);
118 119
         table.setDefaultRenderer(Color.class, new ColourRenderer());
119 120
 
120
-        setLayout(new MigLayout("ins 0, fill, h " +
121
-                SwingPreferencesDialog.CLIENT_HEIGHT));
122
-        add(scrollPane, "grow, wrap, spanx, hmax 100%");
121
+        setLayout(new MigLayout("ins 0, fillx, hmax " + ((SwingController) Main.
122
+                getUI()).getPrefsDialog().getPanelHeight()));
123
+        add(scrollPane, "grow, push, wrap, spanx");
123 124
 
124 125
         final JButton addButton = new JButton("Add");
125 126
         addButton.addActionListener(this);

+ 12
- 2
src/com/dmdirc/addons/ui_swing/SwingController.java Bestand weergeven

@@ -57,6 +57,7 @@ import com.dmdirc.addons.ui_swing.dialogs.updater.SwingUpdaterDialog;
57 57
 import com.dmdirc.addons.ui_swing.dialogs.url.URLDialog;
58 58
 import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
59 59
 import com.dmdirc.addons.ui_swing.dialogs.error.ErrorListDialog;
60
+import com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog;
60 61
 import com.dmdirc.addons.ui_swing.dialogs.prefs.URLConfigPanel;
61 62
 import com.dmdirc.addons.ui_swing.dialogs.prefs.UpdateConfigPanel;
62 63
 import com.dmdirc.addons.ui_swing.wizard.firstrun.SwingFirstRunWizard;
@@ -531,7 +532,7 @@ public final class SwingController extends Plugin implements UIController {
531 532
             /** {@inheritDoc} */
532 533
             @Override
533 534
             public void run() {
534
-                setObject(new PluginPanel(me));
535
+                setObject(new PluginPanel(me, SwingController.this));
535 536
             }
536 537
         });
537 538
     }
@@ -544,7 +545,7 @@ public final class SwingController extends Plugin implements UIController {
544 545
             /** {@inheritDoc} */
545 546
             @Override
546 547
             public void run() {
547
-                setObject(new UpdateConfigPanel());
548
+                setObject(new UpdateConfigPanel(SwingController.this));
548 549
             }
549 550
         });
550 551
     }
@@ -643,6 +644,15 @@ public final class SwingController extends Plugin implements UIController {
643 644
                 UIManager.getFont("TextPane.font").getSize());
644 645
     }
645 646
 
647
+    /**
648
+     * Returns the preferences dialog instance creating if required.
649
+     *
650
+     * @return Swing prefs dialog
651
+     */
652
+    public SwingPreferencesDialog getPrefsDialog() {
653
+        return SwingPreferencesDialog.getSwingPreferencesDialog(me);
654
+    }
655
+
646 656
     /** {@inheritDoc} */
647 657
     @Override
648 658
     public void showConfig(final PreferencesManager manager) {

+ 2
- 3
src/com/dmdirc/addons/ui_swing/components/TopicBar.java Bestand weergeven

@@ -128,9 +128,6 @@ public class TopicBar extends JComponent implements ActionListener,
128 128
         //}
129 129
         ((DefaultStyledDocument) topicText.getDocument()).setDocumentFilter(
130 130
                 new NewlinesDocumentFilter());
131
-        setAttributes();
132
-        ((DefaultStyledDocument) topicText.getDocument()).setCharacterAttributes(
133
-                0, Integer.MAX_VALUE, as, true);
134 131
 
135 132
         topicText.getActionMap().put("paste-from-clipboard",
136 133
                 new NoNewlinesPasteAction());
@@ -209,6 +206,8 @@ public class TopicBar extends JComponent implements ActionListener,
209 206
         IdentityManager.getGlobalConfig().addChangeListener(
210 207
                 controller.getDomain(), "hideEmptyTopicBar", this);
211 208
         setColours();
209
+        ((DefaultStyledDocument) topicText.getDocument()).setCharacterAttributes(
210
+                0, Integer.MAX_VALUE, as, true);
212 211
     }
213 212
 
214 213
     /** {@inheritDoc} */

+ 17
- 5
src/com/dmdirc/addons/ui_swing/components/pluginpanel/PluginPanel.java Bestand weergeven

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.pluginpanel;
24 24
 
25
+import com.dmdirc.Main;
26
+import com.dmdirc.addons.ui_swing.SwingController;
25 27
 import com.dmdirc.config.prefs.PreferencesInterface;
26 28
 import com.dmdirc.plugins.PluginInfo;
27 29
 import com.dmdirc.plugins.PluginManager;
@@ -29,7 +31,6 @@ import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
29 31
 import com.dmdirc.addons.ui_swing.components.addonbrowser.DownloaderWindow;
30 32
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
31 33
 import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
32
-import com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog;
33 34
 
34 35
 import java.awt.Window;
35 36
 import java.awt.event.ActionEvent;
@@ -72,13 +73,17 @@ public final class PluginPanel extends JPanel implements
72 73
     private TextLabel blurbLabel;
73 74
     /** Parent Window. */
74 75
     private Window parentWindow;
76
+    /** Swing Controller. */
77
+    private SwingController controller;
75 78
 
76 79
     /**
77 80
      * Creates a new instance of PluginDialog.
78 81
      *
79 82
      * @param parentWindow Parent window
83
+     * @param controller Swing Controller
80 84
      */
81
-    public PluginPanel(final Window parentWindow) {
85
+    public PluginPanel(final Window parentWindow,
86
+            final SwingController controller) {
82 87
         super();
83 88
 
84 89
         this.parentWindow = parentWindow;
@@ -128,8 +133,14 @@ public final class PluginPanel extends JPanel implements
128 133
 
129 134
     /** Lays out the dialog. */
130 135
     private void layoutComponents() {
131
-        setLayout(new MigLayout("ins 0, fill, h " +
132
-                SwingPreferencesDialog.CLIENT_HEIGHT));
136
+        final int panelHeight;
137
+        if (controller == null) {
138
+            panelHeight = ((SwingController) Main.getUI()).getPrefsDialog().
139
+                    getPanelHeight();
140
+        } else {
141
+            panelHeight = controller.getPrefsDialog().getPanelHeight();
142
+        }
143
+        setLayout(new MigLayout("ins 0, fill, hmax " + panelHeight));
133 144
 
134 145
         add(blurbLabel, "wrap 10, growx, pushx");
135 146
 
@@ -204,7 +215,8 @@ public final class PluginPanel extends JPanel implements
204 215
                 toggleButton.setEnabled(true);
205 216
 
206 217
                 if (pluginInfo.getState()) {
207
-                    toggleButton.setEnabled(pluginInfo.getPluginInfo().isUnloadable());
218
+                    toggleButton.setEnabled(pluginInfo.getPluginInfo().
219
+                            isUnloadable());
208 220
                     toggleButton.setText("Disable");
209 221
                 } else {
210 222
                     toggleButton.setText("Enable");

+ 18
- 4
src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java Bestand weergeven

@@ -33,12 +33,15 @@ import java.awt.Window;
33 33
 import java.util.Collections;
34 34
 import java.util.HashMap;
35 35
 import java.util.Map;
36
+import java.util.concurrent.atomic.AtomicBoolean;
36 37
 
37 38
 import javax.swing.BorderFactory;
38 39
 import javax.swing.JPanel;
39 40
 import javax.swing.JScrollPane;
40 41
 import javax.swing.ScrollPaneConstants;
41 42
 import javax.swing.SwingWorker;
43
+import net.miginfocom.layout.ComponentWrapper;
44
+import net.miginfocom.layout.LayoutCallback;
42 45
 
43 46
 import net.miginfocom.layout.PlatformDefaults;
44 47
 import net.miginfocom.swing.MigLayout;
@@ -66,7 +69,7 @@ public class CategoryPanel extends JPanel {
66 69
     /** Active preferences category. */
67 70
     private PreferencesCategory category;
68 71
     /** Parent window. */
69
-    private Window parent;
72
+    private SwingPreferencesDialog parent;
70 73
     /** Title label. */
71 74
     private TitlePanel title;
72 75
     /** Tooltip display area. */
@@ -91,7 +94,7 @@ public class CategoryPanel extends JPanel {
91 94
      *
92 95
      * @param parent Parent window
93 96
      */
94
-    public CategoryPanel(final Window parent) {
97
+    public CategoryPanel(final SwingPreferencesDialog parent) {
95 98
         this(parent, null);
96 99
     }
97 100
 
@@ -101,7 +104,7 @@ public class CategoryPanel extends JPanel {
101 104
      * @param parent Parent window
102 105
      * @param category Initial category
103 106
      */
104
-    public CategoryPanel(final Window parent,
107
+    public CategoryPanel(final SwingPreferencesDialog parent,
105 108
             final PreferencesCategory category) {
106 109
         super(new MigLayout("fillx, wrap, ins 0"));
107 110
         this.parent = parent;
@@ -129,11 +132,22 @@ public class CategoryPanel extends JPanel {
129 132
                 "description, if available.");
130 133
 
131 134
         add(title, "pushx, growx, h 45!");
132
-        add(scrollPane, "grow, push, h 425!");
135
+        add(scrollPane, "grow, push");
133 136
         add(tooltip, "pushx, growx, h 65!");
134 137
 
135 138
         panels.put(null, loading);
136 139
         setCategory(category);
140
+        ((MigLayout) getLayout()).addLayoutCallback(new LayoutCallback() {
141
+
142
+            /** {@inheritDoc} */
143
+            @Override
144
+            public void correctBounds(final ComponentWrapper cw) {
145
+                if (cw.getComponent() == scrollPane) {
146
+                   parent.setPanelHeight((int) (scrollPane.getViewport().
147
+                           getExtentSize().height * 0.95));
148
+                }
149
+            }
150
+        });
137 151
     }
138 152
 
139 153
     /**

+ 24
- 8
src/com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.java Bestand weergeven

@@ -64,12 +64,6 @@ public final class SwingPreferencesDialog extends StandardDialog implements
64 64
      * serialized objects being unserialized with the new class).
65 65
      */
66 66
     private static final long serialVersionUID = 9;
67
-    /**
68
-     * The maximum height clients may use if they don't want to scroll.
69
-     *
70
-     * @since 0.6.3m1
71
-     */
72
-    public static final int CLIENT_HEIGHT = 375;
73 67
     /** Previously instantiated instance of SwingPreferencesDialog. */
74 68
     private static volatile SwingPreferencesDialog me;
75 69
     /** Preferences tab list, used to switch option types. */
@@ -84,6 +78,8 @@ public final class SwingPreferencesDialog extends StandardDialog implements
84 78
     private LoggingSwingWorker worker;
85 79
     /** Parent window. */
86 80
     private MainFrame parentWindow;
81
+    /** Panel size. */
82
+    protected int panelSize = 0;
87 83
 
88 84
     /**
89 85
      * Creates a new instance of SwingPreferencesDialog.
@@ -189,8 +185,10 @@ public final class SwingPreferencesDialog extends StandardDialog implements
189 185
         getOkButton().addActionListener(this);
190 186
         getCancelButton().addActionListener(this);
191 187
 
192
-        setLayout(new MigLayout("pack"));
193
-        add(tabListScrollPane, "w 150!, hmax 545, growy, pushy");
188
+        final MigLayout layout = new MigLayout("pack, hmin min(80sp, 700), " +
189
+                "hmax min(700, 80sp)");
190
+        setLayout(layout);
191
+        add(tabListScrollPane, "w 150!, growy, pushy");
194 192
         add(mainPanel, "wrap, w 480!, pushy, growy, pushy");
195 193
         add(getLeftButton(), "span, split, right");
196 194
         add(getRightButton(), "right");
@@ -349,6 +347,24 @@ public final class SwingPreferencesDialog extends StandardDialog implements
349 347
         tabList.setSelectedIndex(indexToSelect);
350 348
     }
351 349
 
350
+    /**
351
+     * Gets the maximum panel size.
352
+     *
353
+     * @return Max panel size
354
+     */
355
+    public int getPanelHeight() {
356
+        return panelSize;
357
+    }
358
+
359
+    /**
360
+     * Sets the panel size to the specified value.
361
+     *
362
+     * @param panelSize New panel size
363
+     */
364
+    protected void setPanelHeight(final int panelSize) {
365
+        this.panelSize = panelSize;
366
+    }
367
+
352 368
     /** {@inheritDoc} */
353 369
     @Override
354 370
     public void dispose() {

+ 12
- 4
src/com/dmdirc/addons/ui_swing/dialogs/prefs/UpdateConfigPanel.java Bestand weergeven

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
24 24
 
25
+import com.dmdirc.Main;
26
+import com.dmdirc.addons.ui_swing.SwingController;
25 27
 import com.dmdirc.config.ConfigManager;
26 28
 import com.dmdirc.config.Identity;
27 29
 import com.dmdirc.config.IdentityManager;
@@ -69,11 +71,17 @@ public class UpdateConfigPanel extends JPanel implements ActionListener,
69 71
     private JButton checkNow;
70 72
     /** Update channel. */
71 73
     private JComboBox updateChannel;
74
+    /** Swing controller. */
75
+    private SwingController controller;
72 76
 
73 77
     /**
74 78
      * Instantiates a new update config panel.
79
+     *
80
+     * @param controller Swing controller
75 81
      */
76
-    public UpdateConfigPanel() {
82
+    public UpdateConfigPanel(final SwingController controller) {
83
+        this.controller = controller;
84
+        
77 85
         initComponents();
78 86
         addListeners();
79 87
         layoutComponents();
@@ -139,13 +147,13 @@ public class UpdateConfigPanel extends JPanel implements ActionListener,
139 147
      * Lays out the components.
140 148
      */
141 149
     private void layoutComponents() {
142
-        setLayout(new MigLayout("fillx, ins 0, hmax " +
143
-                SwingPreferencesDialog.CLIENT_HEIGHT));
150
+        setLayout(new MigLayout("fill, ins 0, hmax " + controller.
151
+                getPrefsDialog().getPanelHeight()));
144 152
 
145 153
         add(new JLabel("Update checking:"), "split");
146 154
         add(enable, "growx");
147 155
         add(updateChannel, "growx, pushx, wrap");
148
-        add(scrollPane, "wrap");
156
+        add(scrollPane, "wrap, grow, push");
149 157
         add(checkNow, "right");
150 158
     }
151 159
 

+ 0
- 1
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuFrameManager.java Bestand weergeven

@@ -192,7 +192,6 @@ public final class WindowMenuFrameManager extends JMenu implements
192 192
             menu.remove(items.get(window));
193 193
             items.remove(window);
194 194
             if (menu.getMenuComponentCount() == 1) {
195
-                System.out.println(getParentMenu(parent));
196 195
                 replaceMenuWithItem(getParentMenu(parent), menus.get(parent),
197 196
                         new FrameContainerMenuItem(parent, this));
198 197
             }

Laden…
Annuleren
Opslaan