Commit 3becb380 authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

Port the ExternalDSEExtensionService to JavaFX pattern controllers

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

Signed-off-by: Tiziano Munaro's avatarTiziano Munaro <munaro@fortiss.org>
parent 8688943b
......@@ -132,7 +132,7 @@
<Insets right="2.0" />
</GridPane.margin>
</Button>
<Button fx:id="importButton" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#onImportButton" text="Import external model" GridPane.columnIndex="1">
<Button fx:id="importButton" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Import external model" GridPane.columnIndex="1">
<GridPane.margin>
<Insets left="2.0" />
</GridPane.margin>
......
DashboardFXController.java 10823c69ca83bb53bb8ca2b800ee6a148823182e GREEN
DashboardFXController.java 3f3908778140dc05c4d1b4c6faf3fd752589f1fb YELLOW
DashboardFXViewPart.java 93e8ed38fb398aa5ababc85877a5fed8d5b88723 GREEN
......@@ -22,24 +22,17 @@ import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.DSE_SELECTED_EVENT;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.service.IDSEBackendService;
import org.fortiss.af3.exploration.ui.AF3ExplorationUIActivator;
import org.fortiss.af3.exploration.ui.perspective.dashboard.projectwizard.DashboardWizard;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager;
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.IEventListener;
import org.fortiss.af3.exploration.ui.perspective.service.IExternalDSEExtensionService;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
......@@ -143,28 +136,6 @@ public class DashboardFXController extends CompositeFXControllerBase<AnchorPane,
wizard.dispose();
}
/** Launches the import dialog for external models. */
public void onImportButton() {
if(!IExternalDSEExtensionService.INSTANCE.isImportWizardAvailable()) {
showError("No external import wizard available: None has been registered.");
return;
}
Class<? extends Wizard> importWizard =
IExternalDSEExtensionService.INSTANCE.getImportWizard();
try {
Constructor<? extends Wizard> constructor = importWizard.getConstructor();
Wizard newInstance = constructor.newInstance();
WizardDialog dialog =
new WizardDialog(Display.getDefault().getActiveShell(), newInstance);
dialog.open();
} catch(NoSuchMethodException | SecurityException | InstantiationException |
IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
showError("Failed to launch the import wirzard. Please refer to the log for details.");
error(AF3ExplorationUIActivator.getDefault(), "Failed to launch the import wirzard", e);
}
}
/** {@inheritDoc} */
@Override
public void propertyChanged(Object source, DSE_EVENT propId) {
......
DSEPerspectiveManager.java ad2b28bf6bb8414eda0b1606c53befb8ef731a3a GREEN
EventBroker.java 5614a199ffe288807a29cf9c213787f52c3555e8 GREEN
ExternalDSEExtensionService.java 7290acc7b8f1735d43a23802f75509e2c441e0d2 GREEN
ExternalDSEExtensionService.java 1f70e2b21f7f898dff39f8be6444adba26e043fc YELLOW
IDSEPerspectiveManager.java 2bc063e88352828ca0d3264730670694dbee76e4 GREEN
IEventListener.java 6d7eb240719a7d7ef0a2619c2fc72a22109c2786 GREEN
IExternalDSEExtensionService.java 32fe4caebc9ebe0660a53e093858b841b279cfe1 GREEN
IExternalDSEExtensionService.java 7fed5771345d2b7510d5bb509240db0a39e99254 YELLOW
......@@ -15,95 +15,113 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.service;
import static java.util.Collections.emptyList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
/**
* Singleton implementation of {@link IExternalDSEExtensionService}.
*
* @author eder
* @author munaro
*/
public class ExternalDSEExtensionService implements IExternalDSEExtensionService {
public class ExternalDSEExtensionService
implements IExternalDSEExtensionService, IIntrospectiveKernelService {
/** List storing all externally registered constraint patterns. */
private List<PatternFXControllerBase> registeredConstraintPatterns = new ArrayList<>();
/** List storing all externally registered objective patterns. */
private List<PatternFXControllerBase> registeredObjectivePatterns = new ArrayList<>();
/** List storing all externally registered constraints patterns. */
private List<PatternStruct> registeredPatterns = new ArrayList<>();
/** Class of external import wizard. */
private Class<? extends Wizard> importWizard = null;
/** Custom logo. */
private Image logo = null;
/** The singleton instance. */
private static IExternalDSEExtensionService INSTANCE;
/** Constructor. */
private ExternalDSEExtensionService() {
// Prevent instantiation of this singleton.
}
/** Returns the singleton instance of {@code this} {@link ExternalDSEExtensionService}. */
public static synchronized IExternalDSEExtensionService getInstance() {
if(INSTANCE == null) {
INSTANCE = new ExternalDSEExtensionService();
}
return INSTANCE;
}
/** {@inheritDoc} */
@Override
public void registerNewConstraintPattern(String name, Class<? extends Composite> composite) {
PatternStruct patternStruct = new PatternStruct();
patternStruct.isUtilizationPattern = false;
patternStruct.name = name;
patternStruct.composite = composite;
registeredPatterns.add(patternStruct);
public void startService() {
IKernelIntrospectionSystemService.getInstance().registerService(this);
}
/** {@inheritDoc} */
@Override
public void registerNewUtilizationConstraintPattern(String name,
Class<? extends Composite> composite, Class<? extends IAnnotatedSpecification> spec1,
Class<? extends IAnnotatedSpecification> spec2) {
PatternStruct patternStruct = new PatternStruct();
patternStruct.isUtilizationPattern = true;
patternStruct.name = name;
patternStruct.composite = composite;
patternStruct.spec1 = spec1;
patternStruct.spec2 = spec2;
registeredPatterns.add(patternStruct);
public void initializeService() {
// Nothing to do
}
/** {@inheritDoc} */
@Override
public List<PatternStruct> getRegisteredPatterns() {
return registeredPatterns;
public void registerConstraintPattern(PatternFXControllerBase pattern) {
registeredConstraintPatterns.add(pattern);
}
/** {@inheritDoc} */
@Override
public void registerImportWizard(Class<? extends Wizard> importWizard) {
this.importWizard = importWizard;
public void registerObjectivePattern(PatternFXControllerBase pattern) {
registeredObjectivePatterns.add(pattern);
}
/** {@inheritDoc} */
@Override
public boolean isImportWizardAvailable() {
return importWizard == null ? false : true;
public List<PatternFXControllerBase> getConstraintPatterns() {
return registeredConstraintPatterns;
}
/** {@inheritDoc} */
@Override
public Class<? extends Wizard> getImportWizard() {
return importWizard;
public List<PatternFXControllerBase> getObjectivePatterns() {
return registeredObjectivePatterns;
}
/** {@inheritDoc} */
@Override
public void registerCustomLogo(ImageDescriptor logoDescr) {
if(logo != null) {
logo.dispose();
}
logo = logoDescr.createImage();
public String getIntrospectionLabel() {
return "External DSE Extension Service";
}
/** {@inheritDoc} */
@Override
public boolean showInIntrospectionNavigation() {
return true;
}
/** {@inheritDoc} */
@Override
public Collection<IIntrospectionItem> getIntrospectionItems() {
return emptyList();
}
/** {@inheritDoc} */
@Override
public boolean isCustomLogoAvailable() {
return logo == null ? false : true;
public IIntrospectionDetailsItem getDetailsItem() {
return null;
}
/** {@inheritDoc} */
@Override
public Image getCustomLogo() {
return logo;
public String getIntrospectionDescription() {
return getIntrospectionLabel() +
"\n\nThe service is used to add external Design Space Exploration (DSE) patterns.";
}
}
......@@ -17,84 +17,46 @@ package org.fortiss.af3.exploration.ui.perspective.service;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
/**
* Service interface to adapt DSE perspective UI from outside this plugin.
* Service interface to add constraint and objective patterns from outside this plug-in.
*
* @author eder
* @author munaro
*/
public interface IExternalDSEExtensionService {
/** Singleton instance. */
public IExternalDSEExtensionService INSTANCE = new ExternalDSEExtensionService();
/**
* Adds a new section to the constraint view. The backend composite should be provided here.
*
* @param name
* the name of the pattern
* @param composite
* the SWT composite
*/
public void registerNewConstraintPattern(String name, Class<? extends Composite> composite);
/** Returns the singleton instance of the {@link IExternalDSEExtensionService}. */
public static IExternalDSEExtensionService getInstance() {
return ExternalDSEExtensionService.getInstance();
}
/**
* Adds a new section to the constraint view. The utilization backend composite should be
* provided here. IMPORTANT: the order of spec1 and spec2 has to be equal to the order of the
* specifications in the constructor of the implemented utilization pattern class.
*
* @param name
* the name of the pattern
* @param composite
* the SWT composite
* @param spec1
* the logical component annotation specification
* @param spec2
* the technical ecu annotation specification
*/
public void registerNewUtilizationConstraintPattern(String name,
Class<? extends Composite> composite, Class<? extends IAnnotatedSpecification> spec1,
Class<? extends IAnnotatedSpecification> spec2);
/** Starts the service. */
public void startService();
/** Returns all registered patterns. */
public List<PatternStruct> getRegisteredPatterns();
/** Initializes the service. */
public void initializeService();
/**
* Registers an import wizard. Only wizards with no arguments in the constructor may be
* registered. Note: Only one wizard maybe registered. will be handled like
* LiFo.
* Adds a new section to the constraint view.
*
* @param pattern
* Controller of the pattern to be included
*/
public void registerImportWizard(Class<? extends Wizard> importWizard);
/** Returns the latest registered import wizard or null if there is none. */
public Class<? extends Wizard> getImportWizard();
/** Returns true if an import wizard has been registered else false. */
public boolean isImportWizardAvailable();
public void registerConstraintPattern(PatternFXControllerBase pattern);
/**
* Registers a custom logo. Note: Only one logo may be registered. Will be handled like LiFo.
* Adds a new section to the objective view.
*
* @param pattern
* Controller of the pattern to be included
*/
public void registerCustomLogo(ImageDescriptor logo);
/** Returns the latest registered custom logo {@link Image} or {@code null} if there is none. */
public Image getCustomLogo();
public void registerObjectivePattern(PatternFXControllerBase pattern);
/** Returns true if an a custom has been registered else false. */
public boolean isCustomLogoAvailable();
/** Returns all registered constraint patterns. */
public List<PatternFXControllerBase> getConstraintPatterns();
/** Struct for storing external pattern information. */
@SuppressWarnings("javadoc")
public class PatternStruct {
public boolean isUtilizationPattern;
public String name;
public Class<? extends Composite> composite;
public Class<? extends IAnnotatedSpecification> spec1;
public Class<? extends IAnnotatedSpecification> spec2;
}
/** Returns all registered objective patterns. */
public List<PatternFXControllerBase> getObjectivePatterns();
}
ConstraintsFXViewPart.java 51d0d643b74d13231e34248702c467949f93936a GREEN
ConstraintsFXViewPart.java 95cb8c21ca2efe514cc765fe4a19d98e4819499b YELLOW
......@@ -15,12 +15,19 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.targetdef.constraint;
import static java.util.Arrays.asList;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.fx.ui.workbench3.FXViewPart;
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.process.IProcessManager;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep;
import org.fortiss.af3.exploration.ui.perspective.service.IExternalDSEExtensionService;
import org.fortiss.af3.exploration.ui.perspective.targetdef.ConstraintObjectiveFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
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.MemoryPatternFXController;
......@@ -36,16 +43,23 @@ public class ConstraintsFXViewPart extends ExplorationUIFXViewPart {
/** Constructor. */
public ConstraintsFXViewPart() throws Exception {
// @CodeFormatterOff
super(new ExplorationUIFXController(
new ConstraintObjectiveFXController(
new AllocationPatternFXController(),
new CouplingPatternFXController(),
new SafetyPatternFXController(),
new MemoryPatternFXController()),
"Constraints"),
"constraints_icon.png", null);
// @CodeFormatterOn
super(new ExplorationUIFXController(new ConstraintObjectiveFXController(getPatterns()),
"Constraints"), "constraints_icon.png", null);
}
/** Fetches internal and external constraint patterns to include in the view. */
private static PatternFXControllerBase[] getPatterns() {
List<PatternFXControllerBase> internalPatterns =
asList(new AllocationPatternFXController(), new CouplingPatternFXController(),
new SafetyPatternFXController(), new MemoryPatternFXController());
List<PatternFXControllerBase> externalPatterns =
IExternalDSEExtensionService.getInstance().getConstraintPatterns();
List<PatternFXControllerBase> patterns = new ArrayList<PatternFXControllerBase>();
patterns.addAll(internalPatterns);
patterns.addAll(externalPatterns);
return patterns.toArray(new PatternFXControllerBase[0]);
}
/** {@inheritDoc} */
......
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