Skip to content
Snippets Groups Projects
Commit f4e22991 authored by Alberto Debiasi's avatar Alberto Debiasi
Browse files

Moved org.polarsys.chess.smvExport in plugin folder

Change-Id: I8473859d612c9ec70181a02f1b9ad647929d8521
parent 766b7df5
No related branches found
No related tags found
No related merge requests found
Showing
with 517 additions and 0 deletions
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/bin/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.polarsys.chess.smvExport</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SmvExport
Bundle-SymbolicName: org.polarsys.chess.smvExport;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: Fondazione Bruno Kessler
Require-Bundle: org.eclipse.papyrus.infra.gmfdiag.common,
eu.fbk.eclipse.standardtools.utils,
org.polarsys.chess.service,
org.eclipse.uml2.uml,
org.polarsys.chess.contracts.profile;bundle-version="0.9.0",
eu.fbk.eclipse.standardtools.StateMachineTranslatorToSmv;bundle-version="1.0.0",
org.eclipse.papyrus.uml.tools,
org.eclipse.core.resources,
org.polarsys.chess.core,
org.eclipse.papyrus.cdo.core
Import-Package: org.apache.log4j
Export-Package: org.polarsys.chess.smvExport.services
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="org.polarsys.chess.smvExport.commands.ExportNominalSMsToSmvFilesCommand"
id="org.polarsys.chess.smvExport.commands.ExportNominalSMsToSmvFilesCommand"
name="Export state machines as .smv files">
</command>
<command
defaultHandler="org.polarsys.chess.smvExport.commands.ExportSelectedNominalSMsToSmvFilesCommand"
id="org.polarsys.chess.smvExport.commands.ExportSelectedNominalSMsToSmvFilesCommand"
name="Export state machines of Selected Component as .smv files">
</command>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu.CHESS.basicOperation">
<command
commandId="org.polarsys.chess.smvExport.commands.ExportNominalSMsToSmvFilesCommand"
style="push">
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.polarsys.chess.modelexplorerpopupmenu.id">
<menu
id="org.eclipse.ui.main.diagramEditorMenu.CHESS.basicOperations"
label="Basic Operations">
<command
commandId="org.polarsys.chess.smvExport.commands.ExportSelectedNominalSMsToSmvFilesCommand"
style="push">
</command>
</menu>
</menuContribution>
</extension>
</plugin>
/*******************************************************************************
* Copyright (C) 2017 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.smvExport.commands;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.papyrus.uml.tools.model.UmlModel;
import org.eclipse.papyrus.uml.tools.model.UmlUtils;
import org.polarsys.chess.service.utils.DialogUtils;
import org.polarsys.chess.smvExport.services.SmvExportService;
import eu.fbk.eclipse.standardtools.commands.AbstractJobCommand;
public class ExportNominalSMsToSmvFilesCommand extends AbstractJobCommand {
private DialogUtils exportDialogUtils = DialogUtils.getInstance();
private SmvExportService smvExportService = SmvExportService.getInstance();
public ExportNominalSMsToSmvFilesCommand() {
super("Export Nominal State Machines To .smv Files");
}
private String outputDirectoryName;
private boolean showPopups;
private UmlModel umlModel;
@Override
public void execPreJobOperations(ExecutionEvent event, IProgressMonitor monitor) throws Exception {
outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog();
showPopups = true;
umlModel = UmlUtils.getUmlModel();
}
@Override
public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception {
smvExportService.exportAllNominalStateMachinesOfTheModel(umlModel, outputDirectoryName, showPopups, monitor);
}
}
/*******************************************************************************
* Copyright (C) 2017 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.smvExport.commands;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.polarsys.chess.service.utils.DialogUtils;
import org.polarsys.chess.service.utils.SelectionUtil;
import org.polarsys.chess.smvExport.services.SmvExportService;
import eu.fbk.eclipse.standardtools.commands.AbstractJobCommand;
import org.eclipse.uml2.uml.Class;
public class ExportSelectedNominalSMsToSmvFilesCommand extends AbstractJobCommand {
private SelectionUtil selectionUtil = SelectionUtil.getInstance();
private DialogUtils dialogUtils = DialogUtils.getInstance();
private SmvExportService smvExportService = SmvExportService.getInstance();
public ExportSelectedNominalSMsToSmvFilesCommand() {
super("Export Nominal State Machines To .smv Files");
}
private Class umlSelectedComponent;
private String outputDirectoryName;
private boolean showPopups;
@Override
public void execPreJobOperations(ExecutionEvent event, IProgressMonitor monitor) throws Exception {
umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event);
outputDirectoryName = dialogUtils.getDirectoryNameFromDialog();
showPopups = true;
}
@Override
public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception {
smvExportService.exportNominalStateMachines(umlSelectedComponent, outputDirectoryName, showPopups, monitor);
}
}
/*******************************************************************************
* Copyright (C) 2017 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.smvExport.model;
import java.util.Set;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.papyrus.sysml.portandflows.FlowDirection;
import org.eclipse.papyrus.uml.tools.model.UmlModel;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.Transition;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.Vertex;
import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil;
import eu.fbk.eclipse.standardtools.StateMachineTranslatorToSmv.stateMachineModel.AbstractStateMachineModel;
public class UMLStateMachineModel implements AbstractStateMachineModel {
private static UMLStateMachineModel umlStateMachineModel;
private EntityUtil entityUtil = EntityUtil.getInstance();
public static UMLStateMachineModel getInstance() {
if (umlStateMachineModel == null) {
umlStateMachineModel = new UMLStateMachineModel();
}
return umlStateMachineModel;
}
@Override
public EList<Port> getOwnerInputPortsExceptEvents(Object stateMachine) {
Element owner = ((StateMachine) stateMachine).getOwner();
return new BasicEList<Port>(entityUtil.getUmlPortsExceptEvents(owner, FlowDirection.IN_VALUE));
}
@Override
public EList<Port> getOwnerOutputPortsExceptEvents(Object stateMachine) {
Element owner = ((StateMachine) stateMachine).getOwner();
return new BasicEList<Port>(entityUtil.getUmlPortsExceptEvents(owner, FlowDirection.OUT_VALUE));
}
@Override
public EList<Element> getOwnerAttributes(Object stateMachine) {
Element owner = ((StateMachine) stateMachine).getOwner();
return new BasicEList<Element>(entityUtil.getAttributesExceptPorts(owner));
}
@Override
public EList<String> getTransitionsNameList(Object stateMachine) throws Exception {
return entityUtil.getTransitionNameList(entityUtil.getTranstitions((StateMachine) stateMachine));
}
@Override
public EList<String> getEventsNameList(Object stateMachine) {
EList<Port> events = entityUtil.getEventPorts(((StateMachine) stateMachine).getOwner());
return (entityUtil.getPortsName(events));
}
@Override
public String getStateMachineName(Object stateMachine) {
return (entityUtil.getStateMachineName((StateMachine) stateMachine));
}
@Override
public EList<Transition> getStartTransitions(Object stateMachine) throws Exception {
return entityUtil.getInitialTransitions((StateMachine) stateMachine);
}
@Override
public EList<Transition> getNonStartTransitions(Object stateMachine) {
return entityUtil.getNonInitialTransitions((StateMachine) stateMachine);
}
@Override
public EList<String> getIntermediateStatesNameList(Object stateMachine) {
EList<Vertex> states = entityUtil.getIntermediateStates((StateMachine) stateMachine);
return entityUtil.getStatesNameList(states);
}
@Override
public String getTransitionName(Object transition) {
return entityUtil.getTransitionName((Transition) transition);
}
@Override
public String getTransitionNextStateName(Object transition) {
Vertex nextState = entityUtil.getTransitionNextState((Transition) transition);
return entityUtil.getStateName(nextState);
}
@Override
public String getTransitionStartStateName(Object transition) {
Vertex sourceState = entityUtil.getTransitionSourceState((Transition) transition);
return entityUtil.getStateName(sourceState);
}
@Override
public EList<String> getTransitionEventsName(Object transition) {
EList<Port> events = entityUtil.getTransitionEvents((Transition) transition);
if (events != null) {
return entityUtil.getPortsName(events);
}
return null;
}
@Override
public String getTransitionGuardCondition(Object transition) {
Constraint condition = entityUtil.getTransitionGuard((Transition) transition);
if (condition != null) {
return entityUtil.getConditionExpression(condition);
}
return null;
}
@Override
public boolean isFinalTransition(Object transition) {
return entityUtil.isFinalTransition((Transition) transition);
}
@Override
public boolean isTransitionWithNoEvent(Object transition) {
return entityUtil.isTransitionWithNoEvent((Transition) transition);
}
@Override
public String getVariableName(Object variable) {
return ((Property) variable).getName();
}
@Override
public Object getVariableType(Object variable) {
return entityUtil.getUmlType((Property) variable);
}
@Override
public boolean isBooleanType(Object type) {
return entityUtil.isBooleanType((Type) type);
}
@Override
public boolean isIntegerType(Object type) {
return entityUtil.isIntegerType((Type) type);
}
@Override
public boolean isRealType(Object type) {
return entityUtil.isRealType((Type) type);
}
@Override
public boolean isIntervalType(Object type) {
return entityUtil.isRangeType((Type) type);
}
@Override
public String[] getLowHighIntervalType(Object type) {
return entityUtil.getLowerUpperBoundsForRangeType((Type) type);
}
@Override
public EList<String> getEnumValues(Object type) {
return new BasicEList<String>(entityUtil.getListValuesForEnumeratorType((Type) type));
}
@Override
public boolean isEnumType(Object type) {
return entityUtil.isEnumerationType((Type) type);
}
@Override
public String getStateMachineOwnerName(Object stateMachine) {
return ((org.eclipse.uml2.uml.Class) entityUtil.getOwner((StateMachine) stateMachine)).getName();
}
@Override
public String getTransitionEffectText(Object transition) {
return entityUtil.getTransitionEffectText((Transition) transition);
}
@Override
public Set<StateMachine> getNominalStateMachinesIncludingFromSubComponents(Object umlSelectedComponent) {
return entityUtil.getNominalStateMachines((org.eclipse.uml2.uml.Class) umlSelectedComponent, true);
}
@Override
public Set<StateMachine> getAllStateMachinesFromModel(Object model) {
return entityUtil.getNominalStateMachines((UmlModel) model);
}
@Override
public Object getFirstNominalStateMachine(Object umlSelectedComponent) {
return entityUtil.getFirstNominalStateMachine((org.eclipse.uml2.uml.Class) umlSelectedComponent);
}
@Override
public Object getStateMachineOwner(Object stateMachine) {
return entityUtil.getOwner((StateMachine) stateMachine);
}
}
/*******************************************************************************
* Copyright (C) 2017 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.smvExport.services;
import java.io.File;
import java.util.HashMap;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.eclipse.papyrus.uml.tools.model.UmlModel;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Property;
import org.polarsys.chess.service.internal.model.ChessSystemModel;
import org.polarsys.chess.smvExport.model.UMLStateMachineModel;
import eu.fbk.eclipse.standardtools.StateMachineTranslatorToSmv.services.SMVTranslatorService;
import eu.fbk.eclipse.standardtools.utils.DialogUtil;
public class SmvExportService {
private static SmvExportService instance;
private ChessSystemModel chessSystemModel = ChessSystemModel.getInstance();
private SMVTranslatorService smvTranslatorService = SMVTranslatorService.getInstance(chessSystemModel,
UMLStateMachineModel.getInstance());
private DialogUtil dialogUtil = DialogUtil.getInstance();
public static SmvExportService getInstance() {
if (instance == null) {
instance = new SmvExportService();
}
return instance;
}
public void exportAllNominalStateMachinesOfTheModel(UmlModel umlModel, String selectedDirectory, boolean showPopups,
IProgressMonitor monitor) throws Exception {
System.out.println("umlModel: " + umlModel);
smvTranslatorService.exportAllNominalStateMachinesOfTheModel(umlModel, selectedDirectory, null, monitor);
if (showPopups) {
dialogUtil.showMessage_ExportNominalStateMachinesDone(selectedDirectory);
}
}
public void exportNominalStateMachines(Class umlSelectedComponent, String selectedDirectory, boolean showPopups,
IProgressMonitor monitor) throws Exception {
smvTranslatorService.exportNominalStateMachines(umlSelectedComponent, selectedDirectory, null, monitor);
if (showPopups) {
dialogUtil.showMessage_ExportNominalStateMachinesDone(selectedDirectory);
}
}
public String exportSingleSmv(Class umlSelectedComponent, boolean showPopups, String selectedDirectory,
IProgressMonitor monitor) throws Exception {
File smvFile = smvTranslatorService.exportSingleSmv(umlSelectedComponent, showPopups, selectedDirectory,
monitor);
if (showPopups) {
dialogUtil.showMessage_ExportBehaviourDone(smvFile.getAbsolutePath());
}
return smvFile.getPath();
}
public HashMap<String, String> exportSmv(Class umlSelectedComponent, boolean showPopups, String selectedDirectory,
IProgressMonitor monitor) throws Exception {
HashMap<String, String> mapSmvFile_ComponentName = smvTranslatorService.exportSmv(umlSelectedComponent,
selectedDirectory, monitor);
if (showPopups) {
dialogUtil.showMessage_ExportBehaviourDone(selectedDirectory);
}
return mapSmvFile_ComponentName;
}
public boolean isLeafComponent(Class umlSelectedComponent){
EList<Property> subComponents = chessSystemModel.getSubComponentsInstances(umlSelectedComponent);
return ((subComponents==null)||(subComponents.size()==0));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment