Browse Source

The client now ensures tab completers are extracted if needbe

tags/0.6.3m1rc1
Chris Smith 15 years ago
parent
commit
28bf4481f8
1 changed files with 22 additions and 15 deletions
  1. 22
    15
      src/com/dmdirc/Main.java

+ 22
- 15
src/com/dmdirc/Main.java View File

102
 
102
 
103
         CommandManager.initCommands();
103
         CommandManager.initCommands();
104
 
104
 
105
-        loadUI(pm, IdentityManager.getGlobalConfig(), true);
105
+        for (String service : new String[]{"ui", "tabcompletion"}) {
106
+            ensureExists(pm, service);
107
+        }
108
+
109
+        loadUI(pm, IdentityManager.getGlobalConfig());
106
 
110
 
107
         getUI().initUISettings();
111
         getUI().initUISettings();
108
 
112
 
135
         }, "Shutdown thread"));        
139
         }, "Shutdown thread"));        
136
     }
140
     }
137
 
141
 
142
+    /**
143
+     * Ensures that there is at least one provider of the specified
144
+     * service type by extracting matching core plugins. Plugins must be named
145
+     * so that their file name starts with the service type, and then an
146
+     * underscore.
147
+     *
148
+     * @param pm The plugin manager to use to access services
149
+     * @param serviceType The type of service that should exist
150
+     */
151
+    protected static void ensureExists(final PluginManager pm, final String serviceType) {
152
+        if (pm.getServicesByType(serviceType).isEmpty()) {
153
+            extractCorePlugins(serviceType + "_");
154
+            pm.getPossiblePluginInfos(true);
155
+        }
156
+    }
157
+
138
     /**
158
     /**
139
      * Attempts to find and activate a service which provides a UI that we
159
      * Attempts to find and activate a service which provides a UI that we
140
      * can use.
160
      * can use.
141
      *
161
      *
142
      * @param pm The plugin manager to use to load plugins
162
      * @param pm The plugin manager to use to load plugins
143
      * @param cm The config manager to use to retrieve settings
163
      * @param cm The config manager to use to retrieve settings
144
-     * @param tryExtracting If no suitable plugins are found and tryExtracting
145
-     * is true, the method will try extracting core UI plugins bundled with
146
-     * DMDirc before giving up.
147
      */
164
      */
148
-    protected static void loadUI(final PluginManager pm, final ConfigManager cm,
149
-            final boolean tryExtracting) {
165
+    protected static void loadUI(final PluginManager pm, final ConfigManager cm) {
150
         final List<Service> uis = pm.getServicesByType("ui");
166
         final List<Service> uis = pm.getServicesByType("ui");
151
         final String desired = cm.getOption("general", "ui");
167
         final String desired = cm.getOption("general", "ui");
152
 
168
 
164
             }
180
             }
165
         }
181
         }
166
 
182
 
167
-        // Third try: extract some core plugins and go again
168
-        if (tryExtracting) {
169
-            extractCorePlugins("ui_");
170
-            pm.getPossiblePluginInfos(true);
171
-
172
-            loadUI(pm, cm, false);
173
-            return;
174
-        }
175
-
176
         if (!GraphicsEnvironment.isHeadless()) {
183
         if (!GraphicsEnvironment.isHeadless()) {
177
             // Show a dialog informing the user that no UI was found.
184
             // Show a dialog informing the user that no UI was found.
178
             NoUIDialog.displayBlocking();
185
             NoUIDialog.displayBlocking();

Loading…
Cancel
Save