Commit 81063c7c authored by Alexander Diewald's avatar Alexander Diewald
Browse files

DSE-Patterns: Move the NameProvider to a util class

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

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 3491637f
/*-------------------------------------------------------------------------+
| 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 8aa3ae1a0c3cb02c65edb1176b157b3e52bc52f0 YELLOW
CouplingPatternFXController.java ff7eb8adde82acafcfe1d5e807ff1e33734a2915 YELLOW
AllocationPatternFXController.java 30c16e1f0981bbb60a988e2cce02a47895881684 YELLOW
CouplingPatternFXController.java b3076fe8990181803a323a1d693e179121806159 YELLOW
MemoryPatternFXController.java 73bb2e75d520086dd50ff45958f02309d01e47c4 GREEN
SafetyPatternFXController.java 840871287a34129c056e4871c1bad744d42e58ab GREEN
......@@ -3,6 +3,7 @@ package org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static org.fortiss.af3.exploration.smt.util.Z3ModelElementFactory.createSMTConstraint;
import static org.fortiss.af3.exploration.ui.util.ExplorationUiUtils.createNameProvider;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.calcPatternName;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createAllocationPatternExpression;
......@@ -17,7 +18,6 @@ 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;
......@@ -148,7 +148,7 @@ public class AllocationPatternFXController extends PatternFXControllerBase {
SuperSet<ExecutionUnit> ecus =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
DynamicTreeTableUIProviderBase uiProvider = new NamedTreeTableUIProvider().create();
DynamicTreeTableUIProviderBase uiProvider = createNameProvider();
// add a viewer for the tasks
DynamicTreeTableViewer<EObject> taskViewer = new DynamicTreeTableViewer<EObject>(
......
......@@ -18,6 +18,7 @@ package org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static org.fortiss.af3.exploration.smt.util.Z3ModelElementFactory.createSMTConstraint;
import static org.fortiss.af3.exploration.ui.util.ExplorationUiUtils.createNameProvider;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.calcPatternName;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createFunctionCouplingPatternExpression;
......@@ -32,7 +33,6 @@ 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;
......@@ -140,7 +140,7 @@ public class CouplingPatternFXController extends PatternFXControllerBase {
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
SuperSet<Task> tasks = dse.getCurrentStep().getSuperSetMap().get(Task.class);
DynamicTreeTableUIProviderBase uiProvider = new NamedTreeTableUIProvider().create();
DynamicTreeTableUIProviderBase uiProvider = createNameProvider();
DynamicTreeTableViewer<EObject> viewer = new DynamicTreeTableViewer<EObject>(view,
tasks, false, 0, new SuperSetContentProvider<Task>(), uiProvider);
......
BusBandwidthOptimizationPatternFXController.java a15261d8f30d3c53d1700adc114aab95962cd71c YELLOW
BusBandwidthOptimizationPatternFXController.java 82242f988c447c8b4ae66cbb8616a69490ead3b6 YELLOW
HardwareOptimizationPatternFXController.java 61f54b317a3a184c3f31104ab8da69e29eda4a5f GREEN
......@@ -19,6 +19,7 @@ import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static org.fortiss.af3.exploration.smt.util.Z3ModelElementFactory.createSMTConstraint;
import static org.fortiss.af3.exploration.smt.util.Z3ModelElementFactory.createSMTObjective;
import static org.fortiss.af3.exploration.ui.util.ExplorationUiUtils.createNameProvider;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createBusWeightOptimizationPatternExpression;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createRouteUsesBusConstraintPatternExpression;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createRouteWeightConstraintPatternExpression;
......@@ -38,7 +39,6 @@ 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;
......@@ -171,7 +171,7 @@ public class BusBandwidthOptimizationPatternFXController extends PatternFXContro
SuperSet<TransmissionUnit> transmissionUnits =
dse.getCurrentStep().getSuperSetMap().get(TransmissionUnit.class);
DynamicTreeTableUIProviderBase uiProvider = new NamedTreeTableUIProvider().create();
DynamicTreeTableUIProviderBase uiProvider = createNameProvider();
DynamicTreeTableViewer<EObject> viewer =
new DynamicTreeTableViewer<EObject>(view, transmissionUnits, false, 0,
......
ExplorationSolutionVisualizationUtils.java 156f33a7040b982323c6daf7da168fdf283c4d65 GREEN
ExplorationUiUtils.java 9deabddcbb16a45a76decf641c9572c2d4a04267 GREEN
ExplorationUiUtils.java 8e4d9a1095f5ef5fc7de5685b5b7f8c59ee325c1 YELLOW
SpiderChartUtils.java 885d37e537db3b6128c08a4c98247f3a9613d9bf GREEN
......@@ -18,6 +18,8 @@ package org.fortiss.af3.exploration.ui.util;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.kernel.model.INamedElement;
/**
* Utility methods for the exploration UI / DSE perspective.
......@@ -41,4 +43,18 @@ public class ExplorationUiUtils {
public static String getFQNID(Class<?> type) {
return type.getName();
}
/**
* Creates a provider for a simple {@TreeTableView} where only names of elements need to be
* displayed.
*/
public static DynamicTreeTableUIProviderBase createNameProvider() {
return new DynamicTreeTableUIProviderBase() {
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int column) {
return (element instanceof INamedElement) ? ((INamedElement)element).getName() : "";
}
};
}
}
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