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

(-)a/autoupdate.services/apichanges.xml (+19 lines)
Lines 57-62 Link Here
57
    <!-- ACTUAL CHANGES BEGIN HERE: -->
57
    <!-- ACTUAL CHANGES BEGIN HERE: -->
58
58
59
    <changes>
59
    <changes>
60
        <change id="custom-icons">
61
            <api name="general"/>
62
            <summary>Icons for update centers</summary>
63
            <version major="1" minor="23"/>
64
            <date day="30" month="11" year="2010"/>
65
            <author login="jtulach"/>   
66
            <compatibility addition="yes" binary="compatible" deletion="no"
67
                deprecation="yes" semantic="compatible" source="compatible"  
68
            />
69
            <description>
70
                <p>
71
                Define icon when specifying an update center using 
72
                <code>categoryIconBase</code> attribute.
73
                </p>
74
            </description>
75
            <class package="org.netbeans.api.autoupdate" name="UpdateElement"/>
76
            <class package="org.netbeans.api.autoupdate" name="UpdateUnitProvider"/>
77
            <issue number="183778"/>
78
        </change>
60
        <change id="source-group-modifier">
79
        <change id="source-group-modifier">
61
            <api name="general"/>
80
            <api name="general"/>
62
            <summary>Feature enabled only when all its dependencies are enabled</summary>
81
            <summary>Feature enabled only when all its dependencies are enabled</summary>
(-)a/autoupdate.services/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.autoupdate.services
2
OpenIDE-Module: org.netbeans.modules.autoupdate.services
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/services/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/services/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.22
4
OpenIDE-Module-Specification-Version: 1.23
5
OpenIDE-Module-Layer: org/netbeans/modules/autoupdate/services/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/autoupdate/services/resources/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Essential-Module: true
7
AutoUpdate-Essential-Module: true
(-)a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateElement.java (+24 lines)
Lines 44-52 Link Here
44
44
45
package org.netbeans.api.autoupdate;
45
package org.netbeans.api.autoupdate;
46
46
47
import java.awt.Image;
47
import java.util.List;
48
import java.util.List;
48
import org.netbeans.modules.autoupdate.services.UpdateElementImpl;
49
import org.netbeans.modules.autoupdate.services.UpdateElementImpl;
49
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
50
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
51
import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl;
50
52
51
/** Instances provided by the <code>UpdateUnit</code> which represents specific version
53
/** Instances provided by the <code>UpdateUnit</code> which represents specific version
52
 * of update (e.g. module or feature). The <code>UpdateElement</code> can be installed,
54
 * of update (e.g. module or feature). The <code>UpdateElement</code> can be installed,
Lines 132-143 Link Here
132
    /**
134
    /**
133
     * @return <code>UpdateUnitProvider.CATEGORY</code> for a quality classification 
135
     * @return <code>UpdateUnitProvider.CATEGORY</code> for a quality classification 
134
     * for update represented by this instance
136
     * for update represented by this instance
137
     * @deprecated Use {@link #getSourceIcon()} and {@link #getSourceDescription()}.
135
     */
138
     */
139
    @Deprecated
136
    public CATEGORY getSourceCategory () {
140
    public CATEGORY getSourceCategory () {
137
        UpdateUnitProvider provider = getUpdateUnitProvider();
141
        UpdateUnitProvider provider = getUpdateUnitProvider();
138
        return (provider != null) ? provider.getCategory() : CATEGORY.COMMUNITY;
142
        return (provider != null) ? provider.getCategory() : CATEGORY.COMMUNITY;
139
    }
143
    }
140
    
144
    
145
    /** Provides an icon associated with the provider of this update element. 
146
     * @return icon representing the provider of this element
147
     * @since 1.23
148
     * @see UpdateUnitProvider#getSourceIcon() 
149
     */
150
    public Image getSourceIcon() {
151
        UpdateUnitProvider provider = getUpdateUnitProvider();
152
        return provider != null ? provider.getSourceIcon() : null;
153
    }
154
    
155
    /** Description of the provider of this element. 
156
     * @return textual description of the provider of this element
157
     * @since 1.23
158
     * @see UpdateUnitProvider#getSourceDescription()
159
     */
160
    public String getSourceDescription() {
161
        UpdateUnitProvider provider = getUpdateUnitProvider();
162
        return provider != null ? provider.getSourceDescription() : null;
163
    }
164
    
141
    private UpdateUnitProvider getUpdateUnitProvider() {
165
    private UpdateUnitProvider getUpdateUnitProvider() {
142
        String source = getSource();
166
        String source = getSource();
143
        UpdateUnitProvider retval = null;
167
        UpdateUnitProvider retval = null;
(-)a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProvider.java (-1 / +22 lines)
Lines 44-49 Link Here
44
44
45
package org.netbeans.api.autoupdate;
45
package org.netbeans.api.autoupdate;
46
46
47
import java.awt.Image;
47
import org.netbeans.spi.autoupdate.*;
48
import org.netbeans.spi.autoupdate.*;
48
import java.io.IOException;
49
import java.io.IOException;
49
import java.net.URL;
50
import java.net.URL;
Lines 106-115 Link Here
106
        return impl.getDescription ();
107
        return impl.getDescription ();
107
    }
108
    }
108
109
109
    
110
111
    /** @deprecated Use {@link #getSourceIcon()} and {@link #getSourceDescription()}.
112
     */
113
    @Deprecated
110
    public CATEGORY getCategory() {
114
    public CATEGORY getCategory() {
111
        return impl.getCategory();
115
        return impl.getCategory();
112
    }
116
    }
117
    
118
    /** The icon associated with this provider. 
119
     * @since 1.23
120
     * @see UpdateElement#getSourceIcon() 
121
     */
122
    public Image getSourceIcon() {
123
        return impl.getSourceIcon();
124
    }
125
126
    /** The description of this provider. Usually associated with {@link #getSourceIcon()}
127
     * @since 1.23
128
     * @return textual description of the provider
129
     * @see UpdateElement#getSourceDescription() 
130
     */
131
    public String getSourceDescription() {
132
        return impl.getSourceDescription();
133
    }
113
134
114
    /** It's special support for <code>UpdateProvider</code> based on Autoupdate Catalog.
135
    /** It's special support for <code>UpdateProvider</code> based on Autoupdate Catalog.
115
     * It's most kind of Update Providers and have a special support in UI.
136
     * It's most kind of Update Providers and have a special support in UI.
(-)a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProviderFactory.java (-3 / +9 lines)
Lines 44-55 Link Here
44
44
45
package org.netbeans.api.autoupdate;
45
package org.netbeans.api.autoupdate;
46
46
47
import java.awt.Image;
47
import java.io.File;
48
import java.io.File;
48
import java.io.IOException;
49
import java.io.IOException;
49
import java.net.URL;
50
import java.net.URL;
50
import java.util.List;
51
import java.util.List;
51
import org.netbeans.api.progress.ProgressHandle;
52
import org.netbeans.api.progress.ProgressHandle;
52
import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl;
53
import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl;
54
import org.netbeans.modules.autoupdate.updateprovider.ProviderCategory;
53
55
54
/** The factory handles <code>UpdateUnitProvider</code>, allow to create or removed them,
56
/** The factory handles <code>UpdateUnitProvider</code>, allow to create or removed them,
55
 * browse the providers or refresh its content.
57
 * browse the providers or refresh its content.
Lines 95-102 Link Here
95
     * comming from returned <code>UpdateUnitProvider</code>
97
     * comming from returned <code>UpdateUnitProvider</code>
96
     * @return URL-based UpdateUnitProvider
98
     * @return URL-based UpdateUnitProvider
97
     */        
99
     */        
98
    public UpdateUnitProvider create (String name, String displayName, URL url, UpdateUnitProvider.CATEGORY  category) {
100
    public UpdateUnitProvider create (String name, String displayName, URL url, UpdateUnitProvider.CATEGORY category) {
99
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, category);
101
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.forValue(category));
102
    }
103
104
    public UpdateUnitProvider create (String name, String displayName, URL url, String categoryIconBase, String categoryDisplayName) {
105
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.create(categoryIconBase, categoryDisplayName));
100
    }
106
    }
101
107
102
    /** Creates new <code>UpdateUnitProvider</code> and store its preferences. The new provider 
108
    /** Creates new <code>UpdateUnitProvider</code> and store its preferences. The new provider 
Lines 109-115 Link Here
109
     * @return URL-based UpdateUnitProvider
115
     * @return URL-based UpdateUnitProvider
110
     */    
116
     */    
111
    public UpdateUnitProvider create (String name, String displayName, URL url) {
117
    public UpdateUnitProvider create (String name, String displayName, URL url) {
112
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, UpdateUnitProvider.CATEGORY.COMMUNITY);
118
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.forValue(UpdateUnitProvider.CATEGORY.COMMUNITY));
113
    }
119
    }
114
    
120
    
115
    /** Creates new <code>UpdateUnitProvider</code> for temporary usage. This provider contains
121
    /** Creates new <code>UpdateUnitProvider</code> for temporary usage. This provider contains
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/UpdateUnitProviderImpl.java (-7 / +32 lines)
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
        
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogFactory.java (-3 / +12 lines)
Lines 86-91 Link Here
86
    public static final String ORIGINAL_DISPLAY_NAME = "originalDisplayName"; // NOI18N
86
    public static final String ORIGINAL_DISPLAY_NAME = "originalDisplayName"; // NOI18N
87
    public static final String ORIGINAL_ENABLED = "originalEnabled"; // NOI18N
87
    public static final String ORIGINAL_ENABLED = "originalEnabled"; // NOI18N
88
    public static final String ORIGINAL_CATEGORY_NAME = "originalCategoryName"; // NOI18N
88
    public static final String ORIGINAL_CATEGORY_NAME = "originalCategoryName"; // NOI18N
89
    public static final String ORIGINAL_CATEGORY_ICON_BASE = "originalCategoryIconBase"; // NOI18N
89
    
90
    
90
    public static UpdateProvider createUpdateProvider (FileObject fo) {
91
    public static UpdateProvider createUpdateProvider (FileObject fo) {
91
        String sKey = (String) fo.getAttribute ("url_key"); // NOI18N
92
        String sKey = (String) fo.getAttribute ("url_key"); // NOI18N
Lines 127-139 Link Here
127
        }
128
        }
128
        url = modifyURL (url);
129
        url = modifyURL (url);
129
        String categoryName = (String) fo.getAttribute ("category"); // NOI18N    
130
        String categoryName = (String) fo.getAttribute ("category"); // NOI18N    
130
        CATEGORY category = (categoryName != null) ? CATEGORY.valueOf(categoryName) : CATEGORY.COMMUNITY;
131
        String categoryIconBase = (String) fo.getAttribute ("categoryIconBase"); // NOI18N
131
        AutoupdateCatalogProvider au_catalog = new AutoupdateCatalogProvider(name, displayName(fo), url, category);
132
        
133
        Preferences providerPreferences = getPreferences().node(name);
132
        Preferences providerPreferences = getPreferences().node(name);
133
        ProviderCategory pc;
134
        if (categoryIconBase != null) {
135
            pc = ProviderCategory.create(categoryIconBase, categoryName);
136
            providerPreferences.put (ORIGINAL_CATEGORY_ICON_BASE, categoryIconBase);
137
        } else {
138
            CATEGORY category = (categoryName != null) ? CATEGORY.valueOf(categoryName) : CATEGORY.COMMUNITY;
139
            pc = ProviderCategory.forValue(category);
140
        }
141
        AutoupdateCatalogProvider au_catalog = new AutoupdateCatalogProvider(name, displayName(fo), url, pc);
134
        providerPreferences.put (ORIGINAL_URL, url.toExternalForm ());
142
        providerPreferences.put (ORIGINAL_URL, url.toExternalForm ());
135
        providerPreferences.put (ORIGINAL_DISPLAY_NAME, au_catalog.getDisplayName ());
143
        providerPreferences.put (ORIGINAL_DISPLAY_NAME, au_catalog.getDisplayName ());
136
        providerPreferences.put (ORIGINAL_CATEGORY_NAME, au_catalog.getCategory().name());        
144
        providerPreferences.put (ORIGINAL_CATEGORY_NAME, au_catalog.getCategory().name());        
145
        
137
        Boolean en = (Boolean) fo.getAttribute("enabled"); // NOI18N        
146
        Boolean en = (Boolean) fo.getAttribute("enabled"); // NOI18N        
138
        if (en != null) {
147
        if (en != null) {
139
            providerPreferences.putBoolean (ORIGINAL_ENABLED, en);
148
            providerPreferences.putBoolean (ORIGINAL_ENABLED, en);
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogProvider.java (-6 / +14 lines)
Lines 64-87 Link Here
64
    private final String codeName;
64
    private final String codeName;
65
    private String displayName;
65
    private String displayName;
66
    private AutoupdateCatalogCache cache = AutoupdateCatalogCache.getDefault ();
66
    private AutoupdateCatalogCache cache = AutoupdateCatalogCache.getDefault ();
67
    private Logger log = Logger.getLogger ("org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalog");
67
    private static final Logger log = Logger.getLogger ("org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalog");
68
    private String description = null;
68
    private String description = null;
69
    private boolean descriptionInitialized = false;
69
    private boolean descriptionInitialized = false;
70
    private CATEGORY category = null;
70
    private ProviderCategory category = null;
71
71
72
    public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter) {
72
    public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter) {
73
        this(name, displayName, updateCenter, CATEGORY.COMMUNITY);
73
        this(name, displayName, updateCenter, ProviderCategory.forValue(CATEGORY.COMMUNITY));
74
    }
74
    }
75
    
75
    
76
    /**
76
    /**
77
     * Creates a new instance of AutoupdateCatalog
77
     * Creates a new instance of AutoupdateCatalog
78
     */
78
     */
79
    public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter, CATEGORY category) {
79
    public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter, ProviderCategory category) {
80
        Parameters.notNull("name", name);
80
        Parameters.notNull("name", name);
81
        this.codeName = name;
81
        this.codeName = name;
82
        this.displayName = displayName;
82
        this.displayName = displayName;
83
        this.updateCenter = updateCenter;
83
        this.updateCenter = updateCenter;
84
        this.category = (category != null) ? category : CATEGORY.COMMUNITY;
84
        this.category = category;
85
    }
86
    public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter, CATEGORY category) {
87
        this(name, displayName, updateCenter, ProviderCategory.forValue(category));
85
    }
88
    }
86
    
89
    
87
    public String getName () {
90
    public String getName () {
Lines 150-156 Link Here
150
        return displayName + "[" + codeName + "] to " + updateCenter;
153
        return displayName + "[" + codeName + "] to " + updateCenter;
151
    }
154
    }
152
155
156
    @Override
153
    public CATEGORY getCategory() {
157
    public CATEGORY getCategory() {
158
        return category.toEnum();
159
    }    
160
    
161
    public ProviderCategory getProviderCategory() {
154
        return category;
162
        return category;
155
    }    
163
    }
156
}
164
}
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/Bundle.properties (+4 lines)
Lines 7-9 Link Here
7
ArtificialFeaturesProvider_Unsorted_Category=Uncategorized
7
ArtificialFeaturesProvider_Unsorted_Category=Uncategorized
8
ArtificialFeaturesProvider_Features_Category=Features
8
ArtificialFeaturesProvider_Features_Category=Features
9
NetworkAccess_Timeout=Timeout while opening connection to {0}
9
NetworkAccess_Timeout=Timeout while opening connection to {0}
10
11
AvailableTab_SourceCategory_Tooltip_STANDARD=Certified Plugin
12
AvailableTab_SourceCategory_Tooltip_BETA=Beta Plugin
13
AvailableTab_SourceCategory_Tooltip_COMMUNITY=Community Contributed Plugin
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/ProviderCategory.java (+115 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.autoupdate.updateprovider;
44
45
import java.awt.Image;
46
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
47
import org.openide.util.ImageUtilities;
48
import org.openide.util.NbBundle;
49
50
/** Represents provider category.
51
 *
52
 * @author Jaroslav Tulach <jtulach@netbeans.org>
53
 */
54
public final class ProviderCategory {
55
    private final String displayName;
56
    private final String iconBase;
57
    private final CATEGORY category;
58
59
    private ProviderCategory(String displayName, String iconBase, CATEGORY category) {
60
        assert (category != null) != (displayName != null && iconBase != null) : 
61
            "Category: " + category + " displayName: " + displayName
62
                    + " iconBase: " + iconBase;
63
        this.displayName = displayName;
64
        this.iconBase = iconBase;
65
        this.category = category;
66
    }
67
68
    public static ProviderCategory create(String iconBase, String categoryDisplayName) {
69
        return new ProviderCategory(categoryDisplayName, iconBase, null);
70
    }
71
    public String getDisplayName() {
72
        return category != null ? getCategoryName(category) : displayName; 
73
    }
74
    public Image getIcon() {
75
        return ImageUtilities.loadImage(getIconBase());
76
    }
77
    
78
    public static ProviderCategory forValue(CATEGORY c) {
79
        return new ProviderCategory(null, null, c);
80
    }
81
82
    CATEGORY toEnum() {
83
        return category == null ? CATEGORY.COMMUNITY : category;
84
    }
85
    
86
    static String getCategoryName(CATEGORY category) {
87
        String key = null;
88
        switch (category) {
89
            case STANDARD:
90
                key = "AvailableTab_SourceCategory_Tooltip_STANDARD"; //NOI18N
91
                break;
92
            case BETA:
93
                key = "AvailableTab_SourceCategory_Tooltip_BETA"; //NOI18N
94
                break;
95
            case COMMUNITY:
96
                key = "AvailableTab_SourceCategory_Tooltip_COMMUNITY"; //NOI18N
97
                break;
98
        }
99
        return (key != null) ? NbBundle.getMessage(ProviderCategory.class, key) : null;
100
    }
101
    
102
    String getIconBase() {
103
        if (iconBase != null) {
104
            return iconBase;
105
        }
106
        switch (category) {
107
            case BETA: 
108
                return "org/netbeans/modules/autoupdate/services/resources/icon-beta.png"; // NOI18N
109
            case STANDARD:
110
                return "org/netbeans/modules/autoupdate/services/resources/icon-standard.png"; // NOI18N
111
            default:
112
                return "org/netbeans/modules/autoupdate/services/resources/icon-community.png"; // NOI18N
113
        }
114
    }
115
}
(-)a/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/DeclarationOfUpdateUnitProviderTest.java (-4 lines)
Lines 44-56 Link Here
44
44
45
package org.netbeans.api.autoupdate;
45
package org.netbeans.api.autoupdate;
46
46
47
import java.net.URL;
48
import java.util.List;
47
import java.util.List;
49
import junit.framework.TestCase;
50
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
48
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
51
import org.netbeans.api.progress.ProgressHandle;
52
import org.netbeans.junit.NbTestCase;
49
import org.netbeans.junit.NbTestCase;
53
import org.openide.filesystems.Repository;
54
50
55
/**
51
/**
56
 *
52
 *
(-)a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/UpdateUnitProviderImplTest.java (-1 / +4 lines)
Lines 170-176 Link Here
170
        String displayName = "2nd Update Provider";
170
        String displayName = "2nd Update Provider";
171
        URL url = URL_TO_TEST_CATALOG;
171
        URL url = URL_TO_TEST_CATALOG;
172
        
172
        
173
        UpdateUnitProvider newProvider = UpdateUnitProviderImpl.createUpdateUnitProvider(codeName, displayName, url, CATEGORY.COMMUNITY);
173
        UpdateUnitProvider newProvider = UpdateUnitProviderImpl.createUpdateUnitProvider(
174
            codeName, displayName, url, 
175
            ProviderCategory.forValue(CATEGORY.COMMUNITY)
176
        );
174
        assertNotNull(codeName + " provider found.", newProvider);
177
        assertNotNull(codeName + " provider found.", newProvider);
175
        
178
        
176
        result = UpdateUnitProviderImpl.getUpdateUnitProviders(false);
179
        result = UpdateUnitProviderImpl.getUpdateUnitProviders(false);
(-)a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogFactoryTest.java (-8 / +27 lines)
Lines 40-68 Link Here
40
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
41
 */
41
 */
42
42
43
package org.netbeans.modules.autoupdate.updateprovider;
43
package org.netbeans.modules.autoupdate.services;
44
44
45
import org.netbeans.modules.autoupdate.updateprovider.*;
46
import java.awt.Image;
45
import java.net.URL;
47
import java.net.URL;
48
import org.netbeans.api.autoupdate.UpdateUnitProvider;
49
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory;
46
import org.netbeans.junit.NbTestCase;
50
import org.netbeans.junit.NbTestCase;
47
import org.netbeans.spi.autoupdate.UpdateProvider;
51
import org.netbeans.spi.autoupdate.UpdateProvider;
48
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileObject;
49
import org.openide.filesystems.FileUtil;
53
import org.openide.filesystems.FileUtil;
54
import org.openide.util.ImageUtilities;
50
55
51
public class AutoupdateCatalogFactoryTest extends NbTestCase {
56
public class UpdateUnitProviderTest extends NbTestCase {
52
57
53
    public AutoupdateCatalogFactoryTest(String n) {
58
    public UpdateUnitProviderTest(String n) {
54
        super(n);
59
        super(n);
55
    }
60
    }
56
61
57
    public void testCreateUpdateProvider() throws Exception {
62
    public void testCreateUpdateProviderWithOwnIcon() throws Exception {
58
        FileObject f = FileUtil.getConfigRoot().createData("whatever.instance");
63
        FileObject f = FileUtil.getConfigRoot().createData("whatever.instance");
59
        f.setAttribute("url", "file:/wherever.xml");
64
        f.setAttribute("url", "file:/wherever.xml");
60
        f.setAttribute("displayName", "Whatever");
65
        f.setAttribute("displayName", "Whatever");
66
        f.setAttribute("category", "Jarda's Updates");
67
        f.setAttribute("categoryIconBase", "org/netbeans/modules/autoupdate/services/resources/icon-standard.png");
61
        UpdateProvider up = AutoupdateCatalogFactory.createUpdateProvider(f);
68
        UpdateProvider up = AutoupdateCatalogFactory.createUpdateProvider(f);
62
        assertEquals("whatever", up.getName());
69
        UpdateUnitProvider uup = Trampoline.API.createUpdateUnitProvider (new UpdateUnitProviderImpl (up));
63
        assertEquals("Whatever", up.getDisplayName());
70
        assertEquals("whatever", uup.getName());
64
        assertEquals(AutoupdateCatalogProvider.class, up.getClass());
71
        assertEquals("Whatever", uup.getDisplayName());
65
        assertEquals(new URL("file:/wherever.xml"), ((AutoupdateCatalogProvider) up).getUpdateCenterURL());
72
        assertEquals(new URL("file:/wherever.xml"), uup.getProviderURL());
73
        Image img = ImageUtilities.loadImage("org/netbeans/modules/autoupdate/services/resources/icon-standard.png");
74
        assertEquals("Icons are the same", img, uup.getSourceIcon());
66
    }
75
    }
67
76
77
    public void testFactoryMethodsAndIcons() throws Exception {
78
        Image img = ImageUtilities.loadImage("org/netbeans/modules/autoupdate/services/resources/icon-standard.png");
79
        UpdateUnitProvider res = UpdateUnitProviderFactory.getDefault().create(
80
           "code-name", "Whatever", new URL("file:/whereever.xml"), 
81
           "org/netbeans/modules/autoupdate/services/resources/icon-standard.png", "my category"
82
        );
83
        assertEquals("code-name", res.getName());
84
        assertEquals("Whatever", res.getDisplayName());
85
        assertEquals("Good image", img, res.getSourceIcon());
86
    }
68
}
87
}
(-)a/autoupdate.ui/nbproject/project.xml (-1 / +1 lines)
Lines 19-25 Link Here
19
                    <build-prerequisite/>
19
                    <build-prerequisite/>
20
                    <compile-dependency/>
20
                    <compile-dependency/>
21
                    <run-dependency>
21
                    <run-dependency>
22
                        <specification-version>1.12</specification-version>
22
                        <specification-version>1.23</specification-version>
23
                    </run-dependency>
23
                    </run-dependency>
24
                </dependency>
24
                </dependency>
25
                <dependency>
25
                <dependency>
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/AvailableTableModel.java (-5 / +6 lines)
Lines 44-49 Link Here
44
44
45
package org.netbeans.modules.autoupdate.ui;
45
package org.netbeans.modules.autoupdate.ui;
46
46
47
import java.awt.Image;
47
import java.util.Comparator;
48
import java.util.Comparator;
48
import java.util.HashSet;
49
import java.util.HashSet;
49
import java.util.List;
50
import java.util.List;
Lines 53-59 Link Here
53
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
54
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
54
import org.netbeans.api.autoupdate.UpdateElement;
55
import org.netbeans.api.autoupdate.UpdateElement;
55
import org.netbeans.api.autoupdate.UpdateUnit;
56
import org.netbeans.api.autoupdate.UpdateUnit;
56
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
57
import org.openide.DialogDisplayer;
57
import org.openide.DialogDisplayer;
58
import org.openide.NotifyDescriptor;
58
import org.openide.NotifyDescriptor;
59
import org.openide.util.NbBundle;
59
import org.openide.util.NbBundle;
Lines 125-131 Link Here
125
            res = u.getCategoryName();
125
            res = u.getCategoryName();
126
            break;
126
            break;
127
        case 3 :
127
        case 3 :
128
            res = u.getSourceCategory();
128
            res = u.getSourceIcon();
129
            break;
129
            break;
130
        }
130
        }
131
        
131
        
Lines 150-156 Link Here
150
            res = String.class;
150
            res = String.class;
151
            break;
151
            break;
152
        case 3 :
152
        case 3 :
153
            res = CATEGORY.class;
153
            res = Image.class;
154
            break;
154
            break;
155
        }
155
        }
156
        
156
        
Lines 189-200 Link Here
189
    @Override
189
    @Override
190
    public String getToolTipText(int row, int col) {
190
    public String getToolTipText(int row, int col) {
191
        if (col == 3) {
191
        if (col == 3) {
192
            CATEGORY category = (CATEGORY) getValueAt (row, 3);
192
            Unit.Available u = (Unit.Available) getUnitAtRow(row);
193
            return Utilities.getCategoryName(category);
193
            return u.getSourceDescription();
194
        }
194
        }
195
        return super.getToolTipText(row, col);
195
        return super.getToolTipText(row, col);
196
    }
196
    }
197
197
198
    @Override
198
    public int getPreferredWidth(JTableHeader header, int col) {
199
    public int getPreferredWidth(JTableHeader header, int col) {
199
        final int minWidth = super.getMinWidth(header, col);
200
        final int minWidth = super.getMinWidth(header, col);
200
        switch (col) {
201
        switch (col) {
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Bundle.properties (-3 lines)
Lines 21-29 Link Here
21
UnitTab_ActivateCategoryAction=Activate Category
21
UnitTab_ActivateCategoryAction=Activate Category
22
UnitTab_DeactivateAction=&Deactivate
22
UnitTab_DeactivateAction=&Deactivate
23
UnitTab_DeactivateCategoryAction=Deactivate Category
23
UnitTab_DeactivateCategoryAction=Deactivate Category
24
AvailableTab_SourceCategory_Tooltip_STANDARD=Certified Plugin
25
AvailableTab_SourceCategory_Tooltip_BETA=Beta Plugin
26
AvailableTab_SourceCategory_Tooltip_COMMUNITY=Community Contributed Plugin
27
InstallTab_Active_Tooltip=Active
24
InstallTab_Active_Tooltip=Active
28
InstallTab_InActive_Tooltip=Inactive
25
InstallTab_InActive_Tooltip=Inactive
29
InstallTab_PendingForInstall_Tooltip=Application restart needed to complete installation
26
InstallTab_PendingForInstall_Tooltip=Application restart needed to complete installation
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/HTMLEditorKitEx.java (-18 / +1 lines)
Lines 44-72 Link Here
44
package org.netbeans.modules.autoupdate.ui;
44
package org.netbeans.modules.autoupdate.ui;
45
45
46
import java.awt.Image;
46
import java.awt.Image;
47
import java.net.URL;
48
import java.util.HashMap;
49
import java.util.Map;
50
import javax.swing.ImageIcon;
51
import javax.swing.text.html.*;
47
import javax.swing.text.html.*;
52
import javax.swing.text.*;
48
import javax.swing.text.*;
53
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
54
49
55
/**
50
/**
56
 * @author Radek Matous
51
 * @author Radek Matous
57
 */
52
 */
58
public class HTMLEditorKitEx extends HTMLEditorKit {
53
public class HTMLEditorKitEx extends HTMLEditorKit {
59
    private static final Map<URL,ImageIcon> ICONS = new HashMap<URL,ImageIcon>();
60
    static {
61
        URL u_standard = Utilities.getCategoryIcon(CATEGORY.STANDARD);
62
        ICONS.put(u_standard, new ImageIcon(u_standard));
63
64
        URL u_beta = Utilities.getCategoryIcon(CATEGORY.BETA);
65
        ICONS.put(u_beta, new ImageIcon(u_beta));
66
67
        URL u_community = Utilities.getCategoryIcon(CATEGORY.COMMUNITY);
68
        ICONS.put(u_community, new ImageIcon(u_community));
69
    }
70
54
71
    public ViewFactory getViewFactory() {
55
    public ViewFactory getViewFactory() {
72
        return new HTMLFactory() {
56
        return new HTMLFactory() {
Lines 85-92 Link Here
85
69
86
        @Override
70
        @Override
87
        public Image getImage() {
71
        public Image getImage() {
88
            ImageIcon img = ICONS.get(getImageURL());
72
            return super.getImage();
89
            return (img != null) ? img.getImage() : super.getImage();
90
        }
73
        }
91
    }
74
    }
92
}
75
}
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.form (-1 / +1 lines)
Lines 1-4 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
1
<?xml version="1.1" encoding="UTF-8" ?>
2
2
3
<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <NonVisualComponents>
4
  <NonVisualComponents>
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.java (-10 / +5 lines)
Lines 48-53 Link Here
48
import java.awt.Component;
48
import java.awt.Component;
49
import java.awt.Dimension;
49
import java.awt.Dimension;
50
import java.awt.EventQueue;
50
import java.awt.EventQueue;
51
import java.awt.Image;
51
import java.awt.event.ActionEvent;
52
import java.awt.event.ActionEvent;
52
import java.awt.event.ActionListener;
53
import java.awt.event.ActionListener;
53
import java.io.File;
54
import java.io.File;
Lines 63-75 Link Here
63
import javax.swing.AbstractAction;
64
import javax.swing.AbstractAction;
64
import javax.swing.Action;
65
import javax.swing.Action;
65
import javax.swing.DefaultComboBoxModel;
66
import javax.swing.DefaultComboBoxModel;
67
import javax.swing.Icon;
66
import javax.swing.JButton;
68
import javax.swing.JButton;
67
import javax.swing.JLabel;
69
import javax.swing.JLabel;
68
import javax.swing.JScrollPane;
70
import javax.swing.JScrollPane;
69
import javax.swing.JTable;
71
import javax.swing.JTable;
70
import javax.swing.ListSelectionModel;
72
import javax.swing.ListSelectionModel;
71
import javax.swing.SwingConstants;
73
import javax.swing.SwingConstants;
72
import javax.swing.SwingUtilities;
73
import javax.swing.UIManager;
74
import javax.swing.UIManager;
74
import javax.swing.event.ListSelectionEvent;
75
import javax.swing.event.ListSelectionEvent;
75
import javax.swing.event.ListSelectionListener;
76
import javax.swing.event.ListSelectionListener;
Lines 80-86 Link Here
80
import javax.swing.table.TableColumn;
81
import javax.swing.table.TableColumn;
81
import javax.swing.table.TableColumnModel;
82
import javax.swing.table.TableColumnModel;
82
import org.netbeans.api.autoupdate.UpdateUnitProvider;
83
import org.netbeans.api.autoupdate.UpdateUnitProvider;
83
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
84
import org.netbeans.api.options.OptionsDisplayer;
84
import org.netbeans.api.options.OptionsDisplayer;
85
import org.netbeans.modules.autoupdate.ui.actions.AutoupdateSettings;
85
import org.netbeans.modules.autoupdate.ui.actions.AutoupdateSettings;
86
import org.openide.DialogDescriptor;
86
import org.openide.DialogDescriptor;
Lines 717-730 Link Here
717
717
718
            if (value instanceof UpdateUnitProvider) {
718
            if (value instanceof UpdateUnitProvider) {
719
                UpdateUnitProvider u = (UpdateUnitProvider) value;
719
                UpdateUnitProvider u = (UpdateUnitProvider) value;
720
                CATEGORY state = u.getCategory();
720
                Image img = u.getSourceIcon();
721
                if (CATEGORY.BETA.equals(state)) {
721
                final Icon icon = ImageUtilities.image2Icon(img);
722
                    renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-beta.png", false)); // NOI18N
722
                renderComponent.setIcon(icon);
723
                } else if (CATEGORY.COMMUNITY.equals(state)) {
724
                    renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-community.png", false)); // NOI18N
725
                } else if (CATEGORY.STANDARD.equals(state)) {
726
                    renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-standard.png", false)); // NOI18N
727
                }
728
                renderComponent.setText (u.getDisplayName());
723
                renderComponent.setText (u.getDisplayName());
729
                renderComponent.setHorizontalAlignment(SwingConstants.LEFT);
724
                renderComponent.setHorizontalAlignment(SwingConstants.LEFT);
730
            }
725
            }
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Unit.java (-4 / +7 lines)
Lines 44-49 Link Here
44
44
45
package org.netbeans.modules.autoupdate.ui;
45
package org.netbeans.modules.autoupdate.ui;
46
46
47
import java.awt.Image;
47
import java.text.Collator;
48
import java.text.Collator;
48
import java.text.DateFormat;
49
import java.text.DateFormat;
49
import java.text.ParseException;
50
import java.text.ParseException;
Lines 61-67 Link Here
61
import org.netbeans.api.autoupdate.UpdateElement;
62
import org.netbeans.api.autoupdate.UpdateElement;
62
import org.netbeans.api.autoupdate.UpdateManager;
63
import org.netbeans.api.autoupdate.UpdateManager;
63
import org.netbeans.api.autoupdate.UpdateUnit;
64
import org.netbeans.api.autoupdate.UpdateUnit;
64
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
65
import org.netbeans.modules.autoupdate.ui.UnitCategoryTableModel.Type;
65
import org.netbeans.modules.autoupdate.ui.UnitCategoryTableModel.Type;
66
import org.openide.modules.SpecificationVersion;
66
import org.openide.modules.SpecificationVersion;
67
import org.openide.util.NbBundle;
67
import org.openide.util.NbBundle;
Lines 654-660 Link Here
654
            if (u1 instanceof Unit.Available && u2 instanceof Unit.Available) {
654
            if (u1 instanceof Unit.Available && u2 instanceof Unit.Available) {
655
                Unit.Available unit1 = (Unit.Available)u1;
655
                Unit.Available unit1 = (Unit.Available)u1;
656
                Unit.Available unit2 = (Unit.Available)u2;
656
                Unit.Available unit2 = (Unit.Available)u2;
657
                return Collator.getInstance().compare(unit1.getSourceCategory().name(), unit2.getSourceCategory().name());
657
                return Collator.getInstance().compare(unit1.getSourceDescription(), unit2.getSourceDescription());
658
            }
658
            }
659
            
659
            
660
            throw new IllegalStateException();
660
            throw new IllegalStateException();
Lines 695-702 Link Here
695
            return (isNbms) ? UnitCategoryTableModel.Type.LOCAL : UnitCategoryTableModel.Type.AVAILABLE;
695
            return (isNbms) ? UnitCategoryTableModel.Type.LOCAL : UnitCategoryTableModel.Type.AVAILABLE;
696
        }        
696
        }        
697
        
697
        
698
        public CATEGORY getSourceCategory() {
698
        public Image getSourceIcon() {
699
            return updateEl.getSourceCategory();
699
            return updateEl.getSourceIcon();
700
        }
701
        public String getSourceDescription() {
702
            return updateEl.getSourceDescription();
700
        }
703
        }
701
    }
704
    }
702
705
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitDetails.java (-6 / +5 lines)
Lines 44-51 Link Here
44
package org.netbeans.modules.autoupdate.ui;
44
package org.netbeans.modules.autoupdate.ui;
45
45
46
import java.awt.Color;
46
import java.awt.Color;
47
import java.awt.Image;
47
import java.io.CharConversionException;
48
import java.io.CharConversionException;
48
import java.net.URL;
49
import java.util.ArrayList;
49
import java.util.ArrayList;
50
import java.util.Comparator;
50
import java.util.Comparator;
51
import java.util.HashSet;
51
import java.util.HashSet;
Lines 63-69 Link Here
63
import org.netbeans.api.autoupdate.UpdateElement;
63
import org.netbeans.api.autoupdate.UpdateElement;
64
import org.netbeans.api.autoupdate.UpdateManager;
64
import org.netbeans.api.autoupdate.UpdateManager;
65
import org.netbeans.api.autoupdate.UpdateUnit;
65
import org.netbeans.api.autoupdate.UpdateUnit;
66
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
67
import org.openide.util.NbBundle;
66
import org.openide.util.NbBundle;
68
import org.openide.util.RequestProcessor;
67
import org.openide.util.RequestProcessor;
69
import org.openide.xml.XMLUtil;
68
import org.openide.xml.XMLUtil;
Lines 131-141 Link Here
131
        StringBuilder text = new StringBuilder();
130
        StringBuilder text = new StringBuilder();
132
        if (u instanceof Unit.Available) {
131
        if (u instanceof Unit.Available) {
133
            Unit.Available u1 = (Unit.Available) u;
132
            Unit.Available u1 = (Unit.Available) u;
134
            CATEGORY c = u1.getSourceCategory();
133
            Image c = u1.getSourceIcon();
135
            String categoryName = Utilities.getCategoryName(c);
134
            String categoryName = u1.getSourceDescription();
136
            URL icon = Utilities.getCategoryIcon(c);
137
            text.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
135
            text.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
138
            text.append("<td><img src=\"" + icon.toExternalForm() + "\"></img></td>");
136
// XXX: regression?           text.append("<td><img src=\"" + icon.toExternalForm() + "\"></img></td>");
137
            text.append("<td></td>");
139
            text.append("<td>&nbsp;&nbsp;</td>");
138
            text.append("<td>&nbsp;&nbsp;</td>");
140
            text.append("<td><b>" + categoryName + "</b></td>");
139
            text.append("<td><b>" + categoryName + "</b></td>");
141
            text.append("</tr></table><br>");
140
            text.append("</tr></table><br>");
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitTab.java (-5 / +3 lines)
Lines 50-55 Link Here
50
import org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard;
50
import org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard;
51
import java.awt.Component;
51
import java.awt.Component;
52
import java.awt.Cursor;
52
import java.awt.Cursor;
53
import java.awt.Image;
53
import java.awt.Point;
54
import java.awt.Point;
54
import java.awt.Rectangle;
55
import java.awt.Rectangle;
55
import java.awt.event.ActionEvent;
56
import java.awt.event.ActionEvent;
Lines 100-106 Link Here
100
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
101
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
101
import org.netbeans.api.autoupdate.UpdateManager;
102
import org.netbeans.api.autoupdate.UpdateManager;
102
import org.netbeans.api.autoupdate.UpdateUnit;
103
import org.netbeans.api.autoupdate.UpdateUnit;
103
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
104
import org.netbeans.api.progress.ProgressHandle;
104
import org.netbeans.api.progress.ProgressHandle;
105
import org.netbeans.api.progress.ProgressHandleFactory;
105
import org.netbeans.api.progress.ProgressHandleFactory;
106
import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
106
import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
Lines 1971-1983 Link Here
1971
                JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
1971
                JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
1972
            JLabel renderComponent = (JLabel)super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
1972
            JLabel renderComponent = (JLabel)super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
1973
            
1973
            
1974
            if (value instanceof CATEGORY) {
1974
            if (value instanceof Image) {
1975
                Unit u = model.getUnitAtRow (row);
1975
                Unit u = model.getUnitAtRow (row);
1976
                if (u instanceof Unit.Available) {
1976
                if (u instanceof Unit.Available) {
1977
                    Unit.Available a = (Unit.Available)u;
1977
                    Unit.Available a = (Unit.Available)u;
1978
                    CATEGORY state = a.getSourceCategory();
1978
                    renderComponent.setIcon(ImageUtilities.image2Icon(a.getSourceIcon()));
1979
                    URL icon = Utilities.getCategoryIcon(state);
1980
                    renderComponent.setIcon(new ImageIcon(icon));
1981
                    renderComponent.setText ("");
1979
                    renderComponent.setText ("");
1982
                    renderComponent.setHorizontalAlignment (SwingConstants.CENTER);
1980
                    renderComponent.setHorizontalAlignment (SwingConstants.CENTER);
1983
                }
1981
                }
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Utilities.java (-28 lines)
Lines 85-91 Link Here
85
import org.openide.util.NbBundle;
85
import org.openide.util.NbBundle;
86
import org.openide.util.NbPreferences;
86
import org.openide.util.NbPreferences;
87
import org.openide.util.RequestProcessor;
87
import org.openide.util.RequestProcessor;
88
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
89
import org.netbeans.modules.autoupdate.ui.actions.Installer;
88
import org.netbeans.modules.autoupdate.ui.actions.Installer;
90
import org.netbeans.modules.autoupdate.ui.actions.ShowNotifications;
89
import org.netbeans.modules.autoupdate.ui.actions.ShowNotifications;
91
import org.openide.util.Task;
90
import org.openide.util.Task;
Lines 908-938 Link Here
908
        return NbPreferences.forModule (Utilities.class);
907
        return NbPreferences.forModule (Utilities.class);
909
    }
908
    }
910
    
909
    
911
    static String getCategoryName(CATEGORY category) {
912
        String key = null;
913
        switch (category) {
914
            case STANDARD:
915
                key = "AvailableTab_SourceCategory_Tooltip_STANDARD"; //NOI18N
916
                break;
917
            case BETA:
918
                key = "AvailableTab_SourceCategory_Tooltip_BETA"; //NOI18N
919
                break;
920
            case COMMUNITY:
921
                key = "AvailableTab_SourceCategory_Tooltip_COMMUNITY"; //NOI18N
922
                break;
923
        }
924
        return (key != null) ? getBundle(key) : null;
925
    }
926
    
927
    static URL getCategoryIcon(CATEGORY state) {
928
        URL retval = null;
929
        if (CATEGORY.BETA.equals(state)) {
930
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-beta.png"); // NOI18N
931
        } else if (CATEGORY.COMMUNITY.equals(state)) {
932
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-community.png"); // NOI18N
933
        } else if (CATEGORY.STANDARD.equals(state)) {
934
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-standard.png"); // NOI18N
935
        }
936
        return retval;
937
    }    
938
}
910
}

Return to bug 183778