This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 183778
Collapse All | Expand All

(-)autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProvider.java (-4 / +43 lines)
Lines 47-56 Link Here
47
import org.netbeans.spi.autoupdate.*;
47
import org.netbeans.spi.autoupdate.*;
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.net.URL;
49
import java.net.URL;
50
import java.util.HashMap;
50
import java.util.List;
51
import java.util.List;
52
import java.util.Map;
51
import org.netbeans.api.autoupdate.UpdateManager.TYPE;
53
import org.netbeans.api.autoupdate.UpdateManager.TYPE;
52
import org.netbeans.api.progress.ProgressHandle;
54
import org.netbeans.api.progress.ProgressHandle;
53
import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl;
55
import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl;
56
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileUtil;
54
58
55
59
56
/**<code>UpdateUnitProvider</code> providers <code>UpdateUnit</code>. The units
60
/**<code>UpdateUnitProvider</code> providers <code>UpdateUnit</code>. The units
Lines 60-69 Link Here
60
 * @author Jiri Rechtacek
64
 * @author Jiri Rechtacek
61
 */
65
 */
62
public final class UpdateUnitProvider {
66
public final class UpdateUnitProvider {
63
    public static enum CATEGORY {
67
    public static final class CATEGORY {
64
        STANDARD,
68
        private static final Map<String,CATEGORY> values
65
        COMMUNITY,
69
            = loadCategories();
66
        BETA
70
        public static final CATEGORY STANDARD = valueOf("STANDARD");
71
        public static final CATEGORY COMMUNITY = valueOf("COMMUNITY");
72
        public static final CATEGORY BETA = valueOf("BETA");
73
        private final String name;
74
75
        private CATEGORY(String name) {
76
          this.name=name;
77
        }
78
79
        private static Map<String, CATEGORY> loadCategories(){
80
          FileObject configRoot =
81
              FileUtil.getConfigFile("Services/AutoupdateCategory");
82
          Map<String,CATEGORY> knownCats = new HashMap<String, CATEGORY>();
83
          for(FileObject child : configRoot.getChildren())
84
          {
85
            String name = child.getName();
86
            knownCats.put(name, new CATEGORY(name));
87
          }
88
          return knownCats;
89
        }
90
91
        public static CATEGORY valueOf(String name) {
92
          if(!values.containsKey(name))
93
            values.put(name, new CATEGORY(name));
94
          return values.get(name);
95
        }
96
97
        public String name() {
98
          return name;
99
        }
100
101
        public static CATEGORY[] values() {
102
          if(values == null)
103
            return new CATEGORY[0];
104
          return values.values().toArray(new CATEGORY[values.size()]);
105
        }
67
    }
106
    }
68
    
107
    
69
    UpdateUnitProviderImpl impl;
108
    UpdateUnitProviderImpl impl;
(-)autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/HTMLEditorKitEx.java (-8 / +5 lines)
Lines 58-71 Link Here
58
public class HTMLEditorKitEx extends HTMLEditorKit {
58
public class HTMLEditorKitEx extends HTMLEditorKit {
59
    private static final Map<URL,ImageIcon> ICONS = new HashMap<URL,ImageIcon>();
59
    private static final Map<URL,ImageIcon> ICONS = new HashMap<URL,ImageIcon>();
60
    static {
60
    static {
61
        URL u_standard = Utilities.getCategoryIcon(CATEGORY.STANDARD);
61
        for(CATEGORY category : CATEGORY.values())
62
        ICONS.put(u_standard, new ImageIcon(u_standard));
62
        {
63
63
          URL u_icon = Utilities.getCategoryIcon(category);
64
        URL u_beta = Utilities.getCategoryIcon(CATEGORY.BETA);
64
          ICONS.put(u_icon, new ImageIcon(u_icon));
65
        ICONS.put(u_beta, new ImageIcon(u_beta));
65
        }
66
67
        URL u_community = Utilities.getCategoryIcon(CATEGORY.COMMUNITY);
68
        ICONS.put(u_community, new ImageIcon(u_community));
69
    }
66
    }
70
67
71
    public ViewFactory getViewFactory() {
68
    public ViewFactory getViewFactory() {
(-)autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/resources/layer.xml (-2 / +18 lines)
Lines 43-49 Link Here
43
Version 2 license, then the option applies only if the new code is
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
44
made subject to such option by the copyright holder.
45
-->
45
-->
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
47
<filesystem>
47
<filesystem>
48
  <folder name="Menu">
48
  <folder name="Menu">
49
        <folder name="Help">
49
        <folder name="Help">
Lines 68-72 Link Here
68
      <file name="org-netbeans-modules-autoupdate-ui-actions-PluginManagerAction.instance"/>
68
      <file name="org-netbeans-modules-autoupdate-ui-actions-PluginManagerAction.instance"/>
69
    </folder>    
69
    </folder>    
70
  </folder>
70
  </folder>
71
  
71
72
  <folder name="Services">
73
    <folder name="AutoupdateCategory">
74
      <file name="STANDARD">
75
        <attr name="displayName" bundlevalue="org.netbeans.modules.autoupdate.ui.Bundle#AvailableTab_SourceCategory_Tooltip_STANDARD"/>
76
        <attr name="iconResource" urlvalue="nbres:/org/netbeans/modules/autoupdate/ui/resources/icon-standard.png"/>
77
      </file>
78
      <file name="COMMUNITY">
79
        <attr name="displayName" bundlevalue="org.netbeans.modules.autoupdate.ui.Bundle#AvailableTab_SourceCategory_Tooltip_COMMUNITY"/>
80
        <attr name="iconResource" urlvalue="nbres:/org/netbeans/modules/autoupdate/ui/resources/icon-community.png"/>
81
      </file>
82
      <file name="BETA">
83
        <attr name="displayName" bundlevalue="org.netbeans.modules.autoupdate.ui.Bundle#AvailableTab_SourceCategory_Tooltip_BETA"/>
84
        <attr name="iconResource" urlvalue="nbres:/org/netbeans/modules/autoupdate/ui/resources/icon-beta.png"/>
85
      </file>
86
    </folder>
87
  </folder>
72
</filesystem>
88
</filesystem>
(-)autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.java (-6 / +13 lines)
Lines 50-55 Link Here
50
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionListener;
51
import java.awt.event.ActionListener;
52
import java.io.File;
52
import java.io.File;
53
import java.io.IOException;
53
import java.net.MalformedURLException;
54
import java.net.MalformedURLException;
54
import java.net.URL;
55
import java.net.URL;
55
import java.text.SimpleDateFormat;
56
import java.text.SimpleDateFormat;
Lines 59-67 Link Here
59
import java.util.logging.Level;
60
import java.util.logging.Level;
60
import java.util.logging.Logger;
61
import java.util.logging.Logger;
61
import java.util.prefs.Preferences;
62
import java.util.prefs.Preferences;
63
import javax.imageio.ImageIO;
62
import javax.swing.AbstractAction;
64
import javax.swing.AbstractAction;
63
import javax.swing.Action;
65
import javax.swing.Action;
64
import javax.swing.DefaultComboBoxModel;
66
import javax.swing.DefaultComboBoxModel;
67
import javax.swing.Icon;
65
import javax.swing.JButton;
68
import javax.swing.JButton;
66
import javax.swing.JLabel;
69
import javax.swing.JLabel;
67
import javax.swing.JScrollPane;
70
import javax.swing.JScrollPane;
Lines 704-716 Link Here
704
            if (value instanceof UpdateUnitProvider) {
707
            if (value instanceof UpdateUnitProvider) {
705
                UpdateUnitProvider u = (UpdateUnitProvider) value;
708
                UpdateUnitProvider u = (UpdateUnitProvider) value;
706
                CATEGORY state = u.getCategory();
709
                CATEGORY state = u.getCategory();
707
                if (CATEGORY.BETA.equals(state)) {
710
                URL categoryIcon = Utilities.getCategoryIcon(state);
708
                    renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-beta.png", false)); // NOI18N
711
                Icon icon = null;
709
                } else if (CATEGORY.COMMUNITY.equals(state)) {
712
                try
710
                    renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-community.png", false)); // NOI18N
713
                {
711
                } else if (CATEGORY.STANDARD.equals(state)) {
714
                  icon = ImageUtilities.image2Icon(ImageIO.read(categoryIcon));
712
                    renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-standard.png", false)); // NOI18N
713
                }
715
                }
716
                catch(IOException ex)
717
                {
718
                  // unable to read resource
719
                }
720
                renderComponent.setIcon(icon);
714
                renderComponent.setText (u.getDisplayName());
721
                renderComponent.setText (u.getDisplayName());
715
                renderComponent.setHorizontalAlignment(SwingConstants.LEFT);
722
                renderComponent.setHorizontalAlignment(SwingConstants.LEFT);
716
            }
723
            }
(-)autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Utilities.java (-20 / +22 lines)
Lines 81-92 Link Here
81
import org.netbeans.api.progress.ProgressHandleFactory;
81
import org.netbeans.api.progress.ProgressHandleFactory;
82
import org.openide.awt.HtmlBrowser;
82
import org.openide.awt.HtmlBrowser;
83
import org.openide.awt.Mnemonics;
83
import org.openide.awt.Mnemonics;
84
import org.openide.filesystems.FileObject;
84
import org.openide.util.Exceptions;
85
import org.openide.util.Exceptions;
85
import org.openide.util.NbBundle;
86
import org.openide.util.NbBundle;
86
import org.openide.util.NbPreferences;
87
import org.openide.util.NbPreferences;
87
import org.openide.util.RequestProcessor;
88
import org.openide.util.RequestProcessor;
88
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
89
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
89
import org.netbeans.modules.autoupdate.ui.actions.ShowNotifications;
90
import org.netbeans.modules.autoupdate.ui.actions.ShowNotifications;
91
import org.openide.filesystems.FileUtil;
92
import org.openide.util.ImageUtilities;
90
import org.openide.util.Task;
93
import org.openide.util.Task;
91
import org.openide.util.TaskListener;
94
import org.openide.util.TaskListener;
92
95
Lines 905-936 Link Here
905
    private static Preferences getPreferences () {
908
    private static Preferences getPreferences () {
906
        return NbPreferences.forModule (Utilities.class);
909
        return NbPreferences.forModule (Utilities.class);
907
    }
910
    }
911
912
    static FileObject getCategoryEntry(CATEGORY category) {
913
        FileObject categoryRoot =
914
            FileUtil.getConfigFile("Services/AutoupdateCategory/");
915
        FileObject categoryData = categoryRoot.getFileObject(category.name());
916
        if(categoryData == null)
917
          categoryData = categoryRoot.getFileObject(CATEGORY.COMMUNITY.name());
918
        return categoryData;
919
    }
908
    
920
    
909
    static String getCategoryName(CATEGORY category) {
921
    static String getCategoryName(CATEGORY category) {
910
        String key = null;
922
        FileObject categoryEntry = getCategoryEntry(category);
911
        switch (category) {
923
        if(categoryEntry == null)
912
            case STANDARD:
924
          return null;
913
                key = "AvailableTab_SourceCategory_Tooltip_STANDARD"; //NOI18N
925
        return (String)categoryEntry.getAttribute("displayName");
914
                break;
915
            case BETA:
916
                key = "AvailableTab_SourceCategory_Tooltip_BETA"; //NOI18N
917
                break;
918
            case COMMUNITY:
919
                key = "AvailableTab_SourceCategory_Tooltip_COMMUNITY"; //NOI18N
920
                break;
921
        }
922
        return (key != null) ? getBundle(key) : null;
923
    }
926
    }
924
    
927
    
925
    static URL getCategoryIcon(CATEGORY state) {
928
    static URL getCategoryIcon(CATEGORY state) {
929
        FileObject categoryEntry = getCategoryEntry(state);
930
        if(categoryEntry == null)
931
          return null;
932
        Object value=categoryEntry.getAttribute("iconResource");
926
        URL retval = null;
933
        URL retval = null;
927
        if (CATEGORY.BETA.equals(state)) {
934
        if(value instanceof URL)
928
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-beta.png"); // NOI18N
935
          retval = (URL)value;
929
        } else if (CATEGORY.COMMUNITY.equals(state)) {
930
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-community.png"); // NOI18N
931
        } else if (CATEGORY.STANDARD.equals(state)) {
932
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-standard.png"); // NOI18N
933
        }
934
        return retval;
936
        return retval;
935
    }    
937
    }    
936
}
938
}

Return to bug 183778