Skip to content
Open
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 @@ -72,6 +72,9 @@
<Connection code="&quot;mmm&quot;" type="code"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="18" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void actionPerformed(ActionEvent e) {
if (srcLevelValueBeingUpdated) {
return;
}
final String oldLevel = getProperty(getJavacLanguageLevelKey());
final String oldLevel = getEffectiveJavacTarget();
final String newLevel = (String) srcLevelValue.getSelectedItem();
SpecificationVersion jdk5 = new SpecificationVersion("1.5"); // NOI18N
if (new SpecificationVersion(oldLevel).compareTo(jdk5) < 0 && new SpecificationVersion(newLevel).compareTo(jdk5) >= 0) {
Expand Down Expand Up @@ -99,7 +99,7 @@ protected void refresh() {
for (String level : levels) {
srcLevelValue.addItem(level);
}
srcLevelValue.setSelectedItem(getProperty(getJavacLanguageLevelKey()));
srcLevelValue.setSelectedItem(getEffectiveJavacTarget());
} finally {
srcLevelValueBeingUpdated = false;
}
Expand All @@ -108,25 +108,43 @@ protected void refresh() {

@Override
public void store() {
setProperty(getJavacLanguageLevelKey(), (String) srcLevelValue.getSelectedItem());
String selected = (String) srcLevelValue.getSelectedItem();
if (!selected.equals(getEffectiveJavacTarget())) {
setProperty(getJavacLanguageLevelKey(), selected);
}
}

private String getJavacLanguageLevelKey() {
return containsProperty(JAVAC_RELEASE) ? JAVAC_RELEASE : JAVAC_SOURCE;
}


private String getEffectiveJavacTarget() {
String release = props.getEvaluator().getProperty(JAVAC_RELEASE);
return isInteger(release) ? release : props.getEvaluator().getProperty(JAVAC_SOURCE);
}

@SuppressWarnings("UnnecessaryTemporaryOnConversionFromString")
private static boolean isInteger(String release) {
try {
Integer.parseInt(release);
return true;
} catch (IllegalArgumentException ex) {
return false;
}
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;

prjFolder = new javax.swing.JLabel();
srcLevel = new javax.swing.JLabel();
srcLevelValue = new javax.swing.JComboBox();
srcLevelValue = new javax.swing.JComboBox<>();
filler = new javax.swing.JLabel();
prjFolderValue = new javax.swing.JTextField();
moduleSuite = new javax.swing.JLabel();
Expand Down Expand Up @@ -193,9 +211,7 @@ private void initComponents() {
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
add(moduleSuiteValue, gridBagConstraints);

}
// </editor-fold>//GEN-END:initComponents
}// </editor-fold>//GEN-END:initComponents

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel filler;
Expand All @@ -204,7 +220,7 @@ private void initComponents() {
private javax.swing.JLabel prjFolder;
private javax.swing.JTextField prjFolderValue;
private javax.swing.JLabel srcLevel;
private javax.swing.JComboBox srcLevelValue;
private javax.swing.JComboBox<String> srcLevelValue;
// End of variables declaration//GEN-END:variables

private static String getMessage(String key) {
Expand Down Expand Up @@ -233,7 +249,7 @@ private String[] sourceLevels(JavaPlatform platform) {
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
return levels.toArray(new String[0]);
return levels.toArray(String[]::new);
}

}
Loading