Commit 3491637f authored by Marco Volpe's avatar Marco Volpe
Browse files

Extraction of a NamedTreeTableProvider for simple TreeTableView cases

*

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

Signed-off-by: Marco Volpe's avatarMarco Volpe <volpe@fortiss.org>
parent a9e83d22
NamedTreeTableUIProvider.java b3493a9446d5a557b26a7d3f42762b6201d830df YELLOW
PatternContainerFXController.java b60abf01f271facd20f92053c432530a632e42c6 GREEN
SuperSetContentProvider.java 86806720c678ba5c92ec2579b665d3f401df07b3 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.targetdef;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.kernel.model.INamedElement;
/**
* Utility class that creates a provider for {@TreeTableView}s where only names of elements need to
* be displayed.
*
* @author volpe
*/
public class NamedTreeTableUIProvider {
/**
* Creates a provider for a simple {@TreeTableView} where only names of elements need to be
* displayed.
*/
public DynamicTreeTableUIProviderBase create() {
return new DynamicTreeTableUIProviderBase() {
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int column) {
return ((INamedElement)element).getName();
}
};
}
}
AllocationPatternFXController.java 57a564e4429c6e4586c85d0993166b4c06e134c3 RED
CouplingPatternFXController.java f94c753b56c349601680964d7d6706579bf9946a RED
AllocationPatternFXController.java 8aa3ae1a0c3cb02c65edb1176b157b3e52bc52f0 YELLOW
CouplingPatternFXController.java ff7eb8adde82acafcfe1d5e807ff1e33734a2915 YELLOW
MemoryPatternFXController.java 73bb2e75d520086dd50ff45958f02309d01e47c4 GREEN
SafetyPatternFXController.java 840871287a34129c056e4871c1bad744d42e58ab GREEN
......@@ -17,11 +17,11 @@ 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.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.targetdef.NamedTreeTableUIProvider;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.task.model.Task;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.model.INamedElement;
import javafx.fxml.FXML;
import javafx.scene.Node;
......@@ -148,22 +148,7 @@ public class AllocationPatternFXController extends PatternFXControllerBase {
SuperSet<ExecutionUnit> ecus =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
// TODO(AD): This is used in several patterns and could be moved to some base class or
// static method. (MV): I don't see an easy way to generalize properly, since depending
// on the table the number of columns and the information required to label each column
// is not necessarily the same. For now I only simplified by removing the switch when
// there is only one column. In other classes, I removed the todo, but feel free to
// reassign to me if you see a better solution.
// AD: Please move this "NamedTreeTableUIProvider" to a utility class and add a create
// method there that just returns the constructed provider. By that, we avoid code
// duplicates.
DynamicTreeTableUIProviderBase uiProvider = new DynamicTreeTableUIProviderBase() {
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int column) {
return ((INamedElement)element).getName();
}
};
DynamicTreeTableUIProviderBase uiProvider = new NamedTreeTableUIProvider().create();
// add a viewer for the tasks
DynamicTreeTableViewer<EObject> taskViewer = new DynamicTreeTableViewer<EObject>(
......
......@@ -32,10 +32,10 @@ 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.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.targetdef.NamedTreeTableUIProvider;
import org.fortiss.af3.task.model.Task;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.model.INamedElement;
import javafx.fxml.FXML;
import javafx.scene.Node;
......@@ -140,13 +140,7 @@ public class CouplingPatternFXController extends PatternFXControllerBase {
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
SuperSet<Task> tasks = dse.getCurrentStep().getSuperSetMap().get(Task.class);
DynamicTreeTableUIProviderBase uiProvider = new DynamicTreeTableUIProviderBase() {
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int column) {
return ((INamedElement)element).getName();
}
};
DynamicTreeTableUIProviderBase uiProvider = new NamedTreeTableUIProvider().create();
DynamicTreeTableViewer<EObject> viewer = new DynamicTreeTableViewer<EObject>(view,
tasks, false, 0, new SuperSetContentProvider<Task>(), uiProvider);
......
BusBandwidthOptimizationPatternFXController.java 0b18eaed7e170b8cac48f3c066302bc6f6bf100f RED
BusBandwidthOptimizationPatternFXController.java a15261d8f30d3c53d1700adc114aab95962cd71c YELLOW
HardwareOptimizationPatternFXController.java 61f54b317a3a184c3f31104ab8da69e29eda4a5f GREEN
......@@ -38,11 +38,11 @@ import org.fortiss.af3.exploration.smt.model.SMTObjective;
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.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.targetdef.NamedTreeTableUIProvider;
import org.fortiss.af3.platform.model.Route;
import org.fortiss.af3.platform.model.TransmissionUnit;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.model.INamedElement;
import javafx.fxml.FXML;
import javafx.scene.Node;
......@@ -171,13 +171,7 @@ public class BusBandwidthOptimizationPatternFXController extends PatternFXContro
SuperSet<TransmissionUnit> transmissionUnits =
dse.getCurrentStep().getSuperSetMap().get(TransmissionUnit.class);
DynamicTreeTableUIProviderBase uiProvider = new DynamicTreeTableUIProviderBase() {
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int column) {
return ((INamedElement)element).getName();
}
};
DynamicTreeTableUIProviderBase uiProvider = new NamedTreeTableUIProvider().create();
DynamicTreeTableViewer<EObject> viewer =
new DynamicTreeTableViewer<EObject>(view, transmissionUnits, false, 0,
......
Markdown is supported
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