Lines 44-49
Link Here
|
44 |
|
44 |
|
45 |
package org.netbeans.modules.autoupdate.services; |
45 |
package org.netbeans.modules.autoupdate.services; |
46 |
|
46 |
|
|
|
47 |
import java.awt.Image; |
47 |
import java.io.File; |
48 |
import java.io.File; |
48 |
import org.netbeans.api.autoupdate.*; |
49 |
import org.netbeans.api.autoupdate.*; |
49 |
import org.netbeans.spi.autoupdate.*; |
50 |
import org.netbeans.spi.autoupdate.*; |
Lines 73-79
Link Here
|
73 |
import org.openide.util.LookupEvent; |
74 |
import org.openide.util.LookupEvent; |
74 |
import org.openide.util.LookupListener; |
75 |
import org.openide.util.LookupListener; |
75 |
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; |
76 |
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; |
|
|
77 |
import org.netbeans.modules.autoupdate.updateprovider.ProviderCategory; |
76 |
import org.openide.filesystems.FileUtil; |
78 |
import org.openide.filesystems.FileUtil; |
|
|
79 |
import org.openide.util.ImageUtilities; |
77 |
|
80 |
|
78 |
|
81 |
|
79 |
/** <code>UpdateProvider</code> providers items for Autoupdate infrastructure. The items |
82 |
/** <code>UpdateProvider</code> providers items for Autoupdate infrastructure. The items |
Lines 86-92
Link Here
|
86 |
public final class UpdateUnitProviderImpl { |
89 |
public final class UpdateUnitProviderImpl { |
87 |
|
90 |
|
88 |
private UpdateProvider provider; |
91 |
private UpdateProvider provider; |
89 |
private static Logger err = Logger.getLogger ("org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl"); |
92 |
private static final Logger err = Logger.getLogger ("org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl"); |
90 |
private static final String REMOVED_MASK ="_removed"; |
93 |
private static final String REMOVED_MASK ="_removed"; |
91 |
private static final String URL = "url"; |
94 |
private static final String URL = "url"; |
92 |
private static final String DISPLAY_NAME = "displayName"; |
95 |
private static final String DISPLAY_NAME = "displayName"; |
Lines 114-119
Link Here
|
114 |
public CATEGORY getCategory() { |
117 |
public CATEGORY getCategory() { |
115 |
return getUpdateProvider().getCategory(); |
118 |
return getUpdateProvider().getCategory(); |
116 |
} |
119 |
} |
|
|
120 |
public Image getSourceIcon() { |
121 |
UpdateProvider up = getUpdateProvider(); |
122 |
if (up instanceof AutoupdateCatalogProvider) { |
123 |
return ((AutoupdateCatalogProvider)up).getProviderCategory().getIcon(); |
124 |
} |
125 |
return ProviderCategory.forValue(CATEGORY.COMMUNITY).getIcon(); |
126 |
} |
127 |
public String getSourceDescription() { |
128 |
UpdateProvider up = getUpdateProvider(); |
129 |
if (up instanceof AutoupdateCatalogProvider) { |
130 |
return ((AutoupdateCatalogProvider) up).getProviderCategory().getDisplayName(); |
131 |
} |
132 |
return ProviderCategory.forValue(CATEGORY.COMMUNITY).getDisplayName(); |
133 |
} |
134 |
|
135 |
|
117 |
|
136 |
|
118 |
/** Display name of provider. This display name can be visualized in UI. |
137 |
/** Display name of provider. This display name can be visualized in UI. |
119 |
* |
138 |
* |
Lines 201-211
Link Here
|
201 |
} |
220 |
} |
202 |
|
221 |
|
203 |
public static UpdateUnitProvider createUpdateUnitProvider (String codeName, String displayName, URL url) { |
222 |
public static UpdateUnitProvider createUpdateUnitProvider (String codeName, String displayName, URL url) { |
204 |
return createUpdateUnitProvider(codeName, displayName, url, CATEGORY.COMMUNITY); |
223 |
return createUpdateUnitProvider(codeName, displayName, url, ProviderCategory.forValue(CATEGORY.COMMUNITY)); |
205 |
} |
224 |
} |
206 |
|
225 |
|
207 |
// static factory methods |
226 |
// static factory methods |
208 |
public static UpdateUnitProvider createUpdateUnitProvider (String codeName, String displayName, URL url, CATEGORY category) { |
227 |
public static UpdateUnitProvider createUpdateUnitProvider (String codeName, String displayName, URL url, ProviderCategory category) { |
209 |
codeName = normalizeCodeName (codeName); |
228 |
codeName = normalizeCodeName (codeName); |
210 |
// store to Preferences |
229 |
// store to Preferences |
211 |
storeProvider(codeName, displayName, url); |
230 |
storeProvider(codeName, displayName, url); |
Lines 337-343
Link Here
|
337 |
|
356 |
|
338 |
String toUrl = providerPreferences.get (URL, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_URL, null)); |
357 |
String toUrl = providerPreferences.get (URL, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_URL, null)); |
339 |
String displayName = providerPreferences.get (DISPLAY_NAME, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_DISPLAY_NAME, codeName)); |
358 |
String displayName = providerPreferences.get (DISPLAY_NAME, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_DISPLAY_NAME, codeName)); |
340 |
CATEGORY category = CATEGORY.valueOf(providerPreferences.get (CATEGORY_NAME, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_CATEGORY_NAME, CATEGORY.COMMUNITY.name()))); |
359 |
String categoryName = providerPreferences.get (CATEGORY_NAME, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_CATEGORY_NAME, CATEGORY.COMMUNITY.name())); |
|
|
360 |
String categoryIconBase = providerPreferences.get(AutoupdateCatalogFactory.ORIGINAL_CATEGORY_ICON_BASE, null); |
361 |
ProviderCategory pc; |
362 |
if (categoryIconBase == null) { |
363 |
pc = ProviderCategory.forValue(CATEGORY.valueOf(categoryName)); |
364 |
} else { |
365 |
pc = ProviderCategory.create(categoryIconBase, categoryName); |
366 |
} |
341 |
|
367 |
|
342 |
// filter Providers which store only its state |
368 |
// filter Providers which store only its state |
343 |
if (toUrl == null) { |
369 |
if (toUrl == null) { |
Lines 350-357
Link Here
|
350 |
} catch (MalformedURLException mue) { |
376 |
} catch (MalformedURLException mue) { |
351 |
assert false : mue; |
377 |
assert false : mue; |
352 |
} |
378 |
} |
353 |
|
379 |
return new AutoupdateCatalogProvider (codeName, displayName, url, pc); |
354 |
return new AutoupdateCatalogProvider (codeName, displayName, url, category); |
|
|
355 |
} |
380 |
} |
356 |
|
381 |
|
357 |
private static boolean loadState (String codename) { |
382 |
private static boolean loadState (String codename) { |
Lines 443-449
Link Here
|
443 |
} |
468 |
} |
444 |
} |
469 |
} |
445 |
} |
470 |
} |
446 |
|
471 |
|
447 |
private static class LookupListenerImpl implements LookupListener { |
472 |
private static class LookupListenerImpl implements LookupListener { |
448 |
final Lookup.Result<UpdateProvider> result = Lookup.getDefault ().lookupResult(UpdateProvider.class); |
473 |
final Lookup.Result<UpdateProvider> result = Lookup.getDefault ().lookupResult(UpdateProvider.class); |
449 |
|
474 |
|