Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ GlassFish 3.0 or later and that server is registered properly in NetBeans.<html>
JavaSEPlatformPanel.title=Java SE Platform
JavaSEPlatformPanel.warning=<html>GlassFish server could not be started with \
<i>{0}</i>. Please select another Java SE Platform.</html>
JavaSEPlatformPanel.noPlatform=<html>GlassFish server could not be started with \
<i>{0}</i> and no installed Java SE platform is compatible with this server \
(supported: {1}). Use <b>Manage Platforms</b> to register a compatible JDK.</html>
JavaSEPlatformPanel.javaLabel=Java Platform:
JavaSEPlatformPanel.platformButton=Manage Platforms
JavaSEPlatformPanel.propertiesLabel=Update properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p/>
* The result is a compact range (e.g. <code>"17 - 25"</code>) when the
* supported set spans more than one version, the single version otherwise,
* or an empty <code>String</code> when nothing is declared as supported.
* <p/>
* @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<JavaSEPlatform> 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.
* <p/>
Expand Down