--- a/autoupdate.services/apichanges.xml +++ a/autoupdate.services/apichanges.xml @@ -57,6 +57,25 @@ + + + Icons for update centers + + + + + +

+ Define icon when specifying an update center using + categoryIconBase attribute. +

+
+ + + +
Feature enabled only when all its dependencies are enabled --- a/autoupdate.services/manifest.mf +++ a/autoupdate.services/manifest.mf @@ -1,7 +1,7 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.autoupdate.services OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/services/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.22 +OpenIDE-Module-Specification-Version: 1.23 OpenIDE-Module-Layer: org/netbeans/modules/autoupdate/services/resources/layer.xml AutoUpdate-Show-In-Client: false AutoUpdate-Essential-Module: true --- a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateElement.java +++ a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateElement.java @@ -44,9 +44,11 @@ package org.netbeans.api.autoupdate; +import java.awt.Image; import java.util.List; import org.netbeans.modules.autoupdate.services.UpdateElementImpl; import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; +import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl; /** Instances provided by the UpdateUnit which represents specific version * of update (e.g. module or feature). The UpdateElement can be installed, @@ -132,12 +134,34 @@ /** * @return UpdateUnitProvider.CATEGORY for a quality classification * for update represented by this instance + * @deprecated Use {@link #getSourceIcon()} and {@link #getSourceDescription()}. */ + @Deprecated public CATEGORY getSourceCategory () { UpdateUnitProvider provider = getUpdateUnitProvider(); return (provider != null) ? provider.getCategory() : CATEGORY.COMMUNITY; } + /** Provides an icon associated with the provider of this update element. + * @return icon representing the provider of this element + * @since 1.23 + * @see UpdateUnitProvider#getSourceIcon() + */ + public Image getSourceIcon() { + UpdateUnitProvider provider = getUpdateUnitProvider(); + return provider != null ? provider.getSourceIcon() : null; + } + + /** Description of the provider of this element. + * @return textual description of the provider of this element + * @since 1.23 + * @see UpdateUnitProvider#getSourceDescription() + */ + public String getSourceDescription() { + UpdateUnitProvider provider = getUpdateUnitProvider(); + return provider != null ? provider.getSourceDescription() : null; + } + private UpdateUnitProvider getUpdateUnitProvider() { String source = getSource(); UpdateUnitProvider retval = null; --- a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProvider.java +++ a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProvider.java @@ -44,6 +44,7 @@ package org.netbeans.api.autoupdate; +import java.awt.Image; import org.netbeans.spi.autoupdate.*; import java.io.IOException; import java.net.URL; @@ -106,10 +107,30 @@ return impl.getDescription (); } - + + /** @deprecated Use {@link #getSourceIcon()} and {@link #getSourceDescription()}. + */ + @Deprecated public CATEGORY getCategory() { return impl.getCategory(); } + + /** The icon associated with this provider. + * @since 1.23 + * @see UpdateElement#getSourceIcon() + */ + public Image getSourceIcon() { + return impl.getSourceIcon(); + } + + /** The description of this provider. Usually associated with {@link #getSourceIcon()} + * @since 1.23 + * @return textual description of the provider + * @see UpdateElement#getSourceDescription() + */ + public String getSourceDescription() { + return impl.getSourceDescription(); + } /** It's special support for UpdateProvider based on Autoupdate Catalog. * It's most kind of Update Providers and have a special support in UI. --- a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProviderFactory.java +++ a/autoupdate.services/src/org/netbeans/api/autoupdate/UpdateUnitProviderFactory.java @@ -44,12 +44,14 @@ package org.netbeans.api.autoupdate; +import java.awt.Image; import java.io.File; import java.io.IOException; import java.net.URL; import java.util.List; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl; +import org.netbeans.modules.autoupdate.updateprovider.ProviderCategory; /** The factory handles UpdateUnitProvider, allow to create or removed them, * browse the providers or refresh its content. @@ -95,8 +97,12 @@ * comming from returned UpdateUnitProvider * @return URL-based UpdateUnitProvider */ - public UpdateUnitProvider create (String name, String displayName, URL url, UpdateUnitProvider.CATEGORY category) { - return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, category); + public UpdateUnitProvider create (String name, String displayName, URL url, UpdateUnitProvider.CATEGORY category) { + return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.forValue(category)); + } + + public UpdateUnitProvider create (String name, String displayName, URL url, String categoryIconBase, String categoryDisplayName) { + return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.create(categoryIconBase, categoryDisplayName)); } /** Creates new UpdateUnitProvider and store its preferences. The new provider @@ -109,7 +115,7 @@ * @return URL-based UpdateUnitProvider */ public UpdateUnitProvider create (String name, String displayName, URL url) { - return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, UpdateUnitProvider.CATEGORY.COMMUNITY); + return UpdateUnitProviderImpl.createUpdateUnitProvider (name, displayName, url, ProviderCategory.forValue(UpdateUnitProvider.CATEGORY.COMMUNITY)); } /** Creates new UpdateUnitProvider for temporary usage. This provider contains --- a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/UpdateUnitProviderImpl.java +++ a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/UpdateUnitProviderImpl.java @@ -44,6 +44,7 @@ package org.netbeans.modules.autoupdate.services; +import java.awt.Image; import java.io.File; import org.netbeans.api.autoupdate.*; import org.netbeans.spi.autoupdate.*; @@ -73,7 +74,9 @@ import org.openide.util.LookupEvent; import org.openide.util.LookupListener; import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; +import org.netbeans.modules.autoupdate.updateprovider.ProviderCategory; import org.openide.filesystems.FileUtil; +import org.openide.util.ImageUtilities; /** UpdateProvider providers items for Autoupdate infrastructure. The items @@ -86,7 +89,7 @@ public final class UpdateUnitProviderImpl { private UpdateProvider provider; - private static Logger err = Logger.getLogger ("org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl"); + private static final Logger err = Logger.getLogger ("org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl"); private static final String REMOVED_MASK ="_removed"; private static final String URL = "url"; private static final String DISPLAY_NAME = "displayName"; @@ -114,6 +117,22 @@ public CATEGORY getCategory() { return getUpdateProvider().getCategory(); } + public Image getSourceIcon() { + UpdateProvider up = getUpdateProvider(); + if (up instanceof AutoupdateCatalogProvider) { + return ((AutoupdateCatalogProvider)up).getProviderCategory().getIcon(); + } + return ProviderCategory.forValue(CATEGORY.COMMUNITY).getIcon(); + } + public String getSourceDescription() { + UpdateProvider up = getUpdateProvider(); + if (up instanceof AutoupdateCatalogProvider) { + return ((AutoupdateCatalogProvider) up).getProviderCategory().getDisplayName(); + } + return ProviderCategory.forValue(CATEGORY.COMMUNITY).getDisplayName(); + } + + /** Display name of provider. This display name can be visualized in UI. * @@ -201,11 +220,11 @@ } public static UpdateUnitProvider createUpdateUnitProvider (String codeName, String displayName, URL url) { - return createUpdateUnitProvider(codeName, displayName, url, CATEGORY.COMMUNITY); + return createUpdateUnitProvider(codeName, displayName, url, ProviderCategory.forValue(CATEGORY.COMMUNITY)); } // static factory methods - public static UpdateUnitProvider createUpdateUnitProvider (String codeName, String displayName, URL url, CATEGORY category) { + public static UpdateUnitProvider createUpdateUnitProvider (String codeName, String displayName, URL url, ProviderCategory category) { codeName = normalizeCodeName (codeName); // store to Preferences storeProvider(codeName, displayName, url); @@ -337,7 +356,14 @@ String toUrl = providerPreferences.get (URL, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_URL, null)); String displayName = providerPreferences.get (DISPLAY_NAME, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_DISPLAY_NAME, codeName)); - CATEGORY category = CATEGORY.valueOf(providerPreferences.get (CATEGORY_NAME, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_CATEGORY_NAME, CATEGORY.COMMUNITY.name()))); + String categoryName = providerPreferences.get (CATEGORY_NAME, providerPreferences.get (AutoupdateCatalogFactory.ORIGINAL_CATEGORY_NAME, CATEGORY.COMMUNITY.name())); + String categoryIconBase = providerPreferences.get(AutoupdateCatalogFactory.ORIGINAL_CATEGORY_ICON_BASE, null); + ProviderCategory pc; + if (categoryIconBase == null) { + pc = ProviderCategory.forValue(CATEGORY.valueOf(categoryName)); + } else { + pc = ProviderCategory.create(categoryIconBase, categoryName); + } // filter Providers which store only its state if (toUrl == null) { @@ -350,8 +376,7 @@ } catch (MalformedURLException mue) { assert false : mue; } - - return new AutoupdateCatalogProvider (codeName, displayName, url, category); + return new AutoupdateCatalogProvider (codeName, displayName, url, pc); } private static boolean loadState (String codename) { @@ -443,7 +468,7 @@ } } } - + private static class LookupListenerImpl implements LookupListener { final Lookup.Result result = Lookup.getDefault ().lookupResult(UpdateProvider.class); --- a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogFactory.java +++ a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogFactory.java @@ -86,6 +86,7 @@ public static final String ORIGINAL_DISPLAY_NAME = "originalDisplayName"; // NOI18N public static final String ORIGINAL_ENABLED = "originalEnabled"; // NOI18N public static final String ORIGINAL_CATEGORY_NAME = "originalCategoryName"; // NOI18N + public static final String ORIGINAL_CATEGORY_ICON_BASE = "originalCategoryIconBase"; // NOI18N public static UpdateProvider createUpdateProvider (FileObject fo) { String sKey = (String) fo.getAttribute ("url_key"); // NOI18N @@ -127,13 +128,21 @@ } url = modifyURL (url); String categoryName = (String) fo.getAttribute ("category"); // NOI18N - CATEGORY category = (categoryName != null) ? CATEGORY.valueOf(categoryName) : CATEGORY.COMMUNITY; - AutoupdateCatalogProvider au_catalog = new AutoupdateCatalogProvider(name, displayName(fo), url, category); - + String categoryIconBase = (String) fo.getAttribute ("categoryIconBase"); // NOI18N Preferences providerPreferences = getPreferences().node(name); + ProviderCategory pc; + if (categoryIconBase != null) { + pc = ProviderCategory.create(categoryIconBase, categoryName); + providerPreferences.put (ORIGINAL_CATEGORY_ICON_BASE, categoryIconBase); + } else { + CATEGORY category = (categoryName != null) ? CATEGORY.valueOf(categoryName) : CATEGORY.COMMUNITY; + pc = ProviderCategory.forValue(category); + } + AutoupdateCatalogProvider au_catalog = new AutoupdateCatalogProvider(name, displayName(fo), url, pc); providerPreferences.put (ORIGINAL_URL, url.toExternalForm ()); providerPreferences.put (ORIGINAL_DISPLAY_NAME, au_catalog.getDisplayName ()); providerPreferences.put (ORIGINAL_CATEGORY_NAME, au_catalog.getCategory().name()); + Boolean en = (Boolean) fo.getAttribute("enabled"); // NOI18N if (en != null) { providerPreferences.putBoolean (ORIGINAL_ENABLED, en); --- a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogProvider.java +++ a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogProvider.java @@ -64,24 +64,27 @@ private final String codeName; private String displayName; private AutoupdateCatalogCache cache = AutoupdateCatalogCache.getDefault (); - private Logger log = Logger.getLogger ("org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalog"); + private static final Logger log = Logger.getLogger ("org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalog"); private String description = null; private boolean descriptionInitialized = false; - private CATEGORY category = null; + private ProviderCategory category = null; public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter) { - this(name, displayName, updateCenter, CATEGORY.COMMUNITY); + this(name, displayName, updateCenter, ProviderCategory.forValue(CATEGORY.COMMUNITY)); } /** * Creates a new instance of AutoupdateCatalog */ - public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter, CATEGORY category) { + public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter, ProviderCategory category) { Parameters.notNull("name", name); this.codeName = name; this.displayName = displayName; this.updateCenter = updateCenter; - this.category = (category != null) ? category : CATEGORY.COMMUNITY; + this.category = category; + } + public AutoupdateCatalogProvider (String name, String displayName, URL updateCenter, CATEGORY category) { + this(name, displayName, updateCenter, ProviderCategory.forValue(category)); } public String getName () { @@ -150,7 +153,12 @@ return displayName + "[" + codeName + "] to " + updateCenter; } + @Override public CATEGORY getCategory() { + return category.toEnum(); + } + + public ProviderCategory getProviderCategory() { return category; - } + } } --- a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/Bundle.properties +++ a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/Bundle.properties @@ -7,3 +7,7 @@ ArtificialFeaturesProvider_Unsorted_Category=Uncategorized ArtificialFeaturesProvider_Features_Category=Features NetworkAccess_Timeout=Timeout while opening connection to {0} + +AvailableTab_SourceCategory_Tooltip_STANDARD=Certified Plugin +AvailableTab_SourceCategory_Tooltip_BETA=Beta Plugin +AvailableTab_SourceCategory_Tooltip_COMMUNITY=Community Contributed Plugin --- a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/ProviderCategory.java +++ a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/ProviderCategory.java @@ -0,0 +1,115 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.autoupdate.updateprovider; + +import java.awt.Image; +import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; +import org.openide.util.ImageUtilities; +import org.openide.util.NbBundle; + +/** Represents provider category. + * + * @author Jaroslav Tulach + */ +public final class ProviderCategory { + private final String displayName; + private final String iconBase; + private final CATEGORY category; + + private ProviderCategory(String displayName, String iconBase, CATEGORY category) { + assert (category != null) != (displayName != null && iconBase != null) : + "Category: " + category + " displayName: " + displayName + + " iconBase: " + iconBase; + this.displayName = displayName; + this.iconBase = iconBase; + this.category = category; + } + + public static ProviderCategory create(String iconBase, String categoryDisplayName) { + return new ProviderCategory(categoryDisplayName, iconBase, null); + } + public String getDisplayName() { + return category != null ? getCategoryName(category) : displayName; + } + public Image getIcon() { + return ImageUtilities.loadImage(getIconBase()); + } + + public static ProviderCategory forValue(CATEGORY c) { + return new ProviderCategory(null, null, c); + } + + CATEGORY toEnum() { + return category == null ? CATEGORY.COMMUNITY : category; + } + + static String getCategoryName(CATEGORY category) { + String key = null; + switch (category) { + case STANDARD: + key = "AvailableTab_SourceCategory_Tooltip_STANDARD"; //NOI18N + break; + case BETA: + key = "AvailableTab_SourceCategory_Tooltip_BETA"; //NOI18N + break; + case COMMUNITY: + key = "AvailableTab_SourceCategory_Tooltip_COMMUNITY"; //NOI18N + break; + } + return (key != null) ? NbBundle.getMessage(ProviderCategory.class, key) : null; + } + + String getIconBase() { + if (iconBase != null) { + return iconBase; + } + switch (category) { + case BETA: + return "org/netbeans/modules/autoupdate/services/resources/icon-beta.png"; // NOI18N + case STANDARD: + return "org/netbeans/modules/autoupdate/services/resources/icon-standard.png"; // NOI18N + default: + return "org/netbeans/modules/autoupdate/services/resources/icon-community.png"; // NOI18N + } + } +} --- a/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/DeclarationOfUpdateUnitProviderTest.java +++ a/autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/DeclarationOfUpdateUnitProviderTest.java @@ -44,13 +44,9 @@ package org.netbeans.api.autoupdate; -import java.net.URL; import java.util.List; -import junit.framework.TestCase; import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; -import org.netbeans.api.progress.ProgressHandle; import org.netbeans.junit.NbTestCase; -import org.openide.filesystems.Repository; /** * --- a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/UpdateUnitProviderImplTest.java +++ a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/UpdateUnitProviderImplTest.java @@ -170,7 +170,10 @@ String displayName = "2nd Update Provider"; URL url = URL_TO_TEST_CATALOG; - UpdateUnitProvider newProvider = UpdateUnitProviderImpl.createUpdateUnitProvider(codeName, displayName, url, CATEGORY.COMMUNITY); + UpdateUnitProvider newProvider = UpdateUnitProviderImpl.createUpdateUnitProvider( + codeName, displayName, url, + ProviderCategory.forValue(CATEGORY.COMMUNITY) + ); assertNotNull(codeName + " provider found.", newProvider); result = UpdateUnitProviderImpl.getUpdateUnitProviders(false); --- a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogFactoryTest.java +++ a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogFactoryTest.java @@ -40,29 +40,48 @@ * Portions Copyrighted 2010 Sun Microsystems, Inc. */ -package org.netbeans.modules.autoupdate.updateprovider; +package org.netbeans.modules.autoupdate.services; +import org.netbeans.modules.autoupdate.updateprovider.*; +import java.awt.Image; import java.net.URL; +import org.netbeans.api.autoupdate.UpdateUnitProvider; +import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; import org.netbeans.junit.NbTestCase; import org.netbeans.spi.autoupdate.UpdateProvider; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; +import org.openide.util.ImageUtilities; -public class AutoupdateCatalogFactoryTest extends NbTestCase { +public class UpdateUnitProviderTest extends NbTestCase { - public AutoupdateCatalogFactoryTest(String n) { + public UpdateUnitProviderTest(String n) { super(n); } - public void testCreateUpdateProvider() throws Exception { + public void testCreateUpdateProviderWithOwnIcon() throws Exception { FileObject f = FileUtil.getConfigRoot().createData("whatever.instance"); f.setAttribute("url", "file:/wherever.xml"); f.setAttribute("displayName", "Whatever"); + f.setAttribute("category", "Jarda's Updates"); + f.setAttribute("categoryIconBase", "org/netbeans/modules/autoupdate/services/resources/icon-standard.png"); UpdateProvider up = AutoupdateCatalogFactory.createUpdateProvider(f); - assertEquals("whatever", up.getName()); - assertEquals("Whatever", up.getDisplayName()); - assertEquals(AutoupdateCatalogProvider.class, up.getClass()); - assertEquals(new URL("file:/wherever.xml"), ((AutoupdateCatalogProvider) up).getUpdateCenterURL()); + UpdateUnitProvider uup = Trampoline.API.createUpdateUnitProvider (new UpdateUnitProviderImpl (up)); + assertEquals("whatever", uup.getName()); + assertEquals("Whatever", uup.getDisplayName()); + assertEquals(new URL("file:/wherever.xml"), uup.getProviderURL()); + Image img = ImageUtilities.loadImage("org/netbeans/modules/autoupdate/services/resources/icon-standard.png"); + assertEquals("Icons are the same", img, uup.getSourceIcon()); } + public void testFactoryMethodsAndIcons() throws Exception { + Image img = ImageUtilities.loadImage("org/netbeans/modules/autoupdate/services/resources/icon-standard.png"); + UpdateUnitProvider res = UpdateUnitProviderFactory.getDefault().create( + "code-name", "Whatever", new URL("file:/whereever.xml"), + "org/netbeans/modules/autoupdate/services/resources/icon-standard.png", "my category" + ); + assertEquals("code-name", res.getName()); + assertEquals("Whatever", res.getDisplayName()); + assertEquals("Good image", img, res.getSourceIcon()); + } } --- a/autoupdate.ui/nbproject/project.xml +++ a/autoupdate.ui/nbproject/project.xml @@ -19,7 +19,7 @@ - 1.12 + 1.23 --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/AvailableTableModel.java +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/AvailableTableModel.java @@ -44,6 +44,7 @@ package org.netbeans.modules.autoupdate.ui; +import java.awt.Image; import java.util.Comparator; import java.util.HashSet; import java.util.List; @@ -53,7 +54,6 @@ import org.netbeans.api.autoupdate.OperationContainer.OperationInfo; import org.netbeans.api.autoupdate.UpdateElement; import org.netbeans.api.autoupdate.UpdateUnit; -import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.util.NbBundle; @@ -125,7 +125,7 @@ res = u.getCategoryName(); break; case 3 : - res = u.getSourceCategory(); + res = u.getSourceIcon(); break; } @@ -150,7 +150,7 @@ res = String.class; break; case 3 : - res = CATEGORY.class; + res = Image.class; break; } @@ -189,12 +189,13 @@ @Override public String getToolTipText(int row, int col) { if (col == 3) { - CATEGORY category = (CATEGORY) getValueAt (row, 3); - return Utilities.getCategoryName(category); + Unit.Available u = (Unit.Available) getUnitAtRow(row); + return u.getSourceDescription(); } return super.getToolTipText(row, col); } + @Override public int getPreferredWidth(JTableHeader header, int col) { final int minWidth = super.getMinWidth(header, col); switch (col) { --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Bundle.properties +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Bundle.properties @@ -21,9 +21,6 @@ UnitTab_ActivateCategoryAction=Activate Category UnitTab_DeactivateAction=&Deactivate UnitTab_DeactivateCategoryAction=Deactivate Category -AvailableTab_SourceCategory_Tooltip_STANDARD=Certified Plugin -AvailableTab_SourceCategory_Tooltip_BETA=Beta Plugin -AvailableTab_SourceCategory_Tooltip_COMMUNITY=Community Contributed Plugin InstallTab_Active_Tooltip=Active InstallTab_InActive_Tooltip=Inactive InstallTab_PendingForInstall_Tooltip=Application restart needed to complete installation --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/HTMLEditorKitEx.java +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/HTMLEditorKitEx.java @@ -44,29 +44,13 @@ package org.netbeans.modules.autoupdate.ui; import java.awt.Image; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import javax.swing.ImageIcon; import javax.swing.text.html.*; import javax.swing.text.*; -import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; /** * @author Radek Matous */ public class HTMLEditorKitEx extends HTMLEditorKit { - private static final Map ICONS = new HashMap(); - static { - URL u_standard = Utilities.getCategoryIcon(CATEGORY.STANDARD); - ICONS.put(u_standard, new ImageIcon(u_standard)); - - URL u_beta = Utilities.getCategoryIcon(CATEGORY.BETA); - ICONS.put(u_beta, new ImageIcon(u_beta)); - - URL u_community = Utilities.getCategoryIcon(CATEGORY.COMMUNITY); - ICONS.put(u_community, new ImageIcon(u_community)); - } public ViewFactory getViewFactory() { return new HTMLFactory() { @@ -85,8 +69,7 @@ @Override public Image getImage() { - ImageIcon img = ICONS.get(getImageURL()); - return (img != null) ? img.getImage() : super.getImage(); + return super.getImage(); } } } --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.form +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.form @@ -1,4 +1,4 @@ - +
--- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.java +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/SettingsTab.java @@ -48,6 +48,7 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; +import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; @@ -63,13 +64,13 @@ import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.DefaultComboBoxModel; +import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -80,7 +81,6 @@ import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import org.netbeans.api.autoupdate.UpdateUnitProvider; -import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; import org.netbeans.api.options.OptionsDisplayer; import org.netbeans.modules.autoupdate.ui.actions.AutoupdateSettings; import org.openide.DialogDescriptor; @@ -717,14 +717,9 @@ if (value instanceof UpdateUnitProvider) { UpdateUnitProvider u = (UpdateUnitProvider) value; - CATEGORY state = u.getCategory(); - if (CATEGORY.BETA.equals(state)) { - renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-beta.png", false)); // NOI18N - } else if (CATEGORY.COMMUNITY.equals(state)) { - renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-community.png", false)); // NOI18N - } else if (CATEGORY.STANDARD.equals(state)) { - renderComponent.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/icon-standard.png", false)); // NOI18N - } + Image img = u.getSourceIcon(); + final Icon icon = ImageUtilities.image2Icon(img); + renderComponent.setIcon(icon); renderComponent.setText (u.getDisplayName()); renderComponent.setHorizontalAlignment(SwingConstants.LEFT); } --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Unit.java +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Unit.java @@ -44,6 +44,7 @@ package org.netbeans.modules.autoupdate.ui; +import java.awt.Image; import java.text.Collator; import java.text.DateFormat; import java.text.ParseException; @@ -61,7 +62,6 @@ import org.netbeans.api.autoupdate.UpdateElement; import org.netbeans.api.autoupdate.UpdateManager; import org.netbeans.api.autoupdate.UpdateUnit; -import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; import org.netbeans.modules.autoupdate.ui.UnitCategoryTableModel.Type; import org.openide.modules.SpecificationVersion; import org.openide.util.NbBundle; @@ -654,7 +654,7 @@ if (u1 instanceof Unit.Available && u2 instanceof Unit.Available) { Unit.Available unit1 = (Unit.Available)u1; Unit.Available unit2 = (Unit.Available)u2; - return Collator.getInstance().compare(unit1.getSourceCategory().name(), unit2.getSourceCategory().name()); + return Collator.getInstance().compare(unit1.getSourceDescription(), unit2.getSourceDescription()); } throw new IllegalStateException(); @@ -695,8 +695,11 @@ return (isNbms) ? UnitCategoryTableModel.Type.LOCAL : UnitCategoryTableModel.Type.AVAILABLE; } - public CATEGORY getSourceCategory() { - return updateEl.getSourceCategory(); + public Image getSourceIcon() { + return updateEl.getSourceIcon(); + } + public String getSourceDescription() { + return updateEl.getSourceDescription(); } } --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitDetails.java +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitDetails.java @@ -44,8 +44,8 @@ package org.netbeans.modules.autoupdate.ui; import java.awt.Color; +import java.awt.Image; import java.io.CharConversionException; -import java.net.URL; import java.util.ArrayList; import java.util.Comparator; import java.util.HashSet; @@ -63,7 +63,6 @@ import org.netbeans.api.autoupdate.UpdateElement; import org.netbeans.api.autoupdate.UpdateManager; import org.netbeans.api.autoupdate.UpdateUnit; -import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; import org.openide.xml.XMLUtil; @@ -131,11 +130,11 @@ StringBuilder text = new StringBuilder(); if (u instanceof Unit.Available) { Unit.Available u1 = (Unit.Available) u; - CATEGORY c = u1.getSourceCategory(); - String categoryName = Utilities.getCategoryName(c); - URL icon = Utilities.getCategoryIcon(c); + Image c = u1.getSourceIcon(); + String categoryName = u1.getSourceDescription(); text.append(""); - text.append(""); +// XXX: regression? text.append(""); + text.append(""); text.append(""); text.append(""); text.append("
  " + categoryName + "

"); --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitTab.java +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitTab.java @@ -50,6 +50,7 @@ import org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard; import java.awt.Component; import java.awt.Cursor; +import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionEvent; @@ -100,7 +101,6 @@ import org.netbeans.api.autoupdate.OperationContainer.OperationInfo; import org.netbeans.api.autoupdate.UpdateManager; import org.netbeans.api.autoupdate.UpdateUnit; -import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType; @@ -1971,13 +1971,11 @@ JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel renderComponent = (JLabel)super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); - if (value instanceof CATEGORY) { + if (value instanceof Image) { Unit u = model.getUnitAtRow (row); if (u instanceof Unit.Available) { Unit.Available a = (Unit.Available)u; - CATEGORY state = a.getSourceCategory(); - URL icon = Utilities.getCategoryIcon(state); - renderComponent.setIcon(new ImageIcon(icon)); + renderComponent.setIcon(ImageUtilities.image2Icon(a.getSourceIcon())); renderComponent.setText (""); renderComponent.setHorizontalAlignment (SwingConstants.CENTER); } --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Utilities.java +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Utilities.java @@ -85,7 +85,6 @@ import org.openide.util.NbBundle; import org.openide.util.NbPreferences; import org.openide.util.RequestProcessor; -import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY; import org.netbeans.modules.autoupdate.ui.actions.Installer; import org.netbeans.modules.autoupdate.ui.actions.ShowNotifications; import org.openide.util.Task; @@ -908,31 +907,4 @@ return NbPreferences.forModule (Utilities.class); } - static String getCategoryName(CATEGORY category) { - String key = null; - switch (category) { - case STANDARD: - key = "AvailableTab_SourceCategory_Tooltip_STANDARD"; //NOI18N - break; - case BETA: - key = "AvailableTab_SourceCategory_Tooltip_BETA"; //NOI18N - break; - case COMMUNITY: - key = "AvailableTab_SourceCategory_Tooltip_COMMUNITY"; //NOI18N - break; - } - return (key != null) ? getBundle(key) : null; - } - - static URL getCategoryIcon(CATEGORY state) { - URL retval = null; - if (CATEGORY.BETA.equals(state)) { - retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-beta.png"); // NOI18N - } else if (CATEGORY.COMMUNITY.equals(state)) { - retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-community.png"); // NOI18N - } else if (CATEGORY.STANDARD.equals(state)) { - retval = Utilities.class.getResource("/org/netbeans/modules/autoupdate/ui/resources/icon-standard.png"); // NOI18N - } - return retval; - } }