diff --git a/java.platform/manifest.mf b/java.platform/manifest.mf --- a/java.platform/manifest.mf +++ b/java.platform/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.java.platform/1 -OpenIDE-Module-Specification-Version: 1.13 +OpenIDE-Module-Specification-Version: 1.14 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/platform/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/java/platform/resources/layer.xml AutoUpdate-Show-In-Client: false diff --git a/java.platform/src/org/netbeans/api/java/platform/Bundle.properties b/java.platform/src/org/netbeans/api/java/platform/Bundle.properties --- a/java.platform/src/org/netbeans/api/java/platform/Bundle.properties +++ b/java.platform/src/org/netbeans/api/java/platform/Bundle.properties @@ -40,3 +40,5 @@ TXT_PlatformsManager=Java Platform Manager CTL_Close=Close AD_Close=N/A +J2ME=Java ME +J2SE=Java SE diff --git a/java.platform/src/org/netbeans/api/java/platform/SpecificationLocalizer.java b/java.platform/src/org/netbeans/api/java/platform/SpecificationLocalizer.java new file mode 100644 --- /dev/null +++ b/java.platform/src/org/netbeans/api/java/platform/SpecificationLocalizer.java @@ -0,0 +1,99 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.api.java.platform; + +import java.util.Collection; +import org.openide.util.Lookup; +import org.openide.util.NbBundle; +import org.openide.util.lookup.ServiceProvider; + +/** + * Provides localized names for Specificiation objects. Instances of this + * class may be registered in the default lookup to provide localized or + * altered names for Java specifications (i.e. J2ME -> Java ME) + * + * @author Tim Boudreau + */ +@ServiceProvider(service=SpecificationLocalizer.class) +public class SpecificationLocalizer { + private static Collection all() { + return Lookup.getDefault().lookupAll(SpecificationLocalizer.class); + } + + /** + * Get the localized display name of a Specification + * @param specificationName The specification's name, e.g. J2SE + * @return The name, which may or may not be the same as the return value + * of Specification.getName() on the passed object + */ + public static String nameOf (String specificationName) { + String orig = specificationName; + for (SpecificationLocalizer l : all()) { + String name = l.getName (specificationName); + assert name != null : l + " returned a null name for " + specificationName; + if (!orig.equals(name)) { + return name; + } + } + return orig; + } + + /** + * Provide an alternate display name for a specification. The default + * implementation simply substitutes "Java ME" for J2ME and + * Java SE for J2SE. If + * the names of other specifications should be changed, simply register + * instances of this class in the default lookup. + *

+ * If the implementation cannot + * @param spec The specification + * @return The display name of the specification, if this implementation + * wishes to modify it, otherwise spec.getName(). May not return null. + */ + protected String getName(String specificationName) { + if ("J2ME".equals(specificationName)) { //NOI18N + return NbBundle.getMessage(SpecificationLocalizer.class, "J2ME"); //NOI18N + } else if ("J2SE".equals(specificationName)) { + return NbBundle.getMessage(SpecificationLocalizer.class, "J2SE"); //NOI18N + } + return specificationName; + } + +} diff --git a/java.platform/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java b/java.platform/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java --- a/java.platform/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java +++ b/java.platform/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java @@ -66,6 +66,7 @@ import javax.swing.UIManager; import org.netbeans.api.java.platform.JavaPlatform; import org.netbeans.api.java.platform.JavaPlatformManager; +import org.netbeans.api.java.platform.SpecificationLocalizer; import org.netbeans.modules.java.platform.wizard.PlatformInstallIterator; import org.openide.DialogDisplayer; import org.openide.ErrorManager; @@ -562,8 +563,8 @@ return this.desc.getName (); } - public @Override String getDisplayName() { - return this.getName (); + public @Override String getDisplayName() { + return SpecificationLocalizer.nameOf(getName()); } public @Override Image getIcon(int type) {