Index: autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProvider.java =================================================================== --- autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProvider.java (Revision 1) +++ autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProvider.java (Arbeitskopie) @@ -47,10 +47,14 @@ import org.netbeans.spi.autoupdate.*; import java.io.IOException; import java.net.URL; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.netbeans.api.autoupdate.UpdateManager.TYPE; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; /**UpdateUnitProvider providers UpdateUnit. The units @@ -60,10 +64,45 @@ * @author Jiri Rechtacek */ public final class UpdateUnitProvider { - public static enum CATEGORY { - STANDARD, - COMMUNITY, - BETA + public static final class CATEGORY { + private static final Map values + = loadCategories(); + public static final CATEGORY STANDARD = valueOf("STANDARD"); + public static final CATEGORY COMMUNITY = valueOf("COMMUNITY"); + public static final CATEGORY BETA = valueOf("BETA"); + private final String name; + + private CATEGORY(String name) { + this.name=name; + } + + private static Map loadCategories(){ + FileObject configRoot = + FileUtil.getConfigFile("Services/AutoupdateCategory"); + Map knownCats = new HashMap(); + for(FileObject child : configRoot.getChildren()) + { + String name = child.getName(); + knownCats.put(name, new CATEGORY(name)); + } + return knownCats; + } + + public static CATEGORY valueOf(String name) { + if(!values.containsKey(name)) + values.put(name, new CATEGORY(name)); + return values.get(name); + } + + public String name() { + return name; + } + + public static CATEGORY[] values() { + if(values == null) + return new CATEGORY[0]; + return values.values().toArray(new CATEGORY[values.size()]); + } } UpdateUnitProviderImpl impl; Index: autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/HTMLEditorKitEx.java =================================================================== --- autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/HTMLEditorKitEx.java (Revision 1) +++ autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/HTMLEditorKitEx.java (Arbeitskopie) @@ -58,14 +58,11 @@ public class HTMLEditorKitEx extends HTMLEditorKit { private static final Map ICONS = new HashMap(); static { - URL u_standard = Utilities.getCategoryIcon(CATEGORY.STANDARD); - ICONS.put(u_standard, new ImageIcon(u_standard)); - - URL u_beta = Utilities.getCategoryIcon(CATEGORY.BETA); - ICONS.put(u_beta, new ImageIcon(u_beta)); - - URL u_community = Utilities.getCategoryIcon(CATEGORY.COMMUNITY); - ICONS.put(u_community, new ImageIcon(u_community)); + for(CATEGORY category : CATEGORY.values()) + { + URL u_icon = Utilities.getCategoryIcon(category); + ICONS.put(u_icon, new ImageIcon(u_icon)); + } } public ViewFactory getViewFactory() { Index: autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/resources/layer.xml =================================================================== --- autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/resources/layer.xml (Revision 1) +++ autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/resources/layer.xml (Arbeitskopie) @@ -43,7 +43,7 @@ Version 2 license, then the option applies only if the new code is made subject to such option by the copyright holder. --> - + @@ -68,5 +68,21 @@ - + + + + + + + + + + + + + + + + + Index: autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.java =================================================================== --- autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.java (Revision 1) +++ autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.java (Arbeitskopie) @@ -50,6 +50,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.text.SimpleDateFormat; @@ -59,9 +60,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.prefs.Preferences; +import javax.imageio.ImageIO; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.DefaultComboBoxModel; +import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JScrollPane; @@ -704,13 +707,17 @@ if (value instanceof UpdateUnitProvider) { UpdateUnitProvider u = (UpdateUnitProvider) value; CATEGORY state = u.getCategory(); - if (CATEGORY.BETA.equals(state)) { - renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-beta.png", false)); // NOI18N - } else if (CATEGORY.COMMUNITY.equals(state)) { - renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-community.png", false)); // NOI18N - } else if (CATEGORY.STANDARD.equals(state)) { - renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-standard.png", false)); // NOI18N + URL categoryIcon = Utilities.getCategoryIcon(state); + Icon icon = null; + try + { + icon = ImageUtilities.image2Icon(ImageIO.read(categoryIcon)); } + catch(IOException ex) + { + // unable to read resource + } + renderComponent.setIcon(icon); renderComponent.setText (u.getDisplayName()); renderComponent.setHorizontalAlignment(SwingConstants.LEFT); } Index: autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Utilities.java =================================================================== --- autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Utilities.java (Revision 1) +++ autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Utilities.java (Arbeitskopie) @@ -81,12 +81,15 @@ import org.netbeans.api.progress.ProgressHandleFactory; import org.openide.awt.HtmlBrowser; import org.openide.awt.Mnemonics; +import org.openide.filesystems.FileObject; import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.util.NbPreferences; import org.openide.util.RequestProcessor; import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; import org.netbeans.modules.autoupdate.ui.actions.ShowNotifications; +import org.openide.filesystems.FileUtil; +import org.openide.util.ImageUtilities; import org.openide.util.Task; import org.openide.util.TaskListener; @@ -905,32 +908,31 @@ private static Preferences getPreferences () { return NbPreferences.forModule (Utilities.class); } + + static FileObject getCategoryEntry(CATEGORY category) { + FileObject categoryRoot = + FileUtil.getConfigFile("Services/AutoupdateCategory/"); + FileObject categoryData = categoryRoot.getFileObject(category.name()); + if(categoryData == null) + categoryData = categoryRoot.getFileObject(CATEGORY.COMMUNITY.name()); + return categoryData; + } static String getCategoryName(CATEGORY category) { - String key = null; - switch (category) { - case STANDARD: - key = "AvailableTab_SourceCategory_Tooltip_STANDARD"; //NOI18N - break; - case BETA: - key = "AvailableTab_SourceCategory_Tooltip_BETA"; //NOI18N - break; - case COMMUNITY: - key = "AvailableTab_SourceCategory_Tooltip_COMMUNITY"; //NOI18N - break; - } - return (key != null) ? getBundle(key) : null; + FileObject categoryEntry = getCategoryEntry(category); + if(categoryEntry == null) + return null; + return (String)categoryEntry.getAttribute("displayName"); } static URL getCategoryIcon(CATEGORY state) { + FileObject categoryEntry = getCategoryEntry(state); + if(categoryEntry == null) + return null; + Object value=categoryEntry.getAttribute("iconResource"); URL retval = null; - if (CATEGORY.BETA.equals(state)) { - retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-beta.png"); // NOI18N - } else if (CATEGORY.COMMUNITY.equals(state)) { - retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-community.png"); // NOI18N - } else if (CATEGORY.STANDARD.equals(state)) { - retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-standard.png"); // NOI18N - } + if(value instanceof URL) + retval = (URL)value; return retval; } }