Parcourir la source

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 il y a 14 ans
Parent
révision
b44fd4dab5

+ 5
- 4
src/com/dmdirc/addons/nickcolours/NickColourPanel.java Voir le fichier

22
 
22
 
23
 package com.dmdirc.addons.nickcolours;
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
 import com.dmdirc.config.IdentityManager;
27
 import com.dmdirc.config.IdentityManager;
27
 import com.dmdirc.config.prefs.PreferencesInterface;
28
 import com.dmdirc.config.prefs.PreferencesInterface;
28
 
29
 
117
         table.setFillsViewportHeight(true);
118
         table.setFillsViewportHeight(true);
118
         table.setDefaultRenderer(Color.class, new ColourRenderer());
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
         final JButton addButton = new JButton("Add");
125
         final JButton addButton = new JButton("Add");
125
         addButton.addActionListener(this);
126
         addButton.addActionListener(this);

+ 12
- 2
src/com/dmdirc/addons/ui_swing/SwingController.java Voir le fichier

57
 import com.dmdirc.addons.ui_swing.dialogs.url.URLDialog;
57
 import com.dmdirc.addons.ui_swing.dialogs.url.URLDialog;
58
 import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
58
 import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
59
 import com.dmdirc.addons.ui_swing.dialogs.error.ErrorListDialog;
59
 import com.dmdirc.addons.ui_swing.dialogs.error.ErrorListDialog;
60
+import com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog;
60
 import com.dmdirc.addons.ui_swing.dialogs.prefs.URLConfigPanel;
61
 import com.dmdirc.addons.ui_swing.dialogs.prefs.URLConfigPanel;
61
 import com.dmdirc.addons.ui_swing.dialogs.prefs.UpdateConfigPanel;
62
 import com.dmdirc.addons.ui_swing.dialogs.prefs.UpdateConfigPanel;
62
 import com.dmdirc.addons.ui_swing.wizard.firstrun.SwingFirstRunWizard;
63
 import com.dmdirc.addons.ui_swing.wizard.firstrun.SwingFirstRunWizard;
531
             /** {@inheritDoc} */
532
             /** {@inheritDoc} */
532
             @Override
533
             @Override
533
             public void run() {
534
             public void run() {
534
-                setObject(new PluginPanel(me));
535
+                setObject(new PluginPanel(me, SwingController.this));
535
             }
536
             }
536
         });
537
         });
537
     }
538
     }
544
             /** {@inheritDoc} */
545
             /** {@inheritDoc} */
545
             @Override
546
             @Override
546
             public void run() {
547
             public void run() {
547
-                setObject(new UpdateConfigPanel());
548
+                setObject(new UpdateConfigPanel(SwingController.this));
548
             }
549
             }
549
         });
550
         });
550
     }
551
     }
643
                 UIManager.getFont("TextPane.font").getSize());
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
     /** {@inheritDoc} */
656
     /** {@inheritDoc} */
647
     @Override
657
     @Override
648
     public void showConfig(final PreferencesManager manager) {
658
     public void showConfig(final PreferencesManager manager) {

+ 2
- 3
src/com/dmdirc/addons/ui_swing/components/TopicBar.java Voir le fichier

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

+ 17
- 5
src/com/dmdirc/addons/ui_swing/components/pluginpanel/PluginPanel.java Voir le fichier

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.components.pluginpanel;
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
 import com.dmdirc.config.prefs.PreferencesInterface;
27
 import com.dmdirc.config.prefs.PreferencesInterface;
26
 import com.dmdirc.plugins.PluginInfo;
28
 import com.dmdirc.plugins.PluginInfo;
27
 import com.dmdirc.plugins.PluginManager;
29
 import com.dmdirc.plugins.PluginManager;
29
 import com.dmdirc.addons.ui_swing.components.addonbrowser.DownloaderWindow;
31
 import com.dmdirc.addons.ui_swing.components.addonbrowser.DownloaderWindow;
30
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
32
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
31
 import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
33
 import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
32
-import com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog;
33
 
34
 
34
 import java.awt.Window;
35
 import java.awt.Window;
35
 import java.awt.event.ActionEvent;
36
 import java.awt.event.ActionEvent;
72
     private TextLabel blurbLabel;
73
     private TextLabel blurbLabel;
73
     /** Parent Window. */
74
     /** Parent Window. */
74
     private Window parentWindow;
75
     private Window parentWindow;
76
+    /** Swing Controller. */
77
+    private SwingController controller;
75
 
78
 
76
     /**
79
     /**
77
      * Creates a new instance of PluginDialog.
80
      * Creates a new instance of PluginDialog.
78
      *
81
      *
79
      * @param parentWindow Parent window
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
         super();
87
         super();
83
 
88
 
84
         this.parentWindow = parentWindow;
89
         this.parentWindow = parentWindow;
128
 
133
 
129
     /** Lays out the dialog. */
134
     /** Lays out the dialog. */
130
     private void layoutComponents() {
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
         add(blurbLabel, "wrap 10, growx, pushx");
145
         add(blurbLabel, "wrap 10, growx, pushx");
135
 
146
 
204
                 toggleButton.setEnabled(true);
215
                 toggleButton.setEnabled(true);
205
 
216
 
206
                 if (pluginInfo.getState()) {
217
                 if (pluginInfo.getState()) {
207
-                    toggleButton.setEnabled(pluginInfo.getPluginInfo().isUnloadable());
218
+                    toggleButton.setEnabled(pluginInfo.getPluginInfo().
219
+                            isUnloadable());
208
                     toggleButton.setText("Disable");
220
                     toggleButton.setText("Disable");
209
                 } else {
221
                 } else {
210
                     toggleButton.setText("Enable");
222
                     toggleButton.setText("Enable");

+ 18
- 4
src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java Voir le fichier

33
 import java.util.Collections;
33
 import java.util.Collections;
34
 import java.util.HashMap;
34
 import java.util.HashMap;
35
 import java.util.Map;
35
 import java.util.Map;
36
+import java.util.concurrent.atomic.AtomicBoolean;
36
 
37
 
37
 import javax.swing.BorderFactory;
38
 import javax.swing.BorderFactory;
38
 import javax.swing.JPanel;
39
 import javax.swing.JPanel;
39
 import javax.swing.JScrollPane;
40
 import javax.swing.JScrollPane;
40
 import javax.swing.ScrollPaneConstants;
41
 import javax.swing.ScrollPaneConstants;
41
 import javax.swing.SwingWorker;
42
 import javax.swing.SwingWorker;
43
+import net.miginfocom.layout.ComponentWrapper;
44
+import net.miginfocom.layout.LayoutCallback;
42
 
45
 
43
 import net.miginfocom.layout.PlatformDefaults;
46
 import net.miginfocom.layout.PlatformDefaults;
44
 import net.miginfocom.swing.MigLayout;
47
 import net.miginfocom.swing.MigLayout;
66
     /** Active preferences category. */
69
     /** Active preferences category. */
67
     private PreferencesCategory category;
70
     private PreferencesCategory category;
68
     /** Parent window. */
71
     /** Parent window. */
69
-    private Window parent;
72
+    private SwingPreferencesDialog parent;
70
     /** Title label. */
73
     /** Title label. */
71
     private TitlePanel title;
74
     private TitlePanel title;
72
     /** Tooltip display area. */
75
     /** Tooltip display area. */
91
      *
94
      *
92
      * @param parent Parent window
95
      * @param parent Parent window
93
      */
96
      */
94
-    public CategoryPanel(final Window parent) {
97
+    public CategoryPanel(final SwingPreferencesDialog parent) {
95
         this(parent, null);
98
         this(parent, null);
96
     }
99
     }
97
 
100
 
101
      * @param parent Parent window
104
      * @param parent Parent window
102
      * @param category Initial category
105
      * @param category Initial category
103
      */
106
      */
104
-    public CategoryPanel(final Window parent,
107
+    public CategoryPanel(final SwingPreferencesDialog parent,
105
             final PreferencesCategory category) {
108
             final PreferencesCategory category) {
106
         super(new MigLayout("fillx, wrap, ins 0"));
109
         super(new MigLayout("fillx, wrap, ins 0"));
107
         this.parent = parent;
110
         this.parent = parent;
129
                 "description, if available.");
132
                 "description, if available.");
130
 
133
 
131
         add(title, "pushx, growx, h 45!");
134
         add(title, "pushx, growx, h 45!");
132
-        add(scrollPane, "grow, push, h 425!");
135
+        add(scrollPane, "grow, push");
133
         add(tooltip, "pushx, growx, h 65!");
136
         add(tooltip, "pushx, growx, h 65!");
134
 
137
 
135
         panels.put(null, loading);
138
         panels.put(null, loading);
136
         setCategory(category);
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 Voir le fichier

64
      * serialized objects being unserialized with the new class).
64
      * serialized objects being unserialized with the new class).
65
      */
65
      */
66
     private static final long serialVersionUID = 9;
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
     /** Previously instantiated instance of SwingPreferencesDialog. */
67
     /** Previously instantiated instance of SwingPreferencesDialog. */
74
     private static volatile SwingPreferencesDialog me;
68
     private static volatile SwingPreferencesDialog me;
75
     /** Preferences tab list, used to switch option types. */
69
     /** Preferences tab list, used to switch option types. */
84
     private LoggingSwingWorker worker;
78
     private LoggingSwingWorker worker;
85
     /** Parent window. */
79
     /** Parent window. */
86
     private MainFrame parentWindow;
80
     private MainFrame parentWindow;
81
+    /** Panel size. */
82
+    protected int panelSize = 0;
87
 
83
 
88
     /**
84
     /**
89
      * Creates a new instance of SwingPreferencesDialog.
85
      * Creates a new instance of SwingPreferencesDialog.
189
         getOkButton().addActionListener(this);
185
         getOkButton().addActionListener(this);
190
         getCancelButton().addActionListener(this);
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
         add(mainPanel, "wrap, w 480!, pushy, growy, pushy");
192
         add(mainPanel, "wrap, w 480!, pushy, growy, pushy");
195
         add(getLeftButton(), "span, split, right");
193
         add(getLeftButton(), "span, split, right");
196
         add(getRightButton(), "right");
194
         add(getRightButton(), "right");
349
         tabList.setSelectedIndex(indexToSelect);
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
     /** {@inheritDoc} */
368
     /** {@inheritDoc} */
353
     @Override
369
     @Override
354
     public void dispose() {
370
     public void dispose() {

+ 12
- 4
src/com/dmdirc/addons/ui_swing/dialogs/prefs/UpdateConfigPanel.java Voir le fichier

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs.prefs;
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
 import com.dmdirc.config.ConfigManager;
27
 import com.dmdirc.config.ConfigManager;
26
 import com.dmdirc.config.Identity;
28
 import com.dmdirc.config.Identity;
27
 import com.dmdirc.config.IdentityManager;
29
 import com.dmdirc.config.IdentityManager;
69
     private JButton checkNow;
71
     private JButton checkNow;
70
     /** Update channel. */
72
     /** Update channel. */
71
     private JComboBox updateChannel;
73
     private JComboBox updateChannel;
74
+    /** Swing controller. */
75
+    private SwingController controller;
72
 
76
 
73
     /**
77
     /**
74
      * Instantiates a new update config panel.
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
         initComponents();
85
         initComponents();
78
         addListeners();
86
         addListeners();
79
         layoutComponents();
87
         layoutComponents();
139
      * Lays out the components.
147
      * Lays out the components.
140
      */
148
      */
141
     private void layoutComponents() {
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
         add(new JLabel("Update checking:"), "split");
153
         add(new JLabel("Update checking:"), "split");
146
         add(enable, "growx");
154
         add(enable, "growx");
147
         add(updateChannel, "growx, pushx, wrap");
155
         add(updateChannel, "growx, pushx, wrap");
148
-        add(scrollPane, "wrap");
156
+        add(scrollPane, "wrap, grow, push");
149
         add(checkNow, "right");
157
         add(checkNow, "right");
150
     }
158
     }
151
 
159
 

+ 0
- 1
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuFrameManager.java Voir le fichier

192
             menu.remove(items.get(window));
192
             menu.remove(items.get(window));
193
             items.remove(window);
193
             items.remove(window);
194
             if (menu.getMenuComponentCount() == 1) {
194
             if (menu.getMenuComponentCount() == 1) {
195
-                System.out.println(getParentMenu(parent));
196
                 replaceMenuWithItem(getParentMenu(parent), menus.get(parent),
195
                 replaceMenuWithItem(getParentMenu(parent), menus.get(parent),
197
                         new FrameContainerMenuItem(parent, this));
196
                         new FrameContainerMenuItem(parent, this));
198
             }
197
             }

Chargement…
Annuler
Enregistrer