|
@@ -102,7 +102,11 @@ public final class Main {
|
102
|
102
|
|
103
|
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
|
111
|
getUI().initUISettings();
|
108
|
112
|
|
|
@@ -135,18 +139,30 @@ public final class Main {
|
135
|
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
|
159
|
* Attempts to find and activate a service which provides a UI that we
|
140
|
160
|
* can use.
|
141
|
161
|
*
|
142
|
162
|
* @param pm The plugin manager to use to load plugins
|
143
|
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
|
166
|
final List<Service> uis = pm.getServicesByType("ui");
|
151
|
167
|
final String desired = cm.getOption("general", "ui");
|
152
|
168
|
|
|
@@ -164,15 +180,6 @@ public final class Main {
|
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
|
183
|
if (!GraphicsEnvironment.isHeadless()) {
|
177
|
184
|
// Show a dialog informing the user that no UI was found.
|
178
|
185
|
NoUIDialog.displayBlocking();
|