Commit d55eb994 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

DSE-UI: Show visualization from loaded models

Issue-Ref: 4035
Issue-Url: https://af3-developer.fortiss.org/issues/4035

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent ed1e5cb9
Z3Backend.java 070f627218b36e50f61c56d850d0679e5a69d332 GREEN
Z3Backend.java d58fc12855dc3597e52fe0fe59cb2607d77d5583 YELLOW
......@@ -32,7 +32,6 @@ import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.af3.exploration.model.solutions.ExplorationSolution;
import org.fortiss.af3.exploration.service.DSESolutionVisualization;
import org.fortiss.af3.exploration.service.IDSEBackend;
import org.fortiss.af3.exploration.smt.modeltransformation.BasicScheduleConstraint;
import org.fortiss.af3.exploration.smt.modeltransformation.DeploScheduleRun;
......@@ -60,8 +59,6 @@ import org.fortiss.tooling.base.model.element.IModelElement;
* @author diewald
*/
public class Z3Backend implements IDSEBackend {
/** Caches the solution container (metrics/visualization + solution models). */
private DSESolutionVisualization solutionVisualization;
/** {@inheritDoc} */
@Override
......@@ -171,11 +168,6 @@ public class Z3Backend implements IDSEBackend {
return Optional.of(expSolution);
}
/** Returns the cached solution representation (metrics/visualization + solution models). */
public DSESolutionVisualization getSolutionVisualization() {
return solutionVisualization;
}
/** {@inheritDoc} */
@Override
public String getName() {
......
......@@ -7,4 +7,4 @@ HelpComposite.java 72ad69a68860a4c645e2d6c3094be992a53c5d33 GREEN
HelpView.java 5cd89049b0373cacd8fc7e431870260bd81b93c1 GREEN
HierarchicElementContentProvider.java 8a393f0b867ce5616292910a5287b0e39c6d48b7 GREEN
SuperSetContentProvider.java 7e44e42675740b08582dfbc3e4b67ec9bdd73b93 GREEN
SynthesisViewBase.java 8fe309bb06d37a1eb12ddc1a948e864fc6d0806f GREEN
SynthesisViewBase.java 1510ccf7b75faf535ebf7d8e5132e81000ec1ed8 YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
//| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
......@@ -22,7 +22,6 @@ import static org.fortiss.af3.exploration.smt.util.AllocationToSchedule.generate
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.PROCESS_STEP_ADDED;
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.RULE_SET_REMOVED;
import static org.fortiss.af3.exploration.ui.perspective.service.internal.ExplorationCommandRunner.getRunner;
import static org.fortiss.af3.exploration.ui.util.ExplorationSolutionVisualizationUtils.createVisualizationFor;
import static org.fortiss.af3.exploration.ui.util.ExplorationUiUtils.updateTreeWithComboSelection;
import static org.fortiss.af3.exploration.util.DSEProjectModelElementFactory.createExplorationStep;
import static org.fortiss.af3.exploration.util.DSEProjectModelElementFactory.createModelSnapshot;
......@@ -41,7 +40,6 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.runAsCommand;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showInfo;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.fixMissingIDs;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.getLargestID;
......@@ -53,17 +51,12 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Set;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
......@@ -127,12 +120,9 @@ import org.fortiss.af3.exploration.model.project.ProjectPackage;
import org.fortiss.af3.exploration.model.project.RuleSet;
import org.fortiss.af3.exploration.model.project.TargetDefinitionStep;
import org.fortiss.af3.exploration.model.solutions.ExplorationSolution;
import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution;
import org.fortiss.af3.exploration.model.solutions.SolutionState;
import org.fortiss.af3.exploration.service.DSESolutionVisualization;
import org.fortiss.af3.exploration.service.IDSEBackend;
import org.fortiss.af3.exploration.service.IDSEBackendService;
import org.fortiss.af3.exploration.ui.AF3ExplorationUIActivator;
import org.fortiss.af3.exploration.ui.perspective.service.EventBroker;
import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.synthesis.subsetwizards.ConstraintSetWizard;
......@@ -147,8 +137,6 @@ import org.fortiss.af3.task.model.allocation.SignalToRouteAllocationEntry;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationTable;
import org.fortiss.af3.timing.model.TimingSpecification;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.base.model.visualization.DataSet;
import org.fortiss.tooling.base.model.visualization.DataSetCollection;
import org.fortiss.tooling.kernel.ui.presentation.ModelElementLabelProvider;
/**
......@@ -682,43 +670,6 @@ public abstract class SynthesisViewBase extends DSEPerspectiveViewBase {
return constraintsTable;
}
/** Prepares the DSE UI manager to display the results of an exploration run. */
protected void prepareResultVisualization(ExplorationSolution solution) {
Display display = Display.getDefault();
display.syncExec(() -> {
// TODO(AD): This code must be moved to the Visualization backend. (#3666)
IDSEPerspectiveManager pm = IDSEPerspectiveManager.INSTANCE;
pm.setLatestFailedConstraints(Collections.<IExplorationConstraint<?>>emptyList());
DSESolutionVisualization solutionVis = new DSESolutionVisualization();
Map<DataSet, SingleExplorationSolution> visSolutionAssocs = new HashMap<>();
DataSetCollection dataSetCol;
try {
dataSetCol = createVisualizationFor(solution, visSolutionAssocs);
prepareUniqueID(dataSetCol, pm.getCurrentlySelectedDSE());
} catch(InvalidTargetObjectTypeException e) {
error(AF3ExplorationUIActivator.getDefault(),
"ExplorationTarget with unexpected evaluation target encountered: " +
solution,
e);
return;
}
for(Entry<DataSet, SingleExplorationSolution> visSolEntry : visSolutionAssocs
.entrySet()) {
solutionVis.putSolutionVisualization(visSolEntry.getKey(), visSolEntry.getValue());
}
pm.setLatestGeneratedDSVisEElements(dataSetCol);
pm.setDseSolutionVisualization(solutionVis);
if(solution.getSolutionState() == SolutionState.OPTIMIZED) {
showInfoInUIThread("Solution found.",
"The solver returned an optimized but non-optimal solution (Timeout," +
" number of iterations. Please note that \"better\" solutions may" +
" exist.");
}
});
}
/** {@inheritDoc} */
@Override
public void propertyChanged(Object source, DSE_EVENT event) {
......@@ -812,7 +763,14 @@ public abstract class SynthesisViewBase extends DSEPerspectiveViewBase {
.firePropertyChanged(currentStep, PROCESS_STEP_ADDED));
}
prepareResultVisualization(solution);
pm.setLatestFailedConstraints(Collections.<IExplorationConstraint<?>>emptyList());
if(solution.getSolutionState() == SolutionState.OPTIMIZED) {
showInfoInUIThread("Solution found.",
"The solver returned an optimized but non-optimal solution (Timeout," +
" number of iterations. Please note that \"better\" solutions may" +
" exist.");
}
}
}
......
DSEPerspectiveManager.java ad2b28bf6bb8414eda0b1606c53befb8ef731a3a GREEN
DSEPerspectiveManager.java 3ec54cd69961e48cbf3e359c57d4d3dfa421adeb YELLOW
EventBroker.java 5614a199ffe288807a29cf9c213787f52c3555e8 GREEN
ExternalDSEExtensionService.java f402cb069178fdd12ab89f3244490f56bf3f37d1 GREEN
IDSEPerspectiveManager.java 2bc063e88352828ca0d3264730670694dbee76e4 GREEN
IDSEPerspectiveManager.java 499e90dda951ebafedcac484cda065c0eb16ef70 YELLOW
IEventListener.java 6d7eb240719a7d7ef0a2619c2fc72a22109c2786 GREEN
IExternalDSEExtensionService.java f7a7b36329b112a1236752cf7f8f23ebf0f04818 GREEN
......@@ -17,7 +17,6 @@ package org.fortiss.af3.exploration.ui.perspective.service;
import static java.util.Collections.emptyList;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.af3.allocation.utils.AllocationUtils.getOrCreateAllocationTable;
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.CONSTRAINT_ADDED;
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.DSE_REMOVED_EVENT;
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.DSE_SELECTED_EVENT;
......@@ -41,19 +40,13 @@ import java.util.Optional;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ProcessStep;
import org.fortiss.af3.exploration.model.project.RuleSet;
import org.fortiss.af3.exploration.model.project.TargetDefinitionStep;
import org.fortiss.af3.exploration.service.DSESolutionVisualization;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationTable;
import org.fortiss.tooling.base.model.visualization.DataSetCollection;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.service.listener.IPersistencyServiceListener;
......@@ -71,24 +64,12 @@ public class DSEPerspectiveManager implements IDSEPerspectiveManager {
/** Currently active DSE */
private DSE currentDSE;
/** The latest visualization Data set collection. */
private DataSetCollection dataSetCollection;
/** The latest failed constraints. */
private List<IExplorationConstraint<?>> latestFailedConstraints = emptyList();
/** Association container of visualizations to exploration solutions. */
private DSESolutionVisualization dseSolutionVisualization;
/** The sub sets which were used for the latest generation. */
private List<RuleSet> latestUsedSubSets = emptyList();
/** The currently active {@link TaskArchitecture}. */
private TaskArchitecture taskArchitecture;
/** The currently active {@link PlatformArchitecture}. */
private PlatformArchitecture platformArchitecture;
/** Constructor. */
/* package */ DSEPerspectiveManager() {
IPersistencyService.getInstance().addTopLevelElementListener(new DSENodeListener());
......@@ -215,18 +196,6 @@ public class DSEPerspectiveManager implements IDSEPerspectiveManager {
evBroker.firePropertyChanged(subSet, RULE_SET_ADDED);
}
/** {@inheritDoc} */
@Override
public DataSetCollection getLatestGeneratedDSEVisElements() {
return dataSetCollection;
}
/** {@inheritDoc} */
@Override
public void setLatestGeneratedDSVisEElements(DataSetCollection dataSetCollection) {
this.dataSetCollection = dataSetCollection;
}
/** {@inheritDoc} */
@Override
public void addExplorationSubSet(DSE dse, ArrayList<RuleSet> allConstraintsSets) {
......@@ -263,24 +232,6 @@ public class DSEPerspectiveManager implements IDSEPerspectiveManager {
return latestFailedConstraints;
}
/** {@inheritDoc} */
@Override
public DSESolutionVisualization getDseSolutionVisualization() {
return dseSolutionVisualization;
}
/** {@inheritDoc} */
@Override
public void setDseSolutionVisualization(DSESolutionVisualization dseSolutionVisualization) {
this.dseSolutionVisualization = dseSolutionVisualization;
}
/** {@inheritDoc} */
@Override
public PlatformArchitecture getPlatformArchitectureInScope() {
return platformArchitecture;
}
/** {@inheritDoc} */
@Override
public void setLatestCheckedSubsets(List<RuleSet> subSets) {
......@@ -292,31 +243,4 @@ public class DSEPerspectiveManager implements IDSEPerspectiveManager {
public List<RuleSet> getLatestCheckedSubsets() {
return latestUsedSubSets;
}
/** {@inheritDoc} */
@Override
public TaskArchitecture getTaskArchitectureInScope() {
return taskArchitecture;
}
/** {@inheritDoc} */
@Override
public void setTaskArchitectureInScope(TaskArchitecture ta) {
this.taskArchitecture = ta;
}
/** {@inheritDoc} */
@Override
public void setPlatformArchitectureInScope(PlatformArchitecture ta) {
this.platformArchitecture = ta;
}
/** {@inheritDoc} */
@Override
public AllocationTableCollection getInputAllocationTableCollection() {
ComponentToTaskAllocationTable ca2ta =
getOrCreateAllocationTable(ComponentToTaskAllocationTable.class, null,
IDSEPerspectiveManager.INSTANCE.getTaskArchitectureInScope(), null);
return ca2ta.getAllocationTableCollection();
}
}
......@@ -18,18 +18,12 @@ package org.fortiss.af3.exploration.ui.perspective.service;
import java.util.ArrayList;
import java.util.List;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.RuleSet;
import org.fortiss.af3.exploration.model.project.TargetDefinitionStep;
import org.fortiss.af3.exploration.service.DSESolutionVisualization;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationTable;
import org.fortiss.tooling.base.model.visualization.DataSetCollection;
/**
* Interface for the management of the DSE perspective.
......@@ -62,45 +56,15 @@ public interface IDSEPerspectiveManager {
/** Called when a process step changes to another process step. */
void processStepChanged();
/** Returns the latest generated visualization data set. */
DataSetCollection getLatestGeneratedDSEVisElements();
/** Updates the latest generated visualization data set. */
void setLatestGeneratedDSVisEElements(DataSetCollection dataSetCollection);
/** Updates the latest failed constraints. */
void setLatestFailedConstraints(List<IExplorationConstraint<?>> constraints);
/** Returns the latest failed constraints. */
List<IExplorationConstraint<?>> getLatestFailedConstraints();
/** Returns the Visualization Data Set to SingleExplorationSolution mapping. */
DSESolutionVisualization getDseSolutionVisualization();
/** Updates the Visualization Data Set to Component Allocation list (deployment) mapping. */
void setDseSolutionVisualization(DSESolutionVisualization explorationSolution);
/** Returns the {@link TaskArchitecture} which is considered in the current DSE. */
TaskArchitecture getTaskArchitectureInScope();
/** Sets the {@link TaskArchitecture} which is considered in the current DSE. */
void setTaskArchitectureInScope(TaskArchitecture ta);
/** Sets the {@link PlatformArchitecture} which is considered in the current DSE. */
void setPlatformArchitectureInScope(PlatformArchitecture ta);
/** Returns the {@link PlatformArchitecture} which is considered in the current DSE. */
PlatformArchitecture getPlatformArchitectureInScope();
/** Set latest sub sets which were used for generation. */
void setLatestCheckedSubsets(List<RuleSet> subSets);
/** Returns the latest sub sets which were used for generation. */
List<RuleSet> getLatestCheckedSubsets();
/**
* Returns the {@link AllocationTableCollection} that contains the input
* {@link ComponentToTaskAllocationTable}.
*/
AllocationTableCollection getInputAllocationTableCollection();
}
DeploymentSynthesisViewBackend.java df1b02a7a1bda52effda366ad1b47e06c6dc58d7 GREEN
PlatformSynthesisViewBackend.java 40058024c841b27d75c41fa8080493664395b352 GREEN
PlatformSynthesisViewBackend.java 118e753ba6785cb9d4462b43268abbd91c493a08 YELLOW
ScheduleSynthesisViewBackend.java 597320941b651a4c53e313e00ae3b345f111726e GREEN
......@@ -26,6 +26,7 @@ import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.cr
import static org.fortiss.af3.exploration.util.ExplorationUtils.convertRuleSetsToExplorationSpec;
import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.askQuestionInUIThread;
import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showErrorInUIThread;
import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showInfoInUIThread;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.runAsCommand;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showInfo;
......@@ -33,6 +34,7 @@ import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.getLargestID;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.prepareIDs;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
......@@ -45,6 +47,7 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ExplorationStep;
......@@ -226,7 +229,15 @@ public class PlatformSynthesisViewBackend extends PlatformSynthesisViewGUI {
// current one upfront.
ExplorationStep expStep = (ExplorationStep)dse.getCurrentStep();
getRunner().run(() -> expStep.setSolution(solution));
prepareResultVisualization(solution);
pm.setLatestFailedConstraints(Collections.<IExplorationConstraint<?>>emptyList());
if(solution.getSolutionState() == SolutionState.OPTIMIZED) {
showInfoInUIThread("Solution found.",
"The solver returned an optimized but non-optimal solution (Timeout," +
" number of iterations. Please note that \"better\" solutions may" +
" exist.");
}
}
}
}
VisualizationViewBackend.java 2884136e3ed85f1523580bb4864d93cab9446150 GREEN
DSESolutionVisualizationContainer.java 4c97bf1e9885e6bcfc425acad4a71c9f1bb918e9 YELLOW
VisualizationViewBackend.java ad6ccfd7683afc86d8dbfc09c774abf1d8fdecae YELLOW
......@@ -13,26 +13,48 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.service;
package org.fortiss.af3.exploration.ui.perspective.visualization;
import static org.fortiss.af3.exploration.ui.util.ExplorationSolutionVisualizationUtils.createVisualizationFor;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import org.fortiss.af3.exploration.model.solutions.ExplorationSolution;
import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution;
import org.fortiss.af3.exploration.ui.AF3ExplorationUIActivator;
import org.fortiss.tooling.base.model.visualization.DataSet;
import org.fortiss.tooling.base.model.visualization.DataSetCollection;
/**
* This class serves as a wrapper between {@link ExplorationSolution}s and their visualization.
*
* @author diewald
*/
public class DSESolutionVisualization {
public class DSESolutionVisualizationContainer {
/** {@link DataSet} to Deployment mapping. */
private Map<DataSet, SingleExplorationSolution> visToSolutionModel = new HashMap<>();
/** References the {@link DataSetCollection} that supplies a graphical representation. */
private DataSetCollection dataSetCol;
/** Constructor. */
public DSESolutionVisualizationContainer(ExplorationSolution solution) {
try {
dataSetCol = createVisualizationFor(solution, visToSolutionModel);
} catch(InvalidTargetObjectTypeException e) {
error(AF3ExplorationUIActivator.getDefault(),
"ExplorationTarget with unexpected evaluation target encountered: " + solution,
e);
return;
}
}
/**
* Returns the solution model associated with a specific DataSet that quantifies the quality
* metrics of a solution.
......@@ -41,10 +63,9 @@ public class DSESolutionVisualization {
return visToSolutionModel.get(dataSet);
}
/** Adds a {@link DataSet} and solution model to {@code this} container. */
public void putSolutionVisualization(DataSet visualization,
SingleExplorationSolution solution) {
visToSolutionModel.put(visualization, solution);
/** Returns the {@link DataSetCollection} that forms the basis for visualization. */
public DataSetCollection getDataSetCollection() {
return dataSetCol;
}
/** Returns all {@link DataSet} to {@link SingleExplorationSolution} entries. */
......
......@@ -15,12 +15,18 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.visualization;
import static org.eclipse.core.runtime.Assert.isTrue;
import static org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.VisualizationViewFactory.createView;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ExplorationStep;
import org.fortiss.af3.exploration.model.project.ProcessStep;
import org.fortiss.af3.exploration.model.project.SolutionSelectionStep;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager;
import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.IVisualizationView;
import org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.IVisualizationView.ViewConstants;
......@@ -41,31 +47,65 @@ public class VisualizationViewBackend extends VisualizationViewGUI {
public void createPartControl(Composite parent) {
super.createPartControl(parent);
getBtnSpiderChart().addSelectionListener(createVisSubViewActivator(ViewConstants.SPIDER));
getBtndSpace().addSelectionListener(createVisSubViewActivator(ViewConstants.FOURD));
getBtnTable().addSelectionListener(createVisSubViewActivator(ViewConstants.TABLE));
getBtnGanttChart().addSelectionListener(createVisSubViewActivator(ViewConstants.GANTT));
ProcessStep pStep = null;
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
if(dse != null) {
pStep = dse.getCurrentStep();
}
if(pStep != null &&
(pStep instanceof ExplorationStep || pStep instanceof SolutionSelectionStep)) {
ExplorationStep expStep = null;
if(pStep instanceof SolutionSelectionStep) {
ProcessStep parentStep = pStep.getParent();
isTrue(parentStep instanceof ExplorationStep, "According to the DSE Process" +
" model, an ExplorationStep is a successor of a SolutionSelectionStep." +
" If the model changed, please adjust the code.");
expStep = (ExplorationStep)parentStep;
} else {
// We must have an ExplorationStep here, see parent conditional.
expStep = (ExplorationStep)pStep;
}
// Use the spider chart as the default view.
switchView(ViewConstants.SPIDER);
DSESolutionVisualizationContainer solution =
new DSESolutionVisualizationContainer(expStep.getSolution());
getBtnSpiderChart().addSelectionListener(
createVisSubViewActivator(ViewConstants.SPIDER, solution));
getBtndSpace()
.addSelectionListener(createVisSubViewActivator(ViewConstants.FOURD, solution));
getBtnTable()
.addSelectionListener(createVisSubViewActivator(ViewConstants.TABLE, solution));
getBtnGanttChart()
.addSelectionListener(createVisSubViewActivator(ViewConstants.GANTT, solution));
// Use the spider chart as the default view.
switchView(ViewConstants.SPIDER, solution);
} else {
getBtnSpiderChart().setEnabled(false);
getBtndSpace().setEnabled(false);
getBtnTable().setEnabled(false);
getBtnGanttChart().setEnabled(false);
}
}
/** Creates a listener for switching the subview to the given type. */
private SelectionAdapter createVisSubViewActivator(ViewConstants viewType) {
private SelectionAdapter createVisSubViewActivator(ViewConstants viewType,
DSESolutionVisualizationContainer solution) {
return new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
switchView(viewType);