public final class PlatformUiSupport extends Object
JavaPlatform
manipulation in project customizer.Modifier and Type | Method and Description |
---|---|
static ComboBoxModel |
createPlatformComboBoxModel(Project owner,
PropertyEvaluator eval,
String activePlatform,
Collection<? extends PlatformFilter> filters)
Create a
ComboBoxModel of Java platforms. |
static ComboBoxModel |
createPlatformComboBoxModel(String activePlatform)
Create a
ComboBoxModel of Java platforms. |
static ComboBoxModel |
createPlatformComboBoxModel(String activePlatform,
Collection<? extends PlatformFilter> filters)
Create a
ComboBoxModel of Java platforms. |
static ListCellRenderer |
createPlatformListCellRenderer()
Create a
ListCellRenderer for rendering items of the ComboBoxModel
created by the PlatformUiSupport.createPlatformComboBoxModel(String) method. |
static ComboBoxModel |
createProfileComboBoxModel(ComboBoxModel sourceLevelModel,
String initialProfileName,
SourceLevelQuery.Profile minimalProfile)
Create
ComboBoxModel of JRE profiles for active source level. |
static ListCellRenderer |
createProfileListCellRenderer()
Create
ListCellRenderer for JRE profiles. |
static ComboBoxModel |
createSourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel,
String initialSourceLevel,
String initialTargetLevel)
Exactly like
PlatformUiSupport.createSourceLevelComboBoxModel(ComboBoxModel, String, String, SpecificationVersion)
but without any minimal JDK version. |
static ComboBoxModel |
createSourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel,
String initialSourceLevel,
String initialTargetLevel,
SpecificationVersion minimalSpecificationVersion)
Create
ComboBoxModel of source levels for active platform. |
static ListCellRenderer |
createSourceLevelListCellRenderer()
Create
ListCellRenderer for source levels. |
static JavaPlatform |
getPlatform(Object platformKey)
Return a
JavaPlatform for an item obtained from the ComboBoxModel created by
the PlatformUiSupport.createPlatformComboBoxModel(String) method. |
static SourceLevelQuery.Profile |
getProfile(Object profileKey)
Return a
SourceLevelQuery.Profile for an item obtained from the ComboBoxModel created by
the PlatformUiSupport.createProfileComboBoxModel(javax.swing.ComboBoxModel, java.lang.String, org.netbeans.api.java.queries.SourceLevelQuery.Profile) method. |
static SpecificationVersion |
getSourceLevel(Object sourceLevelKey)
Returns a
SpecificationVersion for an item obtained from the ComboBoxModel created by
the PlatformUiSupport.createSourceLevelComboBoxModel(javax.swing.ComboBoxModel, java.lang.String, java.lang.String, org.openide.modules.SpecificationVersion) method. |
static void |
storePlatform(EditableProperties props,
UpdateHelper helper,
String projectConfigurationNamespace,
Object platformKey,
Object sourceLevelKey)
Stores active platform, javac.source and javac.target into the project's metadata.
|
static void |
storePlatform(EditableProperties props,
UpdateHelper helper,
String projectConfigurationNamespace,
Object platformKey,
Object sourceLevelKey,
boolean updatePreferredPlatform)
Stores active platform, javac.source and javac.target into the project's metadata.
|
static void |
storePlatform(EditableProperties props,
UpdateHelper helper,
String projectConfigurationNamespace,
Object platformKey,
Object sourceLevelKey,
Object profileKey,
boolean updatePreferredPlatform)
Stores active platform, javac.source,javac.target and javac.profile into the project's metadata.
|
static void |
storePlatform(EditableProperties props,
UpdateHelper helper,
String projectConfigurationNamespace,
String platformName,
SpecificationVersion sourceLevel)
Like
PlatformUiSupport.storePlatform(EditableProperties, UpdateHelper, String, Object, Object) , but platform name may be
null (in such case the default platform is used). |
public static ComboBoxModel createPlatformComboBoxModel(String activePlatform)
ComboBoxModel
of Java platforms.
The model listens on the JavaPlatformManager
and update its
state according to the changes.activePlatform
- the active project's platform, can be null
.ComboBoxModel
.public static ComboBoxModel createPlatformComboBoxModel(String activePlatform, Collection<? extends PlatformFilter> filters)
ComboBoxModel
of Java platforms.
The model listens on the JavaPlatformManager
and update its
state according to the changes.activePlatform
- the active project's platform, can be null
.filters
- project specific filter to filter-out platforms that are not usable in given contextComboBoxModel
.@NonNull public static ComboBoxModel createPlatformComboBoxModel(@NonNull Project owner, @NonNull PropertyEvaluator eval, @NullAllowed String activePlatform, @NullAllowed Collection<? extends PlatformFilter> filters)
ComboBoxModel
of Java platforms.
The model listens on the JavaPlatformManager
and update its
state according to the changes.owner
- the owning projecteval
- the project's PropertyEvaluator
activePlatform
- the active project's platform, can be null
.filters
- project specific filter to filter-out platforms that are not usable in given contextComboBoxModel
.public static ListCellRenderer createPlatformListCellRenderer()
ListCellRenderer
for rendering items of the ComboBoxModel
created by the PlatformUiSupport.createPlatformComboBoxModel(String)
method.ListCellRenderer
.public static void storePlatform(EditableProperties props, UpdateHelper helper, String projectConfigurationNamespace, String platformName, SpecificationVersion sourceLevel)
PlatformUiSupport.storePlatform(EditableProperties, UpdateHelper, String, Object, Object)
, but platform name may be
null
(in such case the default platform is used).props
- project's shared properties.helper
- UpdateHelper
that is capable to upgrade project metadata if needed.projectConfigurationNamespace
- project configuration namespace.platformName
- platform name to store, can be null
.sourceLevel
- specification version to store.public static void storePlatform(@NonNull EditableProperties props, @NonNull UpdateHelper helper, @NonNull String projectConfigurationNamespace, @NonNull Object platformKey, @NullAllowed Object sourceLevelKey)
props
- project's shared propertieshelper
- UpdateHelper
that is capable to upgrade project metadata if needed.projectConfigurationNamespace
- project configuration namespace.platformKey
- the PlatformKey
got from the platform model.sourceLevelKey
- SourceLevelKey
representing source level; can be null
.public static void storePlatform(@NonNull EditableProperties props, @NonNull UpdateHelper helper, @NonNull String projectConfigurationNamespace, @NonNull Object platformKey, @NullAllowed Object sourceLevelKey, boolean updatePreferredPlatform)
props
- project's shared propertieshelper
- UpdateHelper
that is capable to upgrade project metadata if needed.projectConfigurationNamespace
- project configuration namespace.platformKey
- the PlatformKey
got from the platform model.sourceLevelKey
- SourceLevelKey
representing source level; can be null
.updatePreferredPlatform
- if true the PreferredProjectPlatform
will be updatedpublic static void storePlatform(@NonNull EditableProperties props, @NonNull UpdateHelper helper, @NonNull String projectConfigurationNamespace, @NonNull Object platformKey, @NullAllowed Object sourceLevelKey, @NullAllowed Object profileKey, boolean updatePreferredPlatform)
props
- project's shared propertieshelper
- UpdateHelper
that is capable to upgrade project metadata if needed.projectConfigurationNamespace
- project configuration namespace.platformKey
- the PlatformKey
got from the platform model.sourceLevelKey
- SourceLevelKey
representing source level; can be null
.profileKey
- SourceLevelQuery.Profile
representing required profile; can be null
for full JRE.updatePreferredPlatform
- if true the PreferredProjectPlatform
will be updatedpublic static SpecificationVersion getSourceLevel(@NonNull Object sourceLevelKey)
SpecificationVersion
for an item obtained from the ComboBoxModel
created by
the PlatformUiSupport.createSourceLevelComboBoxModel(javax.swing.ComboBoxModel, java.lang.String, java.lang.String, org.openide.modules.SpecificationVersion)
method. This method
can return null
if the source level is broken.sourceLevelKey
- an item obtained from ComboBoxModel
created by
PlatformUiSupport.createSourceLevelComboBoxModel(javax.swing.ComboBoxModel, java.lang.String, java.lang.String, org.openide.modules.SpecificationVersion)
.SpecificationVersion
or null
in case when source level is broken.IllegalArgumentException
- if the input parameter is not an object created by source level combobox model.public static JavaPlatform getPlatform(Object platformKey)
JavaPlatform
for an item obtained from the ComboBoxModel created by
the PlatformUiSupport.createPlatformComboBoxModel(String)
method. This method
can return null
if the platform is broken.platformKey
- an item obtained from ComboBoxModel
created by
PlatformUiSupport.createPlatformComboBoxModel(String)
.JavaPlatform
or null
in case when platform is broken.IllegalArgumentException
- if the input parameter is not an object created by platform combobox model.@CheckForNull public static SourceLevelQuery.Profile getProfile(@NonNull Object profileKey)
SourceLevelQuery.Profile
for an item obtained from the ComboBoxModel created by
the PlatformUiSupport.createProfileComboBoxModel(javax.swing.ComboBoxModel, java.lang.String, org.netbeans.api.java.queries.SourceLevelQuery.Profile)
method.
This method can return null
if the profile is broken.profileKey
- an item obtained from ComboBoxModel
created by
PlatformUiSupport.createProfileComboBoxModel(javax.swing.ComboBoxModel, java.lang.String, org.netbeans.api.java.queries.SourceLevelQuery.Profile)
.SourceLevelQuery.Profile
or null
in case when profile is broken.IllegalArgumentException
- if the input parameter is not an object created by profile combobox model.public static ComboBoxModel createSourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel, String initialSourceLevel, String initialTargetLevel, SpecificationVersion minimalSpecificationVersion)
ComboBoxModel
of source levels for active platform.
The model listens on the platform's ComboBoxModel
and update its
state according to the changes. It is possible to define minimal JDK version.platformComboBoxModel
- the platform's model used for listenning.initialSourceLevel
- initial source level value, null if unknown.initialTargetLevel
- initial target level value, null if unknown.minimalSpecificationVersion
- minimal JDK version to be displayed. It can be null
if all the JDK versions
should be displayed (typically for Java SE project).ComboBoxModel
of SourceLevelKey
.PlatformUiSupport.createSourceLevelComboBoxModel(ComboBoxModel, String, String)
public static ComboBoxModel createSourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel, String initialSourceLevel, String initialTargetLevel)
PlatformUiSupport.createSourceLevelComboBoxModel(ComboBoxModel, String, String, SpecificationVersion)
but without any minimal JDK version.platformComboBoxModel
- the platform's model used for listenning.initialSourceLevel
- initial source level value, null if unknown.initialTargetLevel
- initial target level value, null if unknown.ComboBoxModel
of SourceLevelKey
.PlatformUiSupport.createSourceLevelComboBoxModel(ComboBoxModel, String, String, SpecificationVersion)
public static ListCellRenderer createSourceLevelListCellRenderer()
ListCellRenderer
for source levels. This method could be used when highlighting
of illegal source levels is needed.ListCellRenderer
for source levels.public static ComboBoxModel createProfileComboBoxModel(@NonNull ComboBoxModel sourceLevelModel, @NullAllowed String initialProfileName, @NullAllowed SourceLevelQuery.Profile minimalProfile)
ComboBoxModel
of JRE profiles for active source level.
The model listens on the source level ComboBoxModel
and update its
state according to the changes. It is possible to define minimal required
JRE profile.sourceLevelModel
- the source level model used for listening.initialProfileName
- initial profile name, null if unknown.minimalProfile
- minimal JRE profile to be displayed.
It can be null
if all the JRE profiles should be displayed.ComboBoxModel
.public static ListCellRenderer createProfileListCellRenderer()
ListCellRenderer
for JRE profiles.
This renderer highlights incorrect profile names.ListCellRenderer
for JRE profiles.