Browse Source

Merge pull request #98 from greboid/fix-statusbar

Remove Statusbar.
pull/101/head
Chris Smith 9 years ago
parent
commit
f934489924

+ 0
- 60
src/com/dmdirc/interfaces/ui/StatusBar.java View File

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.interfaces.ui;
24
-
25
-import com.dmdirc.ui.StatusMessage;
26
-
27
-/**
28
- * Status bar interface.
29
- */
30
-public interface StatusBar {
31
-
32
-    /**
33
-     * Sets the message for this message label.
34
-     *
35
-     * @param message Message object to show
36
-     *
37
-     * @since 0.6.6
38
-     */
39
-    void setMessage(final StatusMessage message);
40
-
41
-    /**
42
-     * Removes the message from the status bar.
43
-     */
44
-    void clearMessage();
45
-
46
-    /**
47
-     * Adds a component to the status bar.
48
-     *
49
-     * @param component component to add
50
-     */
51
-    void addComponent(final StatusBarComponent component);
52
-
53
-    /**
54
-     * Removes a component to the status bar.
55
-     *
56
-     * @param component component to add
57
-     */
58
-    void removeComponent(final StatusBarComponent component);
59
-
60
-}

+ 0
- 5
src/com/dmdirc/plugins/PluginInjectorInitialiser.java View File

35
 import com.dmdirc.messages.MessageSinkManager;
35
 import com.dmdirc.messages.MessageSinkManager;
36
 import com.dmdirc.ui.IconManager;
36
 import com.dmdirc.ui.IconManager;
37
 import com.dmdirc.ui.WindowManager;
37
 import com.dmdirc.ui.WindowManager;
38
-import com.dmdirc.ui.core.components.StatusBarManager;
39
 import com.dmdirc.ui.messages.ColourManager;
38
 import com.dmdirc.ui.messages.ColourManager;
40
 import com.dmdirc.ui.themes.ThemeManager;
39
 import com.dmdirc.ui.themes.ThemeManager;
41
 import com.dmdirc.util.SimpleInjector;
40
 import com.dmdirc.util.SimpleInjector;
59
     private final CommandManager commandManager;
58
     private final CommandManager commandManager;
60
     private final MessageSinkManager messageSinkManager;
59
     private final MessageSinkManager messageSinkManager;
61
     private final WindowManager windowManager;
60
     private final WindowManager windowManager;
62
-    private final StatusBarManager statusBarManager;
63
     private final PreferencesManager preferencesManager;
61
     private final PreferencesManager preferencesManager;
64
     private final LifecycleController lifecycleController;
62
     private final LifecycleController lifecycleController;
65
     private final CorePluginExtractor corePluginExtractor;
63
     private final CorePluginExtractor corePluginExtractor;
79
             final CommandManager commandManager,
77
             final CommandManager commandManager,
80
             final MessageSinkManager messageSinkManager,
78
             final MessageSinkManager messageSinkManager,
81
             final WindowManager windowManager,
79
             final WindowManager windowManager,
82
-            final StatusBarManager statusBarManager,
83
             final PreferencesManager preferencesManager,
80
             final PreferencesManager preferencesManager,
84
             final LifecycleController lifecycleController,
81
             final LifecycleController lifecycleController,
85
             final CorePluginExtractor corePluginExtractor,
82
             final CorePluginExtractor corePluginExtractor,
97
         this.commandManager = commandManager;
94
         this.commandManager = commandManager;
98
         this.messageSinkManager = messageSinkManager;
95
         this.messageSinkManager = messageSinkManager;
99
         this.windowManager = windowManager;
96
         this.windowManager = windowManager;
100
-        this.statusBarManager = statusBarManager;
101
         this.preferencesManager = preferencesManager;
97
         this.preferencesManager = preferencesManager;
102
         this.lifecycleController = lifecycleController;
98
         this.lifecycleController = lifecycleController;
103
         this.corePluginExtractor = corePluginExtractor;
99
         this.corePluginExtractor = corePluginExtractor;
121
         injector.addParameter(commandManager);
117
         injector.addParameter(commandManager);
122
         injector.addParameter(MessageSinkManager.class, messageSinkManager);
118
         injector.addParameter(MessageSinkManager.class, messageSinkManager);
123
         injector.addParameter(WindowManager.class, windowManager);
119
         injector.addParameter(WindowManager.class, windowManager);
124
-        injector.addParameter(statusBarManager);
125
         injector.addParameter(PreferencesManager.class, preferencesManager);
120
         injector.addParameter(PreferencesManager.class, preferencesManager);
126
         injector.addParameter(LifecycleController.class, lifecycleController);
121
         injector.addParameter(LifecycleController.class, lifecycleController);
127
         injector.addParameter(corePluginExtractor);
122
         injector.addParameter(corePluginExtractor);

+ 0
- 109
src/com/dmdirc/ui/core/components/StatusBarManager.java View File

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.ui.core.components;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.events.StatusBarComponentAddedEvent;
27
-import com.dmdirc.events.StatusBarComponentRemovedEvent;
28
-import com.dmdirc.events.StatusBarMessageClearEvent;
29
-import com.dmdirc.events.StatusBarMessageEvent;
30
-import com.dmdirc.interfaces.ui.StatusBar;
31
-import com.dmdirc.interfaces.ui.StatusBarComponent;
32
-import com.dmdirc.ui.StatusMessage;
33
-
34
-import java.util.Collection;
35
-import java.util.concurrent.CopyOnWriteArraySet;
36
-
37
-import javax.inject.Inject;
38
-import javax.inject.Singleton;
39
-
40
-/**
41
- * A manager for status bars or status bar like components.
42
- *
43
- * @since 0.6.5
44
- */
45
-@Singleton
46
-public class StatusBarManager implements StatusBar {
47
-
48
-    /** A collection of known status bars. */
49
-    private final Collection<StatusBar> statusBars = new CopyOnWriteArraySet<>();
50
-    /** Event bus to fire status bar events on. */
51
-    private final DMDircMBassador eventBus;
52
-
53
-    @Inject
54
-    public StatusBarManager(final DMDircMBassador eventBus) {
55
-        this.eventBus = eventBus;
56
-    }
57
-
58
-    /**
59
-     * Registers a new status bar with the manager. All requests to interact with status bars will
60
-     * be passed on to this status bar until it is unregistered.
61
-     *
62
-     * @param statusBar The status bar to be added to the manager
63
-     */
64
-    public void registerStatusBar(final StatusBar statusBar) {
65
-        statusBars.add(statusBar);
66
-    }
67
-
68
-    /**
69
-     * Unregisters the specified status bar with the manager.
70
-     *
71
-     * @param statusBar The status bar to be unregistered
72
-     */
73
-    public void unregisterStatusBar(final StatusBar statusBar) {
74
-        statusBars.remove(statusBar);
75
-    }
76
-
77
-    @Override
78
-    public void setMessage(final StatusMessage message) {
79
-        eventBus.publishAsync(new StatusBarMessageEvent(message));
80
-        for (StatusBar statusBar : statusBars) {
81
-            statusBar.setMessage(message);
82
-        }
83
-    }
84
-
85
-    @Override
86
-    public void clearMessage() {
87
-        eventBus.publishAsync(new StatusBarMessageClearEvent());
88
-        for (StatusBar statusBar : statusBars) {
89
-            statusBar.clearMessage();
90
-        }
91
-    }
92
-
93
-    @Override
94
-    public void addComponent(final StatusBarComponent component) {
95
-        eventBus.publishAsync(new StatusBarComponentAddedEvent(component));
96
-        for (StatusBar statusBar : statusBars) {
97
-            statusBar.addComponent(component);
98
-        }
99
-    }
100
-
101
-    @Override
102
-    public void removeComponent(final StatusBarComponent component) {
103
-        eventBus.publishAsync(new StatusBarComponentRemovedEvent(component));
104
-        for (StatusBar statusBar : statusBars) {
105
-            statusBar.removeComponent(component);
106
-        }
107
-    }
108
-
109
-}

+ 7
- 5
src/com/dmdirc/ui/core/feedback/FeedbackSender.java View File

22
 
22
 
23
 package com.dmdirc.ui.core.feedback;
23
 package com.dmdirc.ui.core.feedback;
24
 
24
 
25
+import com.dmdirc.DMDircMBassador;
26
+import com.dmdirc.events.StatusBarMessageEvent;
25
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
26
-import com.dmdirc.interfaces.ui.StatusBar;
27
 import com.dmdirc.ui.StatusMessage;
28
 import com.dmdirc.ui.StatusMessage;
28
 import com.dmdirc.util.io.Downloader;
29
 import com.dmdirc.util.io.Downloader;
29
 
30
 
38
 public class FeedbackSender implements Runnable {
39
 public class FeedbackSender implements Runnable {
39
 
40
 
40
     private final Map<String, String> postData;
41
     private final Map<String, String> postData;
41
-    private final StatusBar statusBar;
42
+    private final DMDircMBassador eventBus;
42
     private final AggregateConfigProvider config;
43
     private final AggregateConfigProvider config;
43
     private final Downloader downloader;
44
     private final Downloader downloader;
44
 
45
 
45
     public FeedbackSender(
46
     public FeedbackSender(
46
             final AggregateConfigProvider config,
47
             final AggregateConfigProvider config,
47
             final Downloader downloader,
48
             final Downloader downloader,
48
-            final StatusBar statusBar,
49
+            final DMDircMBassador eventBus,
49
             final String name,
50
             final String name,
50
             final String email,
51
             final String email,
51
             final String feedback,
52
             final String feedback,
54
             final String dmdircInfo) {
55
             final String dmdircInfo) {
55
         this.downloader = downloader;
56
         this.downloader = downloader;
56
         this.config = config;
57
         this.config = config;
57
-        this.statusBar = statusBar;
58
+        this.eventBus = eventBus;
58
         this.postData = new HashMap<>(6);
59
         this.postData = new HashMap<>(6);
59
 
60
 
60
         if (!name.isEmpty()) {
61
         if (!name.isEmpty()) {
99
 
100
 
100
     @Override
101
     @Override
101
     public void run() {
102
     public void run() {
102
-        statusBar.setMessage(new StatusMessage(sendData(postData), config));
103
+        eventBus.publishAsync(new StatusBarMessageEvent(
104
+                new StatusMessage(sendData(postData), config)));
103
     }
105
     }
104
 
106
 
105
 }
107
 }

+ 5
- 5
src/com/dmdirc/ui/core/feedback/FeedbackSenderFactory.java View File

22
 
22
 
23
 package com.dmdirc.ui.core.feedback;
23
 package com.dmdirc.ui.core.feedback;
24
 
24
 
25
+import com.dmdirc.DMDircMBassador;
25
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
26
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
26
-import com.dmdirc.interfaces.ui.StatusBar;
27
 import com.dmdirc.util.io.Downloader;
27
 import com.dmdirc.util.io.Downloader;
28
 
28
 
29
 import javax.inject.Inject;
29
 import javax.inject.Inject;
37
 
37
 
38
     private final AggregateConfigProvider config;
38
     private final AggregateConfigProvider config;
39
     private final Downloader downloader;
39
     private final Downloader downloader;
40
-    private final StatusBar statusBar;
40
+    private final DMDircMBassador eventBus;
41
 
41
 
42
     @Inject
42
     @Inject
43
     public FeedbackSenderFactory(
43
     public FeedbackSenderFactory(
44
             @GlobalConfig final AggregateConfigProvider config,
44
             @GlobalConfig final AggregateConfigProvider config,
45
-            final Downloader downloader, final StatusBar statusBar) {
45
+            final Downloader downloader, final DMDircMBassador eventBus) {
46
         this.config = config;
46
         this.config = config;
47
         this.downloader = downloader;
47
         this.downloader = downloader;
48
-        this.statusBar = statusBar;
48
+        this.eventBus = eventBus;
49
     }
49
     }
50
 
50
 
51
     public FeedbackSender getFeedbackSender(
51
     public FeedbackSender getFeedbackSender(
55
             final String version,
55
             final String version,
56
             final String serverInfo,
56
             final String serverInfo,
57
             final String dmdircInfo) {
57
             final String dmdircInfo) {
58
-        return new FeedbackSender(config, downloader, statusBar, name, email, feedback, version,
58
+        return new FeedbackSender(config, downloader, eventBus, name, email, feedback, version,
59
                 serverInfo, dmdircInfo);
59
                 serverInfo, dmdircInfo);
60
     }
60
     }
61
 }
61
 }

+ 0
- 101
test/com/dmdirc/ui/core/components/StatusBarManagerTest.java View File

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
20
- * THE SOFTWARE.
21
- */
22
-package com.dmdirc.ui.core.components;
23
-
24
-import com.dmdirc.DMDircMBassador;
25
-import com.dmdirc.interfaces.ui.StatusBar;
26
-import com.dmdirc.interfaces.ui.StatusBarComponent;
27
-import com.dmdirc.ui.StatusMessage;
28
-
29
-import org.junit.Test;
30
-import org.junit.runner.RunWith;
31
-import org.mockito.Mock;
32
-import org.mockito.runners.MockitoJUnitRunner;
33
-
34
-import static org.mockito.Mockito.mock;
35
-import static org.mockito.Mockito.verify;
36
-import static org.mockito.Mockito.verifyZeroInteractions;
37
-
38
-@RunWith(MockitoJUnitRunner.class)
39
-public class StatusBarManagerTest {
40
-
41
-    @Mock
42
-    private DMDircMBassador eventBus;
43
-
44
-    @Test
45
-    public void testRegisterStatusBar() {
46
-        final StatusBar sb = mock(StatusBar.class);
47
-        final StatusBarManager instance = new StatusBarManager(eventBus);
48
-        instance.registerStatusBar(sb);
49
-        instance.clearMessage();
50
-        verify(sb).clearMessage();
51
-    }
52
-
53
-    @Test
54
-    public void testUnregisterStatusBar() {
55
-        final StatusBar sb = mock(StatusBar.class);
56
-        final StatusBarManager instance = new StatusBarManager(eventBus);
57
-        instance.registerStatusBar(sb);
58
-        instance.unregisterStatusBar(sb);
59
-        instance.clearMessage();
60
-        verifyZeroInteractions(sb);
61
-    }
62
-
63
-    @Test
64
-    public void testSetMessage() {
65
-        final StatusMessage message = mock(StatusMessage.class);
66
-        final StatusBar sb = mock(StatusBar.class);
67
-        final StatusBarManager instance = new StatusBarManager(eventBus);
68
-        instance.registerStatusBar(sb);
69
-        instance.setMessage(message);
70
-        verify(sb).setMessage(message);
71
-    }
72
-
73
-    @Test
74
-    public void testClearMessage() {
75
-        final StatusBar sb = mock(StatusBar.class);
76
-        final StatusBarManager instance = new StatusBarManager(eventBus);
77
-        instance.registerStatusBar(sb);
78
-        instance.clearMessage();
79
-        verify(sb).clearMessage();
80
-    }
81
-
82
-    @Test
83
-    public void testAddComponent() {
84
-        final StatusBarComponent comp = mock(StatusBarComponent.class);
85
-        final StatusBar sb = mock(StatusBar.class);
86
-        final StatusBarManager instance = new StatusBarManager(eventBus);
87
-        instance.registerStatusBar(sb);
88
-        instance.addComponent(comp);
89
-        verify(sb).addComponent(comp);
90
-    }
91
-
92
-    @Test
93
-    public void testRemoveComponent() {
94
-        final StatusBarComponent comp = mock(StatusBarComponent.class);
95
-        final StatusBar sb = mock(StatusBar.class);
96
-        final StatusBarManager instance = new StatusBarManager(eventBus);
97
-        instance.registerStatusBar(sb);
98
-        instance.removeComponent(comp);
99
-        verify(sb).removeComponent(comp);
100
-    }
101
-}

Loading…
Cancel
Save