Skip to content

Commit

Permalink
Fixed error message and potential NPE in SetCompilerVersionCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 23, 2014
1 parent 51298f1 commit a1253ac
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -46,8 +46,8 @@ public UICommandMetadata getMetadata(UIContext context)
public void initializeUI(UIBuilder builder) throws Exception
{
JavaCompilerFacet javaCompilerFacet = getJavaCompilerFacet(builder.getUIContext());
sourceVersion.setValue(javaCompilerFacet.getSourceCompilerVersion());
targetVersion.setValue(javaCompilerFacet.getTargetCompilerVersion());
sourceVersion.setDefaultValue(javaCompilerFacet.getSourceCompilerVersion());
targetVersion.setDefaultValue(javaCompilerFacet.getTargetCompilerVersion());
builder.add(sourceVersion).add(targetVersion);
}

Expand All @@ -71,10 +71,13 @@ private JavaCompilerFacet getJavaCompilerFacet(UIContext context)
@Override
public void validate(UIValidationContext validator)
{
if (sourceVersion.getValue().ordinal() > targetVersion.getValue().ordinal())
if (sourceVersion.hasValue() && targetVersion.hasValue())
{
validator.addValidationError(sourceVersion, "Selected source version (" + sourceVersion.toString() +
") is higher than the target version (" + targetVersion.toString() + ").");
if (sourceVersion.getValue().ordinal() > targetVersion.getValue().ordinal())
{
validator.addValidationError(sourceVersion, "Selected source version (" + sourceVersion.getValue() +
") is higher than the target version (" + targetVersion.getValue() + ").");
}
}
}

Expand Down

0 comments on commit a1253ac

Please sign in to comment.