Skip to content

Commit

Permalink
[eclipse] Fixing issue when selectingg a project SRE setting in launc…
Browse files Browse the repository at this point in the history
…h configuration.

see #804

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Jan 28, 2018
1 parent 54b497f commit c569d43
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
Expand Up @@ -209,8 +209,8 @@ public void detachResources(ILaunchConfigurationWorkingCopy configuration, IReso
@Override
public void setRuntimeConfiguration(ILaunchConfigurationWorkingCopy configuration, ISREInstall sre,
Boolean useSystemSre, Boolean useProjectSre) {
boolean project = useSystemSre == null ? DEFAULT_USE_SYSTEM_SRE : useSystemSre.booleanValue();
boolean system = useProjectSre == null ? DEFAULT_USE_PROJECT_SRE : useProjectSre.booleanValue();
boolean system = useSystemSre == null ? DEFAULT_USE_SYSTEM_SRE : useSystemSre.booleanValue();
boolean project = useProjectSre == null ? DEFAULT_USE_PROJECT_SRE : useProjectSre.booleanValue();
if (system && project) {
system = true;
project = false;
Expand All @@ -233,10 +233,8 @@ public void setRuntimeConfiguration(ILaunchConfigurationWorkingCopy configuratio
configuration.removeAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME);
}
// Save the boolean configuration flags
configuration.setAttribute(ATTR_USE_SYSTEM_SARL_RUNTIME_ENVIRONMENT,
Boolean.valueOf(system).toString());
configuration.setAttribute(ATTR_USE_PROJECT_SARL_RUNTIME_ENVIRONMENT,
Boolean.valueOf(project).toString());
configuration.setAttribute(ATTR_USE_SYSTEM_SARL_RUNTIME_ENVIRONMENT, system);
configuration.setAttribute(ATTR_USE_PROJECT_SARL_RUNTIME_ENVIRONMENT, project);
// Use the default JRE
configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String) null);
}
Expand Down Expand Up @@ -310,7 +308,14 @@ public boolean getUseSystemSREFlag(ILaunchConfiguration configuration) {
try {
return configuration.getAttribute(ATTR_USE_SYSTEM_SARL_RUNTIME_ENVIRONMENT, DEFAULT_USE_SYSTEM_SRE);
} catch (CoreException e) {
return DEFAULT_USE_SYSTEM_SRE;
// For backward compatibility
try {
final String value = configuration.getAttribute(ATTR_USE_SYSTEM_SARL_RUNTIME_ENVIRONMENT,
Boolean.toString(DEFAULT_USE_SYSTEM_SRE));
return Boolean.valueOf(value);
} catch (Throwable e2) {
return DEFAULT_USE_SYSTEM_SRE;
}
}
}

Expand All @@ -319,7 +324,14 @@ public boolean getUseProjectSREFlag(ILaunchConfiguration configuration) {
try {
return configuration.getAttribute(ATTR_USE_PROJECT_SARL_RUNTIME_ENVIRONMENT, DEFAULT_USE_PROJECT_SRE);
} catch (CoreException e) {
return DEFAULT_USE_PROJECT_SRE;
// For backward compatibility
try {
final String value = configuration.getAttribute(ATTR_USE_PROJECT_SARL_RUNTIME_ENVIRONMENT,
Boolean.toString(DEFAULT_USE_PROJECT_SRE));
return Boolean.valueOf(value);
} catch (Throwable e2) {
return DEFAULT_USE_PROJECT_SRE;
}
}
}

Expand Down
Expand Up @@ -165,20 +165,18 @@ public void initializeFrom(ILaunchConfiguration configuration) {
* @param config the config to load the runtime environment from
*/
protected void selectSREFromConfig(ILaunchConfiguration config) {
final String sreId = this.accessor.getSREId(config);
final ISREInstall sre = SARLRuntime.getSREFromId(Strings.nullToEmpty(sreId));
final boolean notify = this.sreBlock.getNotify();
boolean changed;
final boolean changed;
try {
this.sreBlock.setNotify(false);
changed = this.sreBlock.selectSpecificSRE(sre);

if (this.accessor.getUseSystemSREFlag(config)) {
changed = this.sreBlock.selectSystemWideSRE();
}

if (this.accessor.getUseProjectSREFlag(config)) {
} else if (this.accessor.getUseProjectSREFlag(config)) {
changed = this.sreBlock.selectProjectSRE();
} else {
final String sreId = this.accessor.getSREId(config);
final ISREInstall sre = SARLRuntime.getSREFromId(Strings.nullToEmpty(sreId));
changed = this.sreBlock.selectSpecificSRE(sre);
}
} finally {
this.sreBlock.setNotify(notify);
Expand Down
Expand Up @@ -408,7 +408,7 @@ private static ISREInstall getSREFromExtension(IProject project, boolean verify)
return null;
}
if (verify) {
verifySREValidity(sre, sre.getId(), false);
verifySREValidity(sre, sre.getId());
}
return sre;
}
Expand Down Expand Up @@ -444,14 +444,14 @@ private ISREInstall getProjectSpecificSRE(ILaunchConfiguration configuration, bo
sre = provider.getProjectSREInstall();
if (sre != null) {
if (verify) {
verifySREValidity(sre, sre.getId(), true);
verifySREValidity(sre, sre.getId());
}
return sre;
}
}
final ISREInstall sre = SARLRuntime.getDefaultSREInstall();
if (verify) {
verifySREValidity(sre, (sre == null) ? Messages.SARLLaunchConfigurationDelegate_8 : sre.getId(), true);
verifySREValidity(sre, (sre == null) ? Messages.SARLLaunchConfigurationDelegate_8 : sre.getId());
}
return sre;
}
Expand All @@ -464,15 +464,15 @@ private ISREInstall getProjectSpecificSRE(ILaunchConfiguration configuration, bo
*/
private ISREInstall getSREInstallFor(ILaunchConfiguration configuration) throws CoreException {
final ISREInstall sre;
if (this.accessor.getUseSystemSREFlag(configuration)) {
sre = SARLRuntime.getDefaultSREInstall();
verifySREValidity(sre, sre.getId(), true);
} else if (this.accessor.getUseProjectSREFlag(configuration)) {
if (this.accessor.getUseProjectSREFlag(configuration)) {
sre = getProjectSpecificSRE(configuration, true);
} else if (this.accessor.getUseSystemSREFlag(configuration)) {
sre = SARLRuntime.getDefaultSREInstall();
verifySREValidity(sre, sre.getId());
} else {
final String runtime = this.accessor.getSREId(configuration);
sre = SARLRuntime.getSREFromId(runtime);
verifySREValidity(sre, runtime, true);
verifySREValidity(sre, runtime);
}

if (sre == null) {
Expand Down Expand Up @@ -557,7 +557,7 @@ private IRuntimeClasspathEntry[] computeUnresolvedSARLRuntimeClasspath(ILaunchCo
return entries;
}

private static void verifySREValidity(ISREInstall sre, String runtime, boolean onlyStandalone) throws CoreException {
private static void verifySREValidity(ISREInstall sre, String runtime) throws CoreException {
if (sre == null) {
throw new CoreException(SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR,
MessageFormat.format(io.sarl.eclipse.launching.dialog.Messages.RuntimeEnvironmentTab_6, runtime)));
Expand All @@ -583,6 +583,9 @@ public String getProgramArguments(ILaunchConfiguration configuration) throws Cor
final ISREInstall sre = getSREInstallFor(configuration);
assert sre != null;

// Retreive the classname of the boot agent.
final String bootAgent = getAgentName(configuration);

final IStringVariableManager substitutor = VariablesPlugin.getDefault().getStringVariableManager();

// Retreive the SRE arguments from the SRE configuration
Expand All @@ -591,9 +594,6 @@ public String getProgramArguments(ILaunchConfiguration configuration) throws Cor
// Retreive the SRE arguments from the launch configuration
final String sreArgs2 = substitutor.performStringSubstitution(this.accessor.getSRELaunchingArguments(configuration));

// Retreive the classname of the boot agent.
final String bootAgent = getAgentName(configuration);

// Add the options corresponding to the general setting of the launch configuration.
final Map<String, String> cliOptions = sre.getAvailableCommandLineOptions();
assert cliOptions != null;
Expand Down

0 comments on commit c569d43

Please sign in to comment.