diff --git a/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/ui/Bundle.properties b/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/ui/Bundle.properties index e757ff870cdd..0f54b1b21eae 100644 --- a/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/ui/Bundle.properties +++ b/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/ui/Bundle.properties @@ -106,6 +106,9 @@ GlassFish 3.0 or later and that server is registered properly in NetBeans. JavaSEPlatformPanel.title=Java SE Platform JavaSEPlatformPanel.warning=GlassFish server could not be started with \ {0}. Please select another Java SE Platform. +JavaSEPlatformPanel.noPlatform=GlassFish server could not be started with \ +{0} and no installed Java SE platform is compatible with this server \ +(supported: {1}). Use Manage Platforms to register a compatible JDK. JavaSEPlatformPanel.javaLabel=Java Platform: JavaSEPlatformPanel.platformButton=Manage Platforms JavaSEPlatformPanel.propertiesLabel=Update properties: diff --git a/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/ui/JavaSEPlatformPanel.java b/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/ui/JavaSEPlatformPanel.java index c190699b357f..02bc613c503d 100644 --- a/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/ui/JavaSEPlatformPanel.java +++ b/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/ui/JavaSEPlatformPanel.java @@ -105,9 +105,20 @@ public static FileObject selectServerSEPlatform( JavaPlatform platform = JavaUtils.findInstalledPlatform(javaHome); String platformName = platform != null ? platform.getDisplayName() : javaHome.getAbsolutePath(); - String message = NbBundle.getMessage( - JavaSEPlatformPanel.class, - "JavaSEPlatformPanel.warning", platformName); + // When no installed platform is compatible the selection combo is + // empty and OK stays disabled, so point the user at "Manage Platforms" + // and name the supported range instead of the generic warning. + JavaPlatform[] supportedPlatforms + = JavaUtils.findSupportedPlatforms(instance); + String message = supportedPlatforms == null + || supportedPlatforms.length == 0 + ? NbBundle.getMessage( + JavaSEPlatformPanel.class, + "JavaSEPlatformPanel.noPlatform", platformName, + JavaUtils.supportedJavaSERange(instance)) + : NbBundle.getMessage( + JavaSEPlatformPanel.class, + "JavaSEPlatformPanel.warning", platformName); String title = NbBundle.getMessage( JavaSEPlatformPanel.class, "JavaSEPlatformPanel.title", platformName); diff --git a/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/utils/JavaUtils.java b/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/utils/JavaUtils.java index 7c5d34de7ac1..2ef06239aaac 100644 --- a/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/utils/JavaUtils.java +++ b/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/utils/JavaUtils.java @@ -222,6 +222,43 @@ public static JavaPlatform[] findSupportedPlatforms( return platforms; } + /** + * Build a human readable description of the Java SE versions supported + * by the given GlassFish server instance. + *

+ * The result is a compact range (e.g. "17 - 25") when the + * supported set spans more than one version, the single version otherwise, + * or an empty String when nothing is declared as supported. + *

+ * @param instance GlassFish server instance to inspect. + * @return Description of the supported Java SE version range. + */ + public static String supportedJavaSERange( + @NonNull final GlassfishInstance instance) { + Parameters.notNull("instance", instance); + GlassFishJavaSEConfig javaSEConfig + = ConfigBuilderProvider.getBuilder(instance) + .getJavaSEConfig(instance.getVersion()); + Set supportedPlatforms + = javaSEConfig != null ? javaSEConfig.getPlatforms() : null; + if (supportedPlatforms == null || supportedPlatforms.isEmpty()) { + return ""; + } + JavaSEPlatform min = null; + JavaSEPlatform max = null; + for (JavaSEPlatform platform : supportedPlatforms) { + if (min == null || platform.ordinal() < min.ordinal()) { + min = platform; + } + if (max == null || platform.ordinal() > max.ordinal()) { + max = platform; + } + } + return min == max + ? min.toString() + : min.toString() + " - " + max.toString(); + } + /** * Search for first available installed folder in Java SE platform. *