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.updateprovider.ProviderCategory;
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() : ProviderCategory.forValue(CATEGORY.COMMUNITY).getIcon();
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() : ProviderCategory.forValue(CATEGORY.COMMUNITY).getDisplayName();
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 / +26 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. In case no specific icon is 
119
     * associated, a general one is returned.
120
     * 
121
     * @since 1.23
122
     * @see UpdateElement#getSourceIcon() 
123
     */
124
    public Image getSourceIcon() {
125
        return impl.getSourceIcon();
126
    }
127
128
    /** The description of this provider. Usually associated with {@link #getSourceIcon()}.
129
     * In case no special description is found, a general one is returned.
130
     * 
131
     * @since 1.23
132
     * @return textual description of the provider
133
     * @see UpdateElement#getSourceDescription() 
134
     */
135
    public String getSourceDescription() {
136
        return impl.getSourceDescription();
137
    }
113
138
114
    /** It's special support for <code>UpdateProvider</code> based on Autoupdate Catalog.
139
    /** 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.
140
     * 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 / +17 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(
99
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, category);
101
        String name, String displayName, URL url, UpdateUnitProvider.CATEGORY category
102
    ) {
103
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.forValue(category));
104
    }
105
106
    /** 
107
     * @since 1.23
108
     */
109
    public UpdateUnitProvider create(
110
        String name, String displayName, URL url,
111
        String categoryIconBase, String categoryDisplayName
112
    ) {
113
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.create(categoryIconBase, categoryDisplayName));
100
    }
114
    }
101
115
102
    /** Creates new <code>UpdateUnitProvider</code> and store its preferences. The new provider 
116
    /** Creates new <code>UpdateUnitProvider</code> and store its preferences. The new provider 
Lines 109-115 Link Here
109
     * @return URL-based UpdateUnitProvider
123
     * @return URL-based UpdateUnitProvider
110
     */    
124
     */    
111
    public UpdateUnitProvider create (String name, String displayName, URL url) {
125
    public UpdateUnitProvider create (String name, String displayName, URL url) {
112
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, UpdateUnitProvider.CATEGORY.COMMUNITY);
126
        return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.forValue(UpdateUnitProvider.CATEGORY.COMMUNITY));
113
    }
127
    }
114
    
128
    
115
    /** Creates new <code>UpdateUnitProvider</code> for temporary usage. This provider contains
129
    /** Creates new <code>UpdateUnitProvider</code> for temporary usage. This provider contains
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/UpdateUnitProviderImpl.java (-9 / +44 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-214 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, category);
212
        
231
        
213
        AutoupdateCatalogProvider catalog = new AutoupdateCatalogProvider (codeName, displayName, url, category);
232
        AutoupdateCatalogProvider catalog = new AutoupdateCatalogProvider (codeName, displayName, url, category);
214
        
233
        
Lines 309-315 Link Here
309
        UpdateManagerImpl.getInstance().clearCache ();
328
        UpdateManagerImpl.getInstance().clearCache ();
310
    }
329
    }
311
    
330
    
312
    private static void storeProvider (String codeName, String displayName, URL url) {
331
    private static void storeProvider(
332
        String codeName, String displayName, URL url, ProviderCategory c
333
    ) {
313
        if (codeName.contains ("/")) {
334
        if (codeName.contains ("/")) {
314
            codeName = codeName.replaceAll ("/", "_");
335
            codeName = codeName.replaceAll ("/", "_");
315
        }
336
        }
Lines 318-323 Link Here
318
        
339
        
319
        providerPreferences.put (URL, url.toString ());
340
        providerPreferences.put (URL, url.toString ());
320
        providerPreferences.put (DISPLAY_NAME, displayName);
341
        providerPreferences.put (DISPLAY_NAME, displayName);
342
        providerPreferences.put(CATEGORY_NAME, c.getDisplayName());
343
        providerPreferences.put(AutoupdateCatalogFactory.ORIGINAL_CATEGORY_ICON_BASE, c.getIconBase());
321
    }
344
    }
322
    
345
    
323
    private static Preferences getPreferences() {
346
    private static Preferences getPreferences() {
Lines 337-343 Link Here
337
        
360
        
338
        String toUrl = providerPreferences.get (URL, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_URL, null));
361
        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));
362
        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())));
363
        String categoryName = providerPreferences.get (CATEGORY_NAME, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_CATEGORY_NAME, CATEGORY.COMMUNITY.name()));
364
        CATEGORY c;
365
        try {
366
            c = CATEGORY.valueOf(categoryName);
367
        } catch (IllegalArgumentException ex) {
368
            c = null;
369
        }
370
        String categoryIconBase = providerPreferences.get(AutoupdateCatalogFactory.ORIGINAL_CATEGORY_ICON_BASE, null);
371
        ProviderCategory pc;
372
        if (c != null) {
373
            pc = ProviderCategory.forValue(c);
374
        } else {
375
            pc = ProviderCategory.create(categoryIconBase, categoryName);
376
        }
341
        
377
        
342
        // filter Providers which store only its state
378
        // filter Providers which store only its state
343
        if (toUrl == null) {
379
        if (toUrl == null) {
Lines 350-357 Link Here
350
        } catch (MalformedURLException mue) {
386
        } catch (MalformedURLException mue) {
351
            assert false : mue;
387
            assert false : mue;
352
        }
388
        }
353
        
389
        return new AutoupdateCatalogProvider (codeName, displayName, url, pc);
354
        return new AutoupdateCatalogProvider (codeName, displayName, url, category);
355
    }
390
    }
356
    
391
    
357
    private static boolean loadState (String codename) {
392
    private static boolean loadState (String codename) {
Lines 443-449 Link Here
443
            }
478
            }
444
        }
479
        }
445
    }
480
    }
446
    
481
447
    private static class LookupListenerImpl implements LookupListener {
482
    private static class LookupListenerImpl implements LookupListener {
448
        final Lookup.Result<UpdateProvider> result = Lookup.getDefault ().lookupResult(UpdateProvider.class);
483
        final Lookup.Result<UpdateProvider> result = Lookup.getDefault ().lookupResult(UpdateProvider.class);
449
        
484
        
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogFactory.java (-5 / +28 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 126-139 Link Here
126
            return null;
127
            return null;
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
        CATEGORY category;
131
        AutoupdateCatalogProvider au_catalog = new AutoupdateCatalogProvider(name, displayName(fo), url, category);
132
        try {
132
        
133
            if (categoryName == null) {
134
                category = CATEGORY.COMMUNITY;
135
            } else {
136
                category = CATEGORY.valueOf(categoryName);
137
            }
138
        } catch (IllegalArgumentException ex) {
139
            // OK, not a valid name
140
            category = null;
141
        }
142
        String categoryIconBase = (String) fo.getAttribute ("iconBase"); // NOI18N
133
        Preferences providerPreferences = getPreferences().node(name);
143
        Preferences providerPreferences = getPreferences().node(name);
144
        ProviderCategory pc;
145
        if (category == null) {
146
            if (categoryName == null || categoryIconBase == null) {
147
                throw new IllegalStateException("Provide category and iconBase for " + fo); // NOI18N
148
            }
149
            pc = ProviderCategory.create(categoryIconBase, categoryName);
150
            providerPreferences.put (ORIGINAL_CATEGORY_ICON_BASE, categoryIconBase);
151
        } else {
152
            pc = ProviderCategory.forValue(category);
153
        }
154
        AutoupdateCatalogProvider au_catalog = new AutoupdateCatalogProvider(name, displayName(fo), url, pc);
134
        providerPreferences.put (ORIGINAL_URL, url.toExternalForm ());
155
        providerPreferences.put (ORIGINAL_URL, url.toExternalForm ());
135
        providerPreferences.put (ORIGINAL_DISPLAY_NAME, au_catalog.getDisplayName ());
156
        providerPreferences.put (ORIGINAL_DISPLAY_NAME, au_catalog.getDisplayName ());
136
        providerPreferences.put (ORIGINAL_CATEGORY_NAME, au_catalog.getCategory().name());        
157
        providerPreferences.put (ORIGINAL_CATEGORY_NAME, au_catalog.getProviderCategory().getDisplayName());
158
        providerPreferences.put (ORIGINAL_CATEGORY_ICON_BASE, au_catalog.getProviderCategory().getIconBase());
159
        
137
        Boolean en = (Boolean) fo.getAttribute("enabled"); // NOI18N        
160
        Boolean en = (Boolean) fo.getAttribute("enabled"); // NOI18N        
138
        if (en != null) {
161
        if (en != null) {
139
            providerPreferences.putBoolean (ORIGINAL_ENABLED, en);
162
            providerPreferences.putBoolean (ORIGINAL_ENABLED, en);
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogProvider.java (-7 / +14 lines)
Lines 65-87 Link Here
65
    private String displayName;
65
    private String displayName;
66
    private AutoupdateCatalogCache cache = AutoupdateCatalogCache.getDefault ();
66
    private AutoupdateCatalogCache cache = AutoupdateCatalogCache.getDefault ();
67
    private static final 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;
69
    private boolean descriptionInitialized = false;
69
    private boolean descriptionInitialized;
70
    private CATEGORY category = null;
70
    private ProviderCategory category;
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
    @Override
90
    @Override
Lines 157-162 Link Here
157
160
158
    @Override
161
    @Override
159
    public CATEGORY getCategory() {
162
    public CATEGORY getCategory() {
163
        return category.toEnum();
164
    }    
165
    
166
    public ProviderCategory getProviderCategory() {
160
        return category;
167
        return category;
161
    }    
168
    }
162
}
169
}
(-)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
(-)768c414c7ce8 (+125 lines)
Added 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
        String name = category != null ? getCategoryName(category) : displayName; 
73
        if (name == null) {
74
            name = forValue(CATEGORY.COMMUNITY).getDisplayName();
75
            assert name != null;
76
        }
77
        return name;
78
    }
79
    public Image getIcon() {
80
        Image img = ImageUtilities.loadImage(getIconBase(), true);
81
        if (img == null) {
82
            img = forValue(CATEGORY.COMMUNITY).getIcon();
83
            assert img != null;
84
        }
85
        return img;
86
    }
87
    
88
    public static ProviderCategory forValue(CATEGORY c) {
89
        return new ProviderCategory(null, null, c);
90
    }
91
92
    CATEGORY toEnum() {
93
        return category == null ? CATEGORY.COMMUNITY : category;
94
    }
95
    
96
    static String getCategoryName(CATEGORY category) {
97
        String key = null;
98
        switch (category) {
99
            case STANDARD:
100
                key = "AvailableTab_SourceCategory_Tooltip_STANDARD"; //NOI18N
101
                break;
102
            case BETA:
103
                key = "AvailableTab_SourceCategory_Tooltip_BETA"; //NOI18N
104
                break;
105
            case COMMUNITY:
106
                key = "AvailableTab_SourceCategory_Tooltip_COMMUNITY"; //NOI18N
107
                break;
108
        }
109
        return (key != null) ? NbBundle.getMessage(ProviderCategory.class, key) : null;
110
    }
111
    
112
    public final String getIconBase() {
113
        if (iconBase != null) {
114
            return iconBase;
115
        }
116
        switch (category) {
117
            case BETA: 
118
                return "org/netbeans/modules/autoupdate/services/resources/icon-beta.png"; // NOI18N
119
            case STANDARD:
120
                return "org/netbeans/modules/autoupdate/services/resources/icon-standard.png"; // NOI18N
121
            default:
122
                return "org/netbeans/modules/autoupdate/services/resources/icon-community.png"; // NOI18N
123
        }
124
    }
125
}
(-)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
 *
(-)768c414c7ce8 (+87 lines)
Added 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.services;
44
45
import java.awt.Image;
46
import java.net.URL;
47
import org.netbeans.api.autoupdate.UpdateUnitProvider;
48
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory;
49
import org.netbeans.junit.NbTestCase;
50
import org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogFactory;
51
import org.netbeans.spi.autoupdate.UpdateProvider;
52
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileUtil;
54
import org.openide.util.ImageUtilities;
55
56
public class AutoupdateCatalogFactoryTest extends NbTestCase {
57
58
    public AutoupdateCatalogFactoryTest(String n) {
59
        super(n);
60
    }
61
62
    public void testCreateUpdateProviderWithOwnIcon() throws Exception {
63
        FileObject f = FileUtil.getConfigRoot().createData("whatever.instance");
64
        f.setAttribute("url", "file:/wherever.xml");
65
        f.setAttribute("displayName", "Whatever");
66
        f.setAttribute("category", "Jarda's Updates");
67
        f.setAttribute("iconBase", "org/netbeans/modules/autoupdate/services/resources/icon-standard.png");
68
        UpdateProvider up = AutoupdateCatalogFactory.createUpdateProvider(f);
69
        UpdateUnitProvider uup = Trampoline.API.createUpdateUnitProvider (new UpdateUnitProviderImpl (up));
70
        assertEquals("whatever", uup.getName());
71
        assertEquals("Whatever", uup.getDisplayName());
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());
75
    }
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
    }
87
}
(-)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 (-68 lines)
Removed 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.net.URL;
46
import org.netbeans.junit.NbTestCase;
47
import org.netbeans.spi.autoupdate.UpdateProvider;
48
import org.openide.filesystems.FileObject;
49
import org.openide.filesystems.FileUtil;
50
51
public class AutoupdateCatalogFactoryTest extends NbTestCase {
52
53
    public AutoupdateCatalogFactoryTest(String n) {
54
        super(n);
55
    }
56
57
    public void testCreateUpdateProvider() throws Exception {
58
        FileObject f = FileUtil.getConfigRoot().createData("whatever.instance");
59
        f.setAttribute("url", "file:/wherever.xml");
60
        f.setAttribute("displayName", "Whatever");
61
        UpdateProvider up = AutoupdateCatalogFactory.createUpdateProvider(f);
62
        assertEquals("whatever", up.getName());
63
        assertEquals("Whatever", up.getDisplayName());
64
        assertEquals(AutoupdateCatalogProvider.class, up.getClass());
65
        assertEquals(new URL("file:/wherever.xml"), ((AutoupdateCatalogProvider) up).getUpdateCenterURL());
66
    }
67
68
}
(-)a/autoupdate.ui/nbproject/project.xml (-2 / +2 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>
Lines 68-74 Link Here
68
                    <build-prerequisite/>
68
                    <build-prerequisite/>
69
                    <compile-dependency/>
69
                    <compile-dependency/>
70
                    <run-dependency>
70
                    <run-dependency>
71
                        <specification-version>8.0</specification-version>
71
                        <specification-version>8.12</specification-version>
72
                    </run-dependency>
72
                    </run-dependency>
73
                </dependency>
73
                </dependency>
74
                <dependency>
74
                <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 658-664 Link Here
658
            if (u1 instanceof Unit.Available && u2 instanceof Unit.Available) {
658
            if (u1 instanceof Unit.Available && u2 instanceof Unit.Available) {
659
                Unit.Available unit1 = (Unit.Available)u1;
659
                Unit.Available unit1 = (Unit.Available)u1;
660
                Unit.Available unit2 = (Unit.Available)u2;
660
                Unit.Available unit2 = (Unit.Available)u2;
661
                return Collator.getInstance().compare(unit1.getSourceCategory().name(), unit2.getSourceCategory().name());
661
                return Collator.getInstance().compare(unit1.getSourceDescription(), unit2.getSourceDescription());
662
            }
662
            }
663
            
663
            
664
            throw new IllegalStateException();
664
            throw new IllegalStateException();
Lines 699-706 Link Here
699
            return (isNbms) ? UnitCategoryTableModel.Type.LOCAL : UnitCategoryTableModel.Type.AVAILABLE;
699
            return (isNbms) ? UnitCategoryTableModel.Type.LOCAL : UnitCategoryTableModel.Type.AVAILABLE;
700
        }        
700
        }        
701
        
701
        
702
        public CATEGORY getSourceCategory() {
702
        public Image getSourceIcon() {
703
            return updateEl.getSourceCategory();
703
            return updateEl.getSourceIcon();
704
        }
705
        public String getSourceDescription() {
706
            return updateEl.getSourceDescription();
704
        }
707
        }
705
    }
708
    }
706
709
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitDetails.java (-5 / +8 lines)
Lines 44-49 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.net.URL;
49
import java.util.ArrayList;
50
import java.util.ArrayList;
Lines 63-69 Link Here
63
import org.netbeans.api.autoupdate.UpdateElement;
64
import org.netbeans.api.autoupdate.UpdateElement;
64
import org.netbeans.api.autoupdate.UpdateManager;
65
import org.netbeans.api.autoupdate.UpdateManager;
65
import org.netbeans.api.autoupdate.UpdateUnit;
66
import org.netbeans.api.autoupdate.UpdateUnit;
66
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
67
import org.openide.util.Exceptions;
67
import org.openide.util.Exceptions;
68
import org.openide.util.NbBundle;
68
import org.openide.util.NbBundle;
69
import org.openide.util.RequestProcessor;
69
import org.openide.util.RequestProcessor;
Lines 132-142 Link Here
132
        StringBuilder text = new StringBuilder();
132
        StringBuilder text = new StringBuilder();
133
        if (u instanceof Unit.Available) {
133
        if (u instanceof Unit.Available) {
134
            Unit.Available u1 = (Unit.Available) u;
134
            Unit.Available u1 = (Unit.Available) u;
135
            CATEGORY c = u1.getSourceCategory();
135
            Image c = u1.getSourceIcon();
136
            String categoryName = Utilities.getCategoryName(c);
136
            Object url = c.getProperty("url", null);
137
            URL icon = Utilities.getCategoryIcon(c);
137
            String categoryName = u1.getSourceDescription();
138
            text.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
138
            text.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
139
            text.append("<td><img src=\"" + icon.toExternalForm() + "\"></img></td>");
139
            if (url instanceof URL) {
140
                text.append("<td><img src=\"" + url + "\"></img></td>");
141
            }
142
            text.append("<td></td>");
140
            text.append("<td>&nbsp;&nbsp;</td>");
143
            text.append("<td>&nbsp;&nbsp;</td>");
141
            text.append("<td><b>" + categoryName + "</b></td>");
144
            text.append("<td><b>" + categoryName + "</b></td>");
142
            text.append("</tr></table><br>");
145
            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 1975-1987 Link Here
1975
                JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
1975
                JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
1976
            JLabel renderComponent = (JLabel)super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
1976
            JLabel renderComponent = (JLabel)super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
1977
            
1977
            
1978
            if (value instanceof CATEGORY) {
1978
            if (value instanceof Image) {
1979
                Unit u = model.getUnitAtRow (row);
1979
                Unit u = model.getUnitAtRow (row);
1980
                if (u instanceof Unit.Available) {
1980
                if (u instanceof Unit.Available) {
1981
                    Unit.Available a = (Unit.Available)u;
1981
                    Unit.Available a = (Unit.Available)u;
1982
                    CATEGORY state = a.getSourceCategory();
1982
                    renderComponent.setIcon(ImageUtilities.image2Icon(a.getSourceIcon()));
1983
                    URL icon = Utilities.getCategoryIcon(state);
1984
                    renderComponent.setIcon(new ImageIcon(icon));
1985
                    renderComponent.setText ("");
1983
                    renderComponent.setText ("");
1986
                    renderComponent.setHorizontalAlignment (SwingConstants.CENTER);
1984
                    renderComponent.setHorizontalAlignment (SwingConstants.CENTER);
1987
                }
1985
                }
(-)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 914-944 Link Here
914
        return NbPreferences.forModule (Utilities.class);
913
        return NbPreferences.forModule (Utilities.class);
915
    }
914
    }
916
    
915
    
917
    static String getCategoryName(CATEGORY category) {
918
        String key = null;
919
        switch (category) {
920
            case STANDARD:
921
                key = "AvailableTab_SourceCategory_Tooltip_STANDARD"; //NOI18N
922
                break;
923
            case BETA:
924
                key = "AvailableTab_SourceCategory_Tooltip_BETA"; //NOI18N
925
                break;
926
            case COMMUNITY:
927
                key = "AvailableTab_SourceCategory_Tooltip_COMMUNITY"; //NOI18N
928
                break;
929
        }
930
        return (key != null) ? getBundle(key) : null;
931
    }
932
    
933
    static URL getCategoryIcon(CATEGORY state) {
934
        URL retval = null;
935
        if (CATEGORY.BETA.equals(state)) {
936
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-beta.png"); // NOI18N
937
        } else if (CATEGORY.COMMUNITY.equals(state)) {
938
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-community.png"); // NOI18N
939
        } else if (CATEGORY.STANDARD.equals(state)) {
940
            retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-standard.png"); // NOI18N
941
        }
942
        return retval;
943
    }    
944
}
916
}
(-)a/openide.util/apichanges.xml (+17 lines)
Lines 51-56 Link Here
51
    <apidef name="actions">Actions API</apidef>
51
    <apidef name="actions">Actions API</apidef>
52
</apidefs>
52
</apidefs>
53
<changes>
53
<changes>
54
    <change id="ImageUtilities.URL">
55
        <api name="util"/>
56
        <summary>ImageUtilities support "url" attribute</summary>
57
        <version major="8" minor="12"/>
58
        <date day="10" month="1" year="2011"/>
59
        <author login="jtulach"/>
60
        <compatibility addition="yes"/>
61
        <description>
62
            <p>
63
            Images loaded by <a href="@TOP@/org/openide/util/ImageUtilities.html#loadImage(java.lang.String,%20boolean)">
64
            ImageUtilities.loadImage</a> now
65
            respond to <code>getProperty("url", null)</code> calls.
66
            </p>
67
        </description>
68
        <class package="org.openide.util" name="ImageUtilities"/>
69
        <issue number="193944"/>
70
    </change>
54
    <change id="WeakSet.putIfAbsent">
71
    <change id="WeakSet.putIfAbsent">
55
        <api name="util"/>
72
        <api name="util"/>
56
        <summary>New implementation of WeakSet with two new methods <code>putIfAbsent</code> and <code>resize</code>
73
        <summary>New implementation of WeakSet with two new methods <code>putIfAbsent</code> and <code>resize</code>
(-)a/openide.util/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.util
2
OpenIDE-Module: org.openide.util
3
OpenIDE-Module-Localizing-Bundle: org/openide/util/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/util/Bundle.properties
4
OpenIDE-Module-Specification-Version: 8.11
4
OpenIDE-Module-Specification-Version: 8.12
5
5
(-)a/openide.util/src/org/openide/util/ImageUtilities.java (-16 / +33 lines)
Lines 61-66 Link Here
61
import java.awt.image.WritableRaster;
61
import java.awt.image.WritableRaster;
62
import java.io.IOException;
62
import java.io.IOException;
63
import java.lang.ref.SoftReference;
63
import java.lang.ref.SoftReference;
64
import java.net.URL;
64
import java.util.HashMap;
65
import java.util.HashMap;
65
import java.util.HashSet;
66
import java.util.HashSet;
66
import java.util.Hashtable;
67
import java.util.Hashtable;
Lines 139-144 Link Here
139
     * or <samp>org/netbeans/modules/foo/resources/foo_mybranding.gif</samp>.
140
     * or <samp>org/netbeans/modules/foo/resources/foo_mybranding.gif</samp>.
140
     * 
141
     * 
141
     * <p>Caching of loaded images can be used internally to improve performance.
142
     * <p>Caching of loaded images can be used internally to improve performance.
143
     * <p> Since version 8.12 the returned image object responds to call
144
     * <code>image.getProperty("url", null)</code> by returning the internal
145
     * {@link URL} of the found and loaded <code>resource</code>.
142
     * 
146
     * 
143
     * @param resource resource path of the image (no initial slash)
147
     * @param resource resource path of the image (no initial slash)
144
     * @param localized true for localized search
148
     * @param localized true for localized search
Lines 245-251 Link Here
245
                    return cached;
249
                    return cached;
246
                }
250
                }
247
            }
251
            }
248
            cached = ToolTipImage.createNew(text, image);
252
            cached = ToolTipImage.createNew(text, image, null);
249
            imageToolTipCache.put(key, new ActiveRef<ToolTipImageKey>(cached, imageToolTipCache, key));
253
            imageToolTipCache.put(key, new ActiveRef<ToolTipImageKey>(cached, imageToolTipCache, key));
250
            return cached;
254
            return cached;
251
        }
255
        }
Lines 527-533 Link Here
527
531
528
                ERR.log(Level.FINE, "loading icon {0} = {1}", new Object[] {n, result});
532
                ERR.log(Level.FINE, "loading icon {0} = {1}", new Object[] {n, result});
529
                name = new String(name).intern(); // NOPMD
533
                name = new String(name).intern(); // NOPMD
530
                result = ToolTipImage.createNew("", result);
534
                result = ToolTipImage.createNew("", result, url);
531
                cache.put(name, new ActiveRef<String>(result, cache, name));
535
                cache.put(name, new ActiveRef<String>(result, cache, name));
532
                return result;
536
                return result;
533
            } else { // no icon found
537
            } else { // no icon found
Lines 601-607 Link Here
601
        
605
        
602
        ColorModel model = colorModel(bitmask? Transparency.BITMASK: Transparency.TRANSLUCENT);
606
        ColorModel model = colorModel(bitmask? Transparency.BITMASK: Transparency.TRANSLUCENT);
603
        ToolTipImage buffImage = new ToolTipImage(str.toString(), 
607
        ToolTipImage buffImage = new ToolTipImage(str.toString(), 
604
                model, model.createCompatibleWritableRaster(w, h), model.isAlphaPremultiplied(), null
608
                model, model.createCompatibleWritableRaster(w, h), model.isAlphaPremultiplied(), null, null
605
            );
609
            );
606
610
607
        java.awt.Graphics g = buffImage.createGraphics();
611
        java.awt.Graphics g = buffImage.createGraphics();
Lines 738-751 Link Here
738
    private static class ToolTipImage extends BufferedImage implements Icon {
742
    private static class ToolTipImage extends BufferedImage implements Icon {
739
        final String toolTipText;
743
        final String toolTipText;
740
        ImageIcon imageIcon;
744
        ImageIcon imageIcon;
745
        final URL url;
741
746
742
        public static ToolTipImage createNew(String toolTipText, Image image) {
747
        public static ToolTipImage createNew(String toolTipText, Image image, URL url) {
743
            ImageUtilities.ensureLoaded(image);
748
            ImageUtilities.ensureLoaded(image);
744
            boolean bitmask = (image instanceof Transparency) && ((Transparency) image).getTransparency() != Transparency.TRANSLUCENT;
749
            boolean bitmask = (image instanceof Transparency) && ((Transparency) image).getTransparency() != Transparency.TRANSLUCENT;
745
            ColorModel model = colorModel(bitmask ? Transparency.BITMASK : Transparency.TRANSLUCENT);
750
            ColorModel model = colorModel(bitmask ? Transparency.BITMASK : Transparency.TRANSLUCENT);
746
            int w = image.getWidth(null);
751
            int w = image.getWidth(null);
747
            int h = image.getHeight(null);
752
            int h = image.getHeight(null);
748
            ToolTipImage newImage = new ToolTipImage(toolTipText, model, model.createCompatibleWritableRaster(w, h), model.isAlphaPremultiplied(), null);
753
            ToolTipImage newImage = new ToolTipImage(
754
                toolTipText,
755
                model,
756
                model.createCompatibleWritableRaster(w, h),
757
                model.isAlphaPremultiplied(), null, url
758
            );
749
759
750
            java.awt.Graphics g = newImage.createGraphics();
760
            java.awt.Graphics g = newImage.createGraphics();
751
            g.drawImage(image, 0, 0, null);
761
            g.drawImage(image, 0, 0, null);
Lines 753-778 Link Here
753
            return newImage;
763
            return newImage;
754
        }
764
        }
755
        
765
        
756
        public ToolTipImage(String toolTipText, ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?, ?> properties) {
766
        public ToolTipImage(
767
            String toolTipText, ColorModel cm, WritableRaster raster,
768
            boolean isRasterPremultiplied, Hashtable<?, ?> properties, URL url
769
        ) {
757
            super(cm, raster, isRasterPremultiplied, properties);
770
            super(cm, raster, isRasterPremultiplied, properties);
758
            this.toolTipText = toolTipText;
771
            this.toolTipText = toolTipText;
759
        }
772
            this.url = url;
760
761
        public ToolTipImage(String toolTipText, int width, int height, int imageType, IndexColorModel cm) {
762
            super(width, height, imageType, cm);
763
            this.toolTipText = toolTipText;
764
        }
773
        }
765
774
766
        public ToolTipImage(String toolTipText, int width, int height, int imageType) {
775
        public ToolTipImage(String toolTipText, int width, int height, int imageType) {
767
            super(width, height, imageType);
776
            super(width, height, imageType);
768
            this.toolTipText = toolTipText;
777
            this.toolTipText = toolTipText;
778
            this.url = null;
769
        }
779
        }
770
        
780
        
771
        public ToolTipImage(String toolTipText, BufferedImage image) {
772
            super(image.getWidth(), image.getHeight(), image.getType());
773
            this.toolTipText = toolTipText;
774
        }
775
776
        synchronized ImageIcon getIcon() {
781
        synchronized ImageIcon getIcon() {
777
            if (imageIcon == null) {
782
            if (imageIcon == null) {
778
                imageIcon = new ImageIcon(this);
783
                imageIcon = new ImageIcon(this);
Lines 791-796 Link Here
791
        public void paintIcon(Component c, Graphics g, int x, int y) {
796
        public void paintIcon(Component c, Graphics g, int x, int y) {
792
            g.drawImage(this, x, y, null);
797
            g.drawImage(this, x, y, null);
793
        }
798
        }
799
800
        @Override
801
        public Object getProperty(String name, ImageObserver observer) {
802
            if ("url".equals(name)) { // NOI18N
803
                if (url != null) {
804
                    return url;
805
                } else {
806
                    return imageIcon.getImage().getProperty("url", observer);
807
                }
808
            }
809
            return super.getProperty(name, observer);
810
        }
794
    }
811
    }
795
812
796
    private static class LazyDisabledIcon implements Icon {
813
    private static class LazyDisabledIcon implements Icon {
(-)a/openide.util/test/unit/src/org/openide/util/ImageUtilitiesTest.java (+7 lines)
Lines 47-52 Link Here
47
import java.awt.Image;
47
import java.awt.Image;
48
import java.awt.Transparency;
48
import java.awt.Transparency;
49
import java.awt.image.BufferedImage;
49
import java.awt.image.BufferedImage;
50
import java.net.URL;
50
import javax.swing.Icon;
51
import javax.swing.Icon;
51
import junit.framework.*;
52
import junit.framework.*;
52
53
Lines 180-190 Link Here
180
        assertNotNull("Should not be null", icon);
181
        assertNotNull("Should not be null", icon);
181
        assertNotNull("Should not be null", image);
182
        assertNotNull("Should not be null", image);
182
183
184
        URL u = getClass().getResource("/org/openide/util/testimage.png");
185
        assertNotNull("URL found", u);
186
        assertEquals("URL obtained", u, image.getProperty("url", null));
187
183
        Icon icon2 = ImageUtilities.image2Icon(image);
188
        Icon icon2 = ImageUtilities.image2Icon(image);
184
        Image image2 = ImageUtilities.icon2Image(icon);
189
        Image image2 = ImageUtilities.icon2Image(icon);
185
190
186
        assertEquals("Should be same instance", icon, icon2);
191
        assertEquals("Should be same instance", icon, icon2);
187
        assertEquals("Should be same instance", image, image2);
192
        assertEquals("Should be same instance", image, image2);
193
194
        assertEquals("Url is still there", u, image2.getProperty("url", null));
188
    }
195
    }
189
196
190
    public void testLoadingNonExisting() {
197
    public void testLoadingNonExisting() {

Return to bug 183778