Commit 8365bf66 authored by Alexander Diewald's avatar Alexander Diewald

DSE: Cleanup Pattern UI code

* Remove warnings.
* Make the utilization of the Memory Pattern editable again.
* Use TreeViews, instead of TreeTableViews if there is only one column.

Issue-Ref: 3365
Issue-Url: https://af3-developer.fortiss.org/issues/3365Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 255658c4
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?> <?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.TreeTableView?> <?import javafx.scene.control.TreeView?>
<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.Pane?>
<Pane fx:id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="540.0" prefWidth="816.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"> <Pane fx:id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="540.0" prefWidth="816.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<TreeTableView fx:id="ecuView" layoutX="20.0" layoutY="10.0" prefHeight="400.0" prefWidth="250.0" /> <TreeView fx:id="ecuView" layoutX="20.0" layoutY="10.0" prefHeight="400.0" prefWidth="250.0" />
<RadioButton fx:id="minButton" layoutX="236.0" layoutY="468.0" mnemonicParsing="false" text="Minimize" /> <RadioButton fx:id="minButton" layoutX="236.0" layoutY="468.0" mnemonicParsing="false" text="Minimize" />
<RadioButton fx:id="maxButton" layoutX="236.0" layoutY="495.0" mnemonicParsing="false" text="Maximize" /> <RadioButton fx:id="maxButton" layoutX="236.0" layoutY="495.0" mnemonicParsing="false" text="Maximize" />
<TreeTableView fx:id="propertyView" layoutX="290.0" layoutY="10.0" prefHeight="400.0" prefWidth="250.0" /> <TreeView fx:id="propertyView" layoutX="290.0" layoutY="10.0" prefHeight="400.0" prefWidth="250.0" />
<TreeTableView fx:id="taskView" layoutX="560.0" layoutY="10.0" prefHeight="400.0" prefWidth="250.0" /> <TreeView fx:id="taskView" layoutX="560.0" layoutY="10.0" prefHeight="400.0" prefWidth="250.0" />
<Label layoutX="236.0" layoutY="439.0" text="Optimization Direction" /> <Label layoutX="236.0" layoutY="439.0" text="Optimization Direction" />
<RadioButton fx:id="sumButton" layoutX="477.0" layoutY="468.0" mnemonicParsing="false" text="Sum" /> <RadioButton fx:id="sumButton" layoutX="477.0" layoutY="468.0" mnemonicParsing="false" text="Sum" />
<RadioButton fx:id="countButton" layoutX="477.0" layoutY="495.0" mnemonicParsing="false" text="Count" /> <RadioButton fx:id="countButton" layoutX="477.0" layoutY="495.0" mnemonicParsing="false" text="Count" />
......
PatternContainerFXController.java cb92f0084cc9fe9ced342b584d5c010c1e6a77a1 RED ConstraintObjectiveFXController.java 4c7acacb248ed690d042fe729459016137991e2f YELLOW
PatternContainerFXController.java d011fe3eeb5c675d26a6ddcf103b0b9b46aa3a9d YELLOW
PatternFXControllerBase.java bf35741f8936929e008f9bb4ba74c8d02ec859b9 YELLOW
SuperSetContentProvider.java 86806720c678ba5c92ec2579b665d3f401df07b3 GREEN SuperSetContentProvider.java 86806720c678ba5c92ec2579b665d3f401df07b3 GREEN
...@@ -13,13 +13,12 @@ ...@@ -13,13 +13,12 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.generic; package org.fortiss.af3.exploration.ui.perspective.targetdef;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import java.util.List; import java.util.List;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternContainerFXController;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase; import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
import javafx.fxml.FXML; import javafx.fxml.FXML;
......
...@@ -19,7 +19,6 @@ import static java.lang.String.join; ...@@ -19,7 +19,6 @@ import static java.lang.String.join;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showInfo; import static org.conqat.ide.commons.ui.dialog.MessageUtils.showInfo;
import org.fortiss.af3.exploration.model.IExplorationTarget; import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.ui.perspective.generic.PatternFXControllerBase;
import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager; import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase; import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
......
...@@ -13,11 +13,14 @@ ...@@ -13,11 +13,14 @@
| See the License for the specific language governing permissions and | | See the License for the specific language governing permissions and |
| limitations under the License. | | limitations under the License. |
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.generic; package org.fortiss.af3.exploration.ui.perspective.targetdef;
import java.util.Collection; import java.util.Collection;
import org.fortiss.af3.exploration.model.IExplorationTarget; import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.ui.perspective.service.EventBroker;
import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase; import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
import javafx.scene.Node; import javafx.scene.Node;
...@@ -32,6 +35,25 @@ import javafx.scene.control.TitledPane; ...@@ -32,6 +35,25 @@ import javafx.scene.control.TitledPane;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public abstract class PatternFXControllerBase extends CompositeFXControllerBase<TitledPane, Node> { public abstract class PatternFXControllerBase extends CompositeFXControllerBase<TitledPane, Node> {
/** References the currently selected {@link DSE}. */
protected DSE dse;
/** Constructor. */
protected PatternFXControllerBase() {
this.dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
EventBroker.getInstance().addListener((src, event) -> {
switch(event) {
case DSE_SELECTED_EVENT:
dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
break;
case DSE_REMOVED_EVENT:
dse = null;
break;
}
});
}
/** The patterns's name. */ /** The patterns's name. */
public abstract String getPatternName(); public abstract String getPatternName();
......
ConstraintsFXViewPart.java 89893c80b8af0582ce1f2a786a9dce180a7bd099 RED ConstraintsFXViewPart.java 51d0d643b74d13231e34248702c467949f93936a YELLOW
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
package org.fortiss.af3.exploration.ui.perspective.targetdef.constraint; package org.fortiss.af3.exploration.ui.perspective.targetdef.constraint;
import org.eclipse.fx.ui.workbench3.FXViewPart; import org.eclipse.fx.ui.workbench3.FXViewPart;
import org.fortiss.af3.exploration.ui.perspective.generic.ConstraintObjectiveFXController;
import org.fortiss.af3.exploration.ui.perspective.generic.ExplorationUIFXController; import org.fortiss.af3.exploration.ui.perspective.generic.ExplorationUIFXController;
import org.fortiss.af3.exploration.ui.perspective.generic.ExplorationUIFXViewPart; import org.fortiss.af3.exploration.ui.perspective.generic.ExplorationUIFXViewPart;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager; import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep; import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep;
import org.fortiss.af3.exploration.ui.perspective.targetdef.ConstraintObjectiveFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.AllocationPatternFXController; import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.AllocationPatternFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.CouplingPatternFXController; import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.CouplingPatternFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.MemoryPatternFXController; import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.MemoryPatternFXController;
......
AllocationPatternFXController.java 7c3ba677a9b14857d20140d48d321cd4b41d0fda RED AllocationPatternFXController.java 840bc404f6aefb8bc0e6f9b25f156d9db647178b YELLOW
CouplingPatternFXController.java b8270aaddefdde9d845bb2c6624bb850384b4aad RED CouplingPatternFXController.java 937034aa2dd680abfcd815c32deb5f322663dc37 YELLOW
MemoryPatternFXController.java a15b2a0bb69681e4ae675dcc23fc9aaf44558728 RED MemoryPatternFXController.java b45b1eb1418d75cc4f4b2983b996b8ef4abab58d YELLOW
SafetyPatternFXController.java 440af5d6bdd5ce26b4d77461f8b34271fadfc637 RED SafetyPatternFXController.java 4d84c1bd15d1f8d15475849c5e2b9c24f094b76e YELLOW
...@@ -16,9 +16,10 @@ import org.fortiss.af3.exploration.dseml.model.expression.IExpression; ...@@ -16,9 +16,10 @@ import org.fortiss.af3.exploration.dseml.model.expression.IExpression;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet; import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.IExplorationTarget; import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE; import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.ui.perspective.generic.PatternFXControllerBase;
import org.fortiss.af3.exploration.ui.perspective.generic.SuperSetContentProvider; import org.fortiss.af3.exploration.ui.perspective.generic.SuperSetContentProvider;
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.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.task.model.Task; import org.fortiss.af3.task.model.Task;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase; import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase;
...@@ -140,46 +141,51 @@ public class AllocationPatternFXController extends PatternFXControllerBase { ...@@ -140,46 +141,51 @@ public class AllocationPatternFXController extends PatternFXControllerBase {
return "AllocationPatternInterface.fxml"; return "AllocationPatternInterface.fxml";
} }
/**
* Creates a viewer for the table of tasks and the radio buttons.
*/
private class AllocationViewer {
/** Constructor. */
public AllocationViewer() {
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
SuperSet<Task> tasks = dse.getCurrentStep().getSuperSetMap().get(Task.class);
SuperSet<ExecutionUnit> ecus =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
@SuppressWarnings("unchecked") DynamicTreeUIProviderBase<EObject> uiProvider =
(DynamicTreeUIProviderBase<EObject>)(DynamicTreeUIProviderBase<?>)createNameProvider();
// The constructed Object is not needed. It is called from the passed TreeView.
new DynamicTreeViewer<EObject>(taskView, tasks, false, 0,
new SuperSetContentProvider<Task>(), uiProvider);
// add a viewer for the ECUs
// The constructed Object is not needed. It is called from the passed TreeView.
new DynamicTreeViewer<EObject>(ecuView, ecus, false, 0,
new SuperSetContentProvider<ExecutionUnit>(), uiProvider);
// add the radio buttons for switching from allocation to dislocation
final ToggleGroup group = new ToggleGroup();
allocationButton.setToggleGroup(group);
dislocationButton.setToggleGroup(group);
allocationButton.setSelected(true);
}
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void initialize() { public void initialize() {
if(IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE() != null) { EventBroker.getInstance().addListener((src, event) -> {
new AllocationViewer(); switch(event) {
case DSE_SELECTED_EVENT:
setupViews();
break;
case DSE_REMOVED_EVENT:
taskView.setRoot(null);
ecuView.setRoot(null);
break;
}
});
if(dse != null) {
setupViews();
} }
} }
/** Helper method to populate the views and preselect items. */
private void setupViews() {
SuperSet<Task> tasks = dse.getCurrentStep().getSuperSetMap().get(Task.class);
SuperSet<ExecutionUnit> ecus =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
@SuppressWarnings("unchecked") DynamicTreeUIProviderBase<EObject> uiProvider =
(DynamicTreeUIProviderBase<EObject>)(DynamicTreeUIProviderBase<?>)createNameProvider();
// The constructed Object is not needed. It is called from the passed TreeView.
new DynamicTreeViewer<EObject>(taskView, tasks, false, 0,
new SuperSetContentProvider<Task>(), uiProvider);
// add a viewer for the ECUs
// The constructed Object is not needed. It is called from the passed TreeView.
new DynamicTreeViewer<EObject>(ecuView, ecus, false, 0,
new SuperSetContentProvider<ExecutionUnit>(), uiProvider);
// add the radio buttons for switching from allocation to dislocation
final ToggleGroup group = new ToggleGroup();
allocationButton.setToggleGroup(group);
dislocationButton.setToggleGroup(group);
allocationButton.setSelected(true);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Collection<Node> getControls() { public Collection<Node> getControls() {
......
...@@ -31,9 +31,10 @@ import org.fortiss.af3.exploration.dseml.model.expression.IExpression; ...@@ -31,9 +31,10 @@ import org.fortiss.af3.exploration.dseml.model.expression.IExpression;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet; import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.IExplorationTarget; import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE; import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.ui.perspective.generic.PatternFXControllerBase;
import org.fortiss.af3.exploration.ui.perspective.generic.SuperSetContentProvider; import org.fortiss.af3.exploration.ui.perspective.generic.SuperSetContentProvider;
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.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.af3.task.model.Task; import org.fortiss.af3.task.model.Task;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase; import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeViewer; import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeViewer;
...@@ -133,39 +134,43 @@ public class CouplingPatternFXController extends PatternFXControllerBase { ...@@ -133,39 +134,43 @@ public class CouplingPatternFXController extends PatternFXControllerBase {
return "CouplingPatternInterface.fxml"; return "CouplingPatternInterface.fxml";
} }
/**
* Creates a viewer for the table of tasks and the radio buttons.
*/
private class CouplingViewer {
/** Constructor. */
public CouplingViewer() {
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
SuperSet<Task> tasks = dse.getCurrentStep().getSuperSetMap().get(Task.class);
@SuppressWarnings("unchecked") DynamicTreeUIProviderBase<EObject> uiProvider =
(DynamicTreeUIProviderBase<EObject>)(DynamicTreeUIProviderBase<?>)createNameProvider();
// The constructed Object is not needed. It is called from the passed TreeView.
new DynamicTreeViewer<EObject>(view, tasks, false, 0,
new SuperSetContentProvider<Task>(), uiProvider);
// add the radio buttons for switching from coupling to decoupling
final ToggleGroup group = new ToggleGroup();
couplingButton.setToggleGroup(group);
decouplingButton.setToggleGroup(group);
couplingButton.setSelected(true);
}
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void initialize() { public void initialize() {
if(IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE() != null) { EventBroker.getInstance().addListener((src, event) -> {
new CouplingViewer(); switch(event) {
case DSE_SELECTED_EVENT:
setupViews();
break;
case DSE_REMOVED_EVENT:
view.setRoot(null);
break;
}
});
if(dse != null) {
setupViews();
} }
} }
/** Helper method to populate the views and preselect items. */
private void setupViews() {
SuperSet<Task> tasks = dse.getCurrentStep().getSuperSetMap().get(Task.class);
@SuppressWarnings("unchecked") DynamicTreeUIProviderBase<EObject> uiProvider =
(DynamicTreeUIProviderBase<EObject>)(DynamicTreeUIProviderBase<?>)createNameProvider();
// The constructed Object is not needed. It is called from the passed TreeView.
new DynamicTreeViewer<EObject>(view, tasks, false, 0, new SuperSetContentProvider<Task>(),
uiProvider);
// add the radio buttons for switching from coupling to decoupling
final ToggleGroup group = new ToggleGroup();
couplingButton.setToggleGroup(group);
decouplingButton.setToggleGroup(group);
couplingButton.setSelected(true);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Collection<Node> getControls() { public Collection<Node> getControls() {
......
...@@ -35,9 +35,10 @@ import org.fortiss.af3.exploration.dseml.model.booleanp.IBooleanExpression; ...@@ -35,9 +35,10 @@ import org.fortiss.af3.exploration.dseml.model.booleanp.IBooleanExpression;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet; import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.IExplorationTarget; import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE; import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.ui.perspective.generic.PatternFXControllerBase;
import org.fortiss.af3.exploration.ui.perspective.generic.SuperSetContentProvider; import org.fortiss.af3.exploration.ui.perspective.generic.SuperSetContentProvider;
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.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.annotation.FlashSize; import org.fortiss.af3.platform.model.annotation.FlashSize;
import org.fortiss.af3.platform.model.annotation.RamSize; import org.fortiss.af3.platform.model.annotation.RamSize;
...@@ -93,8 +94,7 @@ public class MemoryPatternFXController extends PatternFXControllerBase { ...@@ -93,8 +94,7 @@ public class MemoryPatternFXController extends PatternFXControllerBase {
} }
/** /**
* Returns the {@link ExecutionUnit}s currently selected in the * Returns the {@link ExecutionUnit}s currently selected in the {@link #view}.
* {@link MemoryUtilizationTreeTableViewer}.
*/ */
private Collection<ExecutionUnit> getSelectedExecutionUnits() { private Collection<ExecutionUnit> getSelectedExecutionUnits() {
return view.getSelectionModel().getSelectedItems().stream() return view.getSelectionModel().getSelectedItems().stream()
...@@ -136,67 +136,79 @@ public class MemoryPatternFXController extends PatternFXControllerBase { ...@@ -136,67 +136,79 @@ public class MemoryPatternFXController extends PatternFXControllerBase {
return "MemoryPatternInterface.fxml"; return "MemoryPatternInterface.fxml";
} }
/**
* Creates a {@link DynamicTreeTableViewer} with an editable column for the memory utilization.
*/
private class MemoryUtilizationTreeTableViewer {
/** Constructor. */
public MemoryUtilizationTreeTableViewer() {
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
SuperSet<ExecutionUnit> executionUnits =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
memoryUtilization = new HashMap<ExecutionUnit, Integer>();
executionUnits.getEntries()
.forEach(executionUnit -> memoryUtilization.put(executionUnit, 100));
DynamicTreeTableUIProviderBase uiProvider = new DynamicTreeTableUIProviderBase() {
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int column) {
switch(column) {
case 0:
return ((INamedElement)element).getName();
case 1:
return getAnnotationValue((ExecutionUnit)element, FlashSize.class,
Long.class).toString();
case 2:
return memoryUtilization.get(element).toString();
default:
return "";
}
}
};
DynamicTreeTableViewer<EObject> viewer =
new DynamicTreeTableViewer<EObject>(view, executionUnits, false, 0,
new SuperSetContentProvider<ExecutionUnit>(), uiProvider);
// Name
viewer.addColumn("ECU", 125, true);
// Memory
viewer.addColumn("Memory [bytes]", 125, true);
// Utilization
EventHandler<CellEditEvent<EObject, String>> updateUtilization = (event -> {
memoryUtilization.put((ExecutionUnit)event.getRowValue().getValue(),
valueOf(event.getNewValue()));
view.refresh();
});
viewer.addColumn("Utilization [%]", 125, false).setOnEditCommit(updateUtilization);
}
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void initialize() { public void initialize() {
if(IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE() != null) { EventBroker.getInstance().addListener((src, event) -> {
new MemoryUtilizationTreeTableViewer(); switch(event) {
case DSE_SELECTED_EVENT:
setupViews();
break;
case DSE_REMOVED_EVENT:
view.setRoot(null);
break;
}
});
if(dse != null) {
setupViews();
} }
} }
/** Helper method to populate the views and preselect items. */
private void setupViews() {
SuperSet<ExecutionUnit> executionUnits =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
memoryUtilization = new HashMap<ExecutionUnit, Integer>();
executionUnits.getEntries()
.forEach(executionUnit -> memoryUtilization.put(executionUnit, 100));
@SuppressWarnings("unchecked") DynamicTreeTableUIProviderBase<EObject> uiProvider =
(DynamicTreeTableUIProviderBase<EObject>)(DynamicTreeTableUIProviderBase<?>)new DynamicTreeTableUIProviderBase<INamedElement>() {
@Override
public String getLabel(INamedElement element, int column) {
switch(column) {
case 0:
return element.getName();
case 1:
return getAnnotationValue((ExecutionUnit)element, FlashSize.class,
Long.class).toString();
case 2:
return memoryUtilization.get(element).toString();
default:
return "";
}
}
@Override
public boolean isEditable(int column) {
switch(column) {
case 2:
return true;
}
return false;
}
};
DynamicTreeTableViewer<EObject> viewer = new DynamicTreeTableViewer<EObject>(view,
executionUnits, false, 0, new SuperSetContentProvider<ExecutionUnit>(), uiProvider);
// Name
viewer.addColumn("ECU", 125);
// Memory
viewer.addColumn("Memory [bytes]", 125);
// Utilization
EventHandler<CellEditEvent<EObject, String>> updateUtilization = (event -> {
memoryUtilization.put((ExecutionUnit)event.getRowValue().getValue(),
valueOf(event.getNewValue()));
view.refresh();
});
viewer.addColumn("Utilization [%]", 125).setOnEditCommit(updateUtilization);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Collection<Node> getControls() { public Collection<Node> getControls() {
......
...@@ -28,17 +28,17 @@ import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotationValue; ...@@ -28,17 +28,17 @@ import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotationValue;