소스 검색

Fix nowplaying config failing if plugin isn't loaded.

Change-Id: Ib6419a1b32aac552f1b05c1b93c5813f370bad8b
Reviewed-on: http://gerrit.dmdirc.com/3386
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/86/3386/3
Greg Holmes 10 년 전
부모
커밋
3f65bed196
1개의 변경된 파일43개의 추가작업 그리고 9개의 파일을 삭제
  1. 43
    9
      src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java

+ 43
- 9
src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java 파일 보기

@@ -26,11 +26,17 @@ import com.dmdirc.addons.ui_swing.UIUtilities;
26 26
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
27 27
 import com.dmdirc.config.prefs.PreferencesCategory;
28 28
 import com.dmdirc.config.prefs.PreferencesDialogModel;
29
+import com.dmdirc.config.prefs.PreferencesInterface;
29 30
 import com.dmdirc.plugins.PluginInfo;
30 31
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
31 32
 
32 33
 import java.util.concurrent.Callable;
33 34
 
35
+import javax.swing.JLabel;
36
+import javax.swing.JPanel;
37
+
38
+import net.miginfocom.swing.MigLayout;
39
+
34 40
 import dagger.ObjectGraph;
35 41
 
36 42
 /**
@@ -77,15 +83,28 @@ public class NowPlayingPlugin extends BaseCommandPlugin {
77 83
 
78 84
     @Override
79 85
     public void showConfig(final PreferencesDialogModel manager) {
80
-        final ConfigPanel configPanel = UIUtilities.invokeAndWait(
81
-                new Callable<ConfigPanel>() {
82
-                    @Override
83
-                    public ConfigPanel call() {
84
-                        return new ConfigPanel(nowplayingmanager, manager.getConfigManager(),
85
-                                manager.getIdentity(), domain,
86
-                                nowplayingmanager.getSettings());
87
-                    }
88
-                });
86
+        final PreferencesInterface configPanel;
87
+        if (nowplayingmanager == null) {
88
+            configPanel = UIUtilities.invokeAndWait(
89
+                    new Callable<LoadPluginPanel>() {
90
+
91
+                        @Override
92
+                        public LoadPluginPanel call() {
93
+                            return new LoadPluginPanel();
94
+                        }
95
+                    });
96
+        } else {
97
+            configPanel = UIUtilities.invokeAndWait(
98
+                    new Callable<ConfigPanel>() {
99
+
100
+                        @Override
101
+                        public ConfigPanel call() {
102
+                            return new ConfigPanel(nowplayingmanager, manager.getConfigManager(),
103
+                                    manager.getIdentity(), domain,
104
+                                    nowplayingmanager.getSettings());
105
+                        }
106
+                    });
107
+        }
89 108
 
90 109
         final PreferencesCategory category = new PluginPreferencesCategory(
91 110
                 pluginInfo, "Now Playing",
@@ -93,4 +112,19 @@ public class NowPlayingPlugin extends BaseCommandPlugin {
93 112
         manager.getCategory("Plugins").addSubCategory(category);
94 113
     }
95 114
 
115
+    private class LoadPluginPanel extends JPanel implements PreferencesInterface {
116
+
117
+        private static final long serialVersionUID = 1L;
118
+
119
+        private LoadPluginPanel() {
120
+            super(new MigLayout("fill"));
121
+            add(new JLabel("Please load the plugin to change these settings."));
122
+        }
123
+
124
+        @Override
125
+        public void save() {
126
+        }
127
+
128
+    }
129
+
96 130
 }

Loading…
취소
저장