|
@@ -43,8 +43,8 @@ import com.dmdirc.events.NotificationSetEvent;
|
43
|
43
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
44
|
44
|
import com.dmdirc.interfaces.config.ConfigChangeListener;
|
45
|
45
|
import com.dmdirc.interfaces.ui.Window;
|
46
|
|
-import com.dmdirc.util.colours.Colour;
|
47
|
46
|
import com.dmdirc.ui.WindowManager;
|
|
47
|
+import com.dmdirc.util.colours.Colour;
|
48
|
48
|
|
49
|
49
|
import com.google.common.base.Optional;
|
50
|
50
|
|
|
@@ -58,9 +58,9 @@ import java.awt.event.MouseEvent;
|
58
|
58
|
import java.awt.event.MouseListener;
|
59
|
59
|
import java.io.Serializable;
|
60
|
60
|
import java.util.ArrayList;
|
61
|
|
-import java.util.Collection;
|
62
|
61
|
import java.util.Collections;
|
63
|
62
|
import java.util.HashMap;
|
|
63
|
+import java.util.List;
|
64
|
64
|
import java.util.Map;
|
65
|
65
|
|
66
|
66
|
import javax.inject.Inject;
|
|
@@ -147,8 +147,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
|
147
|
147
|
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
148
|
148
|
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
149
|
149
|
scrollPane.setMinimumSize(new Dimension(0, BUTTON_HEIGHT
|
150
|
|
- + ((int) PlatformDefaults.getUnitValueX("related")
|
151
|
|
- .getValue()) * 2));
|
|
150
|
+ + (int) PlatformDefaults.getUnitValueX("related").getValue() * 2));
|
152
|
151
|
|
153
|
152
|
position = FramemanagerPosition.getPosition(
|
154
|
153
|
globalConfig.getOption("ui", "framemanagerPosition"));
|
|
@@ -205,7 +204,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
|
205
|
204
|
parent.add(scrollPane);
|
206
|
205
|
parent.addComponentListener(ButtonBar.this);
|
207
|
206
|
ButtonBar.this.buttonWidth = position.isHorizontal()
|
208
|
|
- ? 150 : (parent.getWidth() / NUM_CELLS);
|
|
207
|
+ ? 150 : parent.getWidth() / NUM_CELLS;
|
209
|
208
|
initButtons(windowManager.getRootWindows());
|
210
|
209
|
|
211
|
210
|
final TextFrame activeFrame = activeFrameManager.getActiveFrame();
|
|
@@ -226,20 +225,16 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
|
226
|
225
|
*
|
227
|
226
|
* @since 0.6.4
|
228
|
227
|
*/
|
229
|
|
- private void initButtons(
|
230
|
|
- final Collection<FrameContainer> windowCollection) {
|
231
|
|
- TextFrame window;
|
232
|
|
- TextFrame parentWindow;
|
|
228
|
+ private void initButtons(final Iterable<FrameContainer> windowCollection) {
|
233
|
229
|
for (FrameContainer frame : windowCollection) {
|
234
|
|
- window = windowFactory.getSwingWindow(frame);
|
235
|
|
- parentWindow = windowFactory.getSwingWindow(frame.getParent().orNull());
|
|
230
|
+ final TextFrame window = windowFactory.getSwingWindow(frame);
|
|
231
|
+ final TextFrame parentWindow = windowFactory.getSwingWindow(frame.getParent().orNull());
|
236
|
232
|
if (window != null) {
|
237
|
233
|
windowAdded(new SwingWindowAddedEvent(Optional.fromNullable(parentWindow), window));
|
238
|
234
|
}
|
239
|
235
|
|
240
|
236
|
if (!frame.getChildren().isEmpty()) {
|
241
|
|
- final ArrayList<FrameContainer> childList = new ArrayList<>(frame.getChildren());
|
242
|
|
- initButtons(childList);
|
|
237
|
+ initButtons(new ArrayList<>(frame.getChildren()));
|
243
|
238
|
}
|
244
|
239
|
}
|
245
|
240
|
}
|
|
@@ -270,21 +265,16 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
|
270
|
265
|
*
|
271
|
266
|
* @since 0.6.4
|
272
|
267
|
*/
|
273
|
|
- private void displayButtons(
|
274
|
|
- final Collection<FrameContainer> windowCollection) {
|
275
|
|
- FrameToggleButton button;
|
|
268
|
+ private void displayButtons(final Iterable<FrameContainer> windowCollection) {
|
276
|
269
|
for (FrameContainer window : windowCollection) {
|
277
|
|
- button = getButton(window);
|
|
270
|
+ final FrameToggleButton button = getButton(window);
|
278
|
271
|
if (button != null) {
|
279
|
|
- button.setPreferredSize(
|
280
|
|
- new Dimension(buttonWidth, BUTTON_HEIGHT));
|
|
272
|
+ button.setPreferredSize(new Dimension(buttonWidth, BUTTON_HEIGHT));
|
281
|
273
|
buttonPanel.add(button);
|
282
|
274
|
if (!window.getChildren().isEmpty()) {
|
283
|
|
- final ArrayList<FrameContainer> childList
|
284
|
|
- = new ArrayList<>(window.getChildren());
|
|
275
|
+ final List<FrameContainer> childList = new ArrayList<>(window.getChildren());
|
285
|
276
|
if (sortChildWindows) {
|
286
|
|
- Collections.sort(childList,
|
287
|
|
- new FrameContainerComparator());
|
|
277
|
+ Collections.sort(childList, new FrameContainerComparator());
|
288
|
278
|
}
|
289
|
279
|
displayButtons(childList);
|
290
|
280
|
}
|
|
@@ -299,7 +289,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
|
299
|
289
|
buttonPanel.setVisible(false);
|
300
|
290
|
buttonPanel.removeAll();
|
301
|
291
|
|
302
|
|
- final ArrayList<FrameContainer> windowList = new ArrayList<>(windowManager.getRootWindows());
|
|
292
|
+ final List<FrameContainer> windowList = new ArrayList<>(windowManager.getRootWindows());
|
303
|
293
|
if (sortRootWindows) {
|
304
|
294
|
Collections.sort(windowList, new FrameContainerComparator());
|
305
|
295
|
}
|
|
@@ -367,7 +357,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
|
367
|
357
|
|
368
|
358
|
@Override
|
369
|
359
|
public void componentResized(final ComponentEvent e) {
|
370
|
|
- buttonWidth = position.isHorizontal() ? 150 : (parent.getWidth() / NUM_CELLS);
|
|
360
|
+ buttonWidth = position.isHorizontal() ? 150 : parent.getWidth() / NUM_CELLS;
|
371
|
361
|
relayout();
|
372
|
362
|
}
|
373
|
363
|
|
|
@@ -408,8 +398,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
|
408
|
398
|
@Override
|
409
|
399
|
public void run() {
|
410
|
400
|
activeWindow = window;
|
411
|
|
- FrameToggleButton button;
|
412
|
|
- button = getButton(selected);
|
|
401
|
+ FrameToggleButton button = getButton(selected);
|
413
|
402
|
if (selected != null && button != null) {
|
414
|
403
|
button.setSelected(false);
|
415
|
404
|
}
|