Browse Source

fixes issue 2906

tags/0.6.3m2a1
Gregory Holmes 15 years ago
parent
commit
8edefc4137

+ 1
- 1
src/com/dmdirc/addons/ui_swing/SwingController.java View File

@@ -509,7 +509,7 @@ public final class SwingController extends Plugin implements UIController {
509 509
     /** {@inheritDoc} */
510 510
     @Override
511 511
     public PreferencesInterface getPluginPrefsPanel() {
512
-        return new PluginPanel();
512
+        return new PluginPanel(me);
513 513
     }
514 514
 
515 515
     /** {@inheritDoc} */

+ 9
- 2
src/com/dmdirc/addons/ui_swing/components/SwingInputField.java View File

@@ -31,6 +31,7 @@ import com.dmdirc.util.ListenerList;
31 31
 
32 32
 import com.dmdirc.util.ReturnableThread;
33 33
 import java.awt.Color;
34
+import java.awt.Window;
34 35
 import java.awt.event.ActionEvent;
35 36
 import java.awt.event.ActionListener;
36 37
 import java.awt.event.KeyEvent;
@@ -63,13 +64,19 @@ public class SwingInputField extends JComponent implements InputField,
63 64
     private final JLabel errorIndicator;
64 65
     /** Listener list. */
65 66
     private final ListenerList listeners;
67
+    /** Parent Window. */
68
+    private final Window parentWindow;
66 69
 
67 70
     /**
68 71
      * Instantiates a new swing input field.
72
+     *
73
+     * @param parentWindow Parent window
69 74
      */
70
-    public SwingInputField() {
75
+    public SwingInputField(final Window parentWindow) {
71 76
         super();
72 77
 
78
+        this.parentWindow = parentWindow;
79
+
73 80
         listeners = new ListenerList();
74 81
 
75 82
         textField = new JTextField();
@@ -133,7 +140,7 @@ public class SwingInputField extends JComponent implements InputField,
133 140
             public void run() {
134 141
                 if (IdentityManager.getGlobalConfig().getOptionBool("general",
135 142
                         "showcolourdialog")) {
136
-                    colourPicker = new ColourPickerDialog(irc, hex);
143
+                    colourPicker = new ColourPickerDialog(irc, hex, parentWindow);
137 144
                     colourPicker.addActionListener(new ActionListener() {
138 145
 
139 146
                         @Override

+ 9
- 8
src/com/dmdirc/addons/ui_swing/components/addonbrowser/BrowserWindow.java View File

@@ -23,10 +23,11 @@
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25 25
 import com.dmdirc.Main;
26
-import com.dmdirc.addons.ui_swing.MainFrame;
26
+import com.dmdirc.ui.CoreUIUtils;
27 27
 import com.dmdirc.util.ConfigFile;
28 28
 import com.dmdirc.util.InvalidConfigFileException;
29 29
 
30
+import java.awt.Window;
30 31
 import java.awt.event.ActionEvent;
31 32
 import java.awt.event.ActionListener;
32 33
 import java.io.File;
@@ -96,12 +97,12 @@ public class BrowserWindow extends JDialog implements ActionListener {
96 97
 
97 98
     /**
98 99
      * Creates and displays a new browser window.
100
+     *
101
+     * @param parentWindow Parent window
99 102
      */
100
-    public BrowserWindow() {
101
-        super((MainFrame) Main.getUI().getMainWindow(), "DMDirc Addon Browser",
102
-                false);
103
-        setIconImage(((MainFrame) Main.getUI().getMainWindow()).getIcon().
104
-                getImage());
103
+    public BrowserWindow(final Window parentWindow) {
104
+        super(parentWindow, "DMDirc Addon Browser", ModalityType.MODELESS);
105
+        setIconImages(parentWindow.getIconImages());
105 106
         setResizable(false);
106 107
         setLayout(new MigLayout("fill, wmin 650, hmin 600"));
107 108
         scrollPane.getVerticalScrollBar().setUnitIncrement(15);
@@ -158,9 +159,9 @@ public class BrowserWindow extends JDialog implements ActionListener {
158 159
         }
159 160
 
160 161
         pack();
161
-        setLocationRelativeTo((MainFrame) Main.getUI().getMainWindow());
162
+        setLocationRelativeTo(parentWindow);
162 163
         setVisible(true);
163
-        setLocationRelativeTo((MainFrame) Main.getUI().getMainWindow());
164
+        setLocationRelativeTo(parentWindow);
164 165
     }
165 166
 
166 167
     /**

+ 12
- 6
src/com/dmdirc/addons/ui_swing/components/addonbrowser/DownloaderWindow.java View File

@@ -6,11 +6,11 @@
6 6
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
7 7
 
8 8
 import com.dmdirc.Main;
9
-import com.dmdirc.addons.ui_swing.MainFrame;
10 9
 import com.dmdirc.ui.CoreUIUtils;
11 10
 import com.dmdirc.util.DownloadListener;
12 11
 import com.dmdirc.util.Downloader;
13 12
 
13
+import java.awt.Window;
14 14
 import java.io.File;
15 15
 import java.io.IOException;
16 16
 
@@ -33,11 +33,17 @@ public class DownloaderWindow extends JDialog implements Runnable, DownloadListe
33 33
     private static final long serialVersionUID = 1;
34 34
     /** Downloader progress bar. */
35 35
     private final JProgressBar jpb = new JProgressBar(0, 100);
36
+    /** Parent window. */
37
+    private Window parentWindow;
36 38
 
37
-    /** Instantiates a new downloader window. */
38
-    public DownloaderWindow() {
39
-        super((MainFrame) Main.getUI().getMainWindow(), "DMDirc Addon Browser",
40
-                false);
39
+    /**
40
+     * Instantiates a new downloader window.
41
+     *
42
+     * @param parentWindow Parent window
43
+     */
44
+    public DownloaderWindow(final Window parentWindow) {
45
+        super(parentWindow, "DMDirc Addon Browser", ModalityType.MODELESS);
46
+        this.parentWindow = parentWindow;
41 47
         setTitle("Downloading addon information...");
42 48
         setLayout(new MigLayout("fill"));
43 49
         add(jpb, "grow");
@@ -56,7 +62,7 @@ public class DownloaderWindow extends JDialog implements Runnable, DownloadListe
56 62
         try {
57 63
             Downloader.downloadPage("http://addons.dmdirc.com/feed", 
58 64
                     Main.getConfigDir() + File.separator + "addons.feed", this);
59
-            new BrowserWindow();
65
+            new BrowserWindow(parentWindow);
60 66
         } catch (IOException ex) {
61 67
             removeAll();
62 68
             add(new JLabel("Unable to download feed."));

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java View File

@@ -132,7 +132,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
132 132
      * Initialises the components for this frame.
133 133
      */
134 134
     private void initComponents() {
135
-        setInputField(new SwingInputField());
135
+        setInputField(new SwingInputField(getController().getMainFrame()));
136 136
 
137 137
         getInputField().addKeyListener(this);
138 138
         getInputField().addMouseListener(this);

+ 12
- 3
src/com/dmdirc/addons/ui_swing/components/pluginpanel/PluginPanel.java View File

@@ -31,6 +31,7 @@ import com.dmdirc.addons.ui_swing.components.text.TextLabel;
31 31
 import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
32 32
 import com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog;
33 33
 
34
+import java.awt.Window;
34 35
 import java.awt.event.ActionEvent;
35 36
 import java.awt.event.ActionListener;
36 37
 import java.util.Collections;
@@ -69,11 +70,19 @@ public final class PluginPanel extends JPanel implements
69 70
     private int selectedPlugin;
70 71
     /** Blurb label. */
71 72
     private TextLabel blurbLabel;
73
+    /** Parent Window. */
74
+    private Window parentWindow;
72 75
 
73
-    /** Creates a new instance of PluginDialog. */
74
-    public PluginPanel() {
76
+    /**
77
+     * Creates a new instance of PluginDialog.
78
+     *
79
+     * @param parentWindow Parent window
80
+     */
81
+    public PluginPanel(final Window parentWindow) {
75 82
         super();
76 83
 
84
+        this.parentWindow = parentWindow;
85
+
77 86
         initComponents();
78 87
         addListeners();
79 88
         layoutComponents();
@@ -179,7 +188,7 @@ public final class PluginPanel extends JPanel implements
179 188
 
180 189
             pluginList.repaint();
181 190
         } else if (e.getSource() != toggleButton) {
182
-            new DownloaderWindow();
191
+            new DownloaderWindow(parentWindow);
183 192
         }
184 193
     }
185 194
 

+ 4
- 0
src/com/dmdirc/ui/CoreUIUtils.java View File

@@ -32,6 +32,10 @@ import java.awt.Window;
32 32
  * Core UI Utilities.
33 33
  */
34 34
 public class CoreUIUtils {
35
+
36
+    /** Precent creation. */
37
+    private CoreUIUtils() {
38
+    }
35 39
     
36 40
     /**
37 41
      * Centre the specified window on the active monitor.

Loading…
Cancel
Save