Commit e137b5f2 authored by Levi Lucio's avatar Levi Lucio
Browse files

Fixed bug caused by using closures to calculate which configurations are...

Fixed bug caused by using closures to calculate which configurations are satisfied. Also, refreshed upcoming objectives box when project changes.  
refs 3039
parent d6e033f0
......@@ -137,6 +137,7 @@ public class UpcomingObjectiveContributionItem extends ContributionItem implemen
upcomingObjectiveCombo.setItems(configNamesArray);
upcomingObjectiveCombo.setText(configNamesArray[0]);
} else {
upcomingObjectiveCombo.setItems(new String[0]);
upcomingObjectiveCombo.setText(initialObjective);
}
}
......@@ -167,6 +168,7 @@ public class UpcomingObjectiveContributionItem extends ContributionItem implemen
// set the current project to the one selected on the navigation tree
if(selection instanceof ITreeSelection) {
if(((ITreeSelection)selection).getFirstElement() != null) {
Object objectChosenElement = ((ITreeSelection)selection).getFirstElement();
......@@ -198,6 +200,8 @@ public class UpcomingObjectiveContributionItem extends ContributionItem implemen
(ConstraintBasedDevelopmentProcess)processConfig.getDevelopment();
currentDevelopmentProcess = process;
System.out.println("Process: " + currentDevelopmentProcess.toString());
}
}
}
......@@ -217,10 +221,17 @@ public class UpcomingObjectiveContributionItem extends ContributionItem implemen
List<ConstraintConfiguration> atomicConfigs =
LambdaUtils.filterList(configs, c -> c.getIncludedConfigurations().isEmpty());
List<ConstraintConfiguration> satisfiedObjectives =
LambdaUtils.filterList(atomicConfigs, c -> isConfigurationSatisfied(c));
List<ConstraintConfiguration> upcomingObjectives =
LambdaUtils.filterList(atomicConfigs, c -> !isConfigurationSatisfied(c));
List<ConstraintConfiguration> satisfiedObjectives = new ArrayList<>();
List<ConstraintConfiguration> upcomingObjectives = new ArrayList<>();
for(ConstraintConfiguration constraintConfiguration : atomicConfigs) {
if(isConfigurationSatisfied(constraintConfiguration)) {
satisfiedObjectives.add(constraintConfiguration);
} else {
upcomingObjectives.add(constraintConfiguration);
}
}
boolean newSatisfiedAddedObjectives = !satisfiedObjectives.isEmpty();
......@@ -277,45 +288,50 @@ public class UpcomingObjectiveContributionItem extends ContributionItem implemen
ITopLevelElement modelContext =
IPersistencyService.getInstance().getTopLevelElementFor(currentDevelopmentProcess);
modelContext.runAsNonDirtyingCommand(() -> {
// deactivate current configurations
deactivateConfiguration(currentDevelopmentProcess.getCurrentObjective(),
currentDevelopmentProcess.getConstraintInstanceContainer());
// activate configuration to be checked
activateOneConfiguration(constraintConfiguration,
currentDevelopmentProcess.getConstraintInstanceContainer());
});
boolean result = true;
EList<String> activeConstraints = constraintConfiguration.getActiveConstraints();
for(String constraintName : activeConstraints) {
EList<ConstraintInstance> instances =
currentDevelopmentProcess.getConstraintInstanceContainer()
.getConstraintInstances();
for(ConstraintInstance ci : instances) {
if(constraintName.equalsIgnoreCase(ci.getConstraintName())) {
IConstraintInstanceStatus status =
IConstraintUIService.getInstance().getStatus(ci);
if(!(status instanceof SuccessConstraintInstanceStatus)) {
result = false;
break;
if(!activeConstraints.isEmpty()) {
modelContext.runAsNonDirtyingCommand(() -> {
// deactivate current configurations
deactivateConfiguration(currentDevelopmentProcess.getCurrentObjective(),
currentDevelopmentProcess.getConstraintInstanceContainer());
// activate configuration to be checked
activateOneConfiguration(constraintConfiguration,
currentDevelopmentProcess.getConstraintInstanceContainer());
});
for(String constraintName : activeConstraints) {
EList<ConstraintInstance> instances =
currentDevelopmentProcess.getConstraintInstanceContainer()
.getConstraintInstances();
for(ConstraintInstance ci : instances) {
if(constraintName.equalsIgnoreCase(ci.getConstraintName())) {
IConstraintInstanceStatus status =
IConstraintUIService.getInstance().getStatus(ci);
if(!(status instanceof SuccessConstraintInstanceStatus)) {
result = false;
break;
}
}
}
}
}
modelContext.runAsNonDirtyingCommand(() -> {
modelContext.runAsNonDirtyingCommand(() -> {
// deactivate configuration to be checked
deactivateOneConfiguration(constraintConfiguration,
currentDevelopmentProcess.getConstraintInstanceContainer());
// deactivate configuration to be checked
deactivateOneConfiguration(constraintConfiguration,
currentDevelopmentProcess.getConstraintInstanceContainer());
// reactivate current configuration
activateConfiguration(currentDevelopmentProcess.getCurrentObjective(),
currentDevelopmentProcess.getConstraintInstanceContainer());
});
// reactivate current configuration
activateConfiguration(currentDevelopmentProcess.getCurrentObjective(),
currentDevelopmentProcess.getConstraintInstanceContainer());
});
}
return result;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment