|
@@ -22,6 +22,7 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
|
24
|
24
|
|
|
25
|
+import com.dmdirc.ClientModule.GlobalConfig;
|
25
|
26
|
import com.dmdirc.FrameContainer;
|
26
|
27
|
import com.dmdirc.FrameContainerComparator;
|
27
|
28
|
import com.dmdirc.addons.ui_swing.MainFrame;
|
|
@@ -31,6 +32,9 @@ import com.dmdirc.addons.ui_swing.SwingWindowFactory;
|
31
|
32
|
import com.dmdirc.addons.ui_swing.SwingWindowListener;
|
32
|
33
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
33
|
34
|
import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
|
|
35
|
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
|
36
|
+import com.dmdirc.plugins.PluginDomain;
|
|
37
|
+import com.dmdirc.ui.IconManager;
|
34
|
38
|
|
35
|
39
|
import java.awt.Component;
|
36
|
40
|
import java.awt.event.ActionEvent;
|
|
@@ -81,20 +85,32 @@ public class WindowMenuFrameManager extends JMenu implements
|
81
|
85
|
private final Map<FrameContainer, FrameContainerMenuItem> items;
|
82
|
86
|
private final Map<FrameContainer, FrameContainerMenuItem> menuItems;
|
83
|
87
|
|
|
88
|
+ private final MainFrame mainFrame;
|
|
89
|
+ private final AggregateConfigProvider globalConfig;
|
|
90
|
+ private final String domain;
|
|
91
|
+
|
84
|
92
|
/**
|
85
|
93
|
* Creates a new instance of WindowMenuFrameManager.
|
86
|
94
|
*
|
87
|
95
|
* @param controller Swing controller
|
|
96
|
+ * @param iconManager Icon manager to use for window icons.
|
|
97
|
+ * @param globalConfig Config to read settings from.
|
|
98
|
+ * @param domain Domain to read settings from.
|
88
|
99
|
* @param windowFactory The window factory to use to create and listen for windows.
|
89
|
100
|
* @param mainFrame The frame that owns this manager
|
90
|
101
|
*/
|
91
|
102
|
@Inject
|
92
|
103
|
public WindowMenuFrameManager(
|
93
|
104
|
final SwingController controller,
|
|
105
|
+ @GlobalConfig final IconManager iconManager,
|
|
106
|
+ @GlobalConfig final AggregateConfigProvider globalConfig,
|
|
107
|
+ @PluginDomain(SwingController.class) final String domain,
|
94
|
108
|
final SwingWindowFactory windowFactory,
|
95
|
109
|
final MainFrame mainFrame) {
|
96
|
|
- super();
|
97
|
110
|
this.controller = controller;
|
|
111
|
+ this.globalConfig = globalConfig;
|
|
112
|
+ this.domain = domain;
|
|
113
|
+ this.mainFrame = mainFrame;
|
98
|
114
|
|
99
|
115
|
menus = Collections.synchronizedMap(
|
100
|
116
|
new HashMap<FrameContainer, FrameContainerMenu>());
|
|
@@ -107,8 +123,7 @@ public class WindowMenuFrameManager extends JMenu implements
|
107
|
123
|
setMnemonic('w');
|
108
|
124
|
windowFactory.addWindowListener(this);
|
109
|
125
|
|
110
|
|
- closeMenuItem = new JMenuItem(controller
|
111
|
|
- .getIconManager().getIcon("close"));
|
|
126
|
+ closeMenuItem = new JMenuItem(iconManager.getIcon("close"));
|
112
|
127
|
closeMenuItem.setMnemonic('c');
|
113
|
128
|
closeMenuItem.setText("Close");
|
114
|
129
|
closeMenuItem.setActionCommand("Close");
|
|
@@ -122,8 +137,7 @@ public class WindowMenuFrameManager extends JMenu implements
|
122
|
137
|
|
123
|
138
|
mainFrame.addSelectionListener(this);
|
124
|
139
|
|
125
|
|
- new WindowMenuScroller(this, controller.getGlobalConfig(),
|
126
|
|
- controller.getDomain(), itemCount);
|
|
140
|
+ new WindowMenuScroller(this, globalConfig, domain, itemCount);
|
127
|
141
|
checkMenuItems();
|
128
|
142
|
}
|
129
|
143
|
|
|
@@ -144,8 +158,10 @@ public class WindowMenuFrameManager extends JMenu implements
|
144
|
158
|
|
145
|
159
|
@Override
|
146
|
160
|
public FrameContainerMenuItem call() {
|
147
|
|
- return new FrameContainerMenuItem(controller,
|
|
161
|
+ return new FrameContainerMenuItem(
|
|
162
|
+ controller,
|
148
|
163
|
window.getContainer(),
|
|
164
|
+ window,
|
149
|
165
|
WindowMenuFrameManager.this);
|
150
|
166
|
}
|
151
|
167
|
});
|
|
@@ -164,8 +180,10 @@ public class WindowMenuFrameManager extends JMenu implements
|
164
|
180
|
|
165
|
181
|
@Override
|
166
|
182
|
public FrameContainerMenuItem call() {
|
167
|
|
- return new FrameContainerMenuItem(controller,
|
|
183
|
+ return new FrameContainerMenuItem(
|
|
184
|
+ controller,
|
168
|
185
|
window.getContainer(),
|
|
186
|
+ window,
|
169
|
187
|
WindowMenuFrameManager.this);
|
170
|
188
|
}
|
171
|
189
|
});
|
|
@@ -176,8 +194,12 @@ public class WindowMenuFrameManager extends JMenu implements
|
176
|
194
|
|
177
|
195
|
@Override
|
178
|
196
|
public FrameContainerMenu call() {
|
179
|
|
- return new FrameContainerMenu(parent.
|
180
|
|
- getContainer(), controller);
|
|
197
|
+ return new FrameContainerMenu(
|
|
198
|
+ controller,
|
|
199
|
+ globalConfig,
|
|
200
|
+ domain,
|
|
201
|
+ parent,
|
|
202
|
+ parent.getContainer());
|
181
|
203
|
}
|
182
|
204
|
});
|
183
|
205
|
replaceItemWithMenu(getParentMenu(parent.getContainer()),
|
|
@@ -234,8 +256,10 @@ public class WindowMenuFrameManager extends JMenu implements
|
234
|
256
|
replaceMenuWithItem(getParentMenu(parent.
|
235
|
257
|
getContainer()),
|
236
|
258
|
menus.get(parent.getContainer()),
|
237
|
|
- new FrameContainerMenuItem(controller,
|
|
259
|
+ new FrameContainerMenuItem(
|
|
260
|
+ controller,
|
238
|
261
|
parent.getContainer(),
|
|
262
|
+ parent,
|
239
|
263
|
WindowMenuFrameManager.this));
|
240
|
264
|
}
|
241
|
265
|
}
|
|
@@ -290,7 +314,7 @@ public class WindowMenuFrameManager extends JMenu implements
|
290
|
314
|
@Override
|
291
|
315
|
public void actionPerformed(final ActionEvent e) {
|
292
|
316
|
if (enabledMenuItems.get() && e.getActionCommand().equals("Close")) {
|
293
|
|
- controller.getMainFrame().getActiveFrame().getContainer().close();
|
|
317
|
+ mainFrame.getActiveFrame().getContainer().close();
|
294
|
318
|
}
|
295
|
319
|
}
|
296
|
320
|
|
|
@@ -362,10 +386,9 @@ public class WindowMenuFrameManager extends JMenu implements
|
362
|
386
|
final FrameContainer child = ((FrameContainerMenuInterface) component).getFrame();
|
363
|
387
|
if (sortBefore(newChild, child)) {
|
364
|
388
|
return i;
|
365
|
|
- } else if (!sortAfter(newChild, child) && controller
|
366
|
|
- .getGlobalConfig().getOptionBool("treeview",
|
367
|
|
- "sortwindows") && newChild.getName().compareToIgnoreCase(
|
368
|
|
- child.getName()) < 0) {
|
|
389
|
+ } else if (!sortAfter(newChild, child)
|
|
390
|
+ && globalConfig.getOptionBool("treeview", "sortwindows")
|
|
391
|
+ && newChild.getName().compareToIgnoreCase(child.getName()) < 0) {
|
369
|
392
|
return i;
|
370
|
393
|
}
|
371
|
394
|
}
|