Bladeren bron

Merge pull request #139 from greboid/windowmenusorting

Remove the window menu.
pull/141/head
Chris Smith 9 jaren geleden
bovenliggende
commit
28cb808cdd

+ 0
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/MenuBar.java Bestand weergeven

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing.components.menubar;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.components.MDIBar;
26
-import com.dmdirc.addons.ui_swing.framemanager.windowmenu.WindowMenuFrameManager;
27 26
 
28 27
 import java.awt.Component;
29 28
 import java.util.HashMap;
@@ -59,7 +58,6 @@ public class MenuBar extends JMenuBar {
59 58
      * @param serverMenu   The server menu to use.
60 59
      * @param channelMenu  The channel menu to use.
61 60
      * @param settingsMenu The settings menu to use.
62
-     * @param windowMenu   The window menu to use.
63 61
      * @param helpMenu     The help menu to use.
64 62
      * @param mdiBar       The MDI bar to use.
65 63
      */
@@ -68,7 +66,6 @@ public class MenuBar extends JMenuBar {
68 66
             final ServerMenu serverMenu,
69 67
             final ChannelMenu channelMenu,
70 68
             final SettingsMenu settingsMenu,
71
-            final WindowMenuFrameManager windowMenu,
72 69
             final HelpMenu helpMenu,
73 70
             final MDIBar mdiBar) {
74 71
         menuItems = new HashMap<>();
@@ -77,7 +74,6 @@ public class MenuBar extends JMenuBar {
77 74
         add(serverMenu);
78 75
         add(channelMenu);
79 76
         add(settingsMenu);
80
-        add(windowMenu);
81 77
         add(helpMenu);
82 78
         final int tempCount = getComponentCount();
83 79
         add(Box.createHorizontalGlue(), "growx, pushx");
@@ -85,7 +81,6 @@ public class MenuBar extends JMenuBar {
85 81
         add(Box.createHorizontalStrut(PlatformDefaults.getPanelInsets(1)
86 82
                 .getUnit()));
87 83
         menuItemCount = getComponentCount() - tempCount;
88
-        windowMenu.init();
89 84
 
90 85
         getActionMap().setParent(null);
91 86
         getActionMap().clear();

+ 0
- 84
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/CloseActiveWindowMenuItem.java Bestand weergeven

@@ -1,84 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.ClientModule;
26
-import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
27
-import com.dmdirc.addons.ui_swing.events.SwingEventBus;
28
-import com.dmdirc.addons.ui_swing.events.SwingWindowAddedEvent;
29
-import com.dmdirc.addons.ui_swing.events.SwingWindowDeletedEvent;
30
-import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
31
-import com.dmdirc.ui.IconManager;
32
-import com.dmdirc.ui.WindowManager;
33
-
34
-import java.awt.event.ActionEvent;
35
-import java.awt.event.ActionListener;
36
-
37
-import javax.inject.Inject;
38
-import javax.swing.JMenuItem;
39
-
40
-import net.engio.mbassy.listener.Handler;
41
-import net.engio.mbassy.listener.Invoke;
42
-
43
-/**
44
- * A Menu item that closes the active window when triggered.
45
- */
46
-public class CloseActiveWindowMenuItem extends JMenuItem {
47
-
48
-    private final ActiveFrameManager activeFrameManager;
49
-    private final SwingEventBus eventBus;
50
-    private final WindowManager windowManager;
51
-
52
-    @Inject
53
-    public CloseActiveWindowMenuItem(final ActiveFrameManager activeFrameManager,
54
-            @ClientModule.GlobalConfig final IconManager iconManager,
55
-            final SwingEventBus eventBus,
56
-            final WindowManager windowManager) {
57
-        super(iconManager.getIcon("close"));
58
-        this.activeFrameManager = activeFrameManager;
59
-        this.eventBus = eventBus;
60
-        this.windowManager = windowManager;
61
-        setMnemonic('c');
62
-        setText("Close");
63
-        setActionCommand("Close");
64
-    }
65
-
66
-    /**
67
-     * Initialises the menu item adding listeners as required.
68
-     */
69
-    public void init() {
70
-        addActionListener(l -> activeFrameManager.getActiveFrame()
71
-                .ifPresent(c -> c.getContainer().close()));
72
-        eventBus.subscribe(this);
73
-    }
74
-
75
-    @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
76
-    public void windowAdded(final SwingWindowAddedEvent event) {
77
-        setEnabled(true);
78
-    }
79
-
80
-    @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
81
-    public void windowDeleted(final SwingWindowDeletedEvent event) {
82
-        setEnabled(!windowManager.getRootWindows().isEmpty());
83
-    }
84
-}

+ 0
- 83
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowAction.java Bestand weergeven

@@ -1,83 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
27
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
28
-import com.dmdirc.addons.ui_swing.events.SwingActiveWindowChangeRequestEvent;
29
-import com.dmdirc.addons.ui_swing.events.SwingEventBus;
30
-import com.dmdirc.events.FrameIconChangedEvent;
31
-import com.dmdirc.events.FrameNameChangedEvent;
32
-import com.dmdirc.ui.IconManager;
33
-import com.dmdirc.ui.messages.Styliser;
34
-
35
-import java.awt.event.ActionEvent;
36
-import java.util.Optional;
37
-
38
-import javax.swing.AbstractAction;
39
-import javax.swing.Action;
40
-
41
-import net.engio.mbassy.listener.Handler;
42
-
43
-/**
44
- * An action representing a window.
45
- */
46
-public class WindowAction extends AbstractAction {
47
-
48
-    private final SwingEventBus eventBus;
49
-    private final IconManager iconManager;
50
-    private final TextFrame window;
51
-
52
-    public WindowAction(final SwingEventBus eventBus, final IconManager iconManager,
53
-            final TextFrame window) {
54
-        this.eventBus = eventBus;
55
-        this.iconManager = iconManager;
56
-        this.window = window;
57
-    }
58
-
59
-    public void init(final DMDircMBassador eventBus) {
60
-        eventBus.subscribe(this);
61
-        putValue(Action.SMALL_ICON, iconManager.getIcon(window.getContainer().getIcon()));
62
-        putValue(Action.NAME, Styliser.stipControlCodes(window.getContainer().getName()));
63
-    }
64
-
65
-    @Handler(invocation = EdtHandlerInvocation.class)
66
-    public void iconChanged(final FrameIconChangedEvent event) {
67
-        if (event.getContainer().equals(window.getContainer())) {
68
-            putValue(Action.SMALL_ICON, iconManager.getIcon(event.getIcon()));
69
-        }
70
-    }
71
-
72
-    @Handler(invocation = EdtHandlerInvocation.class)
73
-    public void nameChanged(final FrameNameChangedEvent event) {
74
-        if (event.getContainer().equals(window.getContainer())) {
75
-            putValue(Action.NAME, Styliser.stipControlCodes(event.getName()));
76
-        }
77
-    }
78
-
79
-    @Override
80
-    public void actionPerformed(final ActionEvent e) {
81
-        eventBus.publishAsync(new SwingActiveWindowChangeRequestEvent(Optional.ofNullable(window)));
82
-    }
83
-}

+ 0
- 56
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowActionFactory.java Bestand weergeven

@@ -1,56 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.DMDircMBassador;
27
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
28
-import com.dmdirc.addons.ui_swing.events.SwingEventBus;
29
-import com.dmdirc.ui.IconManager;
30
-
31
-import javax.inject.Inject;
32
-
33
-/**
34
- * Factory to create {@link WindowAction}s.
35
- */
36
-public class WindowActionFactory {
37
-
38
-    private final DMDircMBassador eventBus;
39
-    private final SwingEventBus swingEventBus;
40
-    private final IconManager iconManager;
41
-
42
-    @Inject
43
-    public WindowActionFactory(final DMDircMBassador eventBus,
44
-            final SwingEventBus swingEventBus,
45
-            @GlobalConfig final IconManager iconManager) {
46
-        this.eventBus = eventBus;
47
-        this.swingEventBus = swingEventBus;
48
-        this.iconManager = iconManager;
49
-    }
50
-
51
-    public WindowAction getWindowAction(final TextFrame window) {
52
-        final WindowAction windowAction = new WindowAction(swingEventBus, iconManager, window);
53
-        windowAction.init(eventBus);
54
-        return windowAction;
55
-    }
56
-}

+ 0
- 165
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuFrameManager.java Bestand weergeven

@@ -1,165 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
27
-import com.dmdirc.addons.ui_swing.SwingController;
28
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
29
-import com.dmdirc.addons.ui_swing.events.SwingEventBus;
30
-import com.dmdirc.addons.ui_swing.events.SwingWindowAddedEvent;
31
-import com.dmdirc.addons.ui_swing.events.SwingWindowDeletedEvent;
32
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
33
-import com.dmdirc.plugins.PluginDomain;
34
-
35
-import com.google.common.collect.Maps;
36
-
37
-import java.util.Map;
38
-
39
-import javax.inject.Inject;
40
-import javax.inject.Singleton;
41
-import javax.swing.AbstractButton;
42
-import javax.swing.Action;
43
-import javax.swing.JMenu;
44
-import javax.swing.JMenuItem;
45
-
46
-import net.engio.mbassy.listener.Handler;
47
-
48
-/**
49
- * Manages the window menu window list.
50
- */
51
-@Singleton
52
-public class WindowMenuFrameManager extends JMenu {
53
-
54
-    /** A version number for this class. */
55
-    private static final long serialVersionUID = 1;
56
-    /** Window action factory. */
57
-    private final WindowActionFactory windowActionFactory;
58
-    /** Window selection font changer. */
59
-    private final WindowSelectionFontChangerFactory windowSelectionFontChanger;
60
-    /** Window to item mapping. */
61
-    private final Map<TextFrame, AbstractButton> menuItems;
62
-    /** Swing event bus. */
63
-    private final SwingEventBus swingEventBus;
64
-    /** Close menu item. */
65
-    private final CloseActiveWindowMenuItem closeMenuItem;
66
-    /** Global config. */
67
-    private final AggregateConfigProvider globalConfig;
68
-    /** Plugin domain. */
69
-    private final String domain;
70
-    /** Menu separator. */
71
-    private final WindowMenuSeparator separator;
72
-
73
-    @Inject
74
-    public WindowMenuFrameManager(@GlobalConfig final AggregateConfigProvider globalConfig,
75
-            @PluginDomain(SwingController.class) final String domain,
76
-            final SwingEventBus swingEventBus,
77
-            final CloseActiveWindowMenuItem closeMenuItem,
78
-            final WindowActionFactory windowActionFactory,
79
-            final WindowSelectionFontChangerFactory windowSelectionFontChanger,
80
-            final WindowMenuSeparator separator) {
81
-        this.windowActionFactory = windowActionFactory;
82
-        this.windowSelectionFontChanger = windowSelectionFontChanger;
83
-        this.swingEventBus = swingEventBus;
84
-        this.closeMenuItem = closeMenuItem;
85
-        this.globalConfig = globalConfig;
86
-        this.separator = separator;
87
-        this.domain = domain;
88
-        menuItems = Maps.newHashMap();
89
-    }
90
-
91
-    /**
92
-     * Initialises the frame managers and adds appropriate listeners.
93
-     */
94
-    public void init() {
95
-        swingEventBus.subscribe(this);
96
-
97
-        setText("Window");
98
-        setMnemonic('w');
99
-
100
-        closeMenuItem.init();
101
-        add(closeMenuItem);
102
-        separator.init();
103
-        add(separator);
104
-
105
-        WindowMenuScroller.createScroller(this, globalConfig, domain, getMenuComponentCount());
106
-    }
107
-
108
-    @Handler(invocation = EdtHandlerInvocation.class)
109
-    public void windowAdded(final SwingWindowAddedEvent event) {
110
-        if (event.getParentWindow().isPresent()) {
111
-            addChildWindow(event.getParentWindow().get(), event.getChildWindow());
112
-        } else {
113
-            addTopLevelWindow(event.getChildWindow());
114
-        }
115
-    }
116
-
117
-    @Handler(invocation = EdtHandlerInvocation.class)
118
-    public void windowDeleted(final SwingWindowDeletedEvent event) {
119
-        if (event.getParentWindow().isPresent()) {
120
-            deleteChildWindow(event.getParentWindow().get(), event.getChildWindow());
121
-        } else {
122
-            deleteTopLevelWindow(event.getChildWindow());
123
-        }
124
-    }
125
-
126
-    private JMenu getMenu(final TextFrame window) {
127
-        final Action action = windowActionFactory.getWindowAction(window);
128
-        final JMenu menu = new JMenu(action);
129
-        windowSelectionFontChanger.getWindowSelectionFontChanger(menu, window);
130
-        return menu;
131
-    }
132
-
133
-    private JMenuItem getMenuItem(final TextFrame window) {
134
-        final Action action = windowActionFactory.getWindowAction(window);
135
-        final JMenuItem menu = new JMenuItem(action);
136
-        windowSelectionFontChanger.getWindowSelectionFontChanger(menu, window);
137
-        return menu;
138
-    }
139
-
140
-    private void addChildWindow(final TextFrame parent, final TextFrame child) {
141
-        if (!(menuItems.get(parent) instanceof JMenu)) {
142
-            remove(menuItems.get(parent));
143
-            final AbstractButton item = getMenu(parent);
144
-            menuItems.put(parent, item);
145
-            add(item);
146
-        }
147
-        final AbstractButton item = getMenuItem(child);
148
-        menuItems.put(child, item);
149
-        menuItems.get(parent).add(item);
150
-    }
151
-
152
-    private void addTopLevelWindow(final TextFrame window) {
153
-        final AbstractButton item = getMenuItem(window);
154
-        menuItems.put(window, item);
155
-        add(item);
156
-    }
157
-
158
-    private void deleteTopLevelWindow(final TextFrame window) {
159
-        remove(menuItems.get(window));
160
-    }
161
-
162
-    private void deleteChildWindow(final TextFrame parent, final TextFrame child) {
163
-        menuItems.get(parent).remove(menuItems.get(child));
164
-    }
165
-}

+ 0
- 95
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuScroller.java Bestand weergeven

@@ -1,95 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2012 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.addons.ui_swing.UIUtilities;
26
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
27
-import com.dmdirc.interfaces.config.ConfigChangeListener;
28
-
29
-import javax.swing.JMenu;
30
-
31
-import darrylbu.util.MenuScroller;
32
-
33
-/**
34
- * Window menu scroller.
35
- */
36
-public class WindowMenuScroller implements ConfigChangeListener {
37
-
38
-    /** Config manager. */
39
-    private final AggregateConfigProvider config;
40
-    /** Config domain. */
41
-    private final String configDomain;
42
-    /** Menu to scroll. */
43
-    private final JMenu menu;
44
-    /** Fixed menu item count. */
45
-    private final int fixedCount;
46
-    /** Menu scroller. */
47
-    private MenuScroller scroller;
48
-
49
-    /**
50
-     * Creates a new menu scroller for the window menu.
51
-     *
52
-     * @param menu         Menu to create scroller for
53
-     * @param config       Config manager
54
-     * @param configDomain Domain to check config settings in
55
-     * @param fixedCount   Number of fixed items in the menu
56
-     */
57
-    private WindowMenuScroller(final JMenu menu, final AggregateConfigProvider config,
58
-            final String configDomain, final int fixedCount) {
59
-        this.menu = menu;
60
-        this.config = config;
61
-        this.configDomain = configDomain;
62
-        this.fixedCount = fixedCount;
63
-    }
64
-
65
-    private void init() {
66
-        this.scroller = new MenuScroller(menu,
67
-                config.getOptionInt(configDomain,"windowMenuItems"),
68
-                config.getOptionInt(configDomain, "windowMenuScrollInterval"), fixedCount, 0);
69
-        scroller.setShowSeperators(false);
70
-
71
-        config.addChangeListener(configDomain, "windowMenuItems", this);
72
-        config.addChangeListener(configDomain, "windowMenuScrollInterval", this);
73
-    }
74
-
75
-    /**
76
-     * Creates a menu scroller and attaches it to the menu.
77
-     */
78
-    public static void createScroller(final JMenu menu, final AggregateConfigProvider config,
79
-            final String configDomain, final int fixedCount) {
80
-        new WindowMenuScroller(menu, config, configDomain, fixedCount).init();
81
-    }
82
-
83
-    @Override
84
-    public void configChanged(final String domain, final String key) {
85
-        UIUtilities.invokeLater(() -> {
86
-            scroller.dispose();
87
-            scroller = new MenuScroller(menu,
88
-                    config.getOptionInt(configDomain, "windowMenuItems"),
89
-                    config.getOptionInt(configDomain, "windowMenuScrollInterval"),
90
-                    fixedCount, 0);
91
-            scroller.setShowSeperators(false);
92
-        });
93
-    }
94
-
95
-}

+ 0
- 79
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuSeparator.java Bestand weergeven

@@ -1,79 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
26
-import com.dmdirc.addons.ui_swing.events.SwingEventBus;
27
-import com.dmdirc.addons.ui_swing.events.SwingWindowAddedEvent;
28
-import com.dmdirc.addons.ui_swing.events.SwingWindowDeletedEvent;
29
-import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
30
-import com.dmdirc.ui.WindowManager;
31
-
32
-import java.awt.event.ActionEvent;
33
-import java.awt.event.ActionListener;
34
-
35
-import javax.inject.Inject;
36
-import javax.swing.JPopupMenu;
37
-
38
-import net.engio.mbassy.listener.Handler;
39
-import net.engio.mbassy.listener.Invoke;
40
-
41
-/**
42
- * Separator that only appears when there are top level windows.
43
- */
44
-public class WindowMenuSeparator extends JPopupMenu.Separator implements ActionListener {
45
-
46
-    private final ActiveFrameManager activeFrameManager;
47
-    private final SwingEventBus eventBus;
48
-    private final WindowManager windowManager;
49
-
50
-    @Inject
51
-    public WindowMenuSeparator(final ActiveFrameManager activeFrameManager,
52
-            final SwingEventBus eventBus,
53
-            final WindowManager windowManager) {
54
-        this.activeFrameManager = activeFrameManager;
55
-        this.eventBus = eventBus;
56
-        this.windowManager = windowManager;
57
-    }
58
-    /**
59
-     * Initialises the menu item adding listeners as required.
60
-     */
61
-    public void init() {
62
-        eventBus.subscribe(this);
63
-    }
64
-
65
-    @Override
66
-    public void actionPerformed(final ActionEvent e) {
67
-        activeFrameManager.getActiveFrame().ifPresent(c -> c.getContainer().close());
68
-    }
69
-
70
-    @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
71
-    public void windowAdded(final SwingWindowAddedEvent event) {
72
-        setVisible(true);
73
-    }
74
-
75
-    @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
76
-    public void windowDeleted(final SwingWindowDeletedEvent event) {
77
-        setVisible(!windowManager.getRootWindows().isEmpty());
78
-    }
79
-}

+ 0
- 68
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowSelectionFontChanger.java Bestand weergeven

@@ -1,68 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
26
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
27
-import com.dmdirc.addons.ui_swing.events.SwingEventBus;
28
-import com.dmdirc.addons.ui_swing.events.SwingWindowSelectedEvent;
29
-import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
30
-
31
-import java.awt.Font;
32
-
33
-import javax.swing.JComponent;
34
-import javax.swing.UIManager;
35
-
36
-import net.engio.mbassy.listener.Handler;
37
-import net.engio.mbassy.listener.Listener;
38
-import net.engio.mbassy.listener.References;
39
-
40
-/**
41
- * Changes the font for a JComponent on a selection change.
42
- */
43
-@Listener(references = References.Strong)
44
-public class WindowSelectionFontChanger {
45
-
46
-    private final JComponent component;
47
-    private final TextFrame window;
48
-
49
-    public WindowSelectionFontChanger(final JComponent component, final TextFrame window) {
50
-        this.component = component;
51
-        this.window = window;
52
-    }
53
-
54
-    public void init(final ActiveFrameManager activeFrameMaanger, final SwingEventBus eventBus) {
55
-        eventBus.subscribe(this);
56
-        selectionChanged(new SwingWindowSelectedEvent(activeFrameMaanger.getActiveFrame()));
57
-    }
58
-
59
-    @Handler(invocation = EdtHandlerInvocation.class)
60
-    public void selectionChanged(final SwingWindowSelectedEvent event) {
61
-        // TODO: Check children and set italic
62
-        if (event.getWindow().isPresent() && window.equals(event.getWindow().get())) {
63
-            component.setFont(UIManager.getFont("MenuItem.font").deriveFont(Font.BOLD));
64
-        } else {
65
-            component.setFont(UIManager.getFont("MenuItem.font").deriveFont(Font.PLAIN));
66
-        }
67
-    }
68
-}

+ 0
- 54
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowSelectionFontChangerFactory.java Bestand weergeven

@@ -1,54 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
24
-
25
-import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
26
-import com.dmdirc.addons.ui_swing.events.SwingEventBus;
27
-import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
28
-
29
-import javax.inject.Inject;
30
-import javax.swing.JComponent;
31
-
32
-/**
33
- * Factory to create {@link WindowSelectionFontChanger}s.
34
- */
35
-public class WindowSelectionFontChangerFactory {
36
-
37
-    private final ActiveFrameManager activeFrameManager;
38
-    private final SwingEventBus swingEventBus;
39
-
40
-    @Inject
41
-    public WindowSelectionFontChangerFactory(final ActiveFrameManager activeFrameManager,
42
-            final SwingEventBus swingEventBus) {
43
-        this.activeFrameManager = activeFrameManager;
44
-        this.swingEventBus = swingEventBus;
45
-    }
46
-
47
-    public WindowSelectionFontChanger getWindowSelectionFontChanger(final JComponent component,
48
-            final TextFrame window) {
49
-        final WindowSelectionFontChanger windowSelectionFontChanger
50
-                = new WindowSelectionFontChanger(component, window);
51
-        windowSelectionFontChanger.init(activeFrameManager, swingEventBus);
52
-        return windowSelectionFontChanger;
53
-    }
54
-}

+ 0
- 26
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/package-info.java Bestand weergeven

@@ -1,26 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-/**
24
- * Window menu list frame manager.
25
- */
26
-package com.dmdirc.addons.ui_swing.framemanager.windowmenu;

Laden…
Annuleren
Opslaan