瀏覽代碼

Adds some owner related methods to standard dialog

Fixes issue 2670: AED is all broken on OS X

Change-Id: I54a7e22aa1497b3ec69d3e48b6f39b0bd5098bf3
Reviewed-on: http://gerrit.dmdirc.com/524
Automatic-Compile: Chris Smith <chris@dmdirc.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.3
Gregory Holmes 14 年之前
父節點
當前提交
1060746e73

+ 19
- 2
src/com/dmdirc/addons/ui_swing/dialogs/StandardDialog.java 查看文件

@@ -117,13 +117,30 @@ public class StandardDialog extends JDialog {
117 117
             }
118 118
         });
119 119
         pack();
120
+        centreOnOwner();
121
+        setVisible(false);
122
+        setVisible(true);
123
+    }
124
+
125
+
126
+    /**
127
+     * Centres this dialog on its owner, or the screen if no owner is present.
128
+     */
129
+    public void centreOnOwner() {
120 130
         if (owner == null) {
121 131
             CoreUIUtils.centreWindow(this);
122 132
         } else {
123 133
             setLocationRelativeTo(owner);
124 134
         }
125
-        setVisible(false);
126
-        setVisible(true);
135
+    }
136
+
137
+    /**
138
+     * Returns the window owner for this dialog.
139
+     *
140
+     * @return Parent window or null
141
+     */
142
+    public Window getOwner() {
143
+        return owner;
127 144
     }
128 145
 
129 146
     /**

+ 9
- 0
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionEditorDialog.java 查看文件

@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_swing.dialogs.actioneditor;
24 24
 
25 25
 import com.dmdirc.actions.Action;
26 26
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
27
+import com.dmdirc.ui.CoreUIUtils;
27 28
 
28 29
 import java.awt.Dimension;
29 30
 import java.awt.Window;
@@ -256,6 +257,14 @@ public class ActionEditorDialog extends StandardDialog implements ActionListener
256 257
         }
257 258
     }
258 259
 
260
+    /** {@inheritDoc} */
261
+    @Override
262
+    public void validate() {
263
+        super.validate();
264
+        
265
+        centreOnOwner();
266
+    }
267
+
259 268
     /** Saves the action being edited. */
260 269
     private void save() {
261 270
         name.getActionName();

Loading…
取消
儲存