diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/entries b/org.polarsys.chess.constraints.constraintEditor/.svn/entries new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/entries @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/format b/org.polarsys.chess.constraints.constraintEditor/.svn/format new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/format @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/1a/1ab71f2c7a720f53c4ba759f6a29a8898725e49f.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/1a/1ab71f2c7a720f53c4ba759f6a29a8898725e49f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..deb23680562983d05dd86e11a598db9a61d66deb --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/1a/1ab71f2c7a720f53c4ba759f6a29a8898725e49f.svn-base @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> + <propertyTabs + contributorId="TreeOutlinePage"> + <propertyTab + afterTab="advanced" + category="Editors" + id="CustomConstraintTab" + label="ConstraintEditor+"> + </propertyTab> + </propertyTabs> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections + contributorId="TreeOutlinePage"> + <propertySection + class="org.polarsys.chess.constraints.constraintEditor.CustomConstraintEditorTab" + filter="org.polarsys.chess.constraints.constraintEditor.ConstraintEditorFilter" + id="CustomConstraintEditorSection" + tab="CustomConstraintTab"> + </propertySection> + </propertySections> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage"> + <propertyCategory + category="Editors"> + </propertyCategory> + </propertyContributor> + </extension> + +</plugin> diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6f20375d6c7d98fbc80bb5da99be9866b1fe2f73 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/43/4377991a8eea2f6077e4bb8766cef91d7e23c957.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/43/4377991a8eea2f6077e4bb8766cef91d7e23c957.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ec88aeb61ff8ec224647217256a45794ceefe749 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/43/4377991a8eea2f6077e4bb8766cef91d7e23c957.svn-base @@ -0,0 +1,230 @@ +/******************************************************************************* + * 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.constraints.constraintEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.constraintEditor.constraintTab.ConstraintEditorTab; + +/** + * This is the constraint editor designed for the CHESS platform. It extends the + * ConstraintEditorTab that is designed to be extended and contains standard + * methods not related to specific technologies. The only rule is that it works + * for Eclipse based platforms. + * + */ +public class CustomConstraintEditorTab extends ConstraintEditorTab { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public Resource getResourceFromConstraint(Object constraint) { + + return ((Constraint) constraint).eResource(); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getSubComponentsName(java.lang.Object) + */ + @Override + public String[] getSubComponentsName(Object constraint) { + Element umlElement = ((Constraint) constraint).getOwner(); + EList<String> subCompArr = entityUtil.getSubComponentsNames((Class) umlElement); + String[] subComStrArr = new String[subCompArr.size()]; + return subCompArr.toArray(subComStrArr); + + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getSubComponent(java.lang.Object, java.lang.String) + */ + @Override + public Object getSubComponent(Object constraint, String componentName) { + Element element = ((Constraint) constraint).getOwner(); + + for (Property umlProperty : entityUtil.getSubComponents((Class) element)) { + if (umlProperty.getName().compareTo(componentName) == 0) { + return entityUtil.getUmlType(umlProperty); + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getInputOutputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.INOUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getInputPorts(java.lang.Object) + */ + @Override + public String[] getInputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.IN_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getOutputPorts(java.lang.Object) + */ + @Override + public String[] getOutputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.OUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerInputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerInputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getInputPorts(element); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerOutputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerOutputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getOutputPorts(element); + + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerInputOutputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getInputOutputPorts(element); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerProperties(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerProperties(Object constraint) { + Class element = (Class) ((Constraint) constraint).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(element)); + + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#returnConstraint(org.eclipse.jface.viewers. + * ISelection) + */ + @Override + public Object returnConstraint(ISelection selection) { + /* + * Object selected = null; if ((selection instanceof + * IStructuredSelection)) { + * + * List<?> selectionList = ((IStructuredSelection) selection).toList(); + * if (selectionList.size() == 1) { selected = selectionList.get(0); } } + * EObject selectedEObject = EMFHelper.getEObject(selected); if + * (selectedEObject != null) { selected = selectedEObject; } if + * (selected instanceof GraphicalEditPart) { selected = + * (((GraphicalEditPart) selected).resolveSemanticElement()); } + */ + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + return (Constraint) selectedUmlElement; + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#constraintEditorchanged(java.lang.Object, + * java.lang.String) + */ + @Override + public void constraintEditorchanged(Object constraint, String textChanged) { + entityUtil.saveConstraint(((Constraint) constraint), textChanged); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintName(java.lang.Object) + */ + public String getConstraintName(Object constraint) { + if (constraint != null) { + return ((Constraint) constraint).getQualifiedName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getStrFromConstraint(java.lang.Object) + */ + public String getStrFromConstraint(Object constraint) { + return ((Constraint) constraint).getSpecification().stringValue(); + } + +} diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..295926d964165896ea8aa7c1b1b3c9d3d3caa77e --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base @@ -0,0 +1,7 @@ +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 diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/5c/5c85c60c623add4d3f561e1355ea35a342f36ae2.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/5c/5c85c60c623add4d3f561e1355ea35a342f36ae2.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..1e48aa9119e48df1dbeac73c5b5f97d01e717e58 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/5c/5c85c60c623add4d3f561e1355ea35a342f36ae2.svn-base @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> + <propertyTabs + contributorId="TreeOutlinePage"> + <propertyTab + afterTab="advanced" + category="Editors" + id="CustomConstraintTab" + label="CustomConstraintEditor"> + </propertyTab> + </propertyTabs> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections + contributorId="TreeOutlinePage"> + <propertySection + class="org.polarsys.chess.constraints.constraintEditor.CustomConstraintEditorTab" + filter="org.polarsys.chess.constraints.constraintEditor.ConstraintEditorFilter" + id="CustomConstraintEditorSection" + tab="CustomConstraintTab"> + </propertySection> + </propertySections> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage"> + <propertyCategory + category="Editors"> + </propertyCategory> + </propertyContributor> + </extension> + +</plugin> diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/7c/7c9b38a7fbb26ebbf2802fb421fad281fcfb1a45.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/7c/7c9b38a7fbb26ebbf2802fb421fad281fcfb1a45.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..3d12c92a12e5607b0a3fb625f425ee82a126aae8 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/7c/7c9b38a7fbb26ebbf2802fb421fad281fcfb1a45.svn-base @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.polarsys.chess.constraints.constraintEditor</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> diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b862a296d38fe04269faeee6c9d77d11ff77380d --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base @@ -0,0 +1,7 @@ +<?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> diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/a9/a988a4055b38f0ccaf7545d9ebcf47f4c31681f1.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/a9/a988a4055b38f0ccaf7545d9ebcf47f4c31681f1.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d162bb95f3e76a194484b648799576b6e83e954f --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/a9/a988a4055b38f0ccaf7545d9ebcf47f4c31681f1.svn-base @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.constraints.constraintEditor +Bundle-SymbolicName: org.polarsys.chess.constraints.constraintEditor;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.ui.views.properties.tabbed, + org.eclipse.core.resources, + org.eclipse.emf.edit.ui, + org.eclipse.papyrus.infra.emf, + org.polarsys.chess.chessmlprofile;bundle-version="0.9.0", + org.polarsys.chess.utils +Import-Package: eu.fbk.eclipse.standardtools.constraintEditor.constraintTab, + org.eclipse.emf.edit.ui.action, + org.eclipse.gef, + org.eclipse.gmf.runtime.diagram.ui.editparts, + org.eclipse.papyrus.uml.diagram.common.edit.part, + org.eclipse.uml2.uml +Bundle-Vendor: Fondazione Bruno Kessler diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/bf/bfccc7e82f4b8c74130a6926496ed1a791c9368b.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/bf/bfccc7e82f4b8c74130a6926496ed1a791c9368b.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..a5da019aa266788c35944bb24f12992008b1d15a --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/bf/bfccc7e82f4b8c74130a6926496ed1a791c9368b.svn-base @@ -0,0 +1,229 @@ +/******************************************************************************* + * 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.constraints.constraintEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.utils.EntityUtil; +import org.polarsys.chess.utils.SelectionUtil; +import eu.fbk.eclipse.standardtools.constraintEditor.constraintTab.ConstraintEditorTab; + +/** + * This is the constraint editor designed for the CHESS platform. It extends the + * ConstraintEditorTab that is designed to be extended and contains standard + * methods not related to specific technologies. The only rule is that it works + * for Eclipse based platforms. + * + */ +public class CustomConstraintEditorTab extends ConstraintEditorTab { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public Resource getResourceFromConstraint(Object constraint) { + + return ((Constraint) constraint).eResource(); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getSubComponentsName(java.lang.Object) + */ + @Override + public String[] getSubComponentsName(Object constraint) { + Element umlElement = ((Constraint) constraint).getOwner(); + EList<String> subCompArr = entityUtil.getSubComponentsNames((Class) umlElement); + String[] subComStrArr = new String[subCompArr.size()]; + return subCompArr.toArray(subComStrArr); + + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getSubComponent(java.lang.Object, java.lang.String) + */ + @Override + public Object getSubComponent(Object constraint, String componentName) { + Element element = ((Constraint) constraint).getOwner(); + + for (Property umlProperty : entityUtil.getSubComponents((Class) element)) { + if (umlProperty.getName().compareTo(componentName) == 0) { + return entityUtil.getUmlType(umlProperty); + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getInputOutputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.INOUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getInputPorts(java.lang.Object) + */ + @Override + public String[] getInputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.IN_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getOutputPorts(java.lang.Object) + */ + @Override + public String[] getOutputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.OUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerInputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerInputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getInputPorts(element); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerOutputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerOutputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getOutputPorts(element); + + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerInputOutputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getInputOutputPorts(element); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerProperties(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerProperties(Object constraint) { + Class element = (Class) ((Constraint) constraint).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(element)); + + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#returnConstraint(org.eclipse.jface.viewers. + * ISelection) + */ + @Override + public Object returnConstraint(ISelection selection) { + /* + * Object selected = null; if ((selection instanceof + * IStructuredSelection)) { + * + * List<?> selectionList = ((IStructuredSelection) selection).toList(); + * if (selectionList.size() == 1) { selected = selectionList.get(0); } } + * EObject selectedEObject = EMFHelper.getEObject(selected); if + * (selectedEObject != null) { selected = selectedEObject; } if + * (selected instanceof GraphicalEditPart) { selected = + * (((GraphicalEditPart) selected).resolveSemanticElement()); } + */ + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + return (Constraint) selectedUmlElement; + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#constraintEditorchanged(java.lang.Object, + * java.lang.String) + */ + @Override + public void constraintEditorchanged(Object constraint, String textChanged) { + entityUtil.saveConstraint(((Constraint) constraint), textChanged); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintName(java.lang.Object) + */ + public String getConstraintName(Object constraint) { + if (constraint != null) { + return ((Constraint) constraint).getQualifiedName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getStrFromConstraint(java.lang.Object) + */ + public String getStrFromConstraint(Object constraint) { + return ((Constraint) constraint).getSpecification().stringValue(); + } + +} diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ae3c1726048cd06b9a143e0376ed46dd9b9a8d53 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base @@ -0,0 +1 @@ +/bin/ diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/d5/d5bbba515fd03a9179dbca41effc6570b20b93fe.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/d5/d5bbba515fd03a9179dbca41effc6570b20b93fe.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..27365a5f4a88c3e85a5dece8c5430a5ab6184200 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/d5/d5bbba515fd03a9179dbca41effc6570b20b93fe.svn-base @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.constraints.constraintEditor; + + +import org.eclipse.uml2.uml.Constraint; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.SelectionUtil; + +/** + * It Filters the selected objects that are constraints. * + */ +public class ConstraintEditorFilter implements org.eclipse.jface.viewers.IFilter { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + + @Override + public boolean select(Object selected) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selected); + + if (selectedUmlElement instanceof Constraint) { + if (!contractEntityUtil.isFormalProperty((Constraint) selectedUmlElement)) { + return true; + } + } + return false; + } +} diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/e7/e727259afdfe97c65e99593eaf5f5bfcef7c9c8e.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/e7/e727259afdfe97c65e99593eaf5f5bfcef7c9c8e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..c95a29af1fb5b017e6fe3f3a6952097834b31702 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/e7/e727259afdfe97c65e99593eaf5f5bfcef7c9c8e.svn-base @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.constraints.constraintEditor; + + +import org.eclipse.uml2.uml.Constraint; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; +/** + * It Filters the selected objects that are constraints. * + */ +public class ConstraintEditorFilter implements org.eclipse.jface.viewers.IFilter { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + + @Override + public boolean select(Object selected) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selected); + + if (selectedUmlElement instanceof Constraint) { + if (!contractEntityUtil.isFormalProperty((Constraint) selectedUmlElement)) { + return true; + } + } + return false; + } +} diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/f0/f0b30e2ba2e78ea9a2501830d28ef843263b8b9e.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/f0/f0b30e2ba2e78ea9a2501830d28ef843263b8b9e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d7ca716e7d78def514c2acf8b29452ba0c8e595a --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/f0/f0b30e2ba2e78ea9a2501830d28ef843263b8b9e.svn-base @@ -0,0 +1,240 @@ +/******************************************************************************* + * 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.constraints.constraintEditor; + +import java.util.Set; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.constraintEditor.constraintTab.ConstraintEditorTab; + +/** + * This is the constraint editor designed for the CHESS platform. It extends the + * ConstraintEditorTab that is designed to be extended and contains standard + * methods not related to specific technologies. The only rule is that it works + * for Eclipse based platforms. + * + */ +public class CustomConstraintEditorTab extends ConstraintEditorTab { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public Resource getResourceFromConstraint(Object constraint) { + + return ((Constraint) constraint).eResource(); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getSubComponentsName(java.lang.Object) + */ + @Override + public String[] getSubComponentsName(Object constraint) { + Element umlElement = ((Constraint) constraint).getOwner(); + Set<String> subCompArr = entityUtil.getSubComponentsNames((Class) umlElement); + String[] subComStrArr = new String[subCompArr.size()]; + return subCompArr.toArray(subComStrArr); + + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getSubComponent(java.lang.Object, java.lang.String) + */ + @Override + public Object getSubComponent(Object constraint, String componentName) { + Element element = ((Constraint) constraint).getOwner(); + + for (Property umlProperty : entityUtil.getSubComponents((Class) element)) { + if (umlProperty.getName().compareTo(componentName) == 0) { + return entityUtil.getUmlType(umlProperty); + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getInputOutputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.INOUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getInputPorts(java.lang.Object) + */ + @Override + public String[] getInputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.IN_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getOutputPorts(java.lang.Object) + */ + @Override + public String[] getOutputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.OUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerInputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerInputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getInputPorts(element); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerOutputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerOutputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getOutputPorts(element); + + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerInputOutputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getInputOutputPorts(element); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerProperties(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerProperties(Object constraint) { + Class element = (Class) ((Constraint) constraint).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(element)); + + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#returnConstraint(org.eclipse.jface.viewers. + * ISelection) + */ + @Override + public Object returnConstraint(ISelection selection) { + /* + * Object selected = null; if ((selection instanceof + * IStructuredSelection)) { + * + * List<?> selectionList = ((IStructuredSelection) selection).toList(); + * if (selectionList.size() == 1) { selected = selectionList.get(0); } } + * EObject selectedEObject = EMFHelper.getEObject(selected); if + * (selectedEObject != null) { selected = selectedEObject; } if + * (selected instanceof GraphicalEditPart) { selected = + * (((GraphicalEditPart) selected).resolveSemanticElement()); } + */ + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + return (Constraint) selectedUmlElement; + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#constraintEditorchanged(java.lang.Object, + * java.lang.String) + */ + @Override + public void constraintEditorchanged(Object constraint, String textChanged) { + entityUtil.saveConstraint(((Constraint) constraint), textChanged); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintName(java.lang.Object) + */ + public String getConstraintName(Object constraint) { + if (constraint != null) { + return ((Constraint) constraint).getQualifiedName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getStrFromConstraint(java.lang.Object) + */ + public String getStrFromConstraint(Object constraint) { + return ((Constraint) constraint).getSpecification().stringValue(); + } + + @Override + public String[] getEnumValuesFromConstraintOwnerPorts(Object constraint) { + Class element = (Class) ((Constraint) constraint).getOwner(); + return entityUtil.getEnumValuesFromComponentPorts(element); + } + + + +} diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/f0/f0f591093aefdcc952d4f20dadfee720b6eb3d71.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/f0/f0f591093aefdcc952d4f20dadfee720b6eb3d71.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..fcf4d7b9d29c67fa664ecf3c55ff0b4f1709a793 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/f0/f0f591093aefdcc952d4f20dadfee720b6eb3d71.svn-base @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.constraints.constraintEditor +Bundle-SymbolicName: org.polarsys.chess.constraints.constraintEditor;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.ui.views.properties.tabbed, + org.eclipse.core.resources, + org.eclipse.emf.edit.ui, + org.eclipse.papyrus.infra.emf, + org.polarsys.chess.chessmlprofile;bundle-version="0.9.0", + org.polarsys.chess.contracts.profile, + org.polarsys.chess.core +Import-Package: eu.fbk.eclipse.standardtools.constraintEditor.constraintTab, + org.eclipse.emf.edit.ui.action, + org.eclipse.gef, + org.eclipse.gmf.runtime.diagram.ui.editparts, + org.eclipse.papyrus.uml.diagram.common.edit.part, + org.eclipse.uml2.uml, + org.polarsys.chess.service.internal.utils +Bundle-Vendor: Fondazione Bruno Kessler diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/fe/fe05b7d9cd64896b96e32d8084095dae3cd29532.svn-base b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/fe/fe05b7d9cd64896b96e32d8084095dae3cd29532.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..5b58d71c54b484a45cab9e896f90aae7824e0188 --- /dev/null +++ b/org.polarsys.chess.constraints.constraintEditor/.svn/pristine/fe/fe05b7d9cd64896b96e32d8084095dae3cd29532.svn-base @@ -0,0 +1,230 @@ +/******************************************************************************* + * 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.constraints.constraintEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.core.util.uml.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.constraintEditor.constraintTab.ConstraintEditorTab; + +/** + * This is the constraint editor designed for the CHESS platform. It extends the + * ConstraintEditorTab that is designed to be extended and contains standard + * methods not related to specific technologies. The only rule is that it works + * for Eclipse based platforms. + * + */ +public class CustomConstraintEditorTab extends ConstraintEditorTab { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public Resource getResourceFromConstraint(Object constraint) { + + return ((Constraint) constraint).eResource(); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getSubComponentsName(java.lang.Object) + */ + @Override + public String[] getSubComponentsName(Object constraint) { + Element umlElement = ((Constraint) constraint).getOwner(); + EList<String> subCompArr = entityUtil.getSubComponentsNames((Class) umlElement); + String[] subComStrArr = new String[subCompArr.size()]; + return subCompArr.toArray(subComStrArr); + + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getSubComponent(java.lang.Object, java.lang.String) + */ + @Override + public Object getSubComponent(Object constraint, String componentName) { + Element element = ((Constraint) constraint).getOwner(); + + for (Property umlProperty : entityUtil.getSubComponents((Class) element)) { + if (umlProperty.getName().compareTo(componentName) == 0) { + return entityUtil.getUmlType(umlProperty); + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getInputOutputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.INOUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getInputPorts(java.lang.Object) + */ + @Override + public String[] getInputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.IN_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getOutputPorts(java.lang.Object) + */ + @Override + public String[] getOutputPorts(Object component) { + return entityUtil.getPortsNames((Element) component, FlowDirection.OUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerInputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerInputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getInputPorts(element); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerOutputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerOutputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getOutputPorts(element); + + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerInputOutputPorts(Object constraint) { + Element element = ((Constraint) constraint).getOwner(); + return getInputOutputPorts(element); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintOwnerProperties(java.lang.Object) + */ + @Override + public String[] getConstraintOwnerProperties(Object constraint) { + Class element = (Class) ((Constraint) constraint).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(element)); + + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#returnConstraint(org.eclipse.jface.viewers. + * ISelection) + */ + @Override + public Object returnConstraint(ISelection selection) { + /* + * Object selected = null; if ((selection instanceof + * IStructuredSelection)) { + * + * List<?> selectionList = ((IStructuredSelection) selection).toList(); + * if (selectionList.size() == 1) { selected = selectionList.get(0); } } + * EObject selectedEObject = EMFHelper.getEObject(selected); if + * (selectedEObject != null) { selected = selectedEObject; } if + * (selected instanceof GraphicalEditPart) { selected = + * (((GraphicalEditPart) selected).resolveSemanticElement()); } + */ + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + return (Constraint) selectedUmlElement; + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#constraintEditorchanged(java.lang.Object, + * java.lang.String) + */ + @Override + public void constraintEditorchanged(Object constraint, String textChanged) { + entityUtil.saveConstraint(((Constraint) constraint), textChanged); + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getConstraintName(java.lang.Object) + */ + public String getConstraintName(Object constraint) { + if (constraint != null) { + return ((Constraint) constraint).getQualifiedName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see eu.fbk.eclipse.standardtools.constraintEditor.constraintTab. + * ConstraintEditorTab#getStrFromConstraint(java.lang.Object) + */ + public String getStrFromConstraint(Object constraint) { + return ((Constraint) constraint).getSpecification().stringValue(); + } + +} diff --git a/org.polarsys.chess.constraints.constraintEditor/.svn/wc.db b/org.polarsys.chess.constraints.constraintEditor/.svn/wc.db new file mode 100644 index 0000000000000000000000000000000000000000..1a1a12926864e30673b4122d40b26e634725c532 Binary files /dev/null and b/org.polarsys.chess.constraints.constraintEditor/.svn/wc.db differ diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/entries b/org.polarsys.chess.contracts.contractEditor/.svn/entries new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/entries @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/format b/org.polarsys.chess.contracts.contractEditor/.svn/format new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/format @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/18/181172530eba71aa8c9453b9b9e7253787bc60f6.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/18/181172530eba71aa8c9453b9b9e7253787bc60f6.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..c48d9a95677cb24967cc55ef2ec1b2ce0c7ce585 Binary files /dev/null and b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/18/181172530eba71aa8c9453b9b9e7253787bc60f6.svn-base differ diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/18/18ab27444d6f87c6be46104640cc63cb249b47ac.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/18/18ab27444d6f87c6be46104640cc63cb249b47ac.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..62d81b9cce9f7653731afed541df61ace6fc0166 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/18/18ab27444d6f87c6be46104640cc63cb249b47ac.svn-base @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.contracts.contractEditor +Bundle-SymbolicName: org.polarsys.chess.contracts.contractEditor;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.papyrus.uml.diagram.composite;bundle-version="1.0.0", + org.polarsys.chess.chessmlprofile;bundle-version="0.9.0", + org.eclipse.papyrus.uml.properties;bundle-version="1.0.0", + org.polarsys.chess.contracts.profile, + org.polarsys.chess.core +Bundle-ActivationPolicy: lazy +Bundle-Vendor: Fondazione Bruno Kessler +Import-Package: eu.fbk.eclipse.standardtools.contractEditor.core, + eu.fbk.eclipse.standardtools.contractEditor.propertyTab, + eu.fbk.eclipse.standardtools.contractEditor.view, + org.eclipse.emf.cdo.internal.explorer.checkouts;version="4.5.0", + org.eclipse.emf.cdo.transfer, + org.eclipse.emf.cdo.transfer.ui;version="4.2.300", + org.eclipse.ui.navigator.resources, + org.eclipse.xtext.ui.editor.embedded, + org.polarsys.chess.service.internal.utils + diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/2f/2f83278c1df692efeb29a9ed20a7a1e0d39a67a3.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/2f/2f83278c1df692efeb29a9ed20a7a1e0d39a67a3.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..3f057b273ccac52b1e67563f00eacbee4a736df2 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/2f/2f83278c1df692efeb29a9ed20a7a1e0d39a67a3.svn-base @@ -0,0 +1,47 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.EntityUtil; +import org.polarsys.chess.utils.SelectionUtil; + +/** + * It filters the selected objects that are contracts or components. * + */ +public class CustomContractEditorFilter implements org.eclipse.jface.viewers.IFilter { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public boolean select(Object selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + return true; + } + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return true; + } + } else if (selectedUmlElement instanceof Class) { + return true; + } + + return false; + } +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/2f/2f95d3e8882496932ccc76d3d663f4e4c2169b61.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/2f/2f95d3e8882496932ccc76d3d663f4e4c2169b61.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..a0a21389cd51ba6b3a1409db403ac781908f278c --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/2f/2f95d3e8882496932ccc76d3d663f4e4c2169b61.svn-base @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.contracts.contractEditor +Bundle-SymbolicName: org.polarsys.chess.contracts.contractEditor;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.papyrus.uml.diagram.composite;bundle-version="1.0.0", + org.polarsys.chess.chessmlprofile;bundle-version="0.9.0", + org.eclipse.papyrus.uml.properties;bundle-version="1.0.0", + org.polarsys.chess.utils +Bundle-ActivationPolicy: lazy +Bundle-Vendor: Fondazione Bruno Kessler +Import-Package: eu.fbk.eclipse.standardtools.contractEditor.core, + eu.fbk.eclipse.standardtools.contractEditor.propertyTab, + eu.fbk.eclipse.standardtools.contractEditor.view, + org.eclipse.emf.cdo.internal.explorer.checkouts;version="4.5.0", + org.eclipse.emf.cdo.transfer, + org.eclipse.emf.cdo.transfer.ui;version="4.2.300", + org.eclipse.ui.navigator.resources, + org.eclipse.xtext.ui.editor.embedded + diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/39/39eee5b06c23e37b880c71f6166d8166a04fef8d.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/39/39eee5b06c23e37b880c71f6166d8166a04fef8d.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..5a7b50ef282bf2c388ba4ac3e8c926163887fdb9 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/39/39eee5b06c23e37b880c71f6166d8166a04fef8d.svn-base @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <!-- + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage"> + <propertyCategory + category="ContractProperty"></propertyCategory> + </propertyContributor> + </extension> +--> +<!-- + <extension point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections contributorId="TreeOutlinePage"> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyBlock_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyClass_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyComponent_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyBlock_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockCompositeEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyBlock_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockEditPart"/> + </propertySection> + <propertySection class="org.polarsys.chess.contracts.chessextension.propertytab.BlockPropertyCompositeEditPartSection" id="ContractPropertyBlockProperty_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyClassComposite_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyComponentComposite_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.composite.edit.parts.ComponentCompositeEditPart"/> + </propertySection> + <propertySection class="org.polarsys.chess.contracts.chessextension.propertytab.BlockPropertyCompositeEditPartSection" id="ContractPropertyCompositeProperty_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.composite.edit.parts.PropertyPartEditPartCN"/> + </propertySection> + </propertySections> + </extension> + --> + <!-- + <extension + point="org.eclipse.ui.views"> + <view + class="eu.fbk.contract.view.contractEditor.CustomContractEditorView" + icon="icons/editor.gif" + id="eu.fbk.contract.view.contractEditor.ContractEditorView" + name="ContractEditorView" + restorable="true"> + </view> + </extension> + --> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> + <propertyTabs + contributorId="TreeOutlinePage"> + <!-- + <propertyTab + afterTab="advanced" + category="Editors" + id="CustomPropertyTabOld" + label="CustomPropertyTabOld"> + </propertyTab> --> + <propertyTab + afterTab="advanced" + category="Editors" + id="CustomContractTab" + label="CustomContractEditor"> + </propertyTab> + </propertyTabs> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections + contributorId="TreeOutlinePage"> + <!-- + <propertySection + class="eu.fbk.contract.view.propertyEditorOld.CustomConstraintEditPartSection" + filter="eu.fbk.contract.view.propertyEditorOld.PropertyEditorFilter" + id="CustomPropertyEditorSectionOld" + tab="CustomPropertyTabOld"> + </propertySection> --> + <propertySection + class="org.polarsys.chess.contracts.contractEditor.CustomContractEditorTab" + filter="org.polarsys.chess.contracts.contractEditor.CustomContractEditorFilter" + id="CustomContractEditorSection" + tab="CustomContractTab"> + </propertySection> + </propertySections> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage"> + <propertyCategory + category="Editors"> + </propertyCategory> + </propertyContributor> + </extension> + <!-- + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage" + overridableTabListContentProvider="true" + typeMapper="eu.fbk.contract.typeMapper.FormalPropertyMapper"> + <propertyCategory + category="ContractProperty"> + </propertyCategory> + </propertyContributor> + </extension> + --> + <!-- <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage" + tabDescriptorProvider="org.eclipse.papyrus.infra.properties.ui.xwt.XWTTabDescriptorProvider" + typeMapper="eu.fbk.contract.typeMapper.ContractMapper"> + <propertyCategory + category="ContractsTabsGroup"> + </propertyCategory> + </propertyContributor> + </extension> --> +</plugin> diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..295926d964165896ea8aa7c1b1b3c9d3d3caa77e --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base @@ -0,0 +1,7 @@ +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 diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/55/55785085273da4d4c34f47c5fedbd54abd0a0b5f.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/55/55785085273da4d4c34f47c5fedbd54abd0a0b5f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..1c9e1837fe38fc5ea1b1a4686ea5732ba52887e9 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/55/55785085273da4d4c34f47c5fedbd54abd0a0b5f.svn-base @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <!-- + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage"> + <propertyCategory + category="ContractProperty"></propertyCategory> + </propertyContributor> + </extension> +--> +<!-- + <extension point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections contributorId="TreeOutlinePage"> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyBlock_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyClass_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyComponent_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyBlock_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockCompositeEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyBlock_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockEditPart"/> + </propertySection> + <propertySection class="org.polarsys.chess.contracts.chessextension.propertytab.BlockPropertyCompositeEditPartSection" id="ContractPropertyBlockProperty_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyClassComposite_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart"/> + </propertySection> + <propertySection class="eu.fbk.contract.contractEditor.propertytab.BlockEditPartSection" id="ContractPropertyComponentComposite_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.composite.edit.parts.ComponentCompositeEditPart"/> + </propertySection> + <propertySection class="org.polarsys.chess.contracts.chessextension.propertytab.BlockPropertyCompositeEditPartSection" id="ContractPropertyCompositeProperty_v2" tab="Contracts_v2"> + <input type="org.eclipse.papyrus.uml.diagram.composite.edit.parts.PropertyPartEditPartCN"/> + </propertySection> + </propertySections> + </extension> + --> + <!-- + <extension + point="org.eclipse.ui.views"> + <view + class="eu.fbk.contract.view.contractEditor.CustomContractEditorView" + icon="icons/editor.gif" + id="eu.fbk.contract.view.contractEditor.ContractEditorView" + name="ContractEditorView" + restorable="true"> + </view> + </extension> + --> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> + <propertyTabs + contributorId="TreeOutlinePage"> + <!-- + <propertyTab + afterTab="advanced" + category="Editors" + id="CustomPropertyTabOld" + label="CustomPropertyTabOld"> + </propertyTab> --> + <propertyTab + afterTab="advanced" + category="Editors" + id="CustomContractTab" + label="ContractEditor+"> + </propertyTab> + </propertyTabs> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections + contributorId="TreeOutlinePage"> + <!-- + <propertySection + class="eu.fbk.contract.view.propertyEditorOld.CustomConstraintEditPartSection" + filter="eu.fbk.contract.view.propertyEditorOld.PropertyEditorFilter" + id="CustomPropertyEditorSectionOld" + tab="CustomPropertyTabOld"> + </propertySection> --> + <propertySection + class="org.polarsys.chess.contracts.contractEditor.CustomContractEditorTab" + filter="org.polarsys.chess.contracts.contractEditor.CustomContractEditorFilter" + id="CustomContractEditorSection" + tab="CustomContractTab"> + </propertySection> + </propertySections> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage"> + <propertyCategory + category="Editors"> + </propertyCategory> + </propertyContributor> + </extension> + <!-- + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage" + overridableTabListContentProvider="true" + typeMapper="eu.fbk.contract.typeMapper.FormalPropertyMapper"> + <propertyCategory + category="ContractProperty"> + </propertyCategory> + </propertyContributor> + </extension> + --> + <!-- <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage" + tabDescriptorProvider="org.eclipse.papyrus.infra.properties.ui.xwt.XWTTabDescriptorProvider" + typeMapper="eu.fbk.contract.typeMapper.ContractMapper"> + <propertyCategory + category="ContractsTabsGroup"> + </propertyCategory> + </propertyContributor> + </extension> --> +</plugin> diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/57/57ae2bbfdce8a6645a6607604e838a2690e1dc78.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/57/57ae2bbfdce8a6645a6607604e838a2690e1dc78.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..196ca3a44dd7c3b04704ccc4fe6c8d504367d7d7 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/57/57ae2bbfdce8a6645a6607604e838a2690e1dc78.svn-base @@ -0,0 +1,397 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.uml.diagram.composite.part.Messages; +import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.swt.widgets.Display; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.core.util.uml.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab; + +/** + * This is the contract editor designed for the CHESS platform. It extends the + * ContractEditorTab that is designed to be extended and contains standard + * methods not related to specific technologies. The only rule is that it + * requires Eclipse based platforms. + * + */ +public class CustomContractEditorTab extends ContractEditorTab { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public Resource getResourceFromContract(Object contract) { + return ((Class) contract).eResource(); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerInputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerInputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, FlowDirection.IN_VALUE); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerOutputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, FlowDirection.OUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerInputOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, FlowDirection.INOUT_VALUE); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerAttributes(java.lang.Object) + */ + @Override + public String[] getContractOwnerAttributes(Object contract) { + Element element = ((Class) contract).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(element)); + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #returnComponent(org.eclipse.jface.viewers.ISelection) + */ + @Override + public Object returnComponent(ISelection selection) { + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class umlClass = entityUtil.getUmlType((Property) selectedUmlElement); + + if (!contractEntityUtil.isContract(umlClass)) { + return umlClass; + } + } + } else if (selectedUmlElement instanceof Class) { + if (!contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #returnContract(org.eclipse.jface.viewers.ISelection) + */ + @Override + public Object returnContract(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return entityUtil.getUmlType((Property) selectedUmlElement); + } + + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractListStr(java.lang.Object) + */ + @Override + public String[] getContractListStr(Object component) { + EList<String> contractNames = new BasicEList<String>(); + + for (Property prop : ((Class) component).getAttributes()) { + if (contractEntityUtil.isContractProperty(prop)) { + if (prop.getType() == null) { + contractNames.add(prop.getName() + " : <TYPE NOT DEFINED>"); + } else { + contractNames.add(prop.getName() + " : " + prop.getType().getName()); + } + } + } + + String[] contractNamesArr = new String[contractNames.size()]; + return contractNames.toArray(contractNamesArr); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #extractContractFromComponent(java.lang.Object, java.lang.String) + */ + @Override + public Object extractContractFromComponent(Object component, String contractName) { + return contractEntityUtil.getUmlContract((Class) component, contractName); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getComponentName(java.lang.Object) + */ + @Override + public String getComponentName(Object component) { + return ((Class) component).getQualifiedName(); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createAssumption(java.lang.Object) + */ + @Override + public void createAssumption(Object contract) { + contractEntityUtil.createAssumptionToUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #browseAssumptionButtonPressed(java.lang.Object) + */ + @Override + public String browseAssumptionButtonPressed(Object contract) { + + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint assumeConstraint = selectProperty(contract); + if (assumeConstraint != null) { + contractEntityUtil.assignUmlConstraintAssumptionToUmlContract(assumeConstraint, (Class) contract); + } + } + }); + return contractEntityUtil.getAssumeStrFromUmlContract((Class) contract); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createGuarantee(java.lang.Object) + */ + @Override + public void createGuarantee(Object contract) { + contractEntityUtil.createGuaranteeToUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #browseGuaranteeButtonPressed(java.lang.Object) + */ + @Override + public String browseGuaranteeButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint guaranteeConstraint = selectProperty(contract); + if (guaranteeConstraint != null) { + contractEntityUtil.assignUmlConstraintGuaranteeToUmlContract(guaranteeConstraint, (Class) contract); + } + + } + }); + return contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #guaranteeEditorchanged(java.lang.Object, java.lang.String) + */ + @Override + public void guaranteeEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Guarantee", textChanged, (Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #assumptionEditorchanged(java.lang.Object, java.lang.String) + */ + @Override + public void assumptionEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Assume", textChanged, (Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractName(java.lang.Object) + */ + public String getContractName(Object contract) { + if (contract != null) { + return ((Class) contract).getQualifiedName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getAssumeStrFromContract(java.lang.Object) + */ + public String getAssumeStrFromContract(Object contract) { + return (contractEntityUtil.getAssumeStrFromUmlContract((Class) contract)); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getGuaranteeStrFromContract(java.lang.Object) + */ + public String getGuaranteeStrFromContract(Object contract) { + return (contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract)); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createContractProperty(java.lang.Object, java.lang.String) + */ + @Override + public void createContractProperty(Object component, String propertyName) { + contractEntityUtil.createContractPropertyToUmlComponent((Class) component, propertyName); + } + + /** + * It allows the user to select a formal property to be used as assumption + * or guarantee of a contract. + * + * @param contract + * the contract + * @return the formal property selected + */ + private Constraint selectProperty(Object contract) { + TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell()); + + UMLContentProvider provider = new UMLContentProvider(entityUtil.getToPackage((Class) contract), + // contract.getOwner(), + UMLPackage.eINSTANCE.getPackage_PackagedElement()); + + dialog.setContentProvider(provider); + dialog.setLabelProvider(new UMLLabelProvider()); + dialog.setMessage(Messages.UMLModelingAssistantProviderMessage); + dialog.setTitle(Messages.UMLModelingAssistantProviderTitle); + if (dialog.open() == org.eclipse.jface.window.Window.OK) { + Object[] result = dialog.getResult(); + if (result != null && result.length > 0 && result[0] instanceof Constraint) { + return (Constraint) result[0]; + } + } + return null; + } + +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/6b/6b63e80ac55614e8360d1b6078bdff670c439cef.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/6b/6b63e80ac55614e8360d1b6078bdff670c439cef.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..64d79074260faaa463a8897e9fac0acc5c485212 Binary files /dev/null and b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/6b/6b63e80ac55614e8360d1b6078bdff670c439cef.svn-base differ diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/6f/6f3e1634072cdb6f179f7963591717f0f839d8dc.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/6f/6f3e1634072cdb6f179f7963591717f0f839d8dc.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..dc0313355ab281829fc04e96cfc6b61f41a4f6fb --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/6f/6f3e1634072cdb6f179f7963591717f0f839d8dc.svn-base @@ -0,0 +1,403 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.uml.diagram.composite.part.Messages; +import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.swt.widgets.Display; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab; + +/** + * This is the contract editor designed for the CHESS platform. It extends the + * ContractEditorTab that is designed to be extended and contains standard + * methods not related to specific technologies. The only rule is that it + * requires Eclipse based platforms. + * + */ +public class CustomContractEditorTab extends ContractEditorTab { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public Resource getResourceFromContract(Object contract) { + return ((Class) contract).eResource(); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerInputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerInputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getInputPortsNames(umlOwner); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerOutputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getOutputPortsNames(umlOwner); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerInputOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getInputOutputPortsNames(umlOwner); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerAttributes(java.lang.Object) + */ + @Override + public String[] getContractOwnerAttributes(Object contract) { + Element element = ((Class) contract).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(element)); + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #returnComponent(org.eclipse.jface.viewers.ISelection) + */ + @Override + public Object returnComponent(ISelection selection) { + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class umlClass = entityUtil.getUmlType((Property) selectedUmlElement); + + if (!contractEntityUtil.isContract(umlClass)) { + return umlClass; + } + } + } else if (selectedUmlElement instanceof Class) { + if (!contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #returnContract(org.eclipse.jface.viewers.ISelection) + */ + @Override + public Object returnContract(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return entityUtil.getUmlType((Property) selectedUmlElement); + } + + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractListStr(java.lang.Object) + */ + @Override + public String[] getContractListStr(Object component) { + EList<String> contractNames = new BasicEList<String>(); + + for (Property prop : ((Class) component).getAttributes()) { + if (contractEntityUtil.isContractProperty(prop)) { + if (prop.getType() == null) { + contractNames.add(prop.getName() + " : <TYPE NOT DEFINED>"); + } else { + contractNames.add(prop.getName() + " : " + prop.getType().getName()); + } + } + } + + String[] contractNamesArr = new String[contractNames.size()]; + return contractNames.toArray(contractNamesArr); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #extractContractFromComponent(java.lang.Object, java.lang.String) + */ + @Override + public Object extractContractFromComponent(Object component, String contractName) { + return contractEntityUtil.getUmlContract((Class) component, contractName); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getComponentName(java.lang.Object) + */ + @Override + public String getComponentName(Object component) { + return ((Class) component).getQualifiedName(); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createAssumption(java.lang.Object) + */ + @Override + public void createAssumption(Object contract) { + contractEntityUtil.createAssumptionToUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #browseAssumptionButtonPressed(java.lang.Object) + */ + @Override + public String browseAssumptionButtonPressed(Object contract) { + + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint assumeConstraint = selectProperty(contract); + if (assumeConstraint != null) { + contractEntityUtil.assignUmlConstraintAssumptionToUmlContract(assumeConstraint, (Class) contract); + } + } + }); + return contractEntityUtil.getAssumeStrFromUmlContract((Class) contract); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createGuarantee(java.lang.Object) + */ + @Override + public void createGuarantee(Object contract) { + contractEntityUtil.createGuaranteeToUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #browseGuaranteeButtonPressed(java.lang.Object) + */ + @Override + public String browseGuaranteeButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint guaranteeConstraint = selectProperty(contract); + if (guaranteeConstraint != null) { + contractEntityUtil.assignUmlConstraintGuaranteeToUmlContract(guaranteeConstraint, (Class) contract); + } + + } + }); + return contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #guaranteeEditorchanged(java.lang.Object, java.lang.String) + */ + @Override + public void guaranteeEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Guarantee", textChanged, (Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #assumptionEditorchanged(java.lang.Object, java.lang.String) + */ + @Override + public void assumptionEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Assume", textChanged, (Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractName(java.lang.Object) + */ + public String getContractName(Object contract) { + if (contract != null) { + return ((Class) contract).getQualifiedName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getAssumeStrFromContract(java.lang.Object) + */ + public String getAssumeStrFromContract(Object contract) { + return (contractEntityUtil.getAssumeStrFromUmlContract((Class) contract)); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getGuaranteeStrFromContract(java.lang.Object) + */ + public String getGuaranteeStrFromContract(Object contract) { + return (contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract)); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createContractProperty(java.lang.Object, java.lang.String) + */ + @Override + public void createContractProperty(Object component, String propertyName) { + contractEntityUtil.createContractPropertyToUmlComponent((Class) component, propertyName); + } + + /** + * It allows the user to select a formal property to be used as assumption + * or guarantee of a contract. + * + * @param contract + * the contract + * @return the formal property selected + */ + private Constraint selectProperty(Object contract) { + TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell()); + + UMLContentProvider provider = new UMLContentProvider(entityUtil.getToPackage((Class) contract), + // contract.getOwner(), + UMLPackage.eINSTANCE.getPackage_PackagedElement()); + + dialog.setContentProvider(provider); + dialog.setLabelProvider(new UMLLabelProvider()); + dialog.setMessage(Messages.UMLModelingAssistantProviderMessage); + dialog.setTitle(Messages.UMLModelingAssistantProviderTitle); + if (dialog.open() == org.eclipse.jface.window.Window.OK) { + Object[] result = dialog.getResult(); + if (result != null && result.length > 0 && result[0] instanceof Constraint) { + return (Constraint) result[0]; + } + } + return null; + } + + @Override + public String[] getEnumValuesFromContractOwnerPorts(Object contract) { + Class element = (Class) ((Class) contract).getOwner(); + return entityUtil.getEnumValuesFromComponentPorts(element); + } + +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/72/728bd934bf9ee0c36243ca41198e0eff65f53e5a.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/72/728bd934bf9ee0c36243ca41198e0eff65f53e5a.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..cd7d008235cf037cf34b2591e51f3fc6fa9b43cc --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/72/728bd934bf9ee0c36243ca41198e0eff65f53e5a.svn-base @@ -0,0 +1,47 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +/** + * It filters the selected objects that are contracts or components. * + */ +public class CustomContractEditorFilter implements org.eclipse.jface.viewers.IFilter { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public boolean select(Object selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + return true; + } + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return true; + } + } else if (selectedUmlElement instanceof Class) { + return true; + } + + return false; + } +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/77/77802034e497a5ca4b638f6dc792ae9d2880728f.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/77/77802034e497a5ca4b638f6dc792ae9d2880728f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b78d24ce3a53018aa85503b8df012f79c396acf2 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/77/77802034e497a5ca4b638f6dc792ae9d2880728f.svn-base @@ -0,0 +1,233 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.uml.diagram.composite.part.Messages; +import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.swt.widgets.Display; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.core.util.uml.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.contractEditor.view.ContractEditorView; + +/** + * This class in not used. It creates a view that contains the contract editor. + * In our case we use the CustomContractEditorTab that creates a new tab from + * the property view in eclipse. + */ +public class CustomContractEditorView extends ContractEditorView { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getContractOwnerInputPorts(Object contract) { + int direction = FlowDirection.IN_VALUE; + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getContractOwnerOutputPorts(Object contract) { + int direction = FlowDirection.OUT_VALUE; + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getContractOwnerInputOutputPorts(Object contract) { + int direction = FlowDirection.INOUT_VALUE; + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public Object returnComponent(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (!contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (!contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + @Override + public Object returnContract(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return entityUtil.getUmlType((Property) selectedUmlElement); + } + + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + @Override + public String[] getContractListStr(Object component) { + EList<String> contractNames = new BasicEList<String>(); + + for (Property prop : ((Class) component).getAttributes()) { + if (contractEntityUtil.isContractProperty(prop)) { + if (prop.getType() == null) { + contractNames.add(prop.getName() + " : <TYPE NOT DEFINED>"); + } else { + contractNames.add(prop.getName() + " : " + prop.getType().getName()); + } + } + } + + String[] contractNamesArr = new String[contractNames.size()]; + return contractNames.toArray(contractNamesArr); + } + + @Override + public Object extractContractFromComponent(Object component, String contractName) { + return contractEntityUtil.getUmlContract((Class) component, contractName); + } + + @Override + public String getComponentName(Object component) { + return ((Class) component).getQualifiedName(); + } + + @Override + public void createAssumption(Object contract) { + contractEntityUtil.createAssumptionToUmlContract((Class) contract); + } + + @Override + public String browseAssumptionButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint assumeConstraint = selectProperty(contract); + if (assumeConstraint != null) { + contractEntityUtil.assignUmlConstraintAssumptionToUmlContract(assumeConstraint, (Class) contract); + } + } + }); + return contractEntityUtil.getAssumeStrFromUmlContract((Class) contract); + + } + + @Override + public void createGuarantee(Object contract) { + contractEntityUtil.createGuaranteeToUmlContract((Class) contract); + } + + @Override + public String browseGuaranteeButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint guaranteeConstraint = selectProperty(contract); + if (guaranteeConstraint != null) { + contractEntityUtil.assignUmlConstraintGuaranteeToUmlContract(guaranteeConstraint, (Class) contract); + } + + } + }); + return contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract); + } + + @Override + public void guaranteeEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Guarantee", textChanged, (Class) contract); + } + + @Override + public void assumptionEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Assume", textChanged, (Class) contract); + } + + private Constraint selectProperty(Object contract) { + TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell()); + + UMLContentProvider provider = new UMLContentProvider(entityUtil.getToPackage((Class) contract), + // contract.getOwner(), + UMLPackage.eINSTANCE.getPackage_PackagedElement()); + + dialog.setContentProvider(provider); + dialog.setLabelProvider(new UMLLabelProvider()); + dialog.setMessage(Messages.UMLModelingAssistantProviderMessage); + dialog.setTitle(Messages.UMLModelingAssistantProviderTitle); + if (dialog.open() == org.eclipse.jface.window.Window.OK) { + Object[] result = dialog.getResult(); + if (result != null && result.length > 0 && result[0] instanceof Constraint) { + return (Constraint) result[0]; + } + } + return null; + } + + public String getContractName(Object contract) { + if (contract != null) { + return ((Class) contract).getQualifiedName(); + } + return null; + } + + public String getAssumeStrFromContract(Object contract) { + return (contractEntityUtil.getAssumeStrFromUmlContract((Class) contract)); + } + + public String getGuaranteeStrFromContract(Object contract) { + return (contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract)); + } + +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b862a296d38fe04269faeee6c9d77d11ff77380d --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base @@ -0,0 +1,7 @@ +<?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> diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/86/86e1fbf4ea4a6ce61d973999900a856345c5b0e4.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/86/86e1fbf4ea4a6ce61d973999900a856345c5b0e4.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..2986ee7ecb4bbfd8f52045f15303dc08a5e82109 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/86/86e1fbf4ea4a6ce61d973999900a856345c5b0e4.svn-base @@ -0,0 +1,233 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.uml.diagram.composite.part.Messages; +import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.swt.widgets.Display; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.EntityUtil; +import org.polarsys.chess.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.contractEditor.view.ContractEditorView; + +/** + * This class in not used. It creates a view that contains the contract editor. + * In our case we use the CustomContractEditorTab that creates a new tab from + * the property view in eclipse. + */ +public class CustomContractEditorView extends ContractEditorView { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getContractOwnerInputPorts(Object contract) { + int direction = FlowDirection.IN_VALUE; + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getContractOwnerOutputPorts(Object contract) { + int direction = FlowDirection.OUT_VALUE; + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getContractOwnerInputOutputPorts(Object contract) { + int direction = FlowDirection.INOUT_VALUE; + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public Object returnComponent(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (!contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (!contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + @Override + public Object returnContract(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return entityUtil.getUmlType((Property) selectedUmlElement); + } + + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + @Override + public String[] getContractListStr(Object component) { + EList<String> contractNames = new BasicEList<String>(); + + for (Property prop : ((Class) component).getAttributes()) { + if (contractEntityUtil.isContractProperty(prop)) { + if (prop.getType() == null) { + contractNames.add(prop.getName() + " : <TYPE NOT DEFINED>"); + } else { + contractNames.add(prop.getName() + " : " + prop.getType().getName()); + } + } + } + + String[] contractNamesArr = new String[contractNames.size()]; + return contractNames.toArray(contractNamesArr); + } + + @Override + public Object extractContractFromComponent(Object component, String contractName) { + return contractEntityUtil.getUmlContract((Class) component, contractName); + } + + @Override + public String getComponentName(Object component) { + return ((Class) component).getQualifiedName(); + } + + @Override + public void createAssumption(Object contract) { + contractEntityUtil.createAssumptionToUmlContract((Class) contract); + } + + @Override + public String browseAssumptionButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint assumeConstraint = selectProperty(contract); + if (assumeConstraint != null) { + contractEntityUtil.assignUmlConstraintAssumptionToUmlContract(assumeConstraint, (Class) contract); + } + } + }); + return contractEntityUtil.getAssumeStrFromUmlContract((Class) contract); + + } + + @Override + public void createGuarantee(Object contract) { + contractEntityUtil.createGuaranteeToUmlContract((Class) contract); + } + + @Override + public String browseGuaranteeButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint guaranteeConstraint = selectProperty(contract); + if (guaranteeConstraint != null) { + contractEntityUtil.assignUmlConstraintGuaranteeToUmlContract(guaranteeConstraint, (Class) contract); + } + + } + }); + return contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract); + } + + @Override + public void guaranteeEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Guarantee", textChanged, (Class) contract); + } + + @Override + public void assumptionEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Assume", textChanged, (Class) contract); + } + + private Constraint selectProperty(Object contract) { + TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell()); + + UMLContentProvider provider = new UMLContentProvider(entityUtil.getToPackage((Class) contract), + // contract.getOwner(), + UMLPackage.eINSTANCE.getPackage_PackagedElement()); + + dialog.setContentProvider(provider); + dialog.setLabelProvider(new UMLLabelProvider()); + dialog.setMessage(Messages.UMLModelingAssistantProviderMessage); + dialog.setTitle(Messages.UMLModelingAssistantProviderTitle); + if (dialog.open() == org.eclipse.jface.window.Window.OK) { + Object[] result = dialog.getResult(); + if (result != null && result.length > 0 && result[0] instanceof Constraint) { + return (Constraint) result[0]; + } + } + return null; + } + + public String getContractName(Object contract) { + if (contract != null) { + return ((Class) contract).getQualifiedName(); + } + return null; + } + + public String getAssumeStrFromContract(Object contract) { + return (contractEntityUtil.getAssumeStrFromUmlContract((Class) contract)); + } + + public String getGuaranteeStrFromContract(Object contract) { + return (contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract)); + } + +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/97/97ead69dc11cc924a70092b06e53da32b8a1cdcc.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/97/97ead69dc11cc924a70092b06e53da32b8a1cdcc.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..cb415064e026e17ab2b67610add4b665fbe48f65 Binary files /dev/null and b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/97/97ead69dc11cc924a70092b06e53da32b8a1cdcc.svn-base differ diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/98/98173ce02daed18cb5d937a5022b3b2e9ff71465.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/98/98173ce02daed18cb5d937a5022b3b2e9ff71465.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..5e3d217744ef1641ebf6e2bcaa9279ff6cecd9e5 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/98/98173ce02daed18cb5d937a5022b3b2e9ff71465.svn-base @@ -0,0 +1,47 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.core.util.uml.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +/** + * It filters the selected objects that are contracts or components. * + */ +public class CustomContractEditorFilter implements org.eclipse.jface.viewers.IFilter { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public boolean select(Object selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + return true; + } + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return true; + } + } else if (selectedUmlElement instanceof Class) { + return true; + } + + return false; + } +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/9c/9c4c60436712fa0ff91192141e7c8e786f97ac5c.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/9c/9c4c60436712fa0ff91192141e7c8e786f97ac5c.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6491a33b45a922aea8cd90283f96672a55e25b0f --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/9c/9c4c60436712fa0ff91192141e7c8e786f97ac5c.svn-base @@ -0,0 +1,230 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.uml.diagram.composite.part.Messages; +import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.swt.widgets.Display; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.core.util.uml.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.contractEditor.view.ContractEditorView; + +/** + * This class in not used. It creates a view that contains the contract editor. + * In our case we use the CustomContractEditorTab that creates a new tab from + * the property view in eclipse. + */ +public class CustomContractEditorView extends ContractEditorView { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getContractOwnerInputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getInputPortsNames(umlOwner); + } + + @Override + public String[] getContractOwnerOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getOutputPortsNames(umlOwner); + } + + @Override + public String[] getContractOwnerInputOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getInputOutputPortsNames(umlOwner); + } + + @Override + public Object returnComponent(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (!contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (!contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + @Override + public Object returnContract(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return entityUtil.getUmlType((Property) selectedUmlElement); + } + + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + @Override + public String[] getContractListStr(Object component) { + EList<String> contractNames = new BasicEList<String>(); + + for (Property prop : ((Class) component).getAttributes()) { + if (contractEntityUtil.isContractProperty(prop)) { + if (prop.getType() == null) { + contractNames.add(prop.getName() + " : <TYPE NOT DEFINED>"); + } else { + contractNames.add(prop.getName() + " : " + prop.getType().getName()); + } + } + } + + String[] contractNamesArr = new String[contractNames.size()]; + return contractNames.toArray(contractNamesArr); + } + + @Override + public Object extractContractFromComponent(Object component, String contractName) { + return contractEntityUtil.getUmlContract((Class) component, contractName); + } + + @Override + public String getComponentName(Object component) { + return ((Class) component).getQualifiedName(); + } + + @Override + public void createAssumption(Object contract) { + contractEntityUtil.createAssumptionToUmlContract((Class) contract); + } + + @Override + public String browseAssumptionButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint assumeConstraint = selectProperty(contract); + if (assumeConstraint != null) { + contractEntityUtil.assignUmlConstraintAssumptionToUmlContract(assumeConstraint, (Class) contract); + } + } + }); + return contractEntityUtil.getAssumeStrFromUmlContract((Class) contract); + + } + + @Override + public void createGuarantee(Object contract) { + contractEntityUtil.createGuaranteeToUmlContract((Class) contract); + } + + @Override + public String browseGuaranteeButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint guaranteeConstraint = selectProperty(contract); + if (guaranteeConstraint != null) { + contractEntityUtil.assignUmlConstraintGuaranteeToUmlContract(guaranteeConstraint, (Class) contract); + } + + } + }); + return contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract); + } + + @Override + public void guaranteeEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Guarantee", textChanged, (Class) contract); + } + + @Override + public void assumptionEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Assume", textChanged, (Class) contract); + } + + private Constraint selectProperty(Object contract) { + TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell()); + + UMLContentProvider provider = new UMLContentProvider(entityUtil.getToPackage((Class) contract), + // contract.getOwner(), + UMLPackage.eINSTANCE.getPackage_PackagedElement()); + + dialog.setContentProvider(provider); + dialog.setLabelProvider(new UMLLabelProvider()); + dialog.setMessage(Messages.UMLModelingAssistantProviderMessage); + dialog.setTitle(Messages.UMLModelingAssistantProviderTitle); + if (dialog.open() == org.eclipse.jface.window.Window.OK) { + Object[] result = dialog.getResult(); + if (result != null && result.length > 0 && result[0] instanceof Constraint) { + return (Constraint) result[0]; + } + } + return null; + } + + public String getContractName(Object contract) { + if (contract != null) { + return ((Class) contract).getQualifiedName(); + } + return null; + } + + public String getAssumeStrFromContract(Object contract) { + return (contractEntityUtil.getAssumeStrFromUmlContract((Class) contract)); + } + + public String getGuaranteeStrFromContract(Object contract) { + return (contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract)); + } + +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/b0/b045a8019df5d46c6d15460ac5b958d39d908dab.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/b0/b045a8019df5d46c6d15460ac5b958d39d908dab.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..922306cb3bc1f03c7b5cb7593311585886687d60 Binary files /dev/null and b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/b0/b045a8019df5d46c6d15460ac5b958d39d908dab.svn-base differ diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..285b8bf47b6f777dcb23e9b8224db2b68f70e9b6 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/ diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/c6/c61ac3c1e1dbd12506dc44a4551d12b34728309a.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/c6/c61ac3c1e1dbd12506dc44a4551d12b34728309a.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ec206a1740962991d3507a388198ff4369d356f0 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/c6/c61ac3c1e1dbd12506dc44a4551d12b34728309a.svn-base @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.polarsys.chess.contracts.contractEditor</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> diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/ca/ca8c639aa32d569854a45400778e53290bb2f205.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/ca/ca8c639aa32d569854a45400778e53290bb2f205.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..252d7ebcb8c74d6e5de66ef0eb8856622a0e9d89 Binary files /dev/null and b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/ca/ca8c639aa32d569854a45400778e53290bb2f205.svn-base differ diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ae3c1726048cd06b9a143e0376ed46dd9b9a8d53 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base @@ -0,0 +1 @@ +/bin/ diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/d5/d5cba57161ff9f2faf64963c08ec0e6bb1e3eec9.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/d5/d5cba57161ff9f2faf64963c08ec0e6bb1e3eec9.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ff3e6d98eedb9831ae4fcdeaa49b78128fb81f1d --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/d5/d5cba57161ff9f2faf64963c08ec0e6bb1e3eec9.svn-base @@ -0,0 +1,397 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.uml.diagram.composite.part.Messages; +import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.swt.widgets.Display; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.EntityUtil; +import org.polarsys.chess.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab; + +/** + * This is the contract editor designed for the CHESS platform. It extends the + * ContractEditorTab that is designed to be extended and contains standard + * methods not related to specific technologies. The only rule is that it + * requires Eclipse based platforms. + * + */ +public class CustomContractEditorTab extends ContractEditorTab { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public Resource getResourceFromContract(Object contract) { + return ((Class) contract).eResource(); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerInputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerInputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, FlowDirection.IN_VALUE); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerOutputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, FlowDirection.OUT_VALUE); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerInputOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getPortsNames(umlOwner, FlowDirection.INOUT_VALUE); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerAttributes(java.lang.Object) + */ + @Override + public String[] getContractOwnerAttributes(Object contract) { + Element element = ((Class) contract).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(element)); + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #returnComponent(org.eclipse.jface.viewers.ISelection) + */ + @Override + public Object returnComponent(ISelection selection) { + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class umlClass = entityUtil.getUmlType((Property) selectedUmlElement); + + if (!contractEntityUtil.isContract(umlClass)) { + return umlClass; + } + } + } else if (selectedUmlElement instanceof Class) { + if (!contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #returnContract(org.eclipse.jface.viewers.ISelection) + */ + @Override + public Object returnContract(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return entityUtil.getUmlType((Property) selectedUmlElement); + } + + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractListStr(java.lang.Object) + */ + @Override + public String[] getContractListStr(Object component) { + EList<String> contractNames = new BasicEList<String>(); + + for (Property prop : ((Class) component).getAttributes()) { + if (contractEntityUtil.isContractProperty(prop)) { + if (prop.getType() == null) { + contractNames.add(prop.getName() + " : <TYPE NOT DEFINED>"); + } else { + contractNames.add(prop.getName() + " : " + prop.getType().getName()); + } + } + } + + String[] contractNamesArr = new String[contractNames.size()]; + return contractNames.toArray(contractNamesArr); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #extractContractFromComponent(java.lang.Object, java.lang.String) + */ + @Override + public Object extractContractFromComponent(Object component, String contractName) { + return contractEntityUtil.getUmlContract((Class) component, contractName); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getComponentName(java.lang.Object) + */ + @Override + public String getComponentName(Object component) { + return ((Class) component).getQualifiedName(); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createAssumption(java.lang.Object) + */ + @Override + public void createAssumption(Object contract) { + contractEntityUtil.createAssumptionToUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #browseAssumptionButtonPressed(java.lang.Object) + */ + @Override + public String browseAssumptionButtonPressed(Object contract) { + + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint assumeConstraint = selectProperty(contract); + if (assumeConstraint != null) { + contractEntityUtil.assignUmlConstraintAssumptionToUmlContract(assumeConstraint, (Class) contract); + } + } + }); + return contractEntityUtil.getAssumeStrFromUmlContract((Class) contract); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createGuarantee(java.lang.Object) + */ + @Override + public void createGuarantee(Object contract) { + contractEntityUtil.createGuaranteeToUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #browseGuaranteeButtonPressed(java.lang.Object) + */ + @Override + public String browseGuaranteeButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint guaranteeConstraint = selectProperty(contract); + if (guaranteeConstraint != null) { + contractEntityUtil.assignUmlConstraintGuaranteeToUmlContract(guaranteeConstraint, (Class) contract); + } + + } + }); + return contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #guaranteeEditorchanged(java.lang.Object, java.lang.String) + */ + @Override + public void guaranteeEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Guarantee", textChanged, (Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #assumptionEditorchanged(java.lang.Object, java.lang.String) + */ + @Override + public void assumptionEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Assume", textChanged, (Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractName(java.lang.Object) + */ + public String getContractName(Object contract) { + if (contract != null) { + return ((Class) contract).getQualifiedName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getAssumeStrFromContract(java.lang.Object) + */ + public String getAssumeStrFromContract(Object contract) { + return (contractEntityUtil.getAssumeStrFromUmlContract((Class) contract)); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getGuaranteeStrFromContract(java.lang.Object) + */ + public String getGuaranteeStrFromContract(Object contract) { + return (contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract)); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createContractProperty(java.lang.Object, java.lang.String) + */ + @Override + public void createContractProperty(Object component, String propertyName) { + contractEntityUtil.createContractPropertyToUmlComponent((Class) component, propertyName); + } + + /** + * It allows the user to select a formal property to be used as assumption + * or guarantee of a contract. + * + * @param contract + * the contract + * @return the formal property selected + */ + private Constraint selectProperty(Object contract) { + TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell()); + + UMLContentProvider provider = new UMLContentProvider(entityUtil.getToPackage((Class) contract), + // contract.getOwner(), + UMLPackage.eINSTANCE.getPackage_PackagedElement()); + + dialog.setContentProvider(provider); + dialog.setLabelProvider(new UMLLabelProvider()); + dialog.setMessage(Messages.UMLModelingAssistantProviderMessage); + dialog.setTitle(Messages.UMLModelingAssistantProviderTitle); + if (dialog.open() == org.eclipse.jface.window.Window.OK) { + Object[] result = dialog.getResult(); + if (result != null && result.length > 0 && result[0] instanceof Constraint) { + return (Constraint) result[0]; + } + } + return null; + } + +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/e6/e671d3520c066677cb931e85b0941f3abe514693.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/e6/e671d3520c066677cb931e85b0941f3abe514693.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b7b3417a0a84c6d4994c8d425ece2aef08387e53 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/e6/e671d3520c066677cb931e85b0941f3abe514693.svn-base @@ -0,0 +1,236 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.uml.diagram.composite.part.Messages; +import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.swt.widgets.Display; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.contractEditor.view.ContractEditorView; + +/** + * This class in not used. It creates a view that contains the contract editor. + * In our case we use the CustomContractEditorTab that creates a new tab from + * the property view in eclipse. + */ +public class CustomContractEditorView extends ContractEditorView { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getContractOwnerInputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getInputPortsNames(umlOwner); + } + + @Override + public String[] getContractOwnerOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getOutputPortsNames(umlOwner); + } + + @Override + public String[] getContractOwnerInputOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getInputOutputPortsNames(umlOwner); + } + + @Override + public Object returnComponent(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (!contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (!contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + @Override + public Object returnContract(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return entityUtil.getUmlType((Property) selectedUmlElement); + } + + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + @Override + public String[] getContractListStr(Object component) { + EList<String> contractNames = new BasicEList<String>(); + + for (Property prop : ((Class) component).getAttributes()) { + if (contractEntityUtil.isContractProperty(prop)) { + if (prop.getType() == null) { + contractNames.add(prop.getName() + " : <TYPE NOT DEFINED>"); + } else { + contractNames.add(prop.getName() + " : " + prop.getType().getName()); + } + } + } + + String[] contractNamesArr = new String[contractNames.size()]; + return contractNames.toArray(contractNamesArr); + } + + @Override + public Object extractContractFromComponent(Object component, String contractName) { + return contractEntityUtil.getUmlContract((Class) component, contractName); + } + + @Override + public String getComponentName(Object component) { + return ((Class) component).getQualifiedName(); + } + + @Override + public void createAssumption(Object contract) { + contractEntityUtil.createAssumptionToUmlContract((Class) contract); + } + + @Override + public String browseAssumptionButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint assumeConstraint = selectProperty(contract); + if (assumeConstraint != null) { + contractEntityUtil.assignUmlConstraintAssumptionToUmlContract(assumeConstraint, (Class) contract); + } + } + }); + return contractEntityUtil.getAssumeStrFromUmlContract((Class) contract); + + } + + @Override + public void createGuarantee(Object contract) { + contractEntityUtil.createGuaranteeToUmlContract((Class) contract); + } + + @Override + public String browseGuaranteeButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint guaranteeConstraint = selectProperty(contract); + if (guaranteeConstraint != null) { + contractEntityUtil.assignUmlConstraintGuaranteeToUmlContract(guaranteeConstraint, (Class) contract); + } + + } + }); + return contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract); + } + + @Override + public void guaranteeEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Guarantee", textChanged, (Class) contract); + } + + @Override + public void assumptionEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Assume", textChanged, (Class) contract); + } + + private Constraint selectProperty(Object contract) { + TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell()); + + UMLContentProvider provider = new UMLContentProvider(entityUtil.getToPackage((Class) contract), + // contract.getOwner(), + UMLPackage.eINSTANCE.getPackage_PackagedElement()); + + dialog.setContentProvider(provider); + dialog.setLabelProvider(new UMLLabelProvider()); + dialog.setMessage(Messages.UMLModelingAssistantProviderMessage); + dialog.setTitle(Messages.UMLModelingAssistantProviderTitle); + if (dialog.open() == org.eclipse.jface.window.Window.OK) { + Object[] result = dialog.getResult(); + if (result != null && result.length > 0 && result[0] instanceof Constraint) { + return (Constraint) result[0]; + } + } + return null; + } + + public String getContractName(Object contract) { + if (contract != null) { + return ((Class) contract).getQualifiedName(); + } + return null; + } + + public String getAssumeStrFromContract(Object contract) { + return (contractEntityUtil.getAssumeStrFromUmlContract((Class) contract)); + } + + public String getGuaranteeStrFromContract(Object contract) { + return (contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract)); + } + + @Override + public String[] getEnumValuesFromContractOwnerPorts(Object contract) { + Class element = (Class) ((Class) contract).getOwner(); + return entityUtil.getEnumValuesFromComponentPorts(element); + } + +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/pristine/f6/f65dbd3910b374f52dba68e819ca53d86900f5e8.svn-base b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/f6/f65dbd3910b374f52dba68e819ca53d86900f5e8.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d7d6713f26f0146bcda8d08d1464d6df1840d113 --- /dev/null +++ b/org.polarsys.chess.contracts.contractEditor/.svn/pristine/f6/f65dbd3910b374f52dba68e819ca53d86900f5e8.svn-base @@ -0,0 +1,397 @@ +/******************************************************************************* + * 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.contracts.contractEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.uml.diagram.composite.part.Messages; +import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.swt.widgets.Display; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.core.util.uml.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab; + +/** + * This is the contract editor designed for the CHESS platform. It extends the + * ContractEditorTab that is designed to be extended and contains standard + * methods not related to specific technologies. The only rule is that it + * requires Eclipse based platforms. + * + */ +public class CustomContractEditorTab extends ContractEditorTab { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public Resource getResourceFromContract(Object contract) { + return ((Class) contract).eResource(); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerInputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerInputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getInputPortsNames(umlOwner); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerOutputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getOutputPortsNames(umlOwner); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerInputOutputPorts(java.lang.Object) + */ + @Override + public String[] getContractOwnerInputOutputPorts(Object contract) { + Element umlOwner = entityUtil.getOwner((Element) contract); + return entityUtil.getInputOutputPortsNames(umlOwner); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractOwnerAttributes(java.lang.Object) + */ + @Override + public String[] getContractOwnerAttributes(Object contract) { + Element element = ((Class) contract).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(element)); + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #returnComponent(org.eclipse.jface.viewers.ISelection) + */ + @Override + public Object returnComponent(ISelection selection) { + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class umlClass = entityUtil.getUmlType((Property) selectedUmlElement); + + if (!contractEntityUtil.isContract(umlClass)) { + return umlClass; + } + } + } else if (selectedUmlElement instanceof Class) { + if (!contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #returnContract(org.eclipse.jface.viewers.ISelection) + */ + @Override + public Object returnContract(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Property) { + if (contractEntityUtil.isContractProperty((Property) selectedUmlElement)) { + return entityUtil.getUmlType((Property) selectedUmlElement); + } + + if (entityUtil.isComponentInstance((Property) selectedUmlElement)) { + Class classType = entityUtil.getUmlType((Property) selectedUmlElement); + if (contractEntityUtil.isContract(classType)) { + return classType; + } + } + } else if (selectedUmlElement instanceof Class) { + if (contractEntityUtil.isContract((Class) selectedUmlElement)) { + return selectedUmlElement; + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractListStr(java.lang.Object) + */ + @Override + public String[] getContractListStr(Object component) { + EList<String> contractNames = new BasicEList<String>(); + + for (Property prop : ((Class) component).getAttributes()) { + if (contractEntityUtil.isContractProperty(prop)) { + if (prop.getType() == null) { + contractNames.add(prop.getName() + " : <TYPE NOT DEFINED>"); + } else { + contractNames.add(prop.getName() + " : " + prop.getType().getName()); + } + } + } + + String[] contractNamesArr = new String[contractNames.size()]; + return contractNames.toArray(contractNamesArr); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #extractContractFromComponent(java.lang.Object, java.lang.String) + */ + @Override + public Object extractContractFromComponent(Object component, String contractName) { + return contractEntityUtil.getUmlContract((Class) component, contractName); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getComponentName(java.lang.Object) + */ + @Override + public String getComponentName(Object component) { + return ((Class) component).getQualifiedName(); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createAssumption(java.lang.Object) + */ + @Override + public void createAssumption(Object contract) { + contractEntityUtil.createAssumptionToUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #browseAssumptionButtonPressed(java.lang.Object) + */ + @Override + public String browseAssumptionButtonPressed(Object contract) { + + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint assumeConstraint = selectProperty(contract); + if (assumeConstraint != null) { + contractEntityUtil.assignUmlConstraintAssumptionToUmlContract(assumeConstraint, (Class) contract); + } + } + }); + return contractEntityUtil.getAssumeStrFromUmlContract((Class) contract); + + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createGuarantee(java.lang.Object) + */ + @Override + public void createGuarantee(Object contract) { + contractEntityUtil.createGuaranteeToUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #browseGuaranteeButtonPressed(java.lang.Object) + */ + @Override + public String browseGuaranteeButtonPressed(Object contract) { + TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(contract); + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + Constraint guaranteeConstraint = selectProperty(contract); + if (guaranteeConstraint != null) { + contractEntityUtil.assignUmlConstraintGuaranteeToUmlContract(guaranteeConstraint, (Class) contract); + } + + } + }); + return contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #guaranteeEditorchanged(java.lang.Object, java.lang.String) + */ + @Override + public void guaranteeEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Guarantee", textChanged, (Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #assumptionEditorchanged(java.lang.Object, java.lang.String) + */ + @Override + public void assumptionEditorchanged(Object contract, String textChanged) { + contractEntityUtil.saveFormalProperty("Assume", textChanged, (Class) contract); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getContractName(java.lang.Object) + */ + public String getContractName(Object contract) { + if (contract != null) { + return ((Class) contract).getQualifiedName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getAssumeStrFromContract(java.lang.Object) + */ + public String getAssumeStrFromContract(Object contract) { + return (contractEntityUtil.getAssumeStrFromUmlContract((Class) contract)); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #getGuaranteeStrFromContract(java.lang.Object) + */ + public String getGuaranteeStrFromContract(Object contract) { + return (contractEntityUtil.getGuaranteeStrFromUmlContract((Class) contract)); + } + + /* + * (non-Javadoc) + * + * @see + * eu.fbk.eclipse.standardtools.contractEditor.propertyTab.ContractEditorTab + * #createContractProperty(java.lang.Object, java.lang.String) + */ + @Override + public void createContractProperty(Object component, String propertyName) { + contractEntityUtil.createContractPropertyToUmlComponent((Class) component, propertyName); + } + + /** + * It allows the user to select a formal property to be used as assumption + * or guarantee of a contract. + * + * @param contract + * the contract + * @return the formal property selected + */ + private Constraint selectProperty(Object contract) { + TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell()); + + UMLContentProvider provider = new UMLContentProvider(entityUtil.getToPackage((Class) contract), + // contract.getOwner(), + UMLPackage.eINSTANCE.getPackage_PackagedElement()); + + dialog.setContentProvider(provider); + dialog.setLabelProvider(new UMLLabelProvider()); + dialog.setMessage(Messages.UMLModelingAssistantProviderMessage); + dialog.setTitle(Messages.UMLModelingAssistantProviderTitle); + if (dialog.open() == org.eclipse.jface.window.Window.OK) { + Object[] result = dialog.getResult(); + if (result != null && result.length > 0 && result[0] instanceof Constraint) { + return (Constraint) result[0]; + } + } + return null; + } + +} diff --git a/org.polarsys.chess.contracts.contractEditor/.svn/wc.db b/org.polarsys.chess.contracts.contractEditor/.svn/wc.db new file mode 100644 index 0000000000000000000000000000000000000000..7c79b31486885572419033d308130f25fcb55e13 Binary files /dev/null and b/org.polarsys.chess.contracts.contractEditor/.svn/wc.db differ diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/entries b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/entries new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/entries @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/format b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/format new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/format @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/01/01ab9fd085adb4aa6e6cddf9061185997a361249.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/01/01ab9fd085adb4aa6e6cddf9061185997a361249.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..13ce11b1490b0691db9fc3b2a7a2a2055a5cf965 Binary files /dev/null and b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/01/01ab9fd085adb4aa6e6cddf9061185997a361249.svn-base differ diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/0a/0a82249cac8243537996a9a634978c6154e6d440.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/0a/0a82249cac8243537996a9a634978c6154e6d440.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..f6aa93afca699efffa9f1a1eb014336d6948f6ec --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/0a/0a82249cac8243537996a9a634978c6154e6d440.svn-base @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.treeElements; + +import java.util.List; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ComponentNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ContractNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ITreeNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.TreeNode; + +public class CHESSComponentNode extends ComponentNode { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public CHESSComponentNode(ITreeNode parent, Object associatedObject) { + super(parent, associatedObject); + } + + @Override + public void createChildren(Object associatedObject, List<TreeNode> children) { + for (Property umlProperty : ((Class) entityUtil.getUmlType((Property) associatedObject)).getAttributes()) { + if (contractEntityUtil.isContractProperty(umlProperty)) { + children.add(new ContractNode(this, entityUtil.getUmlType(umlProperty).getName())); + } else if (entityUtil.isComponentInstance(umlProperty)) { + children.add(new CHESSComponentNode(this, umlProperty)); + } + } + + } + + @Override + public String getName(Object associatedObject) { + String typeName = entityUtil.getUmlType((Property) associatedObject).getName(); + String propertyName = ((Property) associatedObject).getName(); + return propertyName + ":" + typeName; + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/0d/0d0cfbf78c180409845c386b0741a918c4683253.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/0d/0d0cfbf78c180409845c386b0741a918c4683253.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..e7fd9156d56cfaf0b12ade1c0d03f0d7b053f8f0 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/0d/0d0cfbf78c180409845c386b0741a918c4683253.svn-base @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.treeElements; + +import java.util.List; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ContractNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.SystemNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.TreeNode; + +public class CHESSSystemNode extends SystemNode { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public CHESSSystemNode(Object system) { + super(system); + } + + @Override + public String getName(Object system) { + return entityUtil.getName((Class) system); + } + + @Override + public void createChildren(Object system, List<TreeNode> children) { + for (Property umlProperty : ((Class) system).getAttributes()) { + + if (contractEntityUtil.isContractProperty(umlProperty)) { + children.add(new ContractNode(this, entityUtil.getUmlType(umlProperty).getName())); + } else if (entityUtil.isComponentInstance(umlProperty)) { + children.add(new CHESSComponentNode(this, umlProperty)); + } + } + + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/1b/1b6de9af97137f312a53210fba75ea9cf976f8a6.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/1b/1b6de9af97137f312a53210fba75ea9cf976f8a6.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..a97c45f365420d0d2670faaa393fe3f8767b0daf --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/1b/1b6de9af97137f312a53210fba75ea9cf976f8a6.svn-base @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.hierarchicalContractView.treeElements.CHESSRootNode; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.RootNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.view.HierarchicalView; + +public class CustomHierarchicalView extends HierarchicalView { + + public static String View_ID = "org.polarsys.chess.contracts.hierarchicalContractView.view1"; + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public RootNode getSystemObjects() { + Platform.getBundle(" "); + UmlModel umlModel = UmlUtils.getUmlModel(); + ArrayList<Object> systems = null; + if (umlModel != null) { + systems = new ArrayList<Object>(); + TreeIterator<EObject> allElements = umlModel.getResource().getAllContents(); + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> classes = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); + + for (Class c : classes) { + if (entityUtil.isSystem(c)) { + systems.add(c); + } + } + + return new CHESSRootNode(systems); + + } + } + return null; + } + + + private <T> Collection<T> iterator2Collection(final Iterator<T> iter) { + ArrayList<T> list = new ArrayList<T>(); + for (; iter.hasNext();) { + T item = iter.next(); + list.add(item); + } + return list; + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/2d/2d783db107d2284118e825be555399feac014c0c.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/2d/2d783db107d2284118e825be555399feac014c0c.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..9b59898d6ff4e8a92b71f8d34f0108d88601db33 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/2d/2d783db107d2284118e825be555399feac014c0c.svn-base @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.contracts.hierarchicalContractView +Bundle-SymbolicName: org.polarsys.chess.contracts.hierarchicalContractView;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.polarsys.chess.core, + eu.fbk.eclipse.standardtools.hierarchicalContractView.core, + org.eclipse.papyrus.uml.tools, + org.polarsys.chess.utils +Bundle-ActivationPolicy: lazy +Import-Package: com.google.common.collect;version="10.0.1", + org.eclipse.emf.common.util, + org.eclipse.emf.ecore.resource, + org.eclipse.jface.text, + org.eclipse.jface.text.source, + org.eclipse.papyrus.sysml.blocks, + org.eclipse.papyrus.sysml.diagram.common.edit.part, + org.eclipse.papyrus.uml.diagram.clazz.edit.parts, + org.eclipse.papyrus.uml.diagram.common.editparts, + org.eclipse.ui.part, + org.eclipse.uml2.uml.resources.util +Bundle-Vendor: Fondazione Bruno Kessler diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/3d/3dacdbc2f22793e92e810dea0db2ab3fc75f9cf8.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/3d/3dacdbc2f22793e92e810dea0db2ab3fc75f9cf8.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..75f022696367436c93e89470fa05e28205c38609 Binary files /dev/null and b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/3d/3dacdbc2f22793e92e810dea0db2ab3fc75f9cf8.svn-base differ diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..295926d964165896ea8aa7c1b1b3c9d3d3caa77e --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base @@ -0,0 +1,7 @@ +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 diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/76/76a598fef1badbee7ff487ea4f24c74c7bacccd6.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/76/76a598fef1badbee7ff487ea4f24c74c7bacccd6.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..c3bffa8865fbdd47d559a5810fdeacbe3bb0e77a --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/76/76a598fef1badbee7ff487ea4f24c74c7bacccd6.svn-base @@ -0,0 +1,80 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.listener; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.ui.ISelectionService; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.polarsys.chess.contracts.hierarchicalContractView.view.CustomHierarchicalView; +import org.polarsys.chess.core.resourcelistener.SelectionListenerExtra; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.view.HierarchicalView; + +public class SelectionListener extends SelectionListenerExtra { + + private UmlModel prevModelID; + + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + if (selection instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IAdaptable) { + IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class); + if (resource != null) { + + UmlModel modelID = UmlUtils.getUmlModel(); + + if (modelID != prevModelID) { + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IViewPart modelExplorerViewPart; + + modelExplorerViewPart = window.getActivePage().findView(CustomHierarchicalView.View_ID); + if (modelExplorerViewPart != null) { + HierarchicalView view = (HierarchicalView) modelExplorerViewPart; + view.updateView(); + prevModelID = modelID; + } + } + } + } + } + + } + + public static IProject getCurrentSelectedProject() { + IProject project = null; + ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); + + ISelection selection = selectionService.getSelection(); + + if (selection instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) selection).getFirstElement(); + + IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class); + if (resource != null) { + project = resource.getProject(); + } + } + return project; + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/7b/7bb731e1f72d4935225aa2a066919f3d6d51715f.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/7b/7bb731e1f72d4935225aa2a066919f3d6d51715f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..08b1f5bdec6e9b662298f9300c714a453fed3689 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/7b/7bb731e1f72d4935225aa2a066919f3d6d51715f.svn-base @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.polarsys.chess.contracts.hierarchicalContractView</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> diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/7d/7d528da0acd9334fc6aaca8460f63315934c4de4.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/7d/7d528da0acd9334fc6aaca8460f63315934c4de4.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..2f927d118da5aea9b2b1cce50e7ae1ba5b5fa530 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/7d/7d528da0acd9334fc6aaca8460f63315934c4de4.svn-base @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.views"> + <view + category="org.eclipse.papyrus.views.category" + class="org.polarsys.chess.contracts.hierarchicalContractView.view.CustomHierarchicalView" + icon="icons/site_element.gif" + id="org.polarsys.chess.contracts.hierarchicalContractView.view1" + name="Hierarchical Model View" + restorable="true"> + </view> + </extension> + <extension + point="org.eclipse.papyrus.infra.core.modelListener"> + <listener + name="org.polarsys.chess.contracts.hierarchicalContractView.listener" + realization="org.polarsys.chess.contracts.hierarchicalContractView.listener.PapyrusListener"> + </listener> + </extension> + <!-- <extension + point="org.polarsys.chess.selectionListener"> + <listener + name="eu.fbk.contracts.hierarchicalContractView.listener1" + realization="eu.fbk.contracts.hierarchicalcontractview.listener.SelectionListener"> + </listener> + </extension> --> + +</plugin> diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b862a296d38fe04269faeee6c9d77d11ff77380d --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base @@ -0,0 +1,7 @@ +<?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> diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/85/85626f0b1429896ca7fce0cf76a3e087ece43e67.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/85/85626f0b1429896ca7fce0cf76a3e087ece43e67.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..164f8b8902d394c958641a15d12d948edbbf3aaa --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/85/85626f0b1429896ca7fce0cf76a3e087ece43e67.svn-base @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.treeElements; + +import java.util.List; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ContractNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.SystemNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.TreeNode; + +public class CHESSSystemNode extends SystemNode { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public CHESSSystemNode(Object system) { + super(system); + } + + @Override + public String getName(Object system) { + return entityUtil.getName((Class) system); + } + + @Override + public void createChildren(Object system, List<TreeNode> children) { + for (Property umlProperty : ((Class) system).getAttributes()) { + + if (contractEntityUtil.isContractProperty(umlProperty)) { + children.add(new ContractNode(this, entityUtil.getUmlType(umlProperty).getName())); + } else if (entityUtil.isComponentInstance(umlProperty)) { + children.add(new CHESSComponentNode(this, umlProperty)); + } + } + + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/8a/8a37181c6ba18b2d21364eae045602ace2f25859.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/8a/8a37181c6ba18b2d21364eae045602ace2f25859.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..51d3a980b6a822ff56241ca686715efcf4270358 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/8a/8a37181c6ba18b2d21364eae045602ace2f25859.svn-base @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.treeElements; + +import java.util.ArrayList; +import java.util.List; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.RootNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.TreeNode; + +public class CHESSRootNode extends RootNode { + + public CHESSRootNode(ArrayList<Object> systems) { + super(systems); + } + + @Override + public void createChildren(ArrayList<Object> systems, List<TreeNode> children) { + for (Object s : systems) { + children.add(new CHESSSystemNode(s)); + } + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/93/93162c4d493374bf848f06a11085d0febf7e5082.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/93/93162c4d493374bf848f06a11085d0febf7e5082.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..2bc457cd0e6a0f144bc440712c5b25eee333e314 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/93/93162c4d493374bf848f06a11085d0febf7e5082.svn-base @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.hierarchicalContractView.treeElements.CHESSRootNode; +import org.polarsys.chess.core.util.uml.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.RootNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.view.HierarchicalView; + +public class CustomHierarchicalView extends HierarchicalView { + + public static String View_ID = "org.polarsys.chess.contracts.hierarchicalContractView.view1"; + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public RootNode getSystemObjects() { + Platform.getBundle(" "); + UmlModel umlModel = UmlUtils.getUmlModel(); + ArrayList<Object> systems = null; + if (umlModel != null) { + systems = new ArrayList<Object>(); + TreeIterator<EObject> allElements = umlModel.getResource().getAllContents(); + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> classes = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); + + for (Class c : classes) { + if (entityUtil.isSystem(c)) { + systems.add(c); + } + } + + return new CHESSRootNode(systems); + + } + } + return null; + } + + + private <T> Collection<T> iterator2Collection(final Iterator<T> iter) { + ArrayList<T> list = new ArrayList<T>(); + for (; iter.hasNext();) { + T item = iter.next(); + list.add(item); + } + return list; + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/b8/b84982b4662cb7fb3b466c098d0063a6b427493f.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/b8/b84982b4662cb7fb3b466c098d0063a6b427493f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..0193dbeab7c505ff1b994966119423d252e476d9 Binary files /dev/null and b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/b8/b84982b4662cb7fb3b466c098d0063a6b427493f.svn-base differ diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ba/ba4b606c0fc7e21542c6dcd0272fa546515ab5f1.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ba/ba4b606c0fc7e21542c6dcd0272fa546515ab5f1.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..01f14929be0554b3933ed424d3f270b45de5cab7 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ba/ba4b606c0fc7e21542c6dcd0272fa546515ab5f1.svn-base @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.treeElements; + +import java.util.List; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.core.util.uml.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ComponentNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ContractNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ITreeNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.TreeNode; + +public class CHESSComponentNode extends ComponentNode { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public CHESSComponentNode(ITreeNode parent, Object associatedObject) { + super(parent, associatedObject); + } + + @Override + public void createChildren(Object associatedObject, List<TreeNode> children) { + for (Property umlProperty : ((Class) entityUtil.getUmlType((Property) associatedObject)).getAttributes()) { + if (contractEntityUtil.isContractProperty(umlProperty)) { + children.add(new ContractNode(this, entityUtil.getUmlType(umlProperty).getName())); + } else if (entityUtil.isComponentInstance(umlProperty)) { + children.add(new CHESSComponentNode(this, umlProperty)); + } + } + + } + + @Override + public String getName(Object associatedObject) { + String typeName = entityUtil.getUmlType((Property) associatedObject).getName(); + String propertyName = ((Property) associatedObject).getName(); + return propertyName + ":" + typeName; + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..285b8bf47b6f777dcb23e9b8224db2b68f70e9b6 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/ diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/c4/c443e0ca319ea279262bffebf0f49f1a15d6186c.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/c4/c443e0ca319ea279262bffebf0f49f1a15d6186c.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..794b349d0785a91869e6f2c6ffc1c67d46a617a9 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/c4/c443e0ca319ea279262bffebf0f49f1a15d6186c.svn-base @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.hierarchicalContractView.treeElements.CHESSRootNode; +import org.polarsys.chess.utils.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.RootNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.view.HierarchicalView; + +public class CustomHierarchicalView extends HierarchicalView { + + public static String View_ID = "org.polarsys.chess.contracts.hierarchicalContractView.view1"; + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public RootNode getSystemObjects() { + Platform.getBundle(" "); + UmlModel umlModel = UmlUtils.getUmlModel(); + ArrayList<Object> systems = null; + if (umlModel != null) { + systems = new ArrayList<Object>(); + TreeIterator<EObject> allElements = umlModel.getResource().getAllContents(); + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> classes = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); + + for (Class c : classes) { + if (entityUtil.isSystem(c)) { + systems.add(c); + } + } + + return new CHESSRootNode(systems); + + } + } + return null; + } + + + private <T> Collection<T> iterator2Collection(final Iterator<T> iter) { + ArrayList<T> list = new ArrayList<T>(); + for (; iter.hasNext();) { + T item = iter.next(); + list.add(item); + } + return list; + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/c7/c7d0f79a6181435b8baa61a3ad4d0e6ef3a62df0.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/c7/c7d0f79a6181435b8baa61a3ad4d0e6ef3a62df0.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..696aec546011ba456c81efdfa064b5c8bd13b66c --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/c7/c7d0f79a6181435b8baa61a3ad4d0e6ef3a62df0.svn-base @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.treeElements; + +import java.util.List; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ComponentNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ContractNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ITreeNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.TreeNode; + +public class CHESSComponentNode extends ComponentNode { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public CHESSComponentNode(ITreeNode parent, Object associatedObject) { + super(parent, associatedObject); + } + + @Override + public void createChildren(Object associatedObject, List<TreeNode> children) { + for (Property umlProperty : ((Class) entityUtil.getUmlType((Property) associatedObject)).getAttributes()) { + if (contractEntityUtil.isContractProperty(umlProperty)) { + children.add(new ContractNode(this, entityUtil.getUmlType(umlProperty).getName())); + } else if (entityUtil.isComponentInstance(umlProperty)) { + children.add(new CHESSComponentNode(this, umlProperty)); + } + } + + } + + @Override + public String getName(Object associatedObject) { + String typeName = entityUtil.getUmlType((Property) associatedObject).getName(); + String propertyName = ((Property) associatedObject).getName(); + return propertyName + ":" + typeName; + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ae3c1726048cd06b9a143e0376ed46dd9b9a8d53 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base @@ -0,0 +1 @@ +/bin/ diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/d2/d216665cffdfc798b57c528a92ec9c7e31fe87d5.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/d2/d216665cffdfc798b57c528a92ec9c7e31fe87d5.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d98c668e72f332f83430e5f72a15df4c4803d048 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/d2/d216665cffdfc798b57c528a92ec9c7e31fe87d5.svn-base @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.treeElements; + +import java.util.List; + +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Property; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.core.util.uml.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.ContractNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.SystemNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.TreeNode; + +public class CHESSSystemNode extends SystemNode { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public CHESSSystemNode(Object system) { + super(system); + } + + @Override + public String getName(Object system) { + return entityUtil.getName((Class) system); + } + + @Override + public void createChildren(Object system, List<TreeNode> children) { + for (Property umlProperty : ((Class) system).getAttributes()) { + + if (contractEntityUtil.isContractProperty(umlProperty)) { + children.add(new ContractNode(this, entityUtil.getUmlType(umlProperty).getName())); + } else if (entityUtil.isComponentInstance(umlProperty)) { + children.add(new CHESSComponentNode(this, umlProperty)); + } + } + + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/e1/e1eef673158c7f08ab343019633506cd4c44297c.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/e1/e1eef673158c7f08ab343019633506cd4c44297c.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d6bfe0bf0a3bb069376a0e0f859682ca062584d7 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/e1/e1eef673158c7f08ab343019633506cd4c44297c.svn-base @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.hierarchicalContractView.treeElements.CHESSRootNode; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.treeElements.RootNode; +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.view.HierarchicalView; + +public class CustomHierarchicalView extends HierarchicalView { + + public static String View_ID = "org.polarsys.chess.contracts.hierarchicalContractView.view1"; + private EntityUtil entityUtil = EntityUtil.getInstance(); + + public RootNode getSystemObjects() { + Platform.getBundle(" "); + UmlModel umlModel = UmlUtils.getUmlModel(); + ArrayList<Object> systems = null; + if (umlModel != null) { + systems = new ArrayList<Object>(); + TreeIterator<EObject> allElements = umlModel.getResource().getAllContents(); + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> classes = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); + + for (Class c : classes) { + if (entityUtil.isSystem(c)) { + systems.add(c); + } + } + + if(systems.size()>0){ + return new CHESSRootNode(systems); + } + } + } + return null; + } + + + private <T> Collection<T> iterator2Collection(final Iterator<T> iter) { + ArrayList<T> list = new ArrayList<T>(); + for (; iter.hasNext();) { + T item = iter.next(); + list.add(item); + } + return list; + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/f8/f89221dd03d0eba9db9303e9b2768678ed4abaaa.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/f8/f89221dd03d0eba9db9303e9b2768678ed4abaaa.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..e02c2304d1b4131355868213d7749bf0ca8a651c --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/f8/f89221dd03d0eba9db9303e9b2768678ed4abaaa.svn-base @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.contracts.hierarchicalContractView.listener; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.uml2.uml.Element; +import org.polarsys.chess.contracts.hierarchicalContractView.view.CustomHierarchicalView; + +import eu.fbk.eclipse.standardtools.hierarchicalContractView.core.view.HierarchicalView; + +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +public class PapyrusListener implements IPapyrusListener { + + private UmlModel prevModelID; + + public PapyrusListener() { + } + + @Override + public void notifyChanged(Notification notification) { + + Object notifier = notification.getNotifier(); + + if (notifier instanceof Element) { + + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IViewPart modelExplorerViewPart; + + modelExplorerViewPart = window.getActivePage().findView(CustomHierarchicalView.View_ID); + if (modelExplorerViewPart != null) { + + UmlModel modelID = UmlUtils.getUmlModel(); + + if (modelID != prevModelID) { + HierarchicalView view = (HierarchicalView) modelExplorerViewPart; + view.updateView(); + prevModelID = modelID; + } + } + } + } + +} diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ff/ffd2bf2b6024f1374124340adc5838212ec67be6.svn-base b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ff/ffd2bf2b6024f1374124340adc5838212ec67be6.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..aa51f03c99e306cea01150f37a1761e635f84b62 --- /dev/null +++ b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/pristine/ff/ffd2bf2b6024f1374124340adc5838212ec67be6.svn-base @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.contracts.hierarchicalContractView +Bundle-SymbolicName: org.polarsys.chess.contracts.hierarchicalContractView;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.polarsys.chess.core, + eu.fbk.eclipse.standardtools.hierarchicalContractView.core, + org.eclipse.papyrus.uml.tools, + org.polarsys.chess.contracts.profile +Bundle-ActivationPolicy: lazy +Import-Package: com.google.common.collect;version="10.0.1", + org.eclipse.emf.common.util, + org.eclipse.emf.ecore.resource, + org.eclipse.jface.text, + org.eclipse.jface.text.source, + org.eclipse.papyrus.sysml.blocks, + org.eclipse.papyrus.sysml.diagram.common.edit.part, + org.eclipse.papyrus.uml.diagram.clazz.edit.parts, + org.eclipse.papyrus.uml.diagram.common.editparts, + org.eclipse.ui.part, + org.eclipse.uml2.uml.resources.util +Bundle-Vendor: Fondazione Bruno Kessler diff --git a/org.polarsys.chess.contracts.hierarchicalContractView/.svn/wc.db b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/wc.db new file mode 100644 index 0000000000000000000000000000000000000000..b8c711ae5eb0a921e9d6d0de7fb3177fbbae6c18 Binary files /dev/null and b/org.polarsys.chess.contracts.hierarchicalContractView/.svn/wc.db differ diff --git a/org.polarsys.chess.contracts.refinementView/.svn/entries b/org.polarsys.chess.contracts.refinementView/.svn/entries new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/entries @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.refinementView/.svn/format b/org.polarsys.chess.contracts.refinementView/.svn/format new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/format @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/01/01ab9fd085adb4aa6e6cddf9061185997a361249.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/01/01ab9fd085adb4aa6e6cddf9061185997a361249.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..13ce11b1490b0691db9fc3b2a7a2a2055a5cf965 Binary files /dev/null and b/org.polarsys.chess.contracts.refinementView/.svn/pristine/01/01ab9fd085adb4aa6e6cddf9061185997a361249.svn-base differ diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/1d/1d79d0d7a2ce490dc663585afefd58091f4f295d.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/1d/1d79d0d7a2ce490dc663585afefd58091f4f295d.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..f79c3e2be24576061fc2c221d84f21e682126427 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/1d/1d79d0d7a2ce490dc663585afefd58091f4f295d.svn-base @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.views"> + <view + category="org.eclipse.papyrus.views.category" + class="org.polarsys.chess.contracts.refinementView.view.CustomRefinementView" + icon="icons/main_tab.gif" + id="org.polarsys.chess.contracts.refinementView.view1" + name="Contract Refinement View" + restorable="true"> + </view> + </extension> + <extension + point="org.eclipse.papyrus.infra.core.modelListener"> + <listener + name="org.polarsys.chess.contracts.refinementView.listener" + realization="org.polarsys.chess.contracts.refinementView.listener.PapyrusListener"> + </listener> + </extension> + +</plugin> diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/3d/3dacdbc2f22793e92e810dea0db2ab3fc75f9cf8.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/3d/3dacdbc2f22793e92e810dea0db2ab3fc75f9cf8.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..75f022696367436c93e89470fa05e28205c38609 Binary files /dev/null and b/org.polarsys.chess.contracts.refinementView/.svn/pristine/3d/3dacdbc2f22793e92e810dea0db2ab3fc75f9cf8.svn-base differ diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/46/46b146336a3939e852a53616459fc8c53bbe6f23.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/46/46b146336a3939e852a53616459fc8c53bbe6f23.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..f3fa24a9ee4f2bccd99722471103ad081e115129 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/46/46b146336a3939e852a53616459fc8c53bbe6f23.svn-base @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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.contracts.refinementView.listener; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.uml2.uml.Element; +import org.polarsys.chess.contracts.refinementView.view.CustomRefinementView; + +public class PapyrusListener implements IPapyrusListener { + + public PapyrusListener() { + } + + @Override + public void notifyChanged(Notification notification) { + + Object notifier = notification.getNotifier(); + + if (notifier instanceof Element) { + + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IViewPart modelExplorerViewPart; + + modelExplorerViewPart = window.getActivePage().findView(CustomRefinementView.View_ID); + + if (modelExplorerViewPart != null) { + CustomRefinementView view = (CustomRefinementView) modelExplorerViewPart; + view.updateView(); + } + } + + } + +} diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..295926d964165896ea8aa7c1b1b3c9d3d3caa77e --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base @@ -0,0 +1,7 @@ +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 diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/5b/5b541edd20713a366801ec4d78fa00337838af07.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/5b/5b541edd20713a366801ec4d78fa00337838af07.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..65c75f88c06c0d97537fc803e4447a777c9ba1d7 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/5b/5b541edd20713a366801ec4d78fa00337838af07.svn-base @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.contracts.refinementView.treeElements; + +import java.util.List; + +import org.polarsys.chess.contracts.profile.chesscontract.ContractProperty; +import org.polarsys.chess.contracts.profile.chesscontract.ContractRefinement; +import org.polarsys.chess.contracts.profile.chesscontract.DataTypes.ContractTypes; + +import eu.fbk.contracts.refinementview.treeElements.ContractNode; +import eu.fbk.contracts.refinementview.treeElements.ITreeNode; +import eu.fbk.contracts.refinementview.treeElements.TreeNode; + +public class CHESSContractNode extends ContractNode { + + public CHESSContractNode(Object contractProperty, String compInstance) { + super(contractProperty, compInstance); + } + + public CHESSContractNode(ITreeNode parent, Object contractProperty, String compInstance) { + super(parent, contractProperty, compInstance); + } + + @Override + public String getName(Object contractProperty, String compInstance) { + String contrName = ((ContractProperty) contractProperty).getBase_Property().getName(); + return compInstance + "." + contrName; + } + + @Override + public void createChilden(Object contractProperty, String compInstance, List<TreeNode> children) { + for (ContractRefinement cr : ((ContractProperty) contractProperty).getRefinedBy()) { + + ContractProperty cp = cr.getContract(); + if (true) { + if (cr.getInstance() != null) { + String compoInstance = cr.getInstance().getName(); + children.add(new CHESSContractNode(this, cp, compoInstance)); + } + } + } + + } + + @Override + public boolean isWeak(Object contractProperty) { + return !((ContractProperty) contractProperty).getContractType().equals(ContractTypes.STRONG); + } + +} diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/6a/6a625956398830f3d477ab9fca3bc5d685600747.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/6a/6a625956398830f3d477ab9fca3bc5d685600747.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..bf56aa2e5cd343a261c3a813884ebe24a54646ac --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/6a/6a625956398830f3d477ab9fca3bc5d685600747.svn-base @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.contracts.refinementView +Bundle-SymbolicName: org.polarsys.chess.contracts.refinementView;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.papyrus.infra.core, + org.eclipse.ui.workbench, + org.eclipse.jface, + eu.fbk.eclipse.standardtools.refinementView.core, + org.eclipse.papyrus.uml.tools, + org.polarsys.chess.contracts.profile;bundle-version="0.9.0", + org.polarsys.chess.core;bundle-version="0.9.0", + org.polarsys.chess.utils +Bundle-Vendor: Fondazione Bruno Kessler diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b862a296d38fe04269faeee6c9d77d11ff77380d --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base @@ -0,0 +1,7 @@ +<?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> diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/8f/8f65f89d3cc165733f7cfd5d4c455e8b5a7256fa.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/8f/8f65f89d3cc165733f7cfd5d4c455e8b5a7256fa.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..2277718094c4f30e0d8d38a1690878a73e475ac5 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/8f/8f65f89d3cc165733f7cfd5d4c455e8b5a7256fa.svn-base @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.contracts.refinementView.treeElements; + +import java.util.List; + +import org.polarsys.chess.contracts.profile.chesscontract.ContractProperty; + +import eu.fbk.contracts.refinementview.treeElements.ITreeNode; +import eu.fbk.contracts.refinementview.treeElements.RootNode; +import eu.fbk.contracts.refinementview.treeElements.TreeNode; + +public class CHESSRootNode extends RootNode { + + public CHESSRootNode(ITreeNode parent, List<Object> allContracts, List<String> contractsUsedForRefinement, + List<String> compInstances) { + super(parent, allContracts, contractsUsedForRefinement, compInstances); + } + + public CHESSRootNode(List<Object> allContracts, List<String> contractsUsedForRefinement, + List<String> compInstances) { + super(allContracts, contractsUsedForRefinement, compInstances); + } + + @Override + public void createChildren(List<Object> allContracts, List<String> contractsUsedForRefinement, + List<String> compInstances, List<TreeNode> children) { + for (int i = 0; i < allContracts.size(); i++) { + ContractProperty p = (ContractProperty) allContracts.get(i); + String compInstance = compInstances.get(i); + if (!isUsedForRefinememt(p, contractsUsedForRefinement, compInstance)) { + children.add(new CHESSContractNode(p, compInstance)); + } + } + + } + + private boolean isUsedForRefinememt(ContractProperty p, List<String> contractsUsedForRefinement, + String compInstance) { + String contrRef = compInstance + "." + p.getBase_Property().getName(); + return contractsUsedForRefinement.contains(contrRef); + } +} diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/a2/a215d7c8e5c2735d88c24d480204048b155241d4.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/a2/a215d7c8e5c2735d88c24d480204048b155241d4.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..230b792113eaf54cf2112a0ed12b44aa25c06ead --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/a2/a215d7c8e5c2735d88c24d480204048b155241d4.svn-base @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.contracts.refinementView.listener; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.polarsys.chess.contracts.refinementView.view.CustomRefinementView; +import org.polarsys.chess.core.resourcelistener.SelectionListenerExtra; + +public class SelectionListener extends SelectionListenerExtra { + + private IProject prevProject; + + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + + if (selection instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IAdaptable) { + IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class); + if (resource != null) { + final IProject project = resource.getProject(); + if (project != prevProject) { + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IViewPart modelExplorerViewPart; + + modelExplorerViewPart = window.getActivePage().findView(CustomRefinementView.View_ID); + if (modelExplorerViewPart != null) { + CustomRefinementView view = (CustomRefinementView) modelExplorerViewPart; + view.updateView(); + prevProject = project; + } + } + } + } + } + + } + +} diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/a4/a48f4a824ef9067dd4ea9f5ed38be7cca9142154.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/a4/a48f4a824ef9067dd4ea9f5ed38be7cca9142154.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..55b9a800229c37b44bbfee706cec78a216edd763 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/a4/a48f4a824ef9067dd4ea9f5ed38be7cca9142154.svn-base @@ -0,0 +1,137 @@ +/******************************************************************************* + * 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.contracts.refinementView.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.ContractProperty; +import org.polarsys.chess.contracts.profile.chesscontract.ContractRefinement; +import org.polarsys.chess.contracts.refinementView.treeElements.CHESSRootNode; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.EntityUtil; + +import eu.fbk.contracts.refinementview.treeElements.RootNode; +import eu.fbk.contracts.refinementview.view.RefinementView; + +public class CustomRefinementView extends RefinementView { + public static String View_ID = "org.polarsys.chess.contracts.refinementView.view1"; + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public RootNode getModelObjects(ArrayList<Object> allContracts, ArrayList<String> componentInstances, + ArrayList<String> contractsUsedForRefinement) { + UmlModel umlModel = UmlUtils.getUmlModel(); + + if (umlModel != null) { + + TreeIterator<EObject> allElements = umlModel.getResource().getAllContents(); + + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> umlClasses = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); + + for (Class umlClass : umlClasses) { + + if (entityUtil.isSystem(umlClass)) { + + for (Property ummlProperty : umlClass.getAttributes()) { + + if (contractEntityUtil.isContractProperty(ummlProperty)) { + ContractProperty contractProperty = contractEntityUtil + .getContractProperty(ummlProperty); + // if + // (cp.getContractType().equals(ContractTypes.STRONG)){ + if (true) { + allContracts.add(contractProperty); + componentInstances.add(umlClass.getName()); + } + for (ContractRefinement refinedContr : contractProperty.getRefinedBy()) { + String contractName = refinedContr.getBase_DataType().getName(); + if (!contractsUsedForRefinement.contains(contractName)) { + contractsUsedForRefinement.add(contractName); + } + } + } + } + + } + + for (Property part : umlClass.getParts()) { + if (!(part instanceof Port)) { + Class partUmlClass = (Class) part.getType(); + if (partUmlClass != null) { + for (Property umlProperty : partUmlClass.getAttributes()) { + + if (contractEntityUtil.isContractProperty(umlProperty)) { + ContractProperty contractProperty = contractEntityUtil + .getContractProperty(umlProperty); + // if + // (cp.getContractType().equals(ContractTypes.STRONG)){ + if (true) { + allContracts.add(contractProperty); + componentInstances.add(part.getName()); + } + for (ContractRefinement refinedContr : contractProperty.getRefinedBy()) { + String contractName = refinedContr.getBase_DataType().getName(); + if (!contractsUsedForRefinement.contains(contractName)) { + contractsUsedForRefinement.add(contractName); + } + } + } + } + } + } + } + + } + + } + } + + if (allContracts.size() > 0) { + return new CHESSRootNode(allContracts, contractsUsedForRefinement, componentInstances); + } + return null; + } + + @Override + public void createPartControl(Composite parent) { + super.createPartControl(parent); + } + + @Override + public void setFocus() { + super.setFocus(); + } + + private <T> Collection<T> iterator2Collection(final Iterator<T> iter) { + ArrayList<T> list = new ArrayList<T>(); + for (; iter.hasNext();) { + T item = iter.next(); + list.add(item); + } + return list; + } + +} diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/b8/b84982b4662cb7fb3b466c098d0063a6b427493f.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/b8/b84982b4662cb7fb3b466c098d0063a6b427493f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..0193dbeab7c505ff1b994966119423d252e476d9 Binary files /dev/null and b/org.polarsys.chess.contracts.refinementView/.svn/pristine/b8/b84982b4662cb7fb3b466c098d0063a6b427493f.svn-base differ diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..285b8bf47b6f777dcb23e9b8224db2b68f70e9b6 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/bd/bdecd7617e14c1d9592848da5b048389a4da78ee.svn-base @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/ diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/bf/bfbd1a7fc488a8635f9d02e9d5c7e8dd81eec63e.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/bf/bfbd1a7fc488a8635f9d02e9d5c7e8dd81eec63e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..c62f08bd4a98d14373063d03b86c77943a03c013 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/bf/bfbd1a7fc488a8635f9d02e9d5c7e8dd81eec63e.svn-base @@ -0,0 +1,137 @@ +/******************************************************************************* + * 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.contracts.refinementView.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.ContractProperty; +import org.polarsys.chess.contracts.profile.chesscontract.ContractRefinement; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; +import org.polarsys.chess.contracts.refinementView.treeElements.CHESSRootNode; + +import eu.fbk.contracts.refinementview.treeElements.RootNode; +import eu.fbk.contracts.refinementview.view.RefinementView; + +public class CustomRefinementView extends RefinementView { + public static String View_ID = "org.polarsys.chess.contracts.refinementView.view1"; + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public RootNode getModelObjects(ArrayList<Object> allContracts, ArrayList<String> componentInstances, + ArrayList<String> contractsUsedForRefinement) { + UmlModel umlModel = UmlUtils.getUmlModel(); + + if (umlModel != null) { + + TreeIterator<EObject> allElements = umlModel.getResource().getAllContents(); + + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> umlClasses = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); + + for (Class umlClass : umlClasses) { + + if (entityUtil.isSystem(umlClass)) { + + for (Property ummlProperty : umlClass.getAttributes()) { + + if (contractEntityUtil.isContractProperty(ummlProperty)) { + ContractProperty contractProperty = contractEntityUtil + .getContractProperty(ummlProperty); + // if + // (cp.getContractType().equals(ContractTypes.STRONG)){ + if (true) { + allContracts.add(contractProperty); + componentInstances.add(umlClass.getName()); + } + for (ContractRefinement refinedContr : contractProperty.getRefinedBy()) { + String contractName = refinedContr.getBase_DataType().getName(); + if (!contractsUsedForRefinement.contains(contractName)) { + contractsUsedForRefinement.add(contractName); + } + } + } + } + + } + + for (Property part : umlClass.getParts()) { + if (!(part instanceof Port)) { + Class partUmlClass = (Class) part.getType(); + if (partUmlClass != null) { + for (Property umlProperty : partUmlClass.getAttributes()) { + + if (contractEntityUtil.isContractProperty(umlProperty)) { + ContractProperty contractProperty = contractEntityUtil + .getContractProperty(umlProperty); + // if + // (cp.getContractType().equals(ContractTypes.STRONG)){ + if (true) { + allContracts.add(contractProperty); + componentInstances.add(part.getName()); + } + for (ContractRefinement refinedContr : contractProperty.getRefinedBy()) { + String contractName = refinedContr.getBase_DataType().getName(); + if (!contractsUsedForRefinement.contains(contractName)) { + contractsUsedForRefinement.add(contractName); + } + } + } + } + } + } + } + + } + + } + } + + if (allContracts.size() > 0) { + return new CHESSRootNode(allContracts, contractsUsedForRefinement, componentInstances); + } + return null; + } + + @Override + public void createPartControl(Composite parent) { + super.createPartControl(parent); + } + + @Override + public void setFocus() { + super.setFocus(); + } + + private <T> Collection<T> iterator2Collection(final Iterator<T> iter) { + ArrayList<T> list = new ArrayList<T>(); + for (; iter.hasNext();) { + T item = iter.next(); + list.add(item); + } + return list; + } + +} diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ae3c1726048cd06b9a143e0376ed46dd9b9a8d53 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base @@ -0,0 +1 @@ +/bin/ diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/d3/d34d74fa4e91af8bbb6205a382bc2609c4df5d63.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/d3/d34d74fa4e91af8bbb6205a382bc2609c4df5d63.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..1ca66323c989aa61c794a5fa7ba5ec2970824c01 Binary files /dev/null and b/org.polarsys.chess.contracts.refinementView/.svn/pristine/d3/d34d74fa4e91af8bbb6205a382bc2609c4df5d63.svn-base differ diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/ed/edaf18f520a05f416239ba3637e56782ef64c388.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/ed/edaf18f520a05f416239ba3637e56782ef64c388.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b3e03654ccf21ddde5b2e523d01fc0fc585fe172 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/ed/edaf18f520a05f416239ba3637e56782ef64c388.svn-base @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.contracts.refinementView +Bundle-SymbolicName: org.polarsys.chess.contracts.refinementView;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.papyrus.infra.core, + org.eclipse.ui.workbench, + org.eclipse.jface, + eu.fbk.eclipse.standardtools.refinementView.core, + org.eclipse.papyrus.uml.tools, + org.polarsys.chess.contracts.profile;bundle-version="0.9.0", + org.polarsys.chess.core;bundle-version="0.9.0" +Bundle-Vendor: Fondazione Bruno Kessler diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/ef/efd91704793a843228c38c35b1d04c80916e004f.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/ef/efd91704793a843228c38c35b1d04c80916e004f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..2cdb60a09bb52c7ee2c4220c5addfedd14c2ba94 --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/ef/efd91704793a843228c38c35b1d04c80916e004f.svn-base @@ -0,0 +1,137 @@ +/******************************************************************************* + * 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.contracts.refinementView.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; +import org.polarsys.chess.contracts.profile.chesscontract.ContractProperty; +import org.polarsys.chess.contracts.profile.chesscontract.ContractRefinement; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.refinementView.treeElements.CHESSRootNode; +import org.polarsys.chess.core.util.uml.EntityUtil; + +import eu.fbk.contracts.refinementview.treeElements.RootNode; +import eu.fbk.contracts.refinementview.view.RefinementView; + +public class CustomRefinementView extends RefinementView { + public static String View_ID = "org.polarsys.chess.contracts.refinementView.view1"; + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public RootNode getModelObjects(ArrayList<Object> allContracts, ArrayList<String> componentInstances, + ArrayList<String> contractsUsedForRefinement) { + UmlModel umlModel = UmlUtils.getUmlModel(); + + if (umlModel != null) { + + TreeIterator<EObject> allElements = umlModel.getResource().getAllContents(); + + if (allElements != null) { + Collection<org.eclipse.uml2.uml.Class> umlClasses = EcoreUtil + .getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getClass_()); + + for (Class umlClass : umlClasses) { + + if (entityUtil.isSystem(umlClass)) { + + for (Property ummlProperty : umlClass.getAttributes()) { + + if (contractEntityUtil.isContractProperty(ummlProperty)) { + ContractProperty contractProperty = contractEntityUtil + .getContractProperty(ummlProperty); + // if + // (cp.getContractType().equals(ContractTypes.STRONG)){ + if (true) { + allContracts.add(contractProperty); + componentInstances.add(umlClass.getName()); + } + for (ContractRefinement refinedContr : contractProperty.getRefinedBy()) { + String contractName = refinedContr.getBase_DataType().getName(); + if (!contractsUsedForRefinement.contains(contractName)) { + contractsUsedForRefinement.add(contractName); + } + } + } + } + + } + + for (Property part : umlClass.getParts()) { + if (!(part instanceof Port)) { + Class partUmlClass = (Class) part.getType(); + if (partUmlClass != null) { + for (Property umlProperty : partUmlClass.getAttributes()) { + + if (contractEntityUtil.isContractProperty(umlProperty)) { + ContractProperty contractProperty = contractEntityUtil + .getContractProperty(umlProperty); + // if + // (cp.getContractType().equals(ContractTypes.STRONG)){ + if (true) { + allContracts.add(contractProperty); + componentInstances.add(part.getName()); + } + for (ContractRefinement refinedContr : contractProperty.getRefinedBy()) { + String contractName = refinedContr.getBase_DataType().getName(); + if (!contractsUsedForRefinement.contains(contractName)) { + contractsUsedForRefinement.add(contractName); + } + } + } + } + } + } + } + + } + + } + } + + if (allContracts.size() > 0) { + return new CHESSRootNode(allContracts, contractsUsedForRefinement, componentInstances); + } + return null; + } + + @Override + public void createPartControl(Composite parent) { + super.createPartControl(parent); + } + + @Override + public void setFocus() { + super.setFocus(); + } + + private <T> Collection<T> iterator2Collection(final Iterator<T> iter) { + ArrayList<T> list = new ArrayList<T>(); + for (; iter.hasNext();) { + T item = iter.next(); + list.add(item); + } + return list; + } + +} diff --git a/org.polarsys.chess.contracts.refinementView/.svn/pristine/f8/f8a9adf7141c6f858132f01dd18fe7413bf2e12a.svn-base b/org.polarsys.chess.contracts.refinementView/.svn/pristine/f8/f8a9adf7141c6f858132f01dd18fe7413bf2e12a.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6f959d7f6552b64b8e790e6a6b659db2ffdf226b --- /dev/null +++ b/org.polarsys.chess.contracts.refinementView/.svn/pristine/f8/f8a9adf7141c6f858132f01dd18fe7413bf2e12a.svn-base @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.polarsys.chess.contracts.refinementView</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> diff --git a/org.polarsys.chess.contracts.refinementView/.svn/wc.db b/org.polarsys.chess.contracts.refinementView/.svn/wc.db new file mode 100644 index 0000000000000000000000000000000000000000..0dc2b6247c621dee3ea9007d2a91b2def7cbb9cd Binary files /dev/null and b/org.polarsys.chess.contracts.refinementView/.svn/wc.db differ diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/entries b/org.polarsys.chess.contracts.safetyAnalysis/.svn/entries new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/entries @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/format b/org.polarsys.chess.contracts.safetyAnalysis/.svn/format new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/format @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/11/1142404439b8b9db2780a419efef8b221aa4cb87.svn-base b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/11/1142404439b8b9db2780a419efef8b221aa4cb87.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..634e2ab943657d21b486dc45a6d205fb898cddff --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/11/1142404439b8b9db2780a419efef8b221aa4cb87.svn-base @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="false" + locationURI="menu:org.eclipse.ui.main.menu.AMASS?after=org.eclipse.ui.main.menu.AMASS.funcVer"> + <menu + label="Safety Analysis"> + <menu + label="//Debug Operations"> + <command + commandId="org.polarsys.chess.safetyAnalysis.commands.debug.ComputeContractFaultTreeOnFileCommand" + style="push"> + </command> + </menu> + <menu + label="Fault Tree Viewer"> + <command + commandId="eu.fbk.eclipse.standardtools.faultTreeViewer.commands.ShowFaultTreeFromXmlFileCommand" + style="push"> + </command> + </menu> + <command + commandId="org.polarsys.chess.safetyAnalysis.commands.ComputeContractFaultTreeCommand" + style="push"> + </command> + </menu> + </menuContribution> + <menuContribution + allPopups="false" + locationURI="popup:org.eclipse.ui.main.diagramEditorMenu.AMASS?after=org.eclipse.ui.main.diagramEditorMenu.AMASS.funcVer"> + <menu + label="Safety Analysis" + id="org.eclipse.ui.main.diagramEditorMenu.AMASS.safetyAnalysis"> + <menu + label="Fault Tree Viewer"> + <command + commandId="eu.fbk.eclipse.standardtools.faultTreeViewer.commands.ShowFaultTreeFromXmlFileCommand" + style="push"> + </command> + </menu> + <command + commandId="org.polarsys.chess.safetyAnalysis.commands.ComputeContractFaultTreeCommand" + style="push"> + </command> + </menu> + </menuContribution> + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + defaultHandler="org.polarsys.chess.safetyAnalysis.commands.ComputeContractFaultTreeCommand" + id="org.polarsys.chess.safetyAnalysis.commands.ComputeContractFaultTreeCommand" + name="Contract-based Safety Analysis on selected component"> + </command> + <command + defaultHandler="org.polarsys.chess.safetyAnalysis.commands.debug.ComputeContractFaultTreeOnFileCommand" + id="org.polarsys.chess.safetyAnalysis.commands.debug.ComputeContractFaultTreeOnFileCommand" + name="Compute Contract-based Fault Tree on .oss file"> + </command> + </extension> +</plugin> diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/1f/1f595a704c0d8abfe2211780cde1ac1b638b7d3c.svn-base b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/1f/1f595a704c0d8abfe2211780cde1ac1b638b7d3c.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..e0e145c3c8da23d559104ec85a347cf85759abc4 --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/1f/1f595a704c0d8abfe2211780cde1ac1b638b7d3c.svn-base @@ -0,0 +1,50 @@ +/******************************************************************************* + * 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.safetyAnalysis.commands; + + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.Class; +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ExecOcraCommands.services.OCRAExecService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; + +/** + * + * + */ +public class ComputeContractFaultTreeCommand extends AbstractAsyncJobCommand { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private OCRAExecService ocraExecService = OCRAExecService.getInstance(ChessSystemModel.getInstance()); + + + public ComputeContractFaultTreeCommand() { + super("Contract-based Fault Tree"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + Resource umlSelectedResource = umlSelectedComponent.eResource(); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + boolean showPopups = false; + + ocraExecService.executeComputeFaultTree(umlSelectedComponent,umlSelectedResource, isDiscreteTime, showPopups,monitor); + } + +} diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/2b/2b6fa5d291601b7ec502197e845c658716a7dd14.svn-base b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/2b/2b6fa5d291601b7ec502197e845c658716a7dd14.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..a37e4f8b6595b4ba28ee5a77c99ac1c8343786c5 --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/2b/2b6fa5d291601b7ec502197e845c658716a7dd14.svn-base @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.safetyAnalysis +Bundle-SymbolicName: org.polarsys.chess.contracts.safetyAnalysis;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.core.commands, + eu.fbk.eclipse.standardtools.ModelTranslatorToOcra, + org.eclipse.swt, + org.eclipse.uml2.uml, + eu.fbk.eclipse.standardtools.utils;bundle-version="1.0.0", + eu.fbk.eclipse.standardtools.ExecOcraCommands, + org.polarsys.chess.contracts.verificationService;bundle-version="1.0.0" +Bundle-Vendor: Fondazione Bruno Kessler +Import-Package: org.eclipse.core.runtime, + org.polarsys.chess.service.internal.utils diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6f20375d6c7d98fbc80bb5da99be9866b1fe2f73 --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..295926d964165896ea8aa7c1b1b3c9d3d3caa77e --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base @@ -0,0 +1,7 @@ +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 diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b862a296d38fe04269faeee6c9d77d11ff77380d --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base @@ -0,0 +1,7 @@ +<?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> diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/aa/aa1bac8db08bcadd745d40f8060d0bfda72b3172.svn-base b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/aa/aa1bac8db08bcadd745d40f8060d0bfda72b3172.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..16223c5dca59e5df8bf2f45e78336afabc26cd99 --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/aa/aa1bac8db08bcadd745d40f8060d0bfda72b3172.svn-base @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.polarsys.chess.contracts.safetyAnalysis</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> diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/df/dfef977538a6489a3c736fa99de0a9d0575be955.svn-base b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/df/dfef977538a6489a3c736fa99de0a9d0575be955.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..64b621b2ab8fc7ba46ea7e860ed45837e6a24fdd --- /dev/null +++ b/org.polarsys.chess.contracts.safetyAnalysis/.svn/pristine/df/dfef977538a6489a3c736fa99de0a9d0575be955.svn-base @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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.safetyAnalysis.commands.debug; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ExecOcraCommands.services.OCRAExecService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; + +/** + * + * + */ + + +public class ComputeContractFaultTreeOnFileCommand extends AbstractAsyncJobCommand { + + private OCRAExecService ocraExecService = OCRAExecService.getInstance(ChessSystemModel.getInstance()); + + + public ComputeContractFaultTreeOnFileCommand() { + super("Contract-based Fault Tree"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + ocraExecService.executeComputeFaultTree(isDiscreteTime, monitor); + } + +} diff --git a/org.polarsys.chess.contracts.safetyAnalysis/.svn/wc.db b/org.polarsys.chess.contracts.safetyAnalysis/.svn/wc.db new file mode 100644 index 0000000000000000000000000000000000000000..82edc42d490289d9076be68a08cb0ef6bf524093 Binary files /dev/null and b/org.polarsys.chess.contracts.safetyAnalysis/.svn/wc.db differ diff --git a/org.polarsys.chess.contracts.verificationService/.svn/entries b/org.polarsys.chess.contracts.verificationService/.svn/entries new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/entries @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.verificationService/.svn/format b/org.polarsys.chess.contracts.verificationService/.svn/format new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/format @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/15/153f8763f465a7406d5a4ef9fd99d6d9c71eda40.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/15/153f8763f465a7406d5a4ef9fd99d6d9c71eda40.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b8eb2aafc30c8dfd345b7ec95b811e39932e9fb5 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/15/153f8763f465a7406d5a4ef9fd99d6d9c71eda40.svn-base @@ -0,0 +1,221 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="false" + locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu?after=filtersMenu"> + <menu + label="AMASS" + id="org.eclipse.ui.main.diagramEditorMenu.AMASS"> + <menu + label="Basic Operations"> + <command + commandId="org.polarsys.chess.verificationService.commands.ExportModelToFileCommand" + style="push"> + </command> + </menu> + <menu + id="org.eclipse.ui.main.diagramEditorMenu.AMASS.validation" + label="Validation"> + <command + commandId="org.polarsys.chess.verificationService.commands.CheckValidationPropertyCommand2" + style="push"> + </command> + </menu> + <menu + label="Functional Verifications" + id="org.eclipse.ui.main.diagramEditorMenu.AMASS.funcVer"> + <command + commandId="org.polarsys.chess.verificationService.commands.ContractRefinementCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.ContractImplementationCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.ModelCheckingCommand2" + style="push"> + </command> + </menu> + <menu + label="Safety Analysis"> + </menu> + </menu> + </menuContribution> + <menuContribution + allPopups="false" + locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup"> + <menu + label="AMASS" + id="org.eclipse.ui.main.diagramEditorMenu.AMASS"> + </menu> + <!--<menu + label="AMASS" + id="org.eclipse.ui.main.modelExplorerMenu.AMASS"> + <menu + label="Basic Operations"> + <command + commandId="org.polarsys.chess.verificationService.commands.ExportModelToFileCommand" + style="push"> + </command> + </menu> + <menu + label="Functional Verifications" + id="org.eclipse.ui.main.modelExplorerMenu.AMASS.funcVer"> + <command + commandId="org.polarsys.chess.verificationService.commands.ContractRefinementCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.ContractImplementationCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.CheckValidationPropertyCommand2" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.ModelCheckingCommand2" + style="push"> + </command> + </menu> + <menu + label="Safety Analysis"> + </menu> + <menu + label="Safety Case"> + </menu> + </menu> --> + </menuContribution> + <menuContribution + allPopups="false" + locationURI="menu:org.eclipse.ui.main.menu"> + <menu + label="AMASS" + id="org.eclipse.ui.main.menu.AMASS"> + <menu + label="//Debug Operations"> + </menu> + <menu + label="Basic Operations"> + <menu + label="//Debug Operations"> + <command + commandId="org.polarsys.chess.verificationService.commands.debug.RuntimeErrorsOnFileCommand" + style="push"> + </command> + </menu> + <command + commandId="org.polarsys.chess.verificationService.commands.ExportModelToFileCommand" + style="push"> + </command> + </menu> + <menu + id="org.eclipse.ui.main.menu.AMASS." + label="Validation"> + <command + commandId="org.polarsys.chess.verificationService.commands.CheckValidationPropertyCommand2" + style="push"> + </command> + <menu + label="//Debug Validation"> + <command + commandId="org.polarsys.chess.verificationService.commands.debug.ModelCheckingOnFileCommand" + style="push"> + </command> + </menu> + </menu> + <menu + label="Functional Verifications" + id="org.eclipse.ui.main.menu.AMASS.funcVer"> + <menu + label="//Debug Operations"> + <command + commandId="org.polarsys.chess.verificationService.commands.debug.ContractRefinementOnFileCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.debug.ContractImplementationOnFileCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.debug.CheckValidationPropertyOnFileCommand" + style="push"> + </command> + </menu> + <command + commandId="org.polarsys.chess.verificationService.commands.ContractRefinementCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.ContractImplementationCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.verificationService.commands.ModelCheckingCommand2" + style="push"> + </command> + </menu> + <menu + label="Safety Analysis"> + </menu> + </menu> + </menuContribution> + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.ContractRefinementCommand" + id="org.polarsys.chess.verificationService.commands.ContractRefinementCommand" + name="Check Contract Refinement on selected component"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.debug.RuntimeErrorsOnFileCommand" + id="org.polarsys.chess.verificationService.commands.debug.RuntimeErrorsOnFileCommand" + name="Check Grammar on .oss file"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.debug.ContractRefinementOnFileCommand" + id="org.polarsys.chess.verificationService.commands.debug.ContractRefinementOnFileCommand" + name="Check Contract Refinement on .oss file"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.debug.ContractImplementationOnFileCommand" + id="org.polarsys.chess.verificationService.commands.debug.ContractImplementationOnFileCommand" + name="Check Contract Implementation on .oss and .fmv files"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.ExportModelToFileCommand" + id="org.polarsys.chess.verificationService.commands.ExportModelToFileCommand" + name="Export model as .oss file"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.ContractImplementationCommand" + id="org.polarsys.chess.verificationService.commands.ContractImplementationCommand" + name="Check Contract Implementation on selected component"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.ModelCheckingCommand" + id="org.polarsys.chess.verificationService.commands.ModelCheckingCommand2" + name="Model Checking on selected component"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.debug.ModelCheckingOnFileCommand" + id="org.polarsys.chess.verificationService.commands.debug.ModelCheckingOnFileCommand" + name="Model Checking on .smv file"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.CheckValidationPropertyCommand" + id="org.polarsys.chess.verificationService.commands.CheckValidationPropertyCommand2" + name="Check Validation Property on selected component"> + </command> + <command + defaultHandler="org.polarsys.chess.verificationService.commands.debug.CheckValidationPropertyOnFileCommand" + id="org.polarsys.chess.verificationService.commands.debug.CheckValidationPropertyOnFileCommand" + name="Check Validation Property on .oss file"> + </command> + </extension> +</plugin> diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/26/26253aedaefb5cbe41fdfbda8424cbd3966369cf.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/26/26253aedaefb5cbe41fdfbda8424cbd3966369cf.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..4a937c946b76f976267ca1ea2fb6da10e267ddc1 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/26/26253aedaefb5cbe41fdfbda8424cbd3966369cf.svn-base @@ -0,0 +1,98 @@ +/******************************************************************************* + * 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.verificationService.services; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.uml2.uml.Class; +import org.polarsys.chess.contracts.transformations.main.GenerateErrorModel; + +import eu.fbk.eclipse.standardtools.exceptions.NoComponentException; +import eu.fbk.eclipse.standardtools.nuXmvService.utils.NuXmvDirectoryUtil; +import eu.fbk.eclipse.standardtools.utils.DialogUtil; + +/** + * + * + */ +public class SmvExportService { + + private static SmvExportService smvExportService; + + public static SmvExportService getInstance() { + if (smvExportService == null) { + smvExportService = new SmvExportService(); + } + return smvExportService; + } + + private static DialogUtil dialogUtil = DialogUtil.getInstance(); + private static NuXmvDirectoryUtil nuXmvDirectoryUtil = NuXmvDirectoryUtil.getInstance(); + + + + public File exportSmv(Class umlSelectedComponent,boolean showPopups, IProgressMonitor monitor) + throws Exception { + if (umlSelectedComponent == null) { + throw new NoComponentException(); + } + + File smvOutput = new File(nuXmvDirectoryUtil.getSmvFilePath()); + List<String> args = returnParams(umlSelectedComponent); + + exportSmv(umlSelectedComponent, smvOutput, args, showPopups,monitor); + + return new File(smvOutput + "/" + getSmvFileName(umlSelectedComponent)+".smv"); + } + + + private List<String> returnParams(Class umlSelectedComponent) { + String systemQN = umlSelectedComponent.getQualifiedName(); + final List<String> args = new ArrayList<String>(); + args.add(systemQN); + String systemName = systemQN.substring(systemQN.lastIndexOf("::") + 2); + args.add(systemName); + args.add(umlSelectedComponent.getName()); + + return args; + } + + private String getSmvFileName(Class umlSelectedComponent) { + // String systemQN = umlSelectedComponent.getQualifiedName(); + // String systemName = systemQN.substring(systemQN.lastIndexOf("::") + 2); + // return umlSelectedComponent.getModel().getName() + "_" + systemName + ".smv"; + return umlSelectedComponent.getName(); + } + + private void exportSmv(Class umlSelectedComponent, File targetDir, List<String> args, boolean showPopups, IProgressMonitor monitor) + throws IOException { + monitor.beginTask("operation in progress ...", 3); + monitor.subTask("transforming..."); + + for (String s : args) { + System.out.println("-> " + s); + } + + GenerateErrorModel gen = new GenerateErrorModel(umlSelectedComponent, targetDir, args); + gen.doGenerate(null); + monitor.worked(1); + + +if(showPopups){ + dialogUtil.showMessage_ExportBehaviourDone(targetDir.getAbsolutePath()); +} + monitor.done(); + } +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/29/292ae705f1fda910bf71309d7d53db69b27f0676.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/29/292ae705f1fda910bf71309d7d53db69b27f0676.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..0eecf56bca4cfe8e2a540ad562b7a7280e68f7f8 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/29/292ae705f1fda910bf71309d7d53db69b27f0676.svn-base @@ -0,0 +1,34 @@ +/******************************************************************************* + * 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.verificationService.commands.debug; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ExecOcraCommands.services.OCRAExecService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; + +public class ContractImplementationOnFileCommand extends AbstractAsyncJobCommand { + + private OCRAExecService ocraExecService = OCRAExecService.getInstance(ChessSystemModel.getInstance()); + + + public ContractImplementationOnFileCommand() { + super("Check Implementation on oss file"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + ocraExecService.executeCheckContractImplementation(monitor); + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/30/309f0d801c259abbf51419fecdf69df431d50e3c.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/30/309f0d801c259abbf51419fecdf69df431d50e3c.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..c07b8dde1d800b71e83f227fe4271ea364af9952 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/30/309f0d801c259abbf51419fecdf69df431d50e3c.svn-base @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.verificationService.commands.debug; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.resource.Resource; +import eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.services.OCRARuntimeErrorService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +public class RuntimeErrorsOnFileCommand extends AbstractAsyncJobCommand { + + private SelectionUtil chessSelectionUtil = SelectionUtil.getInstance(); + private OCRARuntimeErrorService ocraRuntimeErrorService = OCRARuntimeErrorService.getInstance(); + + public RuntimeErrorsOnFileCommand() { + super("Show Runtime Errors"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + boolean showNoErrorPopup = true; + + Resource modelResource = chessSelectionUtil.getSelectedModelResource(); + ocraRuntimeErrorService.showRuntimeErrors(modelResource, showNoErrorPopup, monitor); + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6f20375d6c7d98fbc80bb5da99be9866b1fe2f73 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/53/5360b20d9ce5e00d821d0025e7486f11a354df15.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/53/5360b20d9ce5e00d821d0025e7486f11a354df15.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ecccb1f02fbbd31f5c7b54d606f15872f400a479 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/53/5360b20d9ce5e00d821d0025e7486f11a354df15.svn-base @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.verificationService.commands; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.uml2.uml.Class; +import eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.services.OCRATranslatorService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; + + +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +/** + * + * + */ +public class ExportModelToFileCommand extends AbstractAsyncJobCommand { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private OCRATranslatorService ocraTranslatorService = OCRATranslatorService.getInstance(ChessSystemModel.getInstance()); + + public ExportModelToFileCommand() { + super("Export Model To .Oss File"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + Resource umlSelectedResource = umlSelectedComponent.eResource(); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + boolean showPopups = true; + + ocraTranslatorService.exportModelToOssFile(umlSelectedComponent, umlSelectedResource, + isDiscreteTime,showPopups, monitor); + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/56/569ce383a2581df5d77ca5097f3c37a26da3f6a0.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/56/569ce383a2581df5d77ca5097f3c37a26da3f6a0.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ed9c3942a28911dcdbcf4bd3af2ae57c0602ad4e --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/56/569ce383a2581df5d77ca5097f3c37a26da3f6a0.svn-base @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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.verificationService.commands.debug; + + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ExecOcraCommands.services.OCRAExecService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; + +/** + * + * + */ +public class CheckValidationPropertyOnFileCommand extends AbstractAsyncJobCommand { + + private OCRAExecService ocraExecService = OCRAExecService.getInstance(ChessSystemModel.getInstance()); + + public CheckValidationPropertyOnFileCommand() { + super("Check Validation Property"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + ocraExecService.executeValidationProperty(isDiscreteTime,monitor); + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/57/57f4621f24285a6eef9f3ac0caff1ef2ca244c1d.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/57/57f4621f24285a6eef9f3ac0caff1ef2ca244c1d.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..fc13846c846f6082616da696bf43b6dbdbe2bc23 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/57/57f4621f24285a6eef9f3ac0caff1ef2ca244c1d.svn-base @@ -0,0 +1,38 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.verificationService +Bundle-SymbolicName: org.polarsys.chess.contracts.verificationService;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.core.resources, + org.junit, + org.eclipse.papyrus.uml.diagram.composite, + org.eclipse.xtext.testing, + org.eclipse.emf.edit.ui, + org.eclipse.papyrus.uml.tools, + org.eclipse.emf.ecore, + eu.fbk.eclipse.standardtools.ModelTranslatorToOcra, + org.eclipse.swt, + org.eclipse.core.jobs, + eu.fbk.tools.adapter.core;bundle-version="1.0.0", + eu.fbk.tools.adapter.ui;bundle-version="1.0.0", + org.polarsys.chess.contracts.transformations;bundle-version="0.9.0", + org.eclipse.acceleo.engine;bundle-version="3.6.6", + eu.fbk.eclipse.standardtools.utils, + eu.fbk.tools.editor.nusmv.ui;bundle-version="1.0.0", + eu.fbk.eclipse.standardtools.ExecOcraCommands, + eu.fbk.eclipse.standardtools.nuXmvService, + org.polarsys.chess.contracts.profile, + org.polarsys.chess.core +Import-Package: eu.fbk.eclipse.standardtools.nuXmvService.dialogs, + eu.fbk.eclipse.standardtools.nuXmvService.services, + eu.fbk.eclipse.standardtools.nuXmvService.utils, + org.apache.log4j;version="1.2.15", + org.eclipse.gmf.runtime.diagram.ui.editparts, + org.eclipse.papyrus.infra.core.utils, + org.eclipse.papyrus.infra.emf.utils, + org.polarsys.chess.service.internal.utils +Bundle-ActivationPolicy: lazy +Bundle-Vendor: Fondazione Bruno Kessler +Export-Package: org.polarsys.chess.verificationService.model + diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/61/614442f12712d21d864b1f2fdc74f845fed69b39.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/61/614442f12712d21d864b1f2fdc74f845fed69b39.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..dbd0ae5137f504da53f9319a69626396d70169f0 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/61/614442f12712d21d864b1f2fdc74f845fed69b39.svn-base @@ -0,0 +1,601 @@ +/******************************************************************************* + * 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.verificationService.model; + + +import java.util.List; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Connector; +import org.eclipse.uml2.uml.ConnectorEnd; +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.Type; +import org.polarsys.chess.contracts.profile.chesscontract.ContractProperty; +import org.polarsys.chess.contracts.profile.chesscontract.ContractRefinement; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.model.AbstractSystemModel; + +public class ChessSystemModel implements AbstractSystemModel { + + private static ChessSystemModel chessToOCRAModelRunner; + + public static ChessSystemModel getInstance() { + if (chessToOCRAModelRunner == null) { + chessToOCRAModelRunner = new ChessSystemModel(); + } + return chessToOCRAModelRunner; + } + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getLowerUpperBoundsForRangeType(Object rangeTypePort) { + return entityUtil.getLowerUpperBoundsForRangeType((Port) rangeTypePort); + } + + + + @Override + public String[] getValuesForEnumeratorType(Object enumTypePort) { + return entityUtil.getValuesForEnumeratorType((Port) enumTypePort); + } + + + + @Override + public boolean isRangeType(Object port) { + return entityUtil.isRangeAttribute((Property) port); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getContractsOfComponent(java.lang.Object) + */ + @Override + public EList<?> getContractsOfComponent(Object component) { + return contractEntityUtil.getContractProperties((Class) component); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getComponentType(java.lang.Object) + */ + @Override + public String getComponentType(Object component) { + +if (entityUtil.isBlock((Element) component)) { + return ""; + } + + if (entityUtil.isComponentInstance((Element) component)) { + return ((Class) ((Property) component).getType()).getName(); + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * preCompileOperations(java.lang.Object) + */ + @Override + public void preCompileOperations(Object component) { + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getPortName(java.lang.Object) + */ + @Override + public String getPortName(Object port) { + // return ((Port)port).getQualifiedName().replaceAll("::", "_"); + return ((Port) port).getName(); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getConnectorName(java.lang.Object) + */ + @Override + public String getConnectorName(Object connector) { + if (((ConnectorEnd) connector).getRole() != null) { + return ((ConnectorEnd) connector).getRole().getName(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getContractDefinitionsText(java.lang.Object) + */ + @Override + public String getContractDefinitionsText(Object component) throws Exception { + + List<ContractProperty> listCp = null; + if (entityUtil.isComponentInstance((Element) component)) { + Class componentType = (Class) (((Property) component).getType()); + listCp = contractEntityUtil.getContractProperties(componentType); + } else if ((// entityUtil.isSystem((Element) component)|| + (entityUtil.isBlock((Element) component)))) { + listCp = contractEntityUtil.getContractProperties((Class) component); + } + String definitions = ""; + for (ContractProperty contractProperty : listCp) { + String currContract = contractEntityUtil.convertContractPropertyInStr(contractProperty); + definitions = definitions.concat(currContract); + } + return definitions; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getOrcaFormulaConstraintText(java.lang.Object) + */ + @Override + public String getOrcaFormulaConstraintText(Object formulaConstraint) { + return ((Constraint) formulaConstraint).getSpecification().stringValue(); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getFormulaConstraints(java.lang.Object) + */ + @Override + public EList<Constraint> getFormulaConstraints(Object component) { + return contractEntityUtil.getConstraintsProperties((Element) component); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getInputPorts(java.lang.Object) + */ + @Override + public EList<Port> getInputPorts(Object component) { + return new BasicEList<Port>(entityUtil.getUmlPorts((Element) component, FlowDirection.IN_VALUE)); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getParameterName(java.lang.Object) + */ + @Override + public String getParameterName(Object parameter) { + return ((Property) parameter).getName(); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getParameters(java.lang.Object) + */ + @Override + public EList<Property> getParameters(Object component) { + return new BasicEList<Property>(entityUtil.getBooleanAttributesExceptsPorts((Element) component)); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getOutputPorts(java.lang.Object) + */ + @Override + public EList<Port> getOutputPorts(Object component) { + int direction = FlowDirection.OUT_VALUE; + return new BasicEList<Port>(entityUtil.getUmlPorts((Element) component, direction)); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getGenericPorts(java.lang.Object) + */ + @Override + public EList<Port> getGenericPorts(Object component) { + int direction = FlowDirection.INOUT_VALUE; + return new BasicEList<Port>(entityUtil.getUmlPorts((Element) component, direction)); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getConnectionSource(java.lang.Object) + */ + @Override + public Object getConnectionSource(Object connection) { + + ConnectorEnd source = ((Connector) connection).getEnds().get(0); + ConnectorEnd target = ((Connector) connection).getEnds().get(1); + Element sourceOwner = source.getPartWithPort(); + Element targetOwner = target.getPartWithPort(); + + Element sourcePort = source.getRole(); + Element targetPort = target.getRole(); + + int sourceDir = entityUtil.getPortDirection(sourcePort); + int targetDir = entityUtil.getPortDirection(targetPort); + + + if ((sourceOwner == null) && (sourceDir == FlowDirection.IN_VALUE)) { + return source; + } + if ((targetOwner == null) && (targetDir == FlowDirection.IN_VALUE)) { + return target; + } + if ((sourceOwner != null) && (sourceDir == FlowDirection.OUT_VALUE)) { + return source; + } + if ((targetOwner != null) && (targetDir == FlowDirection.OUT_VALUE)) { + return target; + } + + + return ((Connector) connection).getEnds().get(0); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getConnectionTarget(java.lang.Object) + */ + @Override + public Object getConnectionTarget(Object connection) { + + ConnectorEnd source = ((Connector) connection).getEnds().get(0); + ConnectorEnd target = ((Connector) connection).getEnds().get(1); + Element sourceOwner = source.getPartWithPort(); + Element targetOwner = target.getPartWithPort(); + + + Element sourcePort = source.getRole(); + Element targetPort = target.getRole(); + + int sourceDir = entityUtil.getPortDirection(sourcePort); + int targetDir = entityUtil.getPortDirection(targetPort); + + + if ((sourceOwner == null) && (sourceDir == FlowDirection.OUT_VALUE)) { + return source; + } + if ((targetOwner == null) && (targetDir == FlowDirection.OUT_VALUE)) { + return target; + } + if ((sourceOwner != null) && (sourceDir == FlowDirection.IN_VALUE)) { + return source; + } + if ((targetOwner != null) && (targetDir == FlowDirection.IN_VALUE)) { + return target; + } + + return ((Connector) connection).getEnds().get(1); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getConnectionsPorts(java.lang.Object) + */ + @Override + public EList<Connector> getConnectionsPorts(Object component) { + if ( + // entityUtil.isSystem((Element) component)|| + (entityUtil.isBlock((Element) component))) { + return ((Class) component).getOwnedConnectors(); + } else if (entityUtil.isComponentInstance((Element) component)) { + return ((Class) ((Property) component).getType()).getOwnedConnectors(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getSourceConnectorOwner(java.lang.Object) + */ + @Override + public Object getSourceConnectorOwner(Object connector) { + if (connector != null) { + return ((ConnectorEnd) connector).getPartWithPort(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getTargetConnectorOwner(java.lang.Object) + */ + @Override + public Object getTargetConnectorOwner(Object connector) { + if (connector != null) { + return ((ConnectorEnd) connector).getPartWithPort(); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getComponentInstanceName(java.lang.Object) + */ + @Override + public String getComponentInstanceName(Object component) { + if (entityUtil.isComponentInstance((Element) component)) { + return ((Property) component).getName().replaceAll("::", "_"); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getContract(java.lang.Object, java.lang.String) + */ + @Override + public Object getContract(Object component, String contractName) { + if (entityUtil.isComponentInstance((Element) component)) { + Class compClass = ((Class) ((Property) component).getType()); + return contractEntityUtil.getContractProperty(contractEntityUtil + .getUmlContractPropertyOfUmlComponentFromContractPropertyType(compClass, contractName)); + } else if ( + // entityUtil.isSystem((Element) component)|| + (entityUtil.isBlock((Element) component))) { + return contractEntityUtil.getContractProperty(contractEntityUtil + .getUmlContractPropertyOfUmlComponentFromContractPropertyType((Class) component, contractName)); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getContractName(java.lang.Object) + */ + @Override + public String getContractInstanceName(Object contractProperty) throws Exception { + + + if (contractProperty instanceof ContractProperty) { + Type contractType = ((ContractProperty) contractProperty).getBase_Property().getType(); + + if (contractType != null) { + return ((ContractProperty) contractProperty).getBase_Property().getType().getName(); + } else { + throw new Exception( + "The ContractProperty \"" + ((ContractProperty) contractProperty).getBase_Property().getName() + + "\" does not have a type."); + } + } else { + throw new Exception("The element \"" + contractProperty + "\" is not a contract property."); + } + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getComponentName(java.lang.Object) + */ + @Override + public String getComponentName(Object component) { + return entityUtil.getComponentName(component); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getContractRefinements(java.lang.Object) + */ + @Override + public EList<ContractRefinement> getContractRefinements(Object parentContract) { + //for(ContractRefinement cr : ((ContractProperty) parentContract).getRefinedBy()){ + //System.out.println("cr.getContract(): "+cr.getContract().getBase_Property().getName()); + //} + return ((ContractProperty) parentContract).getRefinedBy(); + } + + + + @Override + public String getContractRefinementName(Object contractRefinement) { + // TODO Auto-generated method stub + return ((ContractRefinement) contractRefinement).getBase_DataType().getName(); + } + + + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getComponentOfContractRefinement(java.lang.Object) + */ + @Override + public Object getComponentOfContractRefinement(Object contractRefinement) { + return ((ContractRefinement) contractRefinement).getInstance(); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getContractOfContractRefinement(java.lang.Object) + */ + @Override + public Object getContractInstanceOfContractRefinement(Object contractRefinement) { + return ((ContractRefinement) contractRefinement).getContract(); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * isBooleanType(java.lang.Object) + */ + @Override + public boolean isBooleanType(Object port) { + return entityUtil.isBooleanAttribute((Property) port); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * isDoubleType(java.lang.Object) + */ + @Override + public boolean isDoubleType(Object port) { + return entityUtil.isDoubleAttribute((Property) port); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * isIntType(java.lang.Object) + */ + @Override + public boolean isIntType(Object port) { + return entityUtil.isIntegerAttribute((Property) port); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * isContinuousType(java.lang.Object) + */ + @Override + public boolean isContinuousType(Object port) { + return entityUtil.isContinuousAttribute((Property) port); + } + + + + @Override + public boolean isEnumType(Object port) { + return entityUtil.isEnumerationAttribute((Property) port); + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * getSubComponents(java.lang.Object) + */ + @Override + public EList<Property> getSubComponents(Object component) { + if (( + // entityUtil.isSystem((Element) component)|| + (entityUtil.isBlock((Element) component)))) { + return new BasicEList<Property>(entityUtil.getSubComponents((Class) component)); + } else if (entityUtil.isComponentInstance((Element) component)) { + return new BasicEList<Property>(entityUtil.getSubComponents((Class) ((Property) component).getType())); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + *eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.dsl.run.model.ToolToOCRAModel# + * isContractOwnerEqualToComponent(java.lang.Object, java.lang.Object) + */ + @Override + public boolean isContractInstanceOwnerEqualToComponent(Object contract, Object component) { + + System.out.println("isContractInstanceOwnerEqualToComponent, contractProperty name: "+((ContractProperty) contract).getBase_Property().getName()); + + Element contractOwner = entityUtil + .getOwner(((ContractProperty) contract).getBase_Property()); + + System.out.println("contract owner: "+((Class)contractOwner).getName()); + + Element componentType = (((Property) component).getType()); + + System.out.println("component type: "+((Class)componentType).getName()); + + return contractOwner == componentType; + } + + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/76/7671c586c4f5c3c3d88d7bd92e2726cd227198a3.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/76/7671c586c4f5c3c3d88d7bd92e2726cd227198a3.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..812b5d0572ec361ed5b32f6f8adbd5cf23650fed --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/76/7671c586c4f5c3c3d88d7bd92e2726cd227198a3.svn-base @@ -0,0 +1,65 @@ +/******************************************************************************* + * 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.verificationService.commands; + +import java.io.File; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.uml2.uml.Class; + +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.services.SmvExportService; + +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.nuXmvService.dialogs.NuXmvParametersDialog; +import eu.fbk.eclipse.standardtools.nuXmvService.services.NuXmvService; + +/** + * + * + */ +public class ModelCheckingCommand extends AbstractAsyncJobCommand { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + //private OCRADirectoryUtil ocraDirectoryUtil = OCRADirectoryUtil.getInstance(); + private SmvExportService smvExportService = SmvExportService.getInstance(); + private NuXmvService nuXmvService = NuXmvService.getInstance(); + + public ModelCheckingCommand() { + super("Model Checking"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + //String smvOutputFilePath = ocraDirectoryUtil.getOSSFilePath(); + boolean showPopups = false; + + File smvOutput = smvExportService.exportSmv( umlSelectedComponent,showPopups, monitor); + + if (smvOutput != null) { + + final NuXmvParametersDialog dialog = new NuXmvParametersDialog(); + dialog.open(); + + if (dialog.goAhead()) { + String alg_type = dialog.getAlgorithmType(); + String check_type = dialog.getCheckType(); + String property = dialog.getProperty(); + nuXmvService.modelCheckingCommand(smvOutput, property, alg_type, check_type); + } + + } + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b862a296d38fe04269faeee6c9d77d11ff77380d --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base @@ -0,0 +1,7 @@ +<?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> diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/8f/8f25c814c31eab84f963678cfa9eefba8b2670c6.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/8f/8f25c814c31eab84f963678cfa9eefba8b2670c6.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d41e000648644a69ca5bd9c059cf05773c5b2bcf --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/8f/8f25c814c31eab84f963678cfa9eefba8b2670c6.svn-base @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.verificationService.commands; + +import java.io.File; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.Class; + +import eu.fbk.eclipse.standardtools.ExecOcraCommands.services.OCRAExecService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; + + +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.model.ChessSystemModel; +import org.polarsys.chess.verificationService.services.SmvExportService; + +public class ContractImplementationCommand extends AbstractAsyncJobCommand { + + private OCRAExecService ocraExecService = OCRAExecService.getInstance(ChessSystemModel.getInstance()); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + //private OCRADirectoryUtil ocraDirectoryUtil = OCRADirectoryUtil.getInstance(); + private SmvExportService nuXmvService = SmvExportService.getInstance(); + + + public ContractImplementationCommand() { + super("Check Contract Implementation"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + Resource umlSelectedResource = umlSelectedComponent.eResource(); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + boolean showPopups = false; + + //String smvOutputFilePath = ocraDirectoryUtil.getOSSFilePath(); + File smvOutput = nuXmvService.exportSmv(umlSelectedComponent, showPopups,monitor); + System.out.println("smvOutput: " + smvOutput); + + ocraExecService.executeCheckContractImplementation(umlSelectedComponent,umlSelectedResource, smvOutput, isDiscreteTime,showPopups,monitor); + + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/9b/9b734c73f7a70ce16686e9c748f063bd9ad68d30.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/9b/9b734c73f7a70ce16686e9c748f063bd9ad68d30.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..9e56ef6b828686b8ffe318f4ecb9cdccaa6c25a8 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/9b/9b734c73f7a70ce16686e9c748f063bd9ad68d30.svn-base @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.verificationService.commands.debug; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ExecOcraCommands.services.OCRAExecService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; + +public class ContractRefinementOnFileCommand extends AbstractAsyncJobCommand { + + private OCRAExecService ocraExecService = OCRAExecService.getInstance(ChessSystemModel.getInstance()); + + public ContractRefinementOnFileCommand() { + super("Contract Refinement on oss file"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + ocraExecService.executeCheckContractRefinement(monitor); + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/b2/b20b87675c00d6ea9f2c3ab64543daac42c3969b.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/b2/b20b87675c00d6ea9f2c3ab64543daac42c3969b.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..8bd3a0c18d062c13a98d7f27bf8e10fb0b2b3ce0 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/b2/b20b87675c00d6ea9f2c3ab64543daac42c3969b.svn-base @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.polarsys.chess.contracts.verificationService</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> diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/c2/c298ec84e18c8a023783082438d43f059bb37194.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/c2/c298ec84e18c8a023783082438d43f059bb37194.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6e7634da3c2917931aa69c699fea9dead8ed1eed --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/c2/c298ec84e18c8a023783082438d43f059bb37194.svn-base @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.verificationService.commands.debug; + +import java.io.File; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; + +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.nuXmvService.dialogs.NuXmvParametersDialog; +import eu.fbk.eclipse.standardtools.nuXmvService.services.NuXmvService; +import eu.fbk.eclipse.standardtools.nuXmvService.utils.NuXmvDialogUtil; +import eu.fbk.eclipse.standardtools.nuXmvService.utils.NuXmvDirectoryUtil; + +/** + * + * + */ +public class ModelCheckingOnFileCommand extends AbstractAsyncJobCommand { + + + private NuXmvService nuXmvService = NuXmvService.getInstance(); + private NuXmvDialogUtil nuXmvDialogUtil = NuXmvDialogUtil.getInstance(); + private NuXmvDirectoryUtil nuXmvDirectoryUtil = NuXmvDirectoryUtil.getInstance(); + + public ModelCheckingOnFileCommand() { + super("Model Checking"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + File smvFile = nuXmvDialogUtil.getSmvFileFromFileDialog(nuXmvDirectoryUtil.getSmvFilePath()); + //boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + + + final NuXmvParametersDialog dialog = new NuXmvParametersDialog(); + dialog.open(); + + if (dialog.goAhead()) { + String alg_type = dialog.getAlgorithmType(); + String check_type = dialog.getCheckType(); + String property = dialog.getProperty(); + nuXmvService.modelCheckingCommand(smvFile, property, alg_type, check_type); + } + + } + + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/e4/e4f19d2e02b7fd0fbd23c9902e136c185630c76e.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/e4/e4f19d2e02b7fd0fbd23c9902e136c185630c76e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b20bd16c04ce58d76a3a26a016d20f5078c123c6 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/e4/e4f19d2e02b7fd0fbd23c9902e136c185630c76e.svn-base @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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.verificationService.commands; + + + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.Class; + +import eu.fbk.eclipse.standardtools.ExecOcraCommands.services.OCRAExecService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; + + +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +public class ContractRefinementCommand extends AbstractAsyncJobCommand { + + private OCRAExecService ocraExecService = OCRAExecService.getInstance(ChessSystemModel.getInstance()); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + + public ContractRefinementCommand() { + super("Contract Refinement"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + Resource umlSelectedResource = umlSelectedComponent.eResource(); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + boolean showPopups = false; + + ocraExecService.executeCheckContractRefinement(umlSelectedComponent,umlSelectedResource,isDiscreteTime,showPopups,monitor); + + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/pristine/ec/ec0d2cf4b73ffb43bb9ccd4924ed13c67056fb6c.svn-base b/org.polarsys.chess.contracts.verificationService/.svn/pristine/ec/ec0d2cf4b73ffb43bb9ccd4924ed13c67056fb6c.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..5b87128e97277b03e828fd146ffc5dee490b8490 --- /dev/null +++ b/org.polarsys.chess.contracts.verificationService/.svn/pristine/ec/ec0d2cf4b73ffb43bb9ccd4924ed13c67056fb6c.svn-base @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.verificationService.commands; + + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.Class; +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ExecOcraCommands.services.OCRAExecService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; + +/** + * + * + */ +public class CheckValidationPropertyCommand extends AbstractAsyncJobCommand { + + private ChessSystemModel chessToOCRAModelTranslator = ChessSystemModel.getInstance(); + private OCRAExecService ocraExecService = OCRAExecService.getInstance(chessToOCRAModelTranslator); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + + + + public CheckValidationPropertyCommand() { + super("Check Validation Property"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + Resource umlSelectedResource = umlSelectedComponent.eResource(); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + boolean showPopups = false; + + ocraExecService.executeValidationProperty(umlSelectedComponent, umlSelectedResource, isDiscreteTime,showPopups, monitor); + + } + +} diff --git a/org.polarsys.chess.contracts.verificationService/.svn/wc.db b/org.polarsys.chess.contracts.verificationService/.svn/wc.db new file mode 100644 index 0000000000000000000000000000000000000000..beedcb5f623f082d1f618980f17c294986c21197 Binary files /dev/null and b/org.polarsys.chess.contracts.verificationService/.svn/wc.db differ diff --git a/org.polarsys.chess.diagram.ui/.svn/entries b/org.polarsys.chess.diagram.ui/.svn/entries new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/entries @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.diagram.ui/.svn/format b/org.polarsys.chess.diagram.ui/.svn/format new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/format @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/0d/0d7589da4da60e880836d8cb5c9e21e6d02b0f8e.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/0d/0d7589da4da60e880836d8cb5c9e21e6d02b0f8e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d3df103501a077a04cb5ba99a80e8c24f6d546e3 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/0d/0d7589da4da60e880836d8cb5c9e21e6d02b0f8e.svn-base @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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.diagram.ui.commands; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSDiagramModel; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ComponentToImageDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DiagramGeneratorService; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; + +/** + * + * @author Alberto + */ +public class ExportComponentToImageCommand extends AbstractAsyncJobCommand { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + + //private OCRAComponentToImage ocraComponentToImage = OCRAComponentToImage.getInstance(); + //private DocumentGeneratorService ocraComponentToImage = DocumentGeneratorService.getInstance(CHESSGraphicalModel.getInstance()); + private DiagramGeneratorService diagramGeneratorService = DiagramGeneratorService.getInstance(CHESSDiagramModel.getInstance()); + + + public ExportComponentToImageCommand() { + super("Export Component To Image Command"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + GraphicalEditPart selectedGraphicalComponent = selectionUtil + .getSelectedGraphicalObject(event); + + if (selectedGraphicalComponent != null) { + + final ComponentToImageDialog parameterDialog = exportDialogUtils + .getCompiledComponentToImageDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String projectDir = directoryUtils.getCurrentProjectDir(); + String imageName = diagramGeneratorService.getImageName( + selectedGraphicalComponent,parameterDialog.getImageFormat()) ; + + String imageFilePath = exportDialogUtils.openImageDialog(projectDir, imageName); + if ((imageFilePath == null) || imageFilePath.isEmpty()) { + return; + } + + diagramGeneratorService.setParametersBeforeDiagramGenerator + //setParametersBeforeExport + (parameterDialog.getShowPortLabels(), + parameterDialog.getAutomaticPortLabelLayout()); + diagramGeneratorService.createDiagramFile(imageFilePath, selectedGraphicalComponent,monitor); + exportDialogUtils.showMessage_ExportDone(imageFilePath); + } + + } + + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/0e/0e1b8164879023af12eaa795538c8248348233ac.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/0e/0e1b8164879023af12eaa795538c8248348233ac.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..7da5289a61b9922c0ec75d0394955529cdcecd77 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/0e/0e1b8164879023af12eaa795538c8248348233ac.svn-base @@ -0,0 +1,497 @@ +/******************************************************************************* + * 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.diagram.ui.docGenerators; + +import java.awt.Dimension; +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.StructureCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorEditPart; +import org.eclipse.papyrus.uml.diagram.common.editparts.IUMLEditPart; +import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.CustomPropertyPartEditPartCN; +import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.ResizablePortEditPart; +import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeCompartmentEditPart; +import org.eclipse.uml2.uml.Connector; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Port; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.diagram.ui.layout.EOrientation; +import eu.fbk.eclipse.standardtools.diagram.ui.layout.EOrientation.Orientation; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractInternalBlockDiagramModel; + +public class CHESSInternalBlockDiagramModel implements AbstractInternalBlockDiagramModel{ + + + private static CHESSInternalBlockDiagramModel chessModel; + + public static CHESSInternalBlockDiagramModel getInstance(){ + if(chessModel == null){ + chessModel = new CHESSInternalBlockDiagramModel(); + } + return chessModel; + } + + + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String getGraphicalComponentId(Object graphicalComponent) { + Element umlElement = null; + /* + * if(graphicalComponent instanceof BlockCompositeEditPart){ umlElement + * = ((BlockCompositeEditPart)graphicalComponent).getUMLElement(); } + * if(graphicalComponent instanceof BlockPropertyCompositeEditPart){ + * umlElement = + * ((BlockPropertyCompositeEditPart)graphicalComponent).getUMLElement(); + * } + */ + if (graphicalComponent instanceof IUMLEditPart) { + umlElement = ((IUMLEditPart) graphicalComponent).getUMLElement(); + } + return entityUtil.getComponentID(umlElement); + } + + @Override + public String getGraphicalComponentName(Object graphicalComponent) { + EObject component = ((GraphicalEditPart) graphicalComponent).resolveSemanticElement(); + + // ((AppliedStereotypeEmptyEditPart)graphicalComponent).get + + return entityUtil.getComponentName(component); + } + + @Override + public List<GraphicalEditPart> getGraphicalSubComponents(Object graphicalComponent) { + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + List<GraphicalEditPart> graphicalSubComponent = new ArrayList<GraphicalEditPart>(); + for (Object child : children) { + System.out.println("child: " + child); + if (child instanceof StructureCompartmentEditPart) { + for (Object componentChild : ((StructureCompartmentEditPart) child).getChildren()) { + System.out.println("StructureCompartmentEditPart child: " + componentChild); + if (componentChild instanceof BlockPropertyCompositeEditPart) { + graphicalSubComponent.add((GraphicalEditPart) componentChild); + } + } + } + if (child instanceof ClassCompositeCompartmentEditPart) { + for (Object componentChild : ((ClassCompositeCompartmentEditPart) child).getChildren()) { + System.out.println("StructureCompartmentEditPart child: " + componentChild); + if (componentChild instanceof CustomPropertyPartEditPartCN) { + graphicalSubComponent.add((GraphicalEditPart) componentChild); + } + } + } + } + return graphicalSubComponent; + } + + @Override + public Object getGraphicalOwnerComponents(Object graphicalComponent) { + return ((GraphicalEditPart) graphicalComponent).getParent(); + } + + @Override + public List<?> getGraphicalPorts(Object graphicalComponent) { + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + List<GraphicalEditPart> graphicalConnectors = new ArrayList<GraphicalEditPart>(); + for (Object child : children) { + if (child instanceof FlowPortAffixedNodeEditPart) { + graphicalConnectors.add((GraphicalEditPart) child); + } + if (child instanceof ResizablePortEditPart) { + graphicalConnectors.add((GraphicalEditPart) child); + } + } + return graphicalConnectors; + } + + @Override + public Object getGraphicalPortOwner(Object port) { + return ((GraphicalEditPart) port).getParent(); + } + + @Override + public Dimension getGraphicalComponentDimension(Object component) { + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) component).getFigure().getSize(); + Dimension d = new Dimension(domension.width, domension.height); + return d; + } + + @Override + public Point getGraphicalComponentPosition(Object component) { + + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + + printlnGraphicalPosition(graphicalComponent); + + // System.out.println("----------------------------"); + // System.out.println(graphicalComponent.getLocation()); + // System.out.println(component); + // System.out.println(graphicalComponent.getContentPane().getBounds()); + // System.out.println(graphicalComponent.getFigure().getBounds()); + // System.out.println(graphicalComponent.getMainFigure().getBounds()); + // System.out.println(graphicalComponent.getBorderedFigure().getBounds()); + // System.out.println(graphicalComponent.getPrimaryShape().getBounds()); + // System.out.println(graphicalComponent.getPrimaryShape().getLocation()); + + Point point = new Point(x, y); + + Point parentPoint = getOwnerPosition(graphicalComponent.getParent()); + + System.out.println("parentPoint: " + parentPoint); + + point.x = point.x + parentPoint.x; + point.y = point.y + parentPoint.y; + + return point; + } + + private Object printlnGraphicalPosition(Object component) { + if (component instanceof GraphicalEditPart) { + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + System.out.println("-------printlnGraphicalPosition------------"); + System.out.println(graphicalComponent); + System.out.println(graphicalComponent.getFigure().getBounds()); + return printlnGraphicalPosition(graphicalComponent.getParent()); + } + return null; + } + + /* + * @Override public Point getGraphicalComponentPosition(Object component) { + * + * GraphicalEditPart graphicalComponent = (GraphicalEditPart)component; + * + * int x =0; int y =0; if(!(component instanceof + * StructureCompartmentEditPart)){ x = + * graphicalComponent.getFigure().getBounds().x; y = + * graphicalComponent.getFigure().getBounds().y; } + * + * + * System.out.println("----------------------------"); + * //System.out.println(graphicalComponent.getLocation()); + * System.out.println(component); + * //System.out.println(graphicalComponent.getContentPane().getBounds()); + * System.out.println(graphicalComponent.getFigure().getBounds()); + * //System.out.println(graphicalComponent.getMainFigure().getBounds()); + * //System.out.println(graphicalComponent.getBorderedFigure().getBounds()); + * //System.out.println(graphicalComponent.getPrimaryShape().getBounds()); + * //System.out.println(graphicalComponent.getPrimaryShape().getLocation()); + * + * + * Point point = new Point(x, y); + * + * if(graphicalComponent.getParent() instanceof GraphicalEditPart){ Point + * parentPoint = + * getGraphicalComponentPosition(graphicalComponent.getParent()); + * point.x=point.x+parentPoint.x; point.y=point.y+parentPoint.y; } return + * point; } + */ + + + private Point getOwnerPosition(Object component) { + + if (component instanceof GraphicalEditPart) { + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + if (component instanceof StructureCompartmentEditPart) { + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + Point point = new Point(x, y); + return point; + } + if (component instanceof ClassCompositeCompartmentEditPart) { + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + Point point = new Point(x, y); + return point; + } + + return getOwnerPosition(graphicalComponent.getParent()); + } else { + return new Point(0, 0); + } + } + + @Override + public boolean isGraphicalPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public boolean isGraphicalInputPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isInputPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isInputPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public boolean isGraphicalOutputPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isOutputPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isOutputPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public String getGraphicalPortName(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return ((Port) ((FlowPortAffixedNodeEditPart) port).getUMLElement()).getName(); + } + if (port instanceof ResizablePortEditPart) { + return ((Port) ((ResizablePortEditPart) port).getUMLElement()).getName(); + } + return null; + } + + + + @Override + public Object getGraphicalPortVariableType(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return ((Port) ((FlowPortAffixedNodeEditPart) port).getUMLElement()).getType().getName(); + } + if (port instanceof ResizablePortEditPart) { + return ((Port) ((ResizablePortEditPart) port).getUMLElement()).getType().getName(); + } + return null; + } + + @Override + public Point getGraphicalPortPosition(Object port) { + + // org.eclipse.draw2d.geometry.Point p = + // ((FlowPortAffixedNodeEditPart)Port).getLocation(); + // org.eclipse.draw2d.geometry.Point p = + // ((GraphicalEditPart)Port).getFigure().getBounds(); + int x = ((GraphicalEditPart) port).getFigure().getBounds().x; + int y = ((GraphicalEditPart) port).getFigure().getBounds().y; + + // System.out.println("port bounds: + // "+((FlowPortAffixedNodeEditPart)Port).getFigure().getBounds()); + // System.out.println("port loc: "+p); + + // Point point = new Point(p.x, p.y); + Point point = new Point(x, y); + + // GraphicalEditPart portParent = + // (GraphicalEditPart)((GraphicalEditPart)Port).getParent(); + // Point partentPoint = + // getGraphicalComponentPosition(portParent.getParent()); + Point partentPoint = getOwnerPosition(port); + + point.x = point.x + partentPoint.x; + point.y = point.y + partentPoint.y; + return point; + } + + @Override + public Dimension getGraphicalPortDimension(Object port) { + + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) port).getFigure().getSize(); + Dimension dim = new Dimension(domension.width, domension.height); + + return dim; + } + + @Override + public EOrientation getGraphicalPortOffsetOrientation(Object port) { + + int or = 0; + if (port instanceof FlowPortAffixedNodeEditPart) { + or = ((FlowPortAffixedNodeEditPart) port).getBorderItemLocator().getCurrentSideOfParent(); + } + if (port instanceof ResizablePortEditPart) { + or = ((ResizablePortEditPart) port).getBorderItemLocator().getCurrentSideOfParent(); + } + System.out.println("or: " + or); + + EOrientation eOrientation = new EOrientation(); + Point p = getGraphicalPortPosition(port); + int offset = 0; + Orientation orientation = Orientation.NORTH_VALUE; + + switch (or) { + case 1: + orientation = Orientation.NORTH_VALUE; + offset = p.x; + break; + case 4: + orientation = Orientation.SOUTH_VALUE; + offset = p.x; + break; + case 8: + orientation = Orientation.WEST_VALUE; + offset = p.y; + break; + case 16: + orientation = Orientation.EAST_VALUE; + offset = p.y; + break; + } + + eOrientation.setOrientation(orientation); + eOrientation.setOffset(offset); + return eOrientation; + } + + @SuppressWarnings("unchecked") + @Override + public List<?> getPortChannels(Object graphicalComponent) { + + System.out.println("getPortConnections"); + List<Object> connections = new ArrayList<Object>(); + + if (graphicalComponent instanceof GraphicalEditPart) { + + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + for (Object child : children) { + if (child instanceof FlowPortAffixedNodeEditPart) { + GraphicalEditPart graphicalPort = (GraphicalEditPart) child; + connections.addAll(graphicalPort.getSourceConnections()); + + } + if (child instanceof ResizablePortEditPart) { + GraphicalEditPart graphicalPort = (GraphicalEditPart) child; + connections.addAll(graphicalPort.getSourceConnections()); + + } + } + + for (Object subComponents : getGraphicalSubComponents(graphicalComponent)) { + connections.addAll(getPortChannels(subComponents)); + /* + * List children + * =((GraphicalEditPart)subComponents).getChildren(); for(Object + * child : children){ if(child instanceof + * FlowPortAffixedNodeEditPart){ GraphicalEditPart graphicalPort + * = (GraphicalEditPart) child; + * System.out.println("child: "+child); + * connections.addAll(graphicalPort.getSourceConnections()); + * connections.addAll(graphicalPort.getTargetConnections()); + * + * } } + */ + } + + } + System.out.println("connections.size: " + connections.size()); + + return connections; + } + + @Override + public String getChannelName(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((Connector) ((View) ((ConnectorEditPart) channel).getModel()).getElement()).getName(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((Connector) ((View) ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel) + .getModel()).getElement()).getName(); + } + return null; + } + + @Override + public Object getChannelTargetPort(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((ConnectorEditPart) channel).getTarget(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel).getTarget(); + } + return null; + } + + @Override + public Object getChannelSourcePort(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((ConnectorEditPart) channel).getSource(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel).getSource(); + } + return null; + } + + @Override + public ArrayList<?> getPortIncomingChannels(Object port) { + return null; + } + + @Override + public ArrayList<?> getPortOutgoingChannels(Object port) { + return null; + } + + @Override + public List<Point> getLayoutChannelPoints(Object channel) { + int[] pointList = null; + if (channel instanceof ConnectorEditPart) { + pointList = ((ConnectorEditPart) channel).getConnectionFigure().getPoints().toIntArray(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + pointList = ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel) + .getConnectionFigure().getPoints().toIntArray(); + } + List<Point> points = new ArrayList<Point>(); + + for (int i = 0; i < pointList.length; i = i + 2) { + Point p = new Point(pointList[i], pointList[i + 1]); + points.add(p); + } + + return points; + } + + @Override + public Object getChannelOwner(Object channel) { + return ((GraphicalEditPart) channel).getParent(); + } + + + + @Override + public String getGraphicalPortRange(Object component, Object port) { + return "PortRange"; + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/1e/1eebefe6058f80658443eda797831536021aca09.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/1e/1eebefe6058f80658443eda797831536021aca09.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..93d2668164bc2881fb7c63d3efecc328a04156ba --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/1e/1eebefe6058f80658443eda797831536021aca09.svn-base @@ -0,0 +1,225 @@ +package org.polarsys.chess.diagram.ui.services; + +import java.io.File; +import java.net.MalformedURLException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockCompositeEditPart; +import org.eclipse.papyrus.sysml.diagram.internalblock.edit.part.InternalBlockDiagramEditPart; +import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.part.BlockDefinitionDiagramEditPart; +import org.apache.commons.io.FilenameUtils; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.RootEditPart; +import org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.uml2.uml.Class; + +import eu.fbk.eclipse.standardtools.diagram.ContainterDescriptor; +import eu.fbk.eclipse.standardtools.diagram.DiagramDescriptor; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.BlockDefinitionDiagramGeneratorService; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.InternalBlockDiagramGeneratorService; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractBlockDefinitionDiagramModel; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractInternalBlockDiagramModel; + +public class CHESSDiagramsGeneratorService { + + private static CHESSDiagramsGeneratorService instance; + + final private static String IBD = "InternalBlock"; + final private static String BDD = "BlockDefinition"; + + public static CHESSDiagramsGeneratorService getInstance(AbstractInternalBlockDiagramModel ibdModel,AbstractBlockDefinitionDiagramModel bddModel){ + if(instance==null){ + instance = new CHESSDiagramsGeneratorService(ibdModel, bddModel); + } + return instance; + } + + + + public CHESSDiagramsGeneratorService(AbstractInternalBlockDiagramModel ibdModel, AbstractBlockDefinitionDiagramModel bddModel) { + super(); + //graphicalModel = graphModel; + ibdGeneratorService = InternalBlockDiagramGeneratorService.getInstance(ibdModel); + bddGeneratorService = BlockDefinitionDiagramGeneratorService.getInstance(bddModel); + } + + + + //private static AbstractDiagramModel graphicalModel; + private InternalBlockDiagramGeneratorService ibdGeneratorService; + private BlockDefinitionDiagramGeneratorService bddGeneratorService; + + + private String directoryName; + private String imageExtension; + + + + public void setParametersBeforeDiagramsGenerator( + String directoryName, String imageExtension, + boolean showPortLabels, boolean automaticLabelLayout) { + + this.directoryName=directoryName; + this.imageExtension=imageExtension; + + + ibdGeneratorService.setParametersBeforeDiagramGenerator(showPortLabels, automaticLabelLayout); + + } + + public DiagramDescriptor createDiagramWithDescriptor(Diagram diagram, IProgressMonitor monitor){ + EObject diagramOwner = DiagramUtils.getOwner(diagram); + String diagramName = ""; + String ownerName = null; + boolean hasComponentOwner = true; + if(diagramOwner instanceof Class){ + ownerName = ((Class)diagramOwner).getName(); + diagramName = ownerName+"_"+diagram.getName(); + }else{ + hasComponentOwner = false; + diagramName = diagram.getName(); + } + + //if(diagram.getName().compareTo("Contracts")!=0){ + createDiagram(diagram,diagramName, monitor); + //} + return createDiagramDescriptor(diagramName,ownerName,hasComponentOwner ); + } + + + + private void createDiagram(Diagram diagram,String diagramName, IProgressMonitor monitor){ + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + System.out.println("diagram name: "+diagram.getName()); + System.out.println("diagram type: "+diagram.getType()); + + EditPart editPart = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagram, shell); + + RootEditPart root = editPart.getRoot(); + System.out.println("root: "+root); + + if(isInternalBlockDiagram(diagram)){ + InternalBlockDiagramEditPart idb = (InternalBlockDiagramEditPart) root.getChildren().get(0); + BlockCompositeEditPart graphicalComponent = (BlockCompositeEditPart)idb.getChildren().get(0); + + ibdGeneratorService.createDiagramFile(getComponentImageFilePath(diagramName), graphicalComponent, monitor); + }else if(isBlockDefinitionDiagram(diagram)){ + System.out.println("isBlockDefinitionDiagram"); + BlockDefinitionDiagramEditPart bdd = (BlockDefinitionDiagramEditPart) root.getChildren().get(0); + for(Object o : bdd.getChildren()){ + System.out.println("o: "+o); + } + + bddGeneratorService.createDiagramFile(getComponentImageFilePath(diagramName), bdd, monitor); + + } + } + + private DiagramDescriptor createDiagramDescriptor(String diagramName, String ownerName, boolean hasComponentOwner){ + String saveFilePath = getComponentImageFilePath(diagramName); + System.out.println("saveFilePath: "+saveFilePath); + // diagramGeneratorService.createDiagramFile(saveFilePath, component, + // monitor); + final DiagramDescriptor diagramDescriptor = //diagramGeneratorService. + createDiagramDescriptorWithImageFileUrl(diagramName, saveFilePath,ownerName,hasComponentOwner); + return diagramDescriptor; + } + + private DiagramDescriptor createDiagramDescriptorWithImageFileUrl(String diagramName, String saveFilePath,String owner,boolean hasComponentOwner) { + DiagramDescriptor diagramDescriptor = new DiagramDescriptor(); + diagramDescriptor.name = diagramName; + diagramDescriptor.hasComponentOwner = hasComponentOwner; + if(owner!=null){ + diagramDescriptor.ownerName = owner; + } + String diagramFileName; + try { + diagramFileName = new File(saveFilePath).toURI().toURL().getFile(); + } catch (MalformedURLException e) { + return null; + } + + diagramDescriptor.url = FilenameUtils.getName(diagramFileName); + + return diagramDescriptor; + } + + public Collection<Diagram> getDiagrams() { + + NotationModel notationModel = NotationUtils.getNotationModel(); + Set<Diagram> diagrams = getIBD_BDD_Diagrams(notationModel.getResources()); + System.out.println("diagrams"); + for (Diagram c : diagrams) { + System.out.println(c); + } + return diagrams; + + } + + public Set<Diagram> getDiagrams(Set<Resource> resources){ + + Set<Diagram> diagrams = new HashSet<Diagram>(); + + for (Resource current : resources) { + for (EObject element : current.getContents()) { + if (element instanceof Diagram) { + diagrams.add((Diagram)element); + } + } + } + + return diagrams; + } + +private Set<Diagram> getIBD_BDD_Diagrams(Set<Resource> resources){ + + Set<Diagram> diagrams = new HashSet<Diagram>(); + + for (Resource current : resources) { + for (EObject element : current.getContents()) { + if (element instanceof Diagram) { + Diagram diagram = (Diagram)element; + System.out.println("diagram type: "+diagram.getType()); + + if (isBlockDefinitionDiagram(diagram)||isInternalBlockDiagram(diagram)){ + diagrams.add((Diagram)element); + } + } + } + } + + return diagrams; + } + + +private boolean isBlockDefinitionDiagram(Diagram diagram){ + if(diagram.getType().compareTo(BDD)==0){ + return true; + } + return false; +} + +private boolean isInternalBlockDiagram(Diagram diagram){ + if(diagram.getType().compareTo(IBD)==0){ + return true; + } + return false; +} + + private String getComponentImageFilePath(String fileName) { + return directoryName + File.separator + fileName + imageExtension; + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/1f/1f168a040520316d3b229f602d226d665b8caf23.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/1f/1f168a040520316d3b229f602d226d665b8caf23.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..936a603d8174c97c1120a4e24dffe70a9a956813 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/1f/1f168a040520316d3b229f602d226d665b8caf23.svn-base @@ -0,0 +1,90 @@ +/******************************************************************************* + * 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.diagram.ui.commands; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSDiagramModel; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ModelToDocumentDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DocumentGeneratorService; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; + +/** + * + * @author Alberto + */ +public class ExportModelToDocumentCommand extends AbstractAsyncJobCommand { + + public ExportModelToDocumentCommand() { + super("Export Model To Document"); + } + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + //private OCRAComponentToImage ocraComponentToImage = OCRAComponentToImage.getInstance(); + private DocumentGeneratorService documentGeneratorService = DocumentGeneratorService.getInstance(CHESSDiagramModel.getInstance()); + + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + GraphicalEditPart selectedGraphicalComponent = selectionUtil.getSelectedGraphicalObject(event); + + if (selectedGraphicalComponent != null) { + + System.out.println("selectedGraphicalComponent: " + selectedGraphicalComponent); + + ModelToDocumentDialog parameterDialog = exportDialogUtils.getCompiledModelToDocumentDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String docFormat = parameterDialog.getDocumentFormat(); + String imageExtension = ".svg"; + if (docFormat.equals("tex")) { + imageExtension = ".png"; + } + + // setShowLeafComponents(showLeafComponents); + String outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + // setDirectoryName(directoryName); + if ((outputDirectoryName == null) || outputDirectoryName.isEmpty()) { + return; + } + + String currentProjectName = directoryUtils.getCurrentProjectName(); + + documentGeneratorService.setParametersBeforeDocumentGeneration + //setParametersBeforeExport + (parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout(), + outputDirectoryName, imageExtension,parameterDialog.getShowLeafComponents()); + + // ocraComponentToImage.setXTranslation(150); + // ocraComponentToImage.setYTranslation(100); + + documentGeneratorService.createDocumentFile(currentProjectName, docFormat, selectedGraphicalComponent, + monitor); + + exportDialogUtils.showMessage_ExportDone(outputDirectoryName); + + } + + } + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/2f/2f82f1f0c3d4b33f3bf3f5fb36a563dd02d30c22.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/2f/2f82f1f0c3d4b33f3bf3f5fb36a563dd02d30c22.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..047cc4ddf74c37db62b63004e403a4938193aeed --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/2f/2f82f1f0c3d4b33f3bf3f5fb36a563dd02d30c22.svn-base @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.polarsys.chess.diagram.ui</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> diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/3a/3a00dcc8bf9f1745d1cc4215f1d5a4a13b0591ac.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/3a/3a00dcc8bf9f1745d1cc4215f1d5a4a13b0591ac.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6c02481e3a0e4f101276f0812e72396cc908ab91 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/3a/3a00dcc8bf9f1745d1cc4215f1d5a4a13b0591ac.svn-base @@ -0,0 +1,497 @@ +/******************************************************************************* + * 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.diagram.ui.docGenerators; + +import java.awt.Dimension; +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.StructureCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorEditPart; +import org.eclipse.papyrus.uml.diagram.common.editparts.IUMLEditPart; +import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.CustomPropertyPartEditPartCN; +import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.ResizablePortEditPart; +import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeCompartmentEditPart; +import org.eclipse.uml2.uml.Connector; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Port; +import org.polarsys.chess.utils.EntityUtil; + +import eu.fbk.eclipse.standardtools.diagram.ui.layout.EOrientation; +import eu.fbk.eclipse.standardtools.diagram.ui.layout.EOrientation.Orientation; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractDiagramModel; + +public class CHESSDiagramModel implements AbstractDiagramModel{ + + + private static CHESSDiagramModel chessModel; + + public static CHESSDiagramModel getInstance(){ + if(chessModel == null){ + chessModel = new CHESSDiagramModel(); + } + return chessModel; + } + + + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String getGraphicalComponentId(Object graphicalComponent) { + Element umlElement = null; + /* + * if(graphicalComponent instanceof BlockCompositeEditPart){ umlElement + * = ((BlockCompositeEditPart)graphicalComponent).getUMLElement(); } + * if(graphicalComponent instanceof BlockPropertyCompositeEditPart){ + * umlElement = + * ((BlockPropertyCompositeEditPart)graphicalComponent).getUMLElement(); + * } + */ + if (graphicalComponent instanceof IUMLEditPart) { + umlElement = ((IUMLEditPart) graphicalComponent).getUMLElement(); + } + return entityUtil.getComponentID(umlElement); + } + + @Override + public String getGraphicalComponentName(Object graphicalComponent) { + EObject component = ((GraphicalEditPart) graphicalComponent).resolveSemanticElement(); + + // ((AppliedStereotypeEmptyEditPart)graphicalComponent).get + + return entityUtil.getComponentName(component); + } + + @Override + public List<GraphicalEditPart> getGraphicalSubComponents(Object graphicalComponent) { + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + List<GraphicalEditPart> graphicalSubComponent = new ArrayList<GraphicalEditPart>(); + for (Object child : children) { + System.out.println("child: " + child); + if (child instanceof StructureCompartmentEditPart) { + for (Object componentChild : ((StructureCompartmentEditPart) child).getChildren()) { + System.out.println("StructureCompartmentEditPart child: " + componentChild); + if (componentChild instanceof BlockPropertyCompositeEditPart) { + graphicalSubComponent.add((GraphicalEditPart) componentChild); + } + } + } + if (child instanceof ClassCompositeCompartmentEditPart) { + for (Object componentChild : ((ClassCompositeCompartmentEditPart) child).getChildren()) { + System.out.println("StructureCompartmentEditPart child: " + componentChild); + if (componentChild instanceof CustomPropertyPartEditPartCN) { + graphicalSubComponent.add((GraphicalEditPart) componentChild); + } + } + } + } + return graphicalSubComponent; + } + + @Override + public Object getGraphicalOwnerComponents(Object graphicalComponent) { + return ((GraphicalEditPart) graphicalComponent).getParent(); + } + + @Override + public List<?> getGraphicalPorts(Object graphicalComponent) { + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + List<GraphicalEditPart> graphicalConnectors = new ArrayList<GraphicalEditPart>(); + for (Object child : children) { + if (child instanceof FlowPortAffixedNodeEditPart) { + graphicalConnectors.add((GraphicalEditPart) child); + } + if (child instanceof ResizablePortEditPart) { + graphicalConnectors.add((GraphicalEditPart) child); + } + } + return graphicalConnectors; + } + + @Override + public Object getGraphicalPortOwner(Object port) { + return ((GraphicalEditPart) port).getParent(); + } + + @Override + public Dimension getGraphicalComponentDimension(Object component) { + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) component).getFigure().getSize(); + Dimension d = new Dimension(domension.width, domension.height); + return d; + } + + @Override + public Point getGraphicalComponentPosition(Object component) { + + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + + printlnGraphicalPosition(graphicalComponent); + + // System.out.println("----------------------------"); + // System.out.println(graphicalComponent.getLocation()); + // System.out.println(component); + // System.out.println(graphicalComponent.getContentPane().getBounds()); + // System.out.println(graphicalComponent.getFigure().getBounds()); + // System.out.println(graphicalComponent.getMainFigure().getBounds()); + // System.out.println(graphicalComponent.getBorderedFigure().getBounds()); + // System.out.println(graphicalComponent.getPrimaryShape().getBounds()); + // System.out.println(graphicalComponent.getPrimaryShape().getLocation()); + + Point point = new Point(x, y); + + Point parentPoint = getOwnerPosition(graphicalComponent.getParent()); + + System.out.println("parentPoint: " + parentPoint); + + point.x = point.x + parentPoint.x; + point.y = point.y + parentPoint.y; + + return point; + } + + private Object printlnGraphicalPosition(Object component) { + if (component instanceof GraphicalEditPart) { + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + System.out.println("-------printlnGraphicalPosition------------"); + System.out.println(graphicalComponent); + System.out.println(graphicalComponent.getFigure().getBounds()); + return printlnGraphicalPosition(graphicalComponent.getParent()); + } + return null; + } + + /* + * @Override public Point getGraphicalComponentPosition(Object component) { + * + * GraphicalEditPart graphicalComponent = (GraphicalEditPart)component; + * + * int x =0; int y =0; if(!(component instanceof + * StructureCompartmentEditPart)){ x = + * graphicalComponent.getFigure().getBounds().x; y = + * graphicalComponent.getFigure().getBounds().y; } + * + * + * System.out.println("----------------------------"); + * //System.out.println(graphicalComponent.getLocation()); + * System.out.println(component); + * //System.out.println(graphicalComponent.getContentPane().getBounds()); + * System.out.println(graphicalComponent.getFigure().getBounds()); + * //System.out.println(graphicalComponent.getMainFigure().getBounds()); + * //System.out.println(graphicalComponent.getBorderedFigure().getBounds()); + * //System.out.println(graphicalComponent.getPrimaryShape().getBounds()); + * //System.out.println(graphicalComponent.getPrimaryShape().getLocation()); + * + * + * Point point = new Point(x, y); + * + * if(graphicalComponent.getParent() instanceof GraphicalEditPart){ Point + * parentPoint = + * getGraphicalComponentPosition(graphicalComponent.getParent()); + * point.x=point.x+parentPoint.x; point.y=point.y+parentPoint.y; } return + * point; } + */ + + + private Point getOwnerPosition(Object component) { + + if (component instanceof GraphicalEditPart) { + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + if (component instanceof StructureCompartmentEditPart) { + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + Point point = new Point(x, y); + return point; + } + if (component instanceof ClassCompositeCompartmentEditPart) { + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + Point point = new Point(x, y); + return point; + } + + return getOwnerPosition(graphicalComponent.getParent()); + } else { + return new Point(0, 0); + } + } + + @Override + public boolean isGraphicalPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public boolean isGraphicalInputPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isInputPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isInputPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public boolean isGraphicalOutputPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isOutputPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isOutputPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public String getGraphicalPortName(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return ((Port) ((FlowPortAffixedNodeEditPart) port).getUMLElement()).getName(); + } + if (port instanceof ResizablePortEditPart) { + return ((Port) ((ResizablePortEditPart) port).getUMLElement()).getName(); + } + return null; + } + + + + @Override + public Object getGraphicalPortVariableType(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return ((Port) ((FlowPortAffixedNodeEditPart) port).getUMLElement()).getType().getName(); + } + if (port instanceof ResizablePortEditPart) { + return ((Port) ((ResizablePortEditPart) port).getUMLElement()).getType().getName(); + } + return null; + } + + @Override + public Point getGraphicalPortPosition(Object port) { + + // org.eclipse.draw2d.geometry.Point p = + // ((FlowPortAffixedNodeEditPart)Port).getLocation(); + // org.eclipse.draw2d.geometry.Point p = + // ((GraphicalEditPart)Port).getFigure().getBounds(); + int x = ((GraphicalEditPart) port).getFigure().getBounds().x; + int y = ((GraphicalEditPart) port).getFigure().getBounds().y; + + // System.out.println("port bounds: + // "+((FlowPortAffixedNodeEditPart)Port).getFigure().getBounds()); + // System.out.println("port loc: "+p); + + // Point point = new Point(p.x, p.y); + Point point = new Point(x, y); + + // GraphicalEditPart portParent = + // (GraphicalEditPart)((GraphicalEditPart)Port).getParent(); + // Point partentPoint = + // getGraphicalComponentPosition(portParent.getParent()); + Point partentPoint = getOwnerPosition(port); + + point.x = point.x + partentPoint.x; + point.y = point.y + partentPoint.y; + return point; + } + + @Override + public Dimension getGraphicalPortDimension(Object port) { + + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) port).getFigure().getSize(); + Dimension dim = new Dimension(domension.width, domension.height); + + return dim; + } + + @Override + public EOrientation getGraphicalPortOffsetOrientation(Object port) { + + int or = 0; + if (port instanceof FlowPortAffixedNodeEditPart) { + or = ((FlowPortAffixedNodeEditPart) port).getBorderItemLocator().getCurrentSideOfParent(); + } + if (port instanceof ResizablePortEditPart) { + or = ((ResizablePortEditPart) port).getBorderItemLocator().getCurrentSideOfParent(); + } + System.out.println("or: " + or); + + EOrientation eOrientation = new EOrientation(); + Point p = getGraphicalPortPosition(port); + int offset = 0; + Orientation orientation = Orientation.NORTH_VALUE; + + switch (or) { + case 1: + orientation = Orientation.NORTH_VALUE; + offset = p.x; + break; + case 4: + orientation = Orientation.SOUTH_VALUE; + offset = p.x; + break; + case 8: + orientation = Orientation.WEST_VALUE; + offset = p.y; + break; + case 16: + orientation = Orientation.EAST_VALUE; + offset = p.y; + break; + } + + eOrientation.setOrientation(orientation); + eOrientation.setOffset(offset); + return eOrientation; + } + + @SuppressWarnings("unchecked") + @Override + public List<?> getPortChannels(Object graphicalComponent) { + + System.out.println("getPortConnections"); + List<Object> connections = new ArrayList<Object>(); + + if (graphicalComponent instanceof GraphicalEditPart) { + + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + for (Object child : children) { + if (child instanceof FlowPortAffixedNodeEditPart) { + GraphicalEditPart graphicalPort = (GraphicalEditPart) child; + connections.addAll(graphicalPort.getSourceConnections()); + + } + if (child instanceof ResizablePortEditPart) { + GraphicalEditPart graphicalPort = (GraphicalEditPart) child; + connections.addAll(graphicalPort.getSourceConnections()); + + } + } + + for (Object subComponents : getGraphicalSubComponents(graphicalComponent)) { + connections.addAll(getPortChannels(subComponents)); + /* + * List children + * =((GraphicalEditPart)subComponents).getChildren(); for(Object + * child : children){ if(child instanceof + * FlowPortAffixedNodeEditPart){ GraphicalEditPart graphicalPort + * = (GraphicalEditPart) child; + * System.out.println("child: "+child); + * connections.addAll(graphicalPort.getSourceConnections()); + * connections.addAll(graphicalPort.getTargetConnections()); + * + * } } + */ + } + + } + System.out.println("connections.size: " + connections.size()); + + return connections; + } + + @Override + public String getChannelName(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((Connector) ((View) ((ConnectorEditPart) channel).getModel()).getElement()).getName(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((Connector) ((View) ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel) + .getModel()).getElement()).getName(); + } + return null; + } + + @Override + public Object getChannelTargetPort(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((ConnectorEditPart) channel).getTarget(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel).getTarget(); + } + return null; + } + + @Override + public Object getChannelSourcePort(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((ConnectorEditPart) channel).getSource(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel).getSource(); + } + return null; + } + + @Override + public ArrayList<?> getPortIncomingChannels(Object port) { + return null; + } + + @Override + public ArrayList<?> getPortOutgoingChannels(Object port) { + return null; + } + + @Override + public List<Point> getLayoutChannelPoints(Object channel) { + int[] pointList = null; + if (channel instanceof ConnectorEditPart) { + pointList = ((ConnectorEditPart) channel).getConnectionFigure().getPoints().toIntArray(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + pointList = ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel) + .getConnectionFigure().getPoints().toIntArray(); + } + List<Point> points = new ArrayList<Point>(); + + for (int i = 0; i < pointList.length; i = i + 2) { + Point p = new Point(pointList[i], pointList[i + 1]); + points.add(p); + } + + return points; + } + + @Override + public Object getChannelOwner(Object channel) { + return ((GraphicalEditPart) channel).getParent(); + } + + + + @Override + public String getGraphicalPortRange(Object component, Object port) { + return "PortRange"; + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6f20375d6c7d98fbc80bb5da99be9866b1fe2f73 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/46/46337eeb9d7e0ff6f33e5d2b0b99e9672daa8b49.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/46/46337eeb9d7e0ff6f33e5d2b0b99e9672daa8b49.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..fa5c9a02d47d63e38ea7405ef1374d4ff3c466a2 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/46/46337eeb9d7e0ff6f33e5d2b0b99e9672daa8b49.svn-base @@ -0,0 +1,244 @@ +package org.polarsys.chess.diagram.ui.docGenerators; + +import java.awt.Dimension; +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.notation.LayoutConstraint; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.css.CSSDecorationNodeImpl; +import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.part.BlockDefinitionDiagramEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.AssociationEditPart; +import org.eclipse.papyrus.sysml.diagram.common.figure.AssociationFigure; +import org.eclipse.uml2.uml.Association; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractBlockDefinitionDiagramModel; + +public class CHESSBlockDefinitionDiagramModel implements AbstractBlockDefinitionDiagramModel{ + + private static CHESSBlockDefinitionDiagramModel instance; + + public static CHESSBlockDefinitionDiagramModel getInstance(){ + if(instance==null){ + instance = new CHESSBlockDefinitionDiagramModel(); + } + return instance; + } + + private EntityUtil entityUtil = EntityUtil.getInstance(); + + + @Override + public String getGraphicalComponentName(Object graphicalComponent) { + + if(graphicalComponent instanceof EditPart){ + System.out.println("is instanceof EditPart"); + } + if(graphicalComponent instanceof GraphicalEditPart){ + System.out.println("is instanceof GraphicalEditPart"); + } + + EObject component = ((GraphicalEditPart) graphicalComponent).resolveSemanticElement(); + return entityUtil.getComponentName(component); + } + + @Override + public List<?> getGraphicalComponentsOfBDD(Object graphicalComponent) { + + System.out.println("getGraphicalComponentsOfBDD"); + + if(graphicalComponent instanceof EditPart){ + System.out.println("is instanceof EditPart"); + } + if(graphicalComponent instanceof GraphicalEditPart){ + System.out.println("is instanceof GraphicalEditPart"); + } + if(graphicalComponent instanceof BlockDefinitionDiagramEditPart){ + System.out.println("is instanceof BlockDefinitionDiagramEditPart"); + + for(Object o : ((BlockDefinitionDiagramEditPart)graphicalComponent).getChildren()){ + System.out.println("child: "+o); + } + return ((BlockDefinitionDiagramEditPart)graphicalComponent).getChildren(); + } + return null; + } + + @Override + public Dimension getGraphicalComponentDimension(Object graphicalComponent) { + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) graphicalComponent).getFigure().getSize(); + Dimension d = new Dimension(domension.width, domension.height); + return d; + } + + @Override + public Point getGraphicalComponentPosition(Object component) { + + /* if(component instanceof EditPart){ + for(Object o : ((EditPart)component).getChildren()){ + System.out.println("child of component: "+o); + } + }*/ + + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + + Point point = new Point(x, y); + + //Point parentPoint = getOwnerPosition(graphicalComponent.getParent()); + + //System.out.println("parentPoint: " + parentPoint); + + //point.x = point.x + parentPoint.x; + //point.y = point.y + parentPoint.y; + + return point; + } + + @Override + public List<?> getCompositionAssociations(Object graphicalComponent) { + if(graphicalComponent instanceof BlockDefinitionDiagramEditPart){ + System.out.println("is instanceof BlockDefinitionDiagramEditPart"); + + for(Object o : ((BlockDefinitionDiagramEditPart)graphicalComponent).getConnections()){ + System.out.println("connections: "+o); + } + return ((BlockDefinitionDiagramEditPart)graphicalComponent).getConnections(); + } + return null; + } + + @Override + public String getCompositionAssociationName(Object channel) { + AssociationEditPart association = ((AssociationEditPart)channel); + System.out.println("association.getModel(): "+association.getModel()); + View v = ((View) association.getModel()); + System.out.println("v.getElement(): "+v.getElement()); + Association associationEleemnt = (Association)v.getElement(); + return associationEleemnt.getName(); + } + + @Override + public List<Point> getLayoutCompositionAssociationPoints(Object channel) { + int[] pointList = null; + List<Point> points = new ArrayList<Point>(); + + AssociationEditPart association = ((AssociationEditPart)channel); + //pointList = association.getConnectionFigure().getPoints().toIntArray(); + + + AssociationFigure associationFigure = (AssociationFigure)association.getFigure(); + pointList =associationFigure.getPolygonPoints().toIntArray(); + //pointList =associationFigure.getPoints().toIntArray(); + + System.out.println("points"); + for (int i = 0; i < pointList.length; i = i + 2) { + Point p = new Point(pointList[i], pointList[i + 1]); + System.out.println("p: "+p); + points.add(p); + } + + return points; + } + + @Override + public Point getCompositionAssociationLabelPosition(Object graphicalLabel) { + + PapyrusWrappingLabel lab = (PapyrusWrappingLabel)graphicalLabel; + + org.eclipse.draw2d.geometry.Point labelPoint = lab.getLocation(); + return new Point(labelPoint.x, labelPoint.y); + /* AssociationEditPart association = ((AssociationEditPart)graphicalAssociation); + + for(Object o : association.getNotationView().getVisibleChildren()) + { + CSSDecorationNodeImpl decNode = (CSSDecorationNodeImpl)o; + + System.out.println("o: "+o); + + for(Object o2:decNode.getPersistedChildren()){ + System.out.println("getPersistedChildren: "+o2); + } + + for(Object o2:decNode.getSourceEdges()){ + System.out.println("getSourceEdges: "+o2); + } + + for(Object o2:decNode.getTargetEdges()){ + System.out.println("getTargetEdges: "+o2); + } + + LayoutConstraint lc = decNode.getLayoutConstraint(); + + } + + + + for(Object o : association.getConnectionFigure().getChildren()) + { + PapyrusWrappingLabel lab = (PapyrusWrappingLabel)o; + lab.getText(); + lab.getLocation() + System.out.println(o.getClass()); + System.out.println("getConnectionFigure().getChildren(): "+o); + } + + + + org.eclipse.draw2d.geometry.Point midPoint = association.getConnectionFigure().getPoints().getMidpoint(); + return new Point(midPoint.x, midPoint.y);*/ + + + } + + + + @Override + public String getCompositionAssociationLabelText(Object graphicalLabel) { + PapyrusWrappingLabel lab = (PapyrusWrappingLabel)graphicalLabel; + return lab.getText(); + } + + @Override + public List<?> getCompositionAssociationsLabels(Object graphicalAssociation) { + AssociationEditPart association = ((AssociationEditPart)graphicalAssociation); + + List<PapyrusWrappingLabel> labels = new ArrayList<PapyrusWrappingLabel>(); + for(Object o : association.getConnectionFigure().getChildren()) + { + //System.out.println("o.getClass(): "+o.getClass()); + //System.out.println("getConnectionFigure().getChildren(): "+o); + if(o instanceof PapyrusWrappingLabel){ + PapyrusWrappingLabel lab = (PapyrusWrappingLabel)o; + //System.out.println("lab: "+lab); + //System.out.println("lab.text: "+lab.getText()); + //System.out.println("lab.isShowing(): "+lab.isShowing()); + //System.out.println("lab.isVisible():"+lab.isVisible()); + // System.out.println("lab.isEnabled(): "+lab.isEnabled()); + if((lab.getText().compareTo("")!=0)&(lab.isShowing())){ + labels.add(lab); + } + } + + } + + return labels; + + } + + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..295926d964165896ea8aa7c1b1b3c9d3d3caa77e --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base @@ -0,0 +1,7 @@ +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 diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/58/58255b80eccc134fcea0aede9eadb349e3fd54be.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/58/58255b80eccc134fcea0aede9eadb349e3fd54be.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..5c22a1a5a98f89071d7f310c9e17ca580a444e9b --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/58/58255b80eccc134fcea0aede9eadb349e3fd54be.svn-base @@ -0,0 +1,229 @@ +package org.polarsys.chess.diagram.ui.services; + +import java.io.File; +import java.net.MalformedURLException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockCompositeEditPart; +import org.eclipse.papyrus.sysml.diagram.internalblock.edit.part.InternalBlockDiagramEditPart; +import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.part.BlockDefinitionDiagramEditPart; +import org.apache.commons.io.FilenameUtils; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.RootEditPart; +import org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.uml2.uml.Class; + +import eu.fbk.eclipse.standardtools.diagram.ContainterDescriptor; +import eu.fbk.eclipse.standardtools.diagram.DiagramDescriptor; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.BlockDefinitionDiagramGeneratorService; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.InternalBlockDiagramGeneratorService; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractBlockDefinitionDiagramModel; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractInternalBlockDiagramModel; + +public class CHESSDiagramsGeneratorService { + + private static CHESSDiagramsGeneratorService instance; + + final private static String IBD = "InternalBlock"; + final private static String BDD = "BlockDefinition"; + + public static CHESSDiagramsGeneratorService getInstance(AbstractInternalBlockDiagramModel ibdModel,AbstractBlockDefinitionDiagramModel bddModel){ + if(instance==null){ + instance = new CHESSDiagramsGeneratorService(ibdModel, bddModel); + } + return instance; + } + + + + public CHESSDiagramsGeneratorService(AbstractInternalBlockDiagramModel ibdModel, AbstractBlockDefinitionDiagramModel bddModel) { + super(); + //graphicalModel = graphModel; + ibdGeneratorService = InternalBlockDiagramGeneratorService.getInstance(ibdModel); + bddGeneratorService = BlockDefinitionDiagramGeneratorService.getInstance(bddModel); + } + + + + //private static AbstractDiagramModel graphicalModel; + private InternalBlockDiagramGeneratorService ibdGeneratorService; + private BlockDefinitionDiagramGeneratorService bddGeneratorService; + + + private String directoryName; + private String imageExtension; + + + + public void setParametersBeforeDiagramsGenerator( + String directoryName, String imageExtension, + boolean showPortLabels, boolean automaticLabelLayout) { + + this.directoryName=directoryName; + this.imageExtension=imageExtension; + + + ibdGeneratorService.setParametersBeforeDiagramGenerator(showPortLabels, automaticLabelLayout); + + } + + public DiagramDescriptor createDiagramWithDescriptor(Diagram diagram, IProgressMonitor monitor){ + EObject diagramOwner = DiagramUtils.getOwner(diagram); + String diagramName = ""; + String ownerName = null; + boolean hasComponentOwner = true; + if(diagramOwner instanceof Class){ + ownerName = ((Class)diagramOwner).getName(); + diagramName = ownerName+"_"+diagram.getName(); + }else{ + hasComponentOwner = false; + diagramName = diagram.getName(); + } + + //if(diagram.getName().compareTo("Contracts")!=0){ + try{ + createDiagram(diagram,diagramName, monitor); + return createDiagramDescriptor(diagramName,ownerName,hasComponentOwner ); + }catch(NullPointerException e){ + System.out.println("Unable to create diagram "+diagramName); + } + return null; + } + + + + private void createDiagram(Diagram diagram,String diagramName, IProgressMonitor monitor){ + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + System.out.println("diagram name: "+diagram.getName()); + System.out.println("diagram type: "+diagram.getType()); + + EditPart editPart = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagram, shell); + + RootEditPart root = editPart.getRoot(); + System.out.println("root: "+root); + + if(isInternalBlockDiagram(diagram)){ + InternalBlockDiagramEditPart idb = (InternalBlockDiagramEditPart) root.getChildren().get(0); + BlockCompositeEditPart graphicalComponent = (BlockCompositeEditPart)idb.getChildren().get(0); + + ibdGeneratorService.createDiagramFile(getComponentImageFilePath(diagramName), graphicalComponent, monitor); + }else if(isBlockDefinitionDiagram(diagram)){ + System.out.println("isBlockDefinitionDiagram"); + BlockDefinitionDiagramEditPart bdd = (BlockDefinitionDiagramEditPart) root.getChildren().get(0); + for(Object o : bdd.getChildren()){ + System.out.println("o: "+o); + } + + bddGeneratorService.createDiagramFile(getComponentImageFilePath(diagramName), bdd, monitor); + + } + } + + private DiagramDescriptor createDiagramDescriptor(String diagramName, String ownerName, boolean hasComponentOwner){ + String saveFilePath = getComponentImageFilePath(diagramName); + System.out.println("saveFilePath: "+saveFilePath); + // diagramGeneratorService.createDiagramFile(saveFilePath, component, + // monitor); + final DiagramDescriptor diagramDescriptor = //diagramGeneratorService. + createDiagramDescriptorWithImageFileUrl(diagramName, saveFilePath,ownerName,hasComponentOwner); + return diagramDescriptor; + } + + private DiagramDescriptor createDiagramDescriptorWithImageFileUrl(String diagramName, String saveFilePath,String owner,boolean hasComponentOwner) { + DiagramDescriptor diagramDescriptor = new DiagramDescriptor(); + diagramDescriptor.name = diagramName; + diagramDescriptor.hasComponentOwner = hasComponentOwner; + if(owner!=null){ + diagramDescriptor.ownerName = owner; + } + String diagramFileName; + try { + diagramFileName = new File(saveFilePath).toURI().toURL().getFile(); + } catch (MalformedURLException e) { + return null; + } + + diagramDescriptor.url = FilenameUtils.getName(diagramFileName); + + return diagramDescriptor; + } + + public Collection<Diagram> getDiagrams() { + + NotationModel notationModel = NotationUtils.getNotationModel(); + Set<Diagram> diagrams = getIBD_BDD_Diagrams(notationModel.getResources()); + System.out.println("diagrams"); + for (Diagram c : diagrams) { + System.out.println(c); + } + return diagrams; + + } + + public Set<Diagram> getDiagrams(Set<Resource> resources){ + + Set<Diagram> diagrams = new HashSet<Diagram>(); + + for (Resource current : resources) { + for (EObject element : current.getContents()) { + if (element instanceof Diagram) { + diagrams.add((Diagram)element); + } + } + } + + return diagrams; + } + +private Set<Diagram> getIBD_BDD_Diagrams(Set<Resource> resources){ + + Set<Diagram> diagrams = new HashSet<Diagram>(); + + for (Resource current : resources) { + for (EObject element : current.getContents()) { + if (element instanceof Diagram) { + Diagram diagram = (Diagram)element; + System.out.println("diagram type: "+diagram.getType()); + + if (isBlockDefinitionDiagram(diagram)||isInternalBlockDiagram(diagram)){ + diagrams.add((Diagram)element); + } + } + } + } + + return diagrams; + } + + +private boolean isBlockDefinitionDiagram(Diagram diagram){ + if(diagram.getType().compareTo(BDD)==0){ + return true; + } + return false; +} + +private boolean isInternalBlockDiagram(Diagram diagram){ + if(diagram.getType().compareTo(IBD)==0){ + return true; + } + return false; +} + + private String getComponentImageFilePath(String fileName) { + return directoryName + File.separator + fileName + imageExtension; + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/5e/5e72a410181db970c9a093452d153089ef390f87.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/5e/5e72a410181db970c9a093452d153089ef390f87.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..e1423f9b396757ffdabb6df8b9d2ef386d4d2828 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/5e/5e72a410181db970c9a093452d153089ef390f87.svn-base @@ -0,0 +1,46 @@ +package org.polarsys.chess.diagram.ui.docGenerators; + +import java.awt.Dimension; +import java.awt.Point; +import java.util.List; + +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractBlockDefinitionDiagramModel; + +public class CHESSBlockDefinitionDiagramModel implements AbstractBlockDefinitionDiagramModel{ + + private static CHESSBlockDefinitionDiagramModel instance; + + public static CHESSBlockDefinitionDiagramModel getInstance(){ + if(instance==null){ + instance = new CHESSBlockDefinitionDiagramModel(); + } + return instance; + } + + @Override + public String getGraphicalComponentName(Object graphicalComponent) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List<?> getGraphicalComponentsOfBDD(Object graphicalComponent) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Dimension getGraphicalComponentDimension(Object graphicalComponent) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Point getGraphicalComponentPosition(Object graphicalComponent) { + // TODO Auto-generated method stub + return null; + } + + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/6b/6bbf21df3801fb18a3e2c523c7c9e77993cb78b4.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/6b/6bbf21df3801fb18a3e2c523c7c9e77993cb78b4.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d2a1e77fbb4767cb7683eb688d9fdf83be617fb2 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/6b/6bbf21df3801fb18a3e2c523c7c9e77993cb78b4.svn-base @@ -0,0 +1,492 @@ +/******************************************************************************* + * 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.diagram.ui.docGenerators; + +import java.awt.Dimension; +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.StructureCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorEditPart; +import org.eclipse.papyrus.uml.diagram.common.editparts.IUMLEditPart; +import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.CustomPropertyPartEditPartCN; +import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.ResizablePortEditPart; +import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeCompartmentEditPart; +import org.eclipse.uml2.uml.Connector; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Port; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.diagram.ui.layout.EOrientation; +import eu.fbk.eclipse.standardtools.diagram.ui.layout.EOrientation.Orientation; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractInternalBlockDiagramModel; + +public class CHESSInternalBlockDiagramModel implements AbstractInternalBlockDiagramModel{ + + + private static CHESSInternalBlockDiagramModel chessModel; + + public static CHESSInternalBlockDiagramModel getInstance(){ + if(chessModel == null){ + chessModel = new CHESSInternalBlockDiagramModel(); + } + return chessModel; + } + + + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String getGraphicalComponentId(Object graphicalComponent) { + Element umlElement = null; + /* + * if(graphicalComponent instanceof BlockCompositeEditPart){ umlElement + * = ((BlockCompositeEditPart)graphicalComponent).getUMLElement(); } + * if(graphicalComponent instanceof BlockPropertyCompositeEditPart){ + * umlElement = + * ((BlockPropertyCompositeEditPart)graphicalComponent).getUMLElement(); + * } + */ + if (graphicalComponent instanceof IUMLEditPart) { + umlElement = ((IUMLEditPart) graphicalComponent).getUMLElement(); + } + return entityUtil.getComponentID(umlElement); + } + + @Override + public String getGraphicalComponentName(Object graphicalComponent) { + EObject component = ((GraphicalEditPart) graphicalComponent).resolveSemanticElement(); + + // ((AppliedStereotypeEmptyEditPart)graphicalComponent).get + + return entityUtil.getComponentName(component); + } + + @Override + public List<GraphicalEditPart> getGraphicalSubComponents(Object graphicalComponent) { + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + List<GraphicalEditPart> graphicalSubComponent = new ArrayList<GraphicalEditPart>(); + for (Object child : children) { + if (child instanceof StructureCompartmentEditPart) { + for (Object componentChild : ((StructureCompartmentEditPart) child).getChildren()) { + if (componentChild instanceof BlockPropertyCompositeEditPart) { + graphicalSubComponent.add((GraphicalEditPart) componentChild); + } + } + } + if (child instanceof ClassCompositeCompartmentEditPart) { + for (Object componentChild : ((ClassCompositeCompartmentEditPart) child).getChildren()) { + if (componentChild instanceof CustomPropertyPartEditPartCN) { + graphicalSubComponent.add((GraphicalEditPart) componentChild); + } + } + } + } + return graphicalSubComponent; + } + + @Override + public Object getGraphicalOwnerComponents(Object graphicalComponent) { + return ((GraphicalEditPart) graphicalComponent).getParent(); + } + + @Override + public List<?> getGraphicalPorts(Object graphicalComponent) { + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + List<GraphicalEditPart> graphicalConnectors = new ArrayList<GraphicalEditPart>(); + for (Object child : children) { + if (child instanceof FlowPortAffixedNodeEditPart) { + graphicalConnectors.add((GraphicalEditPart) child); + } + if (child instanceof ResizablePortEditPart) { + graphicalConnectors.add((GraphicalEditPart) child); + } + } + return graphicalConnectors; + } + + @Override + public Object getGraphicalPortOwner(Object port) { + return ((GraphicalEditPart) port).getParent(); + } + + @Override + public Dimension getGraphicalComponentDimension(Object component) { + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) component).getFigure().getSize(); + Dimension d = new Dimension(domension.width, domension.height); + return d; + } + + @Override + public Point getGraphicalComponentPosition(Object component) { + + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + + printlnGraphicalPosition(graphicalComponent); + + // System.out.println("----------------------------"); + // System.out.println(graphicalComponent.getLocation()); + // System.out.println(component); + // System.out.println(graphicalComponent.getContentPane().getBounds()); + // System.out.println(graphicalComponent.getFigure().getBounds()); + // System.out.println(graphicalComponent.getMainFigure().getBounds()); + // System.out.println(graphicalComponent.getBorderedFigure().getBounds()); + // System.out.println(graphicalComponent.getPrimaryShape().getBounds()); + // System.out.println(graphicalComponent.getPrimaryShape().getLocation()); + + Point point = new Point(x, y); + + Point parentPoint = getOwnerPosition(graphicalComponent.getParent()); + + System.out.println("parentPoint: " + parentPoint); + + point.x = point.x + parentPoint.x; + point.y = point.y + parentPoint.y; + + return point; + } + + private Object printlnGraphicalPosition(Object component) { + if (component instanceof GraphicalEditPart) { + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + System.out.println("-------printlnGraphicalPosition------------"); + System.out.println(graphicalComponent); + System.out.println(graphicalComponent.getFigure().getBounds()); + return printlnGraphicalPosition(graphicalComponent.getParent()); + } + return null; + } + + /* + * @Override public Point getGraphicalComponentPosition(Object component) { + * + * GraphicalEditPart graphicalComponent = (GraphicalEditPart)component; + * + * int x =0; int y =0; if(!(component instanceof + * StructureCompartmentEditPart)){ x = + * graphicalComponent.getFigure().getBounds().x; y = + * graphicalComponent.getFigure().getBounds().y; } + * + * + * System.out.println("----------------------------"); + * //System.out.println(graphicalComponent.getLocation()); + * System.out.println(component); + * //System.out.println(graphicalComponent.getContentPane().getBounds()); + * System.out.println(graphicalComponent.getFigure().getBounds()); + * //System.out.println(graphicalComponent.getMainFigure().getBounds()); + * //System.out.println(graphicalComponent.getBorderedFigure().getBounds()); + * //System.out.println(graphicalComponent.getPrimaryShape().getBounds()); + * //System.out.println(graphicalComponent.getPrimaryShape().getLocation()); + * + * + * Point point = new Point(x, y); + * + * if(graphicalComponent.getParent() instanceof GraphicalEditPart){ Point + * parentPoint = + * getGraphicalComponentPosition(graphicalComponent.getParent()); + * point.x=point.x+parentPoint.x; point.y=point.y+parentPoint.y; } return + * point; } + */ + + + private Point getOwnerPosition(Object component) { + + if (component instanceof GraphicalEditPart) { + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + if (component instanceof StructureCompartmentEditPart) { + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + Point point = new Point(x, y); + return point; + } + if (component instanceof ClassCompositeCompartmentEditPart) { + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + Point point = new Point(x, y); + return point; + } + + return getOwnerPosition(graphicalComponent.getParent()); + } else { + return new Point(0, 0); + } + } + + @Override + public boolean isGraphicalPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public boolean isGraphicalInputPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isInputPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isInputPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public boolean isGraphicalOutputPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isOutputPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isOutputPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public String getGraphicalPortName(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return ((Port) ((FlowPortAffixedNodeEditPart) port).getUMLElement()).getName(); + } + if (port instanceof ResizablePortEditPart) { + return ((Port) ((ResizablePortEditPart) port).getUMLElement()).getName(); + } + return null; + } + + + + @Override + public Object getGraphicalPortVariableType(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return ((Port) ((FlowPortAffixedNodeEditPart) port).getUMLElement()).getType().getName(); + } + if (port instanceof ResizablePortEditPart) { + return ((Port) ((ResizablePortEditPart) port).getUMLElement()).getType().getName(); + } + return null; + } + + @Override + public Point getGraphicalPortPosition(Object port) { + + // org.eclipse.draw2d.geometry.Point p = + // ((FlowPortAffixedNodeEditPart)Port).getLocation(); + // org.eclipse.draw2d.geometry.Point p = + // ((GraphicalEditPart)Port).getFigure().getBounds(); + int x = ((GraphicalEditPart) port).getFigure().getBounds().x; + int y = ((GraphicalEditPart) port).getFigure().getBounds().y; + + // System.out.println("port bounds: + // "+((FlowPortAffixedNodeEditPart)Port).getFigure().getBounds()); + // System.out.println("port loc: "+p); + + // Point point = new Point(p.x, p.y); + Point point = new Point(x, y); + + // GraphicalEditPart portParent = + // (GraphicalEditPart)((GraphicalEditPart)Port).getParent(); + // Point partentPoint = + // getGraphicalComponentPosition(portParent.getParent()); + Point partentPoint = getOwnerPosition(port); + + point.x = point.x + partentPoint.x; + point.y = point.y + partentPoint.y; + return point; + } + + @Override + public Dimension getGraphicalPortDimension(Object port) { + + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) port).getFigure().getSize(); + Dimension dim = new Dimension(domension.width, domension.height); + + return dim; + } + + @Override + public EOrientation getGraphicalPortOffsetOrientation(Object port) { + + int or = 0; + if (port instanceof FlowPortAffixedNodeEditPart) { + or = ((FlowPortAffixedNodeEditPart) port).getBorderItemLocator().getCurrentSideOfParent(); + } + if (port instanceof ResizablePortEditPart) { + or = ((ResizablePortEditPart) port).getBorderItemLocator().getCurrentSideOfParent(); + } + //System.out.println("or: " + or); + + EOrientation eOrientation = new EOrientation(); + Point p = getGraphicalPortPosition(port); + int offset = 0; + Orientation orientation = Orientation.NORTH_VALUE; + + switch (or) { + case 1: + orientation = Orientation.NORTH_VALUE; + offset = p.x; + break; + case 4: + orientation = Orientation.SOUTH_VALUE; + offset = p.x; + break; + case 8: + orientation = Orientation.WEST_VALUE; + offset = p.y; + break; + case 16: + orientation = Orientation.EAST_VALUE; + offset = p.y; + break; + } + + eOrientation.setOrientation(orientation); + eOrientation.setOffset(offset); + return eOrientation; + } + + @SuppressWarnings("unchecked") + @Override + public List<?> getPortChannels(Object graphicalComponent) { + + List<Object> connections = new ArrayList<Object>(); + + if (graphicalComponent instanceof GraphicalEditPart) { + + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + for (Object child : children) { + if (child instanceof FlowPortAffixedNodeEditPart) { + GraphicalEditPart graphicalPort = (GraphicalEditPart) child; + connections.addAll(graphicalPort.getSourceConnections()); + + } + if (child instanceof ResizablePortEditPart) { + GraphicalEditPart graphicalPort = (GraphicalEditPart) child; + connections.addAll(graphicalPort.getSourceConnections()); + + } + } + + for (Object subComponents : getGraphicalSubComponents(graphicalComponent)) { + connections.addAll(getPortChannels(subComponents)); + /* + * List children + * =((GraphicalEditPart)subComponents).getChildren(); for(Object + * child : children){ if(child instanceof + * FlowPortAffixedNodeEditPart){ GraphicalEditPart graphicalPort + * = (GraphicalEditPart) child; + * System.out.println("child: "+child); + * connections.addAll(graphicalPort.getSourceConnections()); + * connections.addAll(graphicalPort.getTargetConnections()); + * + * } } + */ + } + + } + + return connections; + } + + @Override + public String getChannelName(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((Connector) ((View) ((ConnectorEditPart) channel).getModel()).getElement()).getName(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((Connector) ((View) ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel) + .getModel()).getElement()).getName(); + } + return null; + } + + @Override + public Object getChannelTargetPort(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((ConnectorEditPart) channel).getTarget(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel).getTarget(); + } + return null; + } + + @Override + public Object getChannelSourcePort(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((ConnectorEditPart) channel).getSource(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel).getSource(); + } + return null; + } + + @Override + public ArrayList<?> getPortIncomingChannels(Object port) { + return null; + } + + @Override + public ArrayList<?> getPortOutgoingChannels(Object port) { + return null; + } + + @Override + public List<Point> getLayoutChannelPoints(Object channel) { + int[] pointList = null; + if (channel instanceof ConnectorEditPart) { + pointList = ((ConnectorEditPart) channel).getConnectionFigure().getPoints().toIntArray(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + pointList = ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel) + .getConnectionFigure().getPoints().toIntArray(); + } + List<Point> points = new ArrayList<Point>(); + + for (int i = 0; i < pointList.length; i = i + 2) { + Point p = new Point(pointList[i], pointList[i + 1]); + points.add(p); + } + + return points; + } + + @Override + public Object getChannelOwner(Object channel) { + return ((GraphicalEditPart) channel).getParent(); + } + + + + @Override + public String getGraphicalPortRange(Object component, Object port) { + return "PortRange"; + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/78/786243590d08e772d81457c55d60c96be17614b4.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/78/786243590d08e772d81457c55d60c96be17614b4.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..c99c2da0e9b0decab7fe292e73a93ffdce62f55a --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/78/786243590d08e772d81457c55d60c96be17614b4.svn-base @@ -0,0 +1,74 @@ +package org.polarsys.chess.diagram.ui.commands; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.uml2.uml.Class; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSDiagramModel; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.utils.SelectionUtil;import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.services.OCRATranslatorService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ModelToDocumentDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DocumentGeneratorServiceFromOssModel; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; +import eu.fbk.tools.editor.oss.oss.OSS; + +public class GenerateDocumentCommand extends AbstractAsyncJobCommand { + + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private ChessSystemModel chessToOCRAModelTranslator = ChessSystemModel.getInstance(); + private OCRATranslatorService ocraTranslatorService = OCRATranslatorService.getInstance(chessToOCRAModelTranslator); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + + private DocumentGeneratorServiceFromOssModel documentGeneratorService ; + /** + * @param commandName + */ + public GenerateDocumentCommand() { + super("Generate Documentation"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + + OSS ossModel = ocraTranslatorService.getOssModel(umlSelectedComponent, isDiscreteTime, monitor); + + ModelToDocumentDialog parameterDialog = exportDialogUtils.getCompiledModelToDocumentDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String docFormat = parameterDialog.getDocumentFormat(); + String imageExtension = ".svg"; + if (docFormat.equals("tex")) { + imageExtension = ".png"; + } + + // setShowLeafComponents(showLeafComponents); + String outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + // setDirectoryName(directoryName); + if ((outputDirectoryName == null) || outputDirectoryName.isEmpty()) { + return; + } + + String currentProjectName = directoryUtils.getCurrentProjectName(); + System.out.println("currentProjectName: "+currentProjectName); + + + documentGeneratorService = DocumentGeneratorServiceFromOssModel.getInstance(CHESSDiagramModel.getInstance(), ossModel); + documentGeneratorService.setParametersBeforeDocumentGeneration(parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout(), outputDirectoryName, imageExtension, parameterDialog.getShowLeafComponents()); + + documentGeneratorService.createDocumentFile(currentProjectName, docFormat, ossModel.getSystem(), monitor); + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/82/82105d1a70324e02980d20c97b386c634185f29f.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/82/82105d1a70324e02980d20c97b386c634185f29f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..a0b16f8a7f5b97203c821da393c9077a1572dc8c --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/82/82105d1a70324e02980d20c97b386c634185f29f.svn-base @@ -0,0 +1,27 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ui +Bundle-SymbolicName: org.polarsys.chess.diagram.ui;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.polarsys.chess.utils +Require-Bundle: org.eclipse.core.commands, + org.eclipse.swt, + org.eclipse.core.jobs, + org.eclipse.core.runtime, + org.eclipse.emf.ecore, + org.eclipse.uml2.uml, + eu.fbk.eclipse.standardtools.diagram.ui;bundle-version="1.0.0", + eu.fbk.eclipse.standardtools.diagram;bundle-version="1.0.0", + org.eclipse.ui.workbench, + org.eclipse.jface, + org.eclipse.gmf.runtime.diagram.ui, + org.eclipse.papyrus.infra.emf, + org.eclipse.papyrus.sysml.diagram.common, + org.eclipse.papyrus.uml.diagram.stereotype.edition, + org.eclipse.gmf.runtime.notation.edit, + org.eclipse.papyrus.infra.gmfdiag.css, + eu.fbk.eclipse.standardtools.utils, + eu.fbk.eclipse.standardtools.ModelTranslatorToOcra, + eu.fbk.tools.editor.oss, + org.polarsys.chess.verificationService diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b862a296d38fe04269faeee6c9d77d11ff77380d --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base @@ -0,0 +1,7 @@ +<?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> diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/8f/8fab20204a4496be629caae826128b7ee97a24f9.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/8f/8fab20204a4496be629caae826128b7ee97a24f9.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..fefa0cc28e050e9e5db8e65daa7d5e7b564208c0 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/8f/8fab20204a4496be629caae826128b7ee97a24f9.svn-base @@ -0,0 +1,32 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ui +Bundle-SymbolicName: org.polarsys.chess.diagram.ui;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.polarsys.chess.service.internal.utils +Require-Bundle: org.eclipse.core.commands, + org.eclipse.swt, + org.eclipse.core.jobs, + org.eclipse.core.runtime, + org.eclipse.emf.ecore, + org.eclipse.uml2.uml, + eu.fbk.eclipse.standardtools.diagram.ui;bundle-version="1.0.0", + eu.fbk.eclipse.standardtools.diagram;bundle-version="1.0.0", + org.eclipse.ui.workbench, + org.eclipse.jface, + org.eclipse.gmf.runtime.diagram.ui, + org.eclipse.papyrus.infra.emf, + org.eclipse.papyrus.sysml.diagram.common, + org.eclipse.papyrus.uml.diagram.stereotype.edition, + org.eclipse.gmf.runtime.notation.edit, + org.eclipse.papyrus.infra.gmfdiag.css, + eu.fbk.eclipse.standardtools.utils, + eu.fbk.eclipse.standardtools.ModelTranslatorToOcra, + eu.fbk.tools.editor.oss, + org.polarsys.chess.verificationService;bundle-version="1.0.0", + org.polarsys.chess.core, + org.polarsys.chess.contracts.profile, + org.eclipse.papyrus.uml.tools, + org.eclipse.papyrus.sysml.diagram.internalblock;bundle-version="2.0.0", + org.eclipse.papyrus.sysml.diagram.blockdefinition;bundle-version="2.0.0" diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/a1/a1b3cfce8c1e1ec767b72e2cbc8741475d99220f.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/a1/a1b3cfce8c1e1ec767b72e2cbc8741475d99220f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..c1b435638a3c303a76b7a840d17d763eee5d57e7 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/a1/a1b3cfce8c1e1ec767b72e2cbc8741475d99220f.svn-base @@ -0,0 +1,34 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ui +Bundle-SymbolicName: org.polarsys.chess.diagram.ui;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.polarsys.chess.service.internal.utils +Require-Bundle: org.eclipse.core.commands, + org.eclipse.swt, + org.eclipse.core.jobs, + org.eclipse.core.runtime, + org.eclipse.emf.ecore, + org.eclipse.uml2.uml, + eu.fbk.eclipse.standardtools.diagram.ui;bundle-version="1.0.0", + eu.fbk.eclipse.standardtools.diagram;bundle-version="1.0.0", + org.eclipse.ui.workbench, + org.eclipse.jface, + org.eclipse.gmf.runtime.diagram.ui, + org.eclipse.papyrus.infra.emf, + org.eclipse.papyrus.sysml.diagram.common, + org.eclipse.papyrus.uml.diagram.stereotype.edition, + org.eclipse.gmf.runtime.notation.edit, + org.eclipse.papyrus.infra.gmfdiag.css, + eu.fbk.eclipse.standardtools.utils, + eu.fbk.eclipse.standardtools.ModelTranslatorToOcra, + eu.fbk.tools.editor.oss, + org.polarsys.chess.contracts.verificationService;bundle-version="1.0.0", + org.polarsys.chess.core, + org.polarsys.chess.contracts.profile, + org.eclipse.papyrus.uml.tools, + org.eclipse.papyrus.sysml.diagram.internalblock;bundle-version="2.0.0", + org.eclipse.papyrus.sysml.diagram.blockdefinition;bundle-version="2.0.0", + org.eclipse.papyrus.uml.diagram.profile;bundle-version="2.0.0", + org.eclipse.papyrus.uml.diagram.common diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/b5/b508959255a37b6592178b67c657d13088f2b624.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/b5/b508959255a37b6592178b67c657d13088f2b624.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d103fa320604bb6162a26066f5eacf9f7f57828c --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/b5/b508959255a37b6592178b67c657d13088f2b624.svn-base @@ -0,0 +1,90 @@ +/******************************************************************************* + * 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.diagram.ui.commands; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSDiagramModel; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ModelToDocumentDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DocumentGeneratorService; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; + +/** + * + * @author Alberto + */ +public class ExportModelToDocumentCommand extends AbstractAsyncJobCommand { + + public ExportModelToDocumentCommand() { + super("Export Model To Document"); + } + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + //private OCRAComponentToImage ocraComponentToImage = OCRAComponentToImage.getInstance(); + private DocumentGeneratorService documentGeneratorService = DocumentGeneratorService.getInstance(CHESSDiagramModel.getInstance()); + + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + GraphicalEditPart selectedGraphicalComponent = selectionUtil.getSelectedGraphicalObject(event); + + if (selectedGraphicalComponent != null) { + + System.out.println("selectedGraphicalComponent: " + selectedGraphicalComponent); + + ModelToDocumentDialog parameterDialog = exportDialogUtils.getCompiledModelToDocumentDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String docFormat = parameterDialog.getDocumentFormat(); + String imageExtension = ".svg"; + if (docFormat.equals("tex")) { + imageExtension = ".png"; + } + + // setShowLeafComponents(showLeafComponents); + String outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + // setDirectoryName(directoryName); + if ((outputDirectoryName == null) || outputDirectoryName.isEmpty()) { + return; + } + + String currentProjectName = directoryUtils.getCurrentProjectName(); + + documentGeneratorService.setParametersBeforeDocumentGeneration + //setParametersBeforeExport + (parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout(), + outputDirectoryName, imageExtension,parameterDialog.getShowLeafComponents()); + + // ocraComponentToImage.setXTranslation(150); + // ocraComponentToImage.setYTranslation(100); + + documentGeneratorService.createDocumentFile(currentProjectName, docFormat, selectedGraphicalComponent, + monitor); + + exportDialogUtils.showMessage_ExportDone(outputDirectoryName); + + } + + } + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/bf/bf32700517e1d795aee527a4c60cea46fce2d484.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/bf/bf32700517e1d795aee527a4c60cea46fce2d484.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..a851dcac9a1b11f2952466036d46f03c56f27196 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/bf/bf32700517e1d795aee527a4c60cea46fce2d484.svn-base @@ -0,0 +1,90 @@ +/******************************************************************************* + * 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.diagram.ui.commands; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSInternalBlockDiagramModel; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ModelToDocumentDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DocumentGeneratorService; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; + +/** + * + * @author Alberto + */ +public class ExportModelToDocumentCommand extends AbstractAsyncJobCommand { + + public ExportModelToDocumentCommand() { + super("Export Model To Document"); + } + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + //private OCRAComponentToImage ocraComponentToImage = OCRAComponentToImage.getInstance(); + private DocumentGeneratorService documentGeneratorService = DocumentGeneratorService.getInstance(CHESSInternalBlockDiagramModel.getInstance()); + + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + GraphicalEditPart selectedGraphicalComponent = selectionUtil.getSelectedGraphicalObject(event); + + if (selectedGraphicalComponent != null) { + + System.out.println("selectedGraphicalComponent: " + selectedGraphicalComponent); + + ModelToDocumentDialog parameterDialog = exportDialogUtils.getCompiledModelToDocumentDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String docFormat = parameterDialog.getDocumentFormat(); + String imageExtension = ".svg"; + if (docFormat.equals("tex")) { + imageExtension = ".png"; + } + + // setShowLeafComponents(showLeafComponents); + String outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + // setDirectoryName(directoryName); + if ((outputDirectoryName == null) || outputDirectoryName.isEmpty()) { + return; + } + + String currentProjectName = directoryUtils.getCurrentProjectName(); + + documentGeneratorService.setParametersBeforeDocumentGeneration + //setParametersBeforeExport + (parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout(), + outputDirectoryName, imageExtension,parameterDialog.getShowLeafComponents()); + + // ocraComponentToImage.setXTranslation(150); + // ocraComponentToImage.setYTranslation(100); + + documentGeneratorService.createDocumentFile(currentProjectName, docFormat, selectedGraphicalComponent, + monitor); + + exportDialogUtils.showMessage_ExportDone(outputDirectoryName); + + } + + } + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/c1/c10808819694a69f14c72ee46666537feb615cff.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/c1/c10808819694a69f14c72ee46666537feb615cff.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..883eaa7dd498502f9b97406657d9705b8e2410bb --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/c1/c10808819694a69f14c72ee46666537feb615cff.svn-base @@ -0,0 +1,28 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ui +Bundle-SymbolicName: org.polarsys.chess.diagram.ui;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.polarsys.chess.service.internal.utils +Require-Bundle: org.eclipse.core.commands, + org.eclipse.swt, + org.eclipse.core.jobs, + org.eclipse.core.runtime, + org.eclipse.emf.ecore, + org.eclipse.uml2.uml, + eu.fbk.eclipse.standardtools.diagram.ui;bundle-version="1.0.0", + eu.fbk.eclipse.standardtools.diagram;bundle-version="1.0.0", + org.eclipse.ui.workbench, + org.eclipse.jface, + org.eclipse.gmf.runtime.diagram.ui, + org.eclipse.papyrus.infra.emf, + org.eclipse.papyrus.sysml.diagram.common, + org.eclipse.papyrus.uml.diagram.stereotype.edition, + org.eclipse.gmf.runtime.notation.edit, + org.eclipse.papyrus.infra.gmfdiag.css, + eu.fbk.eclipse.standardtools.utils, + eu.fbk.eclipse.standardtools.ModelTranslatorToOcra, + eu.fbk.tools.editor.oss, + org.polarsys.chess.verificationService;bundle-version="1.0.0", + org.polarsys.chess.core diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/cd/cd422adeddf618207b9c8ca271556e4d482aed3f.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/cd/cd422adeddf618207b9c8ca271556e4d482aed3f.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..4b46a65ef54838352444f0d6489df939ab8f3852 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/cd/cd422adeddf618207b9c8ca271556e4d482aed3f.svn-base @@ -0,0 +1,75 @@ +package org.polarsys.chess.diagram.ui.commands; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.uml2.uml.Class; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSDiagramModel; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.services.OCRATranslatorService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ModelToDocumentDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DocumentGeneratorServiceFromOssModel; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; +import eu.fbk.tools.editor.oss.oss.OSS; + +public class GenerateDocumentCommand extends AbstractAsyncJobCommand { + + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private ChessSystemModel chessToOCRAModelTranslator = ChessSystemModel.getInstance(); + private OCRATranslatorService ocraTranslatorService = OCRATranslatorService.getInstance(chessToOCRAModelTranslator); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + + private DocumentGeneratorServiceFromOssModel documentGeneratorService ; + /** + * @param commandName + */ + public GenerateDocumentCommand() { + super("Generate Documentation"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + + OSS ossModel = ocraTranslatorService.getOssModel(umlSelectedComponent, isDiscreteTime, monitor); + + ModelToDocumentDialog parameterDialog = exportDialogUtils.getCompiledModelToDocumentDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String docFormat = parameterDialog.getDocumentFormat(); + String imageExtension = ".svg"; + if (docFormat.equals("tex")) { + imageExtension = ".png"; + } + + // setShowLeafComponents(showLeafComponents); + String outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + // setDirectoryName(directoryName); + if ((outputDirectoryName == null) || outputDirectoryName.isEmpty()) { + return; + } + + String currentProjectName = directoryUtils.getCurrentProjectName(); + System.out.println("currentProjectName: "+currentProjectName); + + + documentGeneratorService = DocumentGeneratorServiceFromOssModel.getInstance(CHESSDiagramModel.getInstance(), ossModel); + documentGeneratorService.setParametersBeforeDocumentGeneration(parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout(), outputDirectoryName, imageExtension, parameterDialog.getShowLeafComponents()); + + documentGeneratorService.createDocumentFile(currentProjectName, docFormat, ossModel.getSystem(), monitor); + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/d0/d08020689d13fffee5a24476d2d3176b76a9242b.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/d0/d08020689d13fffee5a24476d2d3176b76a9242b.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..736c2f5921a075d84a351d127b9de65b2a0180d2 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/d0/d08020689d13fffee5a24476d2d3176b76a9242b.svn-base @@ -0,0 +1,251 @@ +package org.polarsys.chess.diagram.ui.docGenerators; + +import java.awt.Dimension; +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.notation.LayoutConstraint; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.css.CSSDecorationNodeImpl; +import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.part.BlockDefinitionDiagramEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.AssociationEditPart; +import org.eclipse.papyrus.sysml.diagram.common.figure.AssociationFigure; +import org.eclipse.uml2.uml.Association; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; + +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractBlockDefinitionDiagramModel; + +public class CHESSBlockDefinitionDiagramModel implements AbstractBlockDefinitionDiagramModel{ + + private static CHESSBlockDefinitionDiagramModel instance; + + public static CHESSBlockDefinitionDiagramModel getInstance(){ + if(instance==null){ + instance = new CHESSBlockDefinitionDiagramModel(); + } + return instance; + } + + private EntityUtil entityUtil = EntityUtil.getInstance(); + + + @Override + public String getGraphicalComponentName(Object graphicalComponent) { + + if(graphicalComponent instanceof EditPart){ + System.out.println("is instanceof EditPart"); + } + if(graphicalComponent instanceof GraphicalEditPart){ + System.out.println("is instanceof GraphicalEditPart"); + } + + EObject component = ((GraphicalEditPart) graphicalComponent).resolveSemanticElement(); + return entityUtil.getComponentName(component); + } + + @Override + public List<?> getGraphicalComponentsOfBDD(Object graphicalComponent) { + + System.out.println("getGraphicalComponentsOfBDD"); + + if(graphicalComponent instanceof EditPart){ + System.out.println("is instanceof EditPart"); + } + if(graphicalComponent instanceof GraphicalEditPart){ + System.out.println("is instanceof GraphicalEditPart"); + } + if(graphicalComponent instanceof BlockDefinitionDiagramEditPart){ + System.out.println("is instanceof BlockDefinitionDiagramEditPart"); + + for(Object o : ((BlockDefinitionDiagramEditPart)graphicalComponent).getChildren()){ + System.out.println("child: "+o); + } + return ((BlockDefinitionDiagramEditPart)graphicalComponent).getChildren(); + } + return null; + } + + @Override + public Dimension getGraphicalComponentDimension(Object graphicalComponent) { + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) graphicalComponent).getFigure().getSize(); + Dimension d = new Dimension(domension.width, domension.height); + return d; + } + + @Override + public Point getGraphicalComponentPosition(Object component) { + + /* if(component instanceof EditPart){ + for(Object o : ((EditPart)component).getChildren()){ + System.out.println("child of component: "+o); + } + }*/ + + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + + Point point = new Point(x, y); + + //Point parentPoint = getOwnerPosition(graphicalComponent.getParent()); + + //System.out.println("parentPoint: " + parentPoint); + + //point.x = point.x + parentPoint.x; + //point.y = point.y + parentPoint.y; + + return point; + } + + @Override + public List<?> getCompositionAssociations(Object graphicalComponent) { + List<AssociationEditPart> compositionAssociations = new ArrayList<AssociationEditPart>(); + + if(graphicalComponent instanceof BlockDefinitionDiagramEditPart){ + System.out.println("is instanceof BlockDefinitionDiagramEditPart"); + + for(Object o : ((BlockDefinitionDiagramEditPart)graphicalComponent).getConnections()){ + System.out.println("connections: "+o); + if(o instanceof AssociationEditPart){ + compositionAssociations.add((AssociationEditPart)o); + } + } + //return ((BlockDefinitionDiagramEditPart)graphicalComponent).getConnections(); + return compositionAssociations; + } + return null; + } + + @Override + public String getCompositionAssociationName(Object channel) { + AssociationEditPart association = ((AssociationEditPart)channel); + System.out.println("association.getModel(): "+association.getModel()); + View v = ((View) association.getModel()); + System.out.println("v.getElement(): "+v.getElement()); + Association associationEleemnt = (Association)v.getElement(); + return associationEleemnt.getName(); + } + + @Override + public List<Point> getLayoutCompositionAssociationPoints(Object channel) { + int[] pointList = null; + List<Point> points = new ArrayList<Point>(); + + AssociationEditPart association = ((AssociationEditPart)channel); + //pointList = association.getConnectionFigure().getPoints().toIntArray(); + + + AssociationFigure associationFigure = (AssociationFigure)association.getFigure(); + pointList =associationFigure.getPolygonPoints().toIntArray(); + //pointList =associationFigure.getPoints().toIntArray(); + + System.out.println("points"); + for (int i = 0; i < pointList.length; i = i + 2) { + Point p = new Point(pointList[i], pointList[i + 1]); + System.out.println("p: "+p); + points.add(p); + } + + return points; + } + + @Override + public Point getCompositionAssociationLabelPosition(Object graphicalLabel) { + + PapyrusWrappingLabel lab = (PapyrusWrappingLabel)graphicalLabel; + + org.eclipse.draw2d.geometry.Point labelPoint = lab.getLocation(); + return new Point(labelPoint.x, labelPoint.y); + /* AssociationEditPart association = ((AssociationEditPart)graphicalAssociation); + + for(Object o : association.getNotationView().getVisibleChildren()) + { + CSSDecorationNodeImpl decNode = (CSSDecorationNodeImpl)o; + + System.out.println("o: "+o); + + for(Object o2:decNode.getPersistedChildren()){ + System.out.println("getPersistedChildren: "+o2); + } + + for(Object o2:decNode.getSourceEdges()){ + System.out.println("getSourceEdges: "+o2); + } + + for(Object o2:decNode.getTargetEdges()){ + System.out.println("getTargetEdges: "+o2); + } + + LayoutConstraint lc = decNode.getLayoutConstraint(); + + } + + + + for(Object o : association.getConnectionFigure().getChildren()) + { + PapyrusWrappingLabel lab = (PapyrusWrappingLabel)o; + lab.getText(); + lab.getLocation() + System.out.println(o.getClass()); + System.out.println("getConnectionFigure().getChildren(): "+o); + } + + + + org.eclipse.draw2d.geometry.Point midPoint = association.getConnectionFigure().getPoints().getMidpoint(); + return new Point(midPoint.x, midPoint.y);*/ + + + } + + + + @Override + public String getCompositionAssociationLabelText(Object graphicalLabel) { + PapyrusWrappingLabel lab = (PapyrusWrappingLabel)graphicalLabel; + return lab.getText(); + } + + @Override + public List<?> getCompositionAssociationsLabels(Object graphicalAssociation) { + AssociationEditPart association = ((AssociationEditPart)graphicalAssociation); + + List<PapyrusWrappingLabel> labels = new ArrayList<PapyrusWrappingLabel>(); + for(Object o : association.getConnectionFigure().getChildren()) + { + //System.out.println("o.getClass(): "+o.getClass()); + //System.out.println("getConnectionFigure().getChildren(): "+o); + if(o instanceof PapyrusWrappingLabel){ + PapyrusWrappingLabel lab = (PapyrusWrappingLabel)o; + //System.out.println("lab: "+lab); + //System.out.println("lab.text: "+lab.getText()); + //System.out.println("lab.isShowing(): "+lab.isShowing()); + //System.out.println("lab.isVisible():"+lab.isVisible()); + // System.out.println("lab.isEnabled(): "+lab.isEnabled()); + if((lab.getText().compareTo("")!=0)&(lab.isShowing())){ + labels.add(lab); + } + } + + } + + return labels; + + } + + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/d1/d1b10e7f32fbc82d149503e4d92730c0ca3e7f81.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/d1/d1b10e7f32fbc82d149503e4d92730c0ca3e7f81.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..30b6b847a14cc3b9bfbc1e363b4f430584408408 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/d1/d1b10e7f32fbc82d149503e4d92730c0ca3e7f81.svn-base @@ -0,0 +1,34 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ui +Bundle-SymbolicName: org.polarsys.chess.diagram.ui;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.polarsys.chess.service.internal.utils +Require-Bundle: org.eclipse.core.commands, + org.eclipse.swt, + org.eclipse.core.jobs, + org.eclipse.core.runtime, + org.eclipse.emf.ecore, + org.eclipse.uml2.uml, + eu.fbk.eclipse.standardtools.diagram.ui;bundle-version="1.0.0", + eu.fbk.eclipse.standardtools.diagram;bundle-version="1.0.0", + org.eclipse.ui.workbench, + org.eclipse.jface, + org.eclipse.gmf.runtime.diagram.ui, + org.eclipse.papyrus.infra.emf, + org.eclipse.papyrus.sysml.diagram.common, + org.eclipse.papyrus.uml.diagram.stereotype.edition, + org.eclipse.gmf.runtime.notation.edit, + org.eclipse.papyrus.infra.gmfdiag.css, + eu.fbk.eclipse.standardtools.utils, + eu.fbk.eclipse.standardtools.ModelTranslatorToOcra, + eu.fbk.tools.editor.oss, + org.polarsys.chess.verificationService;bundle-version="1.0.0", + org.polarsys.chess.core, + org.polarsys.chess.contracts.profile, + org.eclipse.papyrus.uml.tools, + org.eclipse.papyrus.sysml.diagram.internalblock;bundle-version="2.0.0", + org.eclipse.papyrus.sysml.diagram.blockdefinition;bundle-version="2.0.0", + org.eclipse.papyrus.uml.diagram.profile;bundle-version="2.0.0", + org.eclipse.papyrus.uml.diagram.common diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/d5/d598a9656bc6c87b876c63a2bad34c9f9738b33e.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/d5/d598a9656bc6c87b876c63a2bad34c9f9738b33e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..8654698296a15a00f48b39384abbef55795516ad --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/d5/d598a9656bc6c87b876c63a2bad34c9f9738b33e.svn-base @@ -0,0 +1,222 @@ +package org.polarsys.chess.diagram.ui.services; + +import java.io.File; +import java.net.MalformedURLException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockCompositeEditPart; +import org.eclipse.papyrus.sysml.diagram.internalblock.edit.part.InternalBlockDiagramEditPart; +import org.eclipse.papyrus.sysml.diagram.blockdefinition.edit.part.BlockDefinitionDiagramEditPart; +import org.apache.commons.io.FilenameUtils; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.RootEditPart; +import org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.uml2.uml.Class; + +import eu.fbk.eclipse.standardtools.diagram.ContainterDescriptor; +import eu.fbk.eclipse.standardtools.diagram.DiagramDescriptor; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.BlockDefinitionDiagramGeneratorService; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.InternalBlockDiagramGeneratorService; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractBlockDefinitionDiagramModel; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractInternalBlockDiagramModel; + +public class CHESSDiagramsGeneratorService { + + private static CHESSDiagramsGeneratorService instance; + + final private static String IBD = "InternalBlock"; + final private static String BDD = "BlockDefinition"; + + public static CHESSDiagramsGeneratorService getInstance(AbstractInternalBlockDiagramModel ibdModel,AbstractBlockDefinitionDiagramModel bddModel){ + if(instance==null){ + instance = new CHESSDiagramsGeneratorService(ibdModel, bddModel); + } + return instance; + } + + + + public CHESSDiagramsGeneratorService(AbstractInternalBlockDiagramModel ibdModel, AbstractBlockDefinitionDiagramModel bddModel) { + super(); + //graphicalModel = graphModel; + ibdGeneratorService = InternalBlockDiagramGeneratorService.getInstance(ibdModel); + bddGeneratorService = BlockDefinitionDiagramGeneratorService.getInstance(bddModel); + } + + + + //private static AbstractDiagramModel graphicalModel; + private InternalBlockDiagramGeneratorService ibdGeneratorService; + private BlockDefinitionDiagramGeneratorService bddGeneratorService; + + + private String directoryName; + private String imageExtension; + + + + public void setParametersBeforeDiagramsGenerator( + String directoryName, String imageExtension, + boolean showPortLabels, boolean automaticLabelLayout) { + + this.directoryName=directoryName; + this.imageExtension=imageExtension; + + + ibdGeneratorService.setParametersBeforeDiagramGenerator(showPortLabels, automaticLabelLayout); + bddGeneratorService.setParametersBeforeDiagramGenerator(showPortLabels, automaticLabelLayout); + } + + public DiagramDescriptor createDiagramWithDescriptor(Diagram diagram, IProgressMonitor monitor){ + EObject diagramOwner = DiagramUtils.getOwner(diagram); + String diagramName = ""; + String ownerName = null; + if(diagramOwner instanceof Class){ + ownerName = ((Class)diagramOwner).getName(); + diagramName = ownerName+"_"+diagram.getName(); + }else{ + diagramName = diagram.getName(); + } + + if(diagram.getName().compareTo("Contracts")!=0){ + createDiagram(diagram,diagramName, monitor); + } + return createDiagramDescriptor(diagramName,ownerName); + } + + + + private void createDiagram(Diagram diagram,String diagramName, IProgressMonitor monitor){ + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + System.out.println("diagram name: "+diagram.getName()); + System.out.println("diagram type: "+diagram.getType()); + + EditPart editPart = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagram, shell); + + RootEditPart root = editPart.getRoot(); + System.out.println("root: "+root); + + if(isInternalBlockDiagram(diagram)){ + InternalBlockDiagramEditPart idb = (InternalBlockDiagramEditPart) root.getChildren().get(0); + BlockCompositeEditPart graphicalComponent = (BlockCompositeEditPart)idb.getChildren().get(0); + + ibdGeneratorService.createDiagramFile(getComponentImageFilePath(diagramName), graphicalComponent, monitor); + }else if(isBlockDefinitionDiagram(diagram)){ + System.out.println("isBlockDefinitionDiagram"); + BlockDefinitionDiagramEditPart bdd = (BlockDefinitionDiagramEditPart) root.getChildren().get(0); + for(Object o : bdd.getChildren()){ + System.out.println("o: "+o); + } + + bddGeneratorService.createDiagramFile(getComponentImageFilePath(diagramName), bdd, monitor); + + } + } + + private DiagramDescriptor createDiagramDescriptor(String diagramName, String ownerName){ + String saveFilePath = getComponentImageFilePath(diagramName); + System.out.println("saveFilePath: "+saveFilePath); + // diagramGeneratorService.createDiagramFile(saveFilePath, component, + // monitor); + final DiagramDescriptor diagramDescriptor = //diagramGeneratorService. + createDiagramDescriptorWithImageFileUrl(diagramName, saveFilePath,ownerName); + return diagramDescriptor; + } + + private DiagramDescriptor createDiagramDescriptorWithImageFileUrl(String diagramName, String saveFilePath,String owner) { + DiagramDescriptor diagramDescriptor = new DiagramDescriptor(); + diagramDescriptor.name = diagramName; + if(owner!=null){ + diagramDescriptor.ownerName = owner; + } + String diagramFileName; + try { + diagramFileName = new File(saveFilePath).toURI().toURL().getFile(); + } catch (MalformedURLException e) { + return null; + } + + diagramDescriptor.url = FilenameUtils.getName(diagramFileName); + + return diagramDescriptor; + } + + public Collection<Diagram> getDiagrams() { + + NotationModel notationModel = NotationUtils.getNotationModel(); + Set<Diagram> diagrams = getIBD_BDD_Diagrams(notationModel.getResources()); + System.out.println("diagrams"); + for (Diagram c : diagrams) { + System.out.println(c); + } + return diagrams; + + } + + public Set<Diagram> getDiagrams(Set<Resource> resources){ + + Set<Diagram> diagrams = new HashSet<Diagram>(); + + for (Resource current : resources) { + for (EObject element : current.getContents()) { + if (element instanceof Diagram) { + diagrams.add((Diagram)element); + } + } + } + + return diagrams; + } + +private Set<Diagram> getIBD_BDD_Diagrams(Set<Resource> resources){ + + Set<Diagram> diagrams = new HashSet<Diagram>(); + + for (Resource current : resources) { + for (EObject element : current.getContents()) { + if (element instanceof Diagram) { + Diagram diagram = (Diagram)element; + System.out.println("diagram type: "+diagram.getType()); + + if (isBlockDefinitionDiagram(diagram)||isInternalBlockDiagram(diagram)){ + diagrams.add((Diagram)element); + } + } + } + } + + return diagrams; + } + + +private boolean isBlockDefinitionDiagram(Diagram diagram){ + if(diagram.getType().compareTo(BDD)==0){ + return true; + } + return false; +} + +private boolean isInternalBlockDiagram(Diagram diagram){ + if(diagram.getType().compareTo(IBD)==0){ + return true; + } + return false; +} + + private String getComponentImageFilePath(String fileName) { + return directoryName + File.separator + fileName + imageExtension; + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/da/da259f35cc3b1f65cfd54a41d0b1f1f34b9c9e88.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/da/da259f35cc3b1f65cfd54a41d0b1f1f34b9c9e88.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..8ac1534d94538eb4e50b50f3821abb5e2ac73624 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/da/da259f35cc3b1f65cfd54a41d0b1f1f34b9c9e88.svn-base @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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.diagram.ui.commands; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSInternalBlockDiagramModel; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; + +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ComponentToImageDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.InternalBlockDiagramGeneratorService; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +/** + * + * @author Alberto + */ +public class ExportComponentToImageCommand extends AbstractAsyncJobCommand { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + + //private OCRAComponentToImage ocraComponentToImage = OCRAComponentToImage.getInstance(); + //private DocumentGeneratorService ocraComponentToImage = DocumentGeneratorService.getInstance(CHESSGraphicalModel.getInstance()); + private InternalBlockDiagramGeneratorService diagramGeneratorService = InternalBlockDiagramGeneratorService.getInstance(CHESSInternalBlockDiagramModel.getInstance()); + + + public ExportComponentToImageCommand() { + super("Export Component To Image Command"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + System.out.println(); + + GraphicalEditPart selectedGraphicalComponent = selectionUtil + .getSelectedGraphicalObject(event); + + System.out.println("selectedGraphicalComponent: "+selectedGraphicalComponent); + + if (selectedGraphicalComponent != null) { + + final ComponentToImageDialog parameterDialog = exportDialogUtils + .getCompiledComponentToImageDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String projectDir = directoryUtils.getCurrentProjectDir(); + String imageName = diagramGeneratorService.getImageName( + selectedGraphicalComponent)+ "." + parameterDialog.getImageFormat() ; + + String imageFilePath = exportDialogUtils.openImageDialog(projectDir, imageName); + if ((imageFilePath == null) || imageFilePath.isEmpty()) { + return; + } + + diagramGeneratorService.setParametersBeforeDiagramGenerator + //setParametersBeforeExport + (parameterDialog.getShowPortLabels(), + parameterDialog.getAutomaticPortLabelLayout()); + diagramGeneratorService.createDiagramFile(imageFilePath, selectedGraphicalComponent,monitor); + exportDialogUtils.showMessage_ExportDone(imageFilePath); + } + + } + + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/dd/dd5379f5577796f4072e8f49e57512e2a99418a9.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/dd/dd5379f5577796f4072e8f49e57512e2a99418a9.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..7f3285f4e7d006ad32850304a96128821d8fb0b0 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/dd/dd5379f5577796f4072e8f49e57512e2a99418a9.svn-base @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="false" + locationURI="menu:org.eclipse.ui.main.menu.AMASS?after=org.eclipse.ui.main.menu.AMASS.funcVer"> + <menu + label="Safety Case" + id="org.eclipse.ui.main.menu.AMASS.safetyCase"> + <menu + label="Document Generation" + id="org.eclipse.ui.main.menu.AMASS.docGen"> + <command + commandId="org.polarsys.chess.diagram.ui.commands.ExportComponentToImageCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.diagram.ui.commands.ExportModelToDocumentCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.diagram.ui.commands.GenerateDocumentCommand" + style="push"> + </command> + </menu> + </menu> + </menuContribution> + <menuContribution + allPopups="false" + locationURI="popup:org.eclipse.ui.main.diagramEditorMenu.AMASS?after=org.eclipse.ui.main.diagramEditorMenu.AMASS.funcVer"> + <menu + label="Safety Case" + id="org.eclipse.ui.main.diagramEditorMenu.AMASS.safetyCase"> + <menu + label="Document Generation" + id="org.eclipse.ui.main.diagramEditorMenu.AMASS.docGen"> + <command + commandId="org.polarsys.chess.diagram.ui.commands.ExportComponentToImageCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.diagram.ui.commands.ExportModelToDocumentCommand" + style="push"> + </command> + <command + commandId="org.polarsys.chess.diagram.ui.commands.GenerateDocumentCommand" + style="push"> + </command> + </menu> + </menu> + </menuContribution> + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + defaultHandler="org.polarsys.chess.diagram.ui.commands.ExportComponentToImageCommand" + id="org.polarsys.chess.diagram.ui.commands.ExportComponentToImageCommand" + name="Export Selected Graphical Component as Image"> + </command> + <command + defaultHandler="org.polarsys.chess.diagram.ui.commands.ExportModelToDocumentCommand" + id="org.polarsys.chess.diagram.ui.commands.ExportModelToDocumentCommand" + name="Export Selected Graphical Component as Document"> + </command> + <command + defaultHandler="org.polarsys.chess.diagram.ui.commands.GenerateDocumentCommand" + id="org.polarsys.chess.diagram.ui.commands.GenerateDocumentCommand" + name="Generate Documentation from selected component"> + </command> + </extension> +</plugin> diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/e7/e72e6532a65328403be9911bc09cdc565857cbfa.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/e7/e72e6532a65328403be9911bc09cdc565857cbfa.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..f8d8130cd696d02591e102d6732f89a3fffd2989 --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/e7/e72e6532a65328403be9911bc09cdc565857cbfa.svn-base @@ -0,0 +1,113 @@ +package org.polarsys.chess.diagram.ui.commands; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.uml2.uml.Class; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSBlockDefinitionDiagramModel; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSInternalBlockDiagramModel; +import org.polarsys.chess.diagram.ui.services.CHESSDiagramsGeneratorService; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.services.OCRATranslatorService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.DiagramDescriptor; +import eu.fbk.eclipse.standardtools.diagram.DocumentGenerator; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ModelToDocumentDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DocumentGeneratorServiceFromOssModel; +import eu.fbk.eclipse.standardtools.diagram.ui.services.DiagramDialogUtil; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; +import eu.fbk.tools.editor.oss.oss.OSS; + +public class GenerateDocumentCommand extends AbstractAsyncJobCommand { + + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private ChessSystemModel chessToOCRAModelTranslator = ChessSystemModel.getInstance(); + private OCRATranslatorService ocraTranslatorService = OCRATranslatorService.getInstance(chessToOCRAModelTranslator); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + private CHESSDiagramsGeneratorService chessDiagramsGeneratorService = CHESSDiagramsGeneratorService.getInstance(CHESSInternalBlockDiagramModel.getInstance(),CHESSBlockDefinitionDiagramModel.getInstance()); + + + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + + private DocumentGeneratorServiceFromOssModel documentGeneratorService ; + /** + * @param commandName + */ + public GenerateDocumentCommand() { + super("Generate Documentation"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + + OSS ossModel = ocraTranslatorService.getOssModel(umlSelectedComponent, isDiscreteTime, monitor); + + ModelToDocumentDialog parameterDialog = exportDialogUtils.getCompiledModelToDocumentDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String docFormat = parameterDialog.getDocumentFormat(); + String imageExtension = ".svg"; + if (docFormat.equals("tex")) { + imageExtension = ".png"; + } + + // setShowLeafComponents(showLeafComponents); + String outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + // setDirectoryName(directoryName); + if ((outputDirectoryName == null) || outputDirectoryName.isEmpty()) { + return; + } + + String currentProjectName = directoryUtils.getCurrentProjectName(); + System.out.println("currentProjectName: "+currentProjectName); + + + //documentGeneratorService = DocumentGeneratorServiceFromOssModel.getInstance(CHESSDiagramModel.getInstance(), ossModel); + documentGeneratorService = new DocumentGeneratorServiceFromOssModel(ossModel); + documentGeneratorService.setParametersBeforeDocumentGeneration( + //parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout(), + outputDirectoryName, imageExtension, parameterDialog.getShowLeafComponents()); + DocumentGenerator documentGenerator = documentGeneratorService.createDocumentFile(currentProjectName, docFormat, ossModel.getSystem(), monitor); + + + //documentGeneratorService.setParametersBeforeDiagramsGenerator( + // outputDirectoryName, imageExtension,parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout()); + + + + chessDiagramsGeneratorService.setParametersBeforeDiagramsGenerator(outputDirectoryName, + imageExtension, + parameterDialog.getShowPortLabels(), + parameterDialog.getAutomaticPortLabelLayout()); + + Set<DiagramDescriptor> diagramDescriptors = new HashSet<DiagramDescriptor>(); + for(Diagram diagram : chessDiagramsGeneratorService.getDiagrams()){ + //chessDiagramsGeneratorService.createDiagram(diagram, monitor); + DiagramDescriptor dd = chessDiagramsGeneratorService.createDiagramWithDescriptor(diagram, monitor); + if(dd!=null){ + diagramDescriptors.add(dd); + } + } + + + documentGeneratorService.addDiagramDescriptors(diagramDescriptors, documentGenerator); + documentGeneratorService.generateDocument(documentGenerator); + + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/e9/e9219cb5d0bf4a113c47cfb404bfa5ef1fa630cc.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/e9/e9219cb5d0bf4a113c47cfb404bfa5ef1fa630cc.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..f234071d1260f31cb9df9cc5732e39676794ab7f --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/e9/e9219cb5d0bf4a113c47cfb404bfa5ef1fa630cc.svn-base @@ -0,0 +1,106 @@ +/** + * + */ +package org.polarsys.chess.diagram.ui.utils; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; + +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ComponentToImageDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ModelToDocumentDialog; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; + +/** + * + * + */ +public class ExportDialogUtils { + + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + private static ExportDialogUtils exportDialogUtils; + + public static ExportDialogUtils getInstance() { + if (exportDialogUtils == null) { + exportDialogUtils = new ExportDialogUtils(); + } + return exportDialogUtils; + } + + public void showMessage_ExportDone(String filePath) { + + Display defaultDisplay = Display.getDefault(); + + defaultDisplay.syncExec(new Runnable() { + @Override + public void run() { + Shell currShell=defaultDisplay.getActiveShell(); + MessageDialog.openInformation(currShell, "Info", + "The model is exported in " + filePath + "."); + } + }); + } + + public String getDirectoryNameFromDialog() throws Exception { + final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + final DirectoryDialog directoryDialog = new DirectoryDialog(shell); + directoryDialog.setText("Select the directory"); + // try { + directoryDialog.setFilterPath(directoryUtils.getCurrentProjectDir()); + /* + * } catch(Exception e) { e.printStackTrace(); } + */ + // dd.setFilterPath(getWorkspace().getRoot().getLocation().toString()); + + String directoryName = directoryDialog.open(); + + return directoryName; + } + + public String openImageDialog(String projectDir, String imageName) { + //Shell shell2 = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + Shell shell = Display.getDefault().getActiveShell(); + + //System.out.println("shell2: "+shell2); + System.out.println("shell: "+shell); + + final FileDialog fd = new FileDialog(shell, SWT.SAVE); + fd.setText("Set target file"); + // try { + fd.setFilterPath(projectDir); + /* + * } catch(Exception e) { e.printStackTrace(); } + */ + // fd.setFilterPath(getWorkspace().getRoot().getLocation().toString()); + + final String[] filterExt = { "*.svg", "*.png", "*.pdf" }; + fd.setFilterExtensions(filterExt); + + fd.setFileName(imageName); + + final String fileName = fd.open(); + return fileName; + } + + public ModelToDocumentDialog getCompiledModelToDocumentDialog() { + final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + final ModelToDocumentDialog parameterDialog = new ModelToDocumentDialog(shell); + parameterDialog.open(); + return parameterDialog; + } + + public ComponentToImageDialog getCompiledComponentToImageDialog() { + final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + final ComponentToImageDialog parameterDialog = new ComponentToImageDialog(shell); + parameterDialog.open(); + return parameterDialog; + } +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/ee/ee6b7d8e64509c69d2ac0827163b8541bdaec00c.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/ee/ee6b7d8e64509c69d2ac0827163b8541bdaec00c.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..07fc9a2aeb7c414ea365bb2f018e797e050105ad --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/ee/ee6b7d8e64509c69d2ac0827163b8541bdaec00c.svn-base @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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.diagram.ui.commands; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSDiagramModel; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; + +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ComponentToImageDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DiagramGeneratorService; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +/** + * + * @author Alberto + */ +public class ExportComponentToImageCommand extends AbstractAsyncJobCommand { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + + //private OCRAComponentToImage ocraComponentToImage = OCRAComponentToImage.getInstance(); + //private DocumentGeneratorService ocraComponentToImage = DocumentGeneratorService.getInstance(CHESSGraphicalModel.getInstance()); + private DiagramGeneratorService diagramGeneratorService = DiagramGeneratorService.getInstance(CHESSDiagramModel.getInstance()); + + + public ExportComponentToImageCommand() { + super("Export Component To Image Command"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + GraphicalEditPart selectedGraphicalComponent = selectionUtil + .getSelectedGraphicalObject(event); + + if (selectedGraphicalComponent != null) { + + final ComponentToImageDialog parameterDialog = exportDialogUtils + .getCompiledComponentToImageDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String projectDir = directoryUtils.getCurrentProjectDir(); + String imageName = diagramGeneratorService.getImageName( + selectedGraphicalComponent,parameterDialog.getImageFormat()) ; + + String imageFilePath = exportDialogUtils.openImageDialog(projectDir, imageName); + if ((imageFilePath == null) || imageFilePath.isEmpty()) { + return; + } + + diagramGeneratorService.setParametersBeforeDiagramGenerator + //setParametersBeforeExport + (parameterDialog.getShowPortLabels(), + parameterDialog.getAutomaticPortLabelLayout()); + diagramGeneratorService.createDiagramFile(imageFilePath, selectedGraphicalComponent,monitor); + exportDialogUtils.showMessage_ExportDone(imageFilePath); + } + + } + + + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/ee/eeb9da4e11212c83ef3110f0cc6f8823c2e958a8.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/ee/eeb9da4e11212c83ef3110f0cc6f8823c2e958a8.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..578e58bb8475eb447fa6057efd91ac1841ca74ac --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/ee/eeb9da4e11212c83ef3110f0cc6f8823c2e958a8.svn-base @@ -0,0 +1,110 @@ +package org.polarsys.chess.diagram.ui.commands; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.uml2.uml.Class; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSBlockDefinitionDiagramModel; +import org.polarsys.chess.diagram.ui.docGenerators.CHESSInternalBlockDiagramModel; +import org.polarsys.chess.diagram.ui.services.CHESSDiagramsGeneratorService; +import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.service.internal.utils.SelectionUtil; +import org.polarsys.chess.verificationService.model.ChessSystemModel; + +import eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.services.OCRATranslatorService; +import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; +import eu.fbk.eclipse.standardtools.diagram.DiagramDescriptor; +import eu.fbk.eclipse.standardtools.diagram.DocumentGenerator; +import eu.fbk.eclipse.standardtools.diagram.ui.dialog.ModelToDocumentDialog; +import eu.fbk.eclipse.standardtools.diagram.ui.docGenerators.DocumentGeneratorServiceFromOssModel; +import eu.fbk.eclipse.standardtools.diagram.ui.services.DiagramDialogUtil; +import eu.fbk.eclipse.standardtools.dialogs.MessageTimeModelDialog; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; +import eu.fbk.tools.editor.oss.oss.OSS; + +public class GenerateDocumentCommand extends AbstractAsyncJobCommand { + + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private ChessSystemModel chessToOCRAModelTranslator = ChessSystemModel.getInstance(); + private OCRATranslatorService ocraTranslatorService = OCRATranslatorService.getInstance(chessToOCRAModelTranslator); + private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + private CHESSDiagramsGeneratorService chessDiagramsGeneratorService = CHESSDiagramsGeneratorService.getInstance(CHESSInternalBlockDiagramModel.getInstance(),CHESSBlockDefinitionDiagramModel.getInstance()); + + + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + + private DocumentGeneratorServiceFromOssModel documentGeneratorService ; + /** + * @param commandName + */ + public GenerateDocumentCommand() { + super("Generate Documentation"); + } + + @Override + public void execJobCommand(ExecutionEvent event, IProgressMonitor monitor) throws Exception { + + + Class umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); + boolean isDiscreteTime = MessageTimeModelDialog.openQuestion(); + + OSS ossModel = ocraTranslatorService.getOssModel(umlSelectedComponent, isDiscreteTime, monitor); + + ModelToDocumentDialog parameterDialog = exportDialogUtils.getCompiledModelToDocumentDialog(); + + if (!parameterDialog.goAhead()) { + return; + } + + String docFormat = parameterDialog.getDocumentFormat(); + String imageExtension = ".svg"; + if (docFormat.equals("tex")) { + imageExtension = ".png"; + } + + // setShowLeafComponents(showLeafComponents); + String outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + // setDirectoryName(directoryName); + if ((outputDirectoryName == null) || outputDirectoryName.isEmpty()) { + return; + } + + String currentProjectName = directoryUtils.getCurrentProjectName(); + System.out.println("currentProjectName: "+currentProjectName); + + + //documentGeneratorService = DocumentGeneratorServiceFromOssModel.getInstance(CHESSDiagramModel.getInstance(), ossModel); + documentGeneratorService = new DocumentGeneratorServiceFromOssModel(ossModel); + documentGeneratorService.setParametersBeforeDocumentGeneration( + //parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout(), + outputDirectoryName, imageExtension, parameterDialog.getShowLeafComponents()); + DocumentGenerator documentGenerator = documentGeneratorService.createDocumentFile(currentProjectName, docFormat, ossModel.getSystem(), monitor); + + + //documentGeneratorService.setParametersBeforeDiagramsGenerator( + // outputDirectoryName, imageExtension,parameterDialog.getShowPortLabels(), parameterDialog.getAutomaticPortLabelLayout()); + + + + chessDiagramsGeneratorService.setParametersBeforeDiagramsGenerator(outputDirectoryName, + imageExtension, + parameterDialog.getShowPortLabels(), + parameterDialog.getAutomaticPortLabelLayout()); + + Set<DiagramDescriptor> diagramDescriptors = new HashSet<DiagramDescriptor>(); + for(Diagram diagram : chessDiagramsGeneratorService.getDiagrams()){ + //chessDiagramsGeneratorService.createDiagram(diagram, monitor); + diagramDescriptors.add(chessDiagramsGeneratorService.createDiagramWithDescriptor(diagram, monitor)); + } + + + documentGeneratorService.addDiagramDescriptors(diagramDescriptors, documentGenerator); + documentGeneratorService.generateDocument(documentGenerator); + + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/pristine/f4/f4cb3488ae90ddddc1cd1a1b41125de09eb8ce31.svn-base b/org.polarsys.chess.diagram.ui/.svn/pristine/f4/f4cb3488ae90ddddc1cd1a1b41125de09eb8ce31.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..abef01106d40a3442064b55f604e52a83a07872e --- /dev/null +++ b/org.polarsys.chess.diagram.ui/.svn/pristine/f4/f4cb3488ae90ddddc1cd1a1b41125de09eb8ce31.svn-base @@ -0,0 +1,497 @@ +/******************************************************************************* + * 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.diagram.ui.docGenerators; + +import java.awt.Dimension; +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEditPart; +import org.eclipse.papyrus.sysml.diagram.common.edit.part.StructureCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorEditPart; +import org.eclipse.papyrus.uml.diagram.common.editparts.IUMLEditPart; +import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.CustomPropertyPartEditPartCN; +import org.eclipse.papyrus.uml.diagram.composite.custom.edit.parts.ResizablePortEditPart; +import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeCompartmentEditPart; +import org.eclipse.uml2.uml.Connector; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Port; +import org.polarsys.chess.core.util.uml.EntityUtil; + +import eu.fbk.eclipse.standardtools.diagram.ui.layout.EOrientation; +import eu.fbk.eclipse.standardtools.diagram.ui.layout.EOrientation.Orientation; +import eu.fbk.eclipse.standardtools.diagram.ui.model.AbstractDiagramModel; + +public class CHESSDiagramModel implements AbstractDiagramModel{ + + + private static CHESSDiagramModel chessModel; + + public static CHESSDiagramModel getInstance(){ + if(chessModel == null){ + chessModel = new CHESSDiagramModel(); + } + return chessModel; + } + + + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String getGraphicalComponentId(Object graphicalComponent) { + Element umlElement = null; + /* + * if(graphicalComponent instanceof BlockCompositeEditPart){ umlElement + * = ((BlockCompositeEditPart)graphicalComponent).getUMLElement(); } + * if(graphicalComponent instanceof BlockPropertyCompositeEditPart){ + * umlElement = + * ((BlockPropertyCompositeEditPart)graphicalComponent).getUMLElement(); + * } + */ + if (graphicalComponent instanceof IUMLEditPart) { + umlElement = ((IUMLEditPart) graphicalComponent).getUMLElement(); + } + return entityUtil.getComponentID(umlElement); + } + + @Override + public String getGraphicalComponentName(Object graphicalComponent) { + EObject component = ((GraphicalEditPart) graphicalComponent).resolveSemanticElement(); + + // ((AppliedStereotypeEmptyEditPart)graphicalComponent).get + + return entityUtil.getComponentName(component); + } + + @Override + public List<GraphicalEditPart> getGraphicalSubComponents(Object graphicalComponent) { + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + List<GraphicalEditPart> graphicalSubComponent = new ArrayList<GraphicalEditPart>(); + for (Object child : children) { + System.out.println("child: " + child); + if (child instanceof StructureCompartmentEditPart) { + for (Object componentChild : ((StructureCompartmentEditPart) child).getChildren()) { + System.out.println("StructureCompartmentEditPart child: " + componentChild); + if (componentChild instanceof BlockPropertyCompositeEditPart) { + graphicalSubComponent.add((GraphicalEditPart) componentChild); + } + } + } + if (child instanceof ClassCompositeCompartmentEditPart) { + for (Object componentChild : ((ClassCompositeCompartmentEditPart) child).getChildren()) { + System.out.println("StructureCompartmentEditPart child: " + componentChild); + if (componentChild instanceof CustomPropertyPartEditPartCN) { + graphicalSubComponent.add((GraphicalEditPart) componentChild); + } + } + } + } + return graphicalSubComponent; + } + + @Override + public Object getGraphicalOwnerComponents(Object graphicalComponent) { + return ((GraphicalEditPart) graphicalComponent).getParent(); + } + + @Override + public List<?> getGraphicalPorts(Object graphicalComponent) { + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + List<GraphicalEditPart> graphicalConnectors = new ArrayList<GraphicalEditPart>(); + for (Object child : children) { + if (child instanceof FlowPortAffixedNodeEditPart) { + graphicalConnectors.add((GraphicalEditPart) child); + } + if (child instanceof ResizablePortEditPart) { + graphicalConnectors.add((GraphicalEditPart) child); + } + } + return graphicalConnectors; + } + + @Override + public Object getGraphicalPortOwner(Object port) { + return ((GraphicalEditPart) port).getParent(); + } + + @Override + public Dimension getGraphicalComponentDimension(Object component) { + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) component).getFigure().getSize(); + Dimension d = new Dimension(domension.width, domension.height); + return d; + } + + @Override + public Point getGraphicalComponentPosition(Object component) { + + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + + printlnGraphicalPosition(graphicalComponent); + + // System.out.println("----------------------------"); + // System.out.println(graphicalComponent.getLocation()); + // System.out.println(component); + // System.out.println(graphicalComponent.getContentPane().getBounds()); + // System.out.println(graphicalComponent.getFigure().getBounds()); + // System.out.println(graphicalComponent.getMainFigure().getBounds()); + // System.out.println(graphicalComponent.getBorderedFigure().getBounds()); + // System.out.println(graphicalComponent.getPrimaryShape().getBounds()); + // System.out.println(graphicalComponent.getPrimaryShape().getLocation()); + + Point point = new Point(x, y); + + Point parentPoint = getOwnerPosition(graphicalComponent.getParent()); + + System.out.println("parentPoint: " + parentPoint); + + point.x = point.x + parentPoint.x; + point.y = point.y + parentPoint.y; + + return point; + } + + private Object printlnGraphicalPosition(Object component) { + if (component instanceof GraphicalEditPart) { + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + System.out.println("-------printlnGraphicalPosition------------"); + System.out.println(graphicalComponent); + System.out.println(graphicalComponent.getFigure().getBounds()); + return printlnGraphicalPosition(graphicalComponent.getParent()); + } + return null; + } + + /* + * @Override public Point getGraphicalComponentPosition(Object component) { + * + * GraphicalEditPart graphicalComponent = (GraphicalEditPart)component; + * + * int x =0; int y =0; if(!(component instanceof + * StructureCompartmentEditPart)){ x = + * graphicalComponent.getFigure().getBounds().x; y = + * graphicalComponent.getFigure().getBounds().y; } + * + * + * System.out.println("----------------------------"); + * //System.out.println(graphicalComponent.getLocation()); + * System.out.println(component); + * //System.out.println(graphicalComponent.getContentPane().getBounds()); + * System.out.println(graphicalComponent.getFigure().getBounds()); + * //System.out.println(graphicalComponent.getMainFigure().getBounds()); + * //System.out.println(graphicalComponent.getBorderedFigure().getBounds()); + * //System.out.println(graphicalComponent.getPrimaryShape().getBounds()); + * //System.out.println(graphicalComponent.getPrimaryShape().getLocation()); + * + * + * Point point = new Point(x, y); + * + * if(graphicalComponent.getParent() instanceof GraphicalEditPart){ Point + * parentPoint = + * getGraphicalComponentPosition(graphicalComponent.getParent()); + * point.x=point.x+parentPoint.x; point.y=point.y+parentPoint.y; } return + * point; } + */ + + + private Point getOwnerPosition(Object component) { + + if (component instanceof GraphicalEditPart) { + GraphicalEditPart graphicalComponent = (GraphicalEditPart) component; + + int x = 0; + int y = 0; + if (component instanceof StructureCompartmentEditPart) { + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + Point point = new Point(x, y); + return point; + } + if (component instanceof ClassCompositeCompartmentEditPart) { + x = graphicalComponent.getFigure().getBounds().x; + y = graphicalComponent.getFigure().getBounds().y; + Point point = new Point(x, y); + return point; + } + + return getOwnerPosition(graphicalComponent.getParent()); + } else { + return new Point(0, 0); + } + } + + @Override + public boolean isGraphicalPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public boolean isGraphicalInputPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isInputPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isInputPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public boolean isGraphicalOutputPort(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return entityUtil.isOutputPort((Element) ((FlowPortAffixedNodeEditPart) port).getUMLElement()); + } + if (port instanceof ResizablePortEditPart) { + return entityUtil.isOutputPort((Element) ((ResizablePortEditPart) port).getUMLElement()); + } + return false; + } + + @Override + public String getGraphicalPortName(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return ((Port) ((FlowPortAffixedNodeEditPart) port).getUMLElement()).getName(); + } + if (port instanceof ResizablePortEditPart) { + return ((Port) ((ResizablePortEditPart) port).getUMLElement()).getName(); + } + return null; + } + + + + @Override + public Object getGraphicalPortVariableType(Object port) { + if (port instanceof FlowPortAffixedNodeEditPart) { + return ((Port) ((FlowPortAffixedNodeEditPart) port).getUMLElement()).getType().getName(); + } + if (port instanceof ResizablePortEditPart) { + return ((Port) ((ResizablePortEditPart) port).getUMLElement()).getType().getName(); + } + return null; + } + + @Override + public Point getGraphicalPortPosition(Object port) { + + // org.eclipse.draw2d.geometry.Point p = + // ((FlowPortAffixedNodeEditPart)Port).getLocation(); + // org.eclipse.draw2d.geometry.Point p = + // ((GraphicalEditPart)Port).getFigure().getBounds(); + int x = ((GraphicalEditPart) port).getFigure().getBounds().x; + int y = ((GraphicalEditPart) port).getFigure().getBounds().y; + + // System.out.println("port bounds: + // "+((FlowPortAffixedNodeEditPart)Port).getFigure().getBounds()); + // System.out.println("port loc: "+p); + + // Point point = new Point(p.x, p.y); + Point point = new Point(x, y); + + // GraphicalEditPart portParent = + // (GraphicalEditPart)((GraphicalEditPart)Port).getParent(); + // Point partentPoint = + // getGraphicalComponentPosition(portParent.getParent()); + Point partentPoint = getOwnerPosition(port); + + point.x = point.x + partentPoint.x; + point.y = point.y + partentPoint.y; + return point; + } + + @Override + public Dimension getGraphicalPortDimension(Object port) { + + org.eclipse.draw2d.geometry.Dimension domension = ((GraphicalEditPart) port).getFigure().getSize(); + Dimension dim = new Dimension(domension.width, domension.height); + + return dim; + } + + @Override + public EOrientation getGraphicalPortOffsetOrientation(Object port) { + + int or = 0; + if (port instanceof FlowPortAffixedNodeEditPart) { + or = ((FlowPortAffixedNodeEditPart) port).getBorderItemLocator().getCurrentSideOfParent(); + } + if (port instanceof ResizablePortEditPart) { + or = ((ResizablePortEditPart) port).getBorderItemLocator().getCurrentSideOfParent(); + } + System.out.println("or: " + or); + + EOrientation eOrientation = new EOrientation(); + Point p = getGraphicalPortPosition(port); + int offset = 0; + Orientation orientation = Orientation.NORTH_VALUE; + + switch (or) { + case 1: + orientation = Orientation.NORTH_VALUE; + offset = p.x; + break; + case 4: + orientation = Orientation.SOUTH_VALUE; + offset = p.x; + break; + case 8: + orientation = Orientation.WEST_VALUE; + offset = p.y; + break; + case 16: + orientation = Orientation.EAST_VALUE; + offset = p.y; + break; + } + + eOrientation.setOrientation(orientation); + eOrientation.setOffset(offset); + return eOrientation; + } + + @SuppressWarnings("unchecked") + @Override + public List<?> getPortChannels(Object graphicalComponent) { + + System.out.println("getPortConnections"); + List<Object> connections = new ArrayList<Object>(); + + if (graphicalComponent instanceof GraphicalEditPart) { + + List<?> children = ((GraphicalEditPart) graphicalComponent).getChildren(); + for (Object child : children) { + if (child instanceof FlowPortAffixedNodeEditPart) { + GraphicalEditPart graphicalPort = (GraphicalEditPart) child; + connections.addAll(graphicalPort.getSourceConnections()); + + } + if (child instanceof ResizablePortEditPart) { + GraphicalEditPart graphicalPort = (GraphicalEditPart) child; + connections.addAll(graphicalPort.getSourceConnections()); + + } + } + + for (Object subComponents : getGraphicalSubComponents(graphicalComponent)) { + connections.addAll(getPortChannels(subComponents)); + /* + * List children + * =((GraphicalEditPart)subComponents).getChildren(); for(Object + * child : children){ if(child instanceof + * FlowPortAffixedNodeEditPart){ GraphicalEditPart graphicalPort + * = (GraphicalEditPart) child; + * System.out.println("child: "+child); + * connections.addAll(graphicalPort.getSourceConnections()); + * connections.addAll(graphicalPort.getTargetConnections()); + * + * } } + */ + } + + } + System.out.println("connections.size: " + connections.size()); + + return connections; + } + + @Override + public String getChannelName(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((Connector) ((View) ((ConnectorEditPart) channel).getModel()).getElement()).getName(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((Connector) ((View) ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel) + .getModel()).getElement()).getName(); + } + return null; + } + + @Override + public Object getChannelTargetPort(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((ConnectorEditPart) channel).getTarget(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel).getTarget(); + } + return null; + } + + @Override + public Object getChannelSourcePort(Object channel) { + if (channel instanceof ConnectorEditPart) { + return ((ConnectorEditPart) channel).getSource(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + return ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel).getSource(); + } + return null; + } + + @Override + public ArrayList<?> getPortIncomingChannels(Object port) { + return null; + } + + @Override + public ArrayList<?> getPortOutgoingChannels(Object port) { + return null; + } + + @Override + public List<Point> getLayoutChannelPoints(Object channel) { + int[] pointList = null; + if (channel instanceof ConnectorEditPart) { + pointList = ((ConnectorEditPart) channel).getConnectionFigure().getPoints().toIntArray(); + } + if (channel instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) { + pointList = ((org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConnectorEditPart) channel) + .getConnectionFigure().getPoints().toIntArray(); + } + List<Point> points = new ArrayList<Point>(); + + for (int i = 0; i < pointList.length; i = i + 2) { + Point p = new Point(pointList[i], pointList[i + 1]); + points.add(p); + } + + return points; + } + + @Override + public Object getChannelOwner(Object channel) { + return ((GraphicalEditPart) channel).getParent(); + } + + + + @Override + public String getGraphicalPortRange(Object component, Object port) { + return "PortRange"; + } + +} diff --git a/org.polarsys.chess.diagram.ui/.svn/wc.db b/org.polarsys.chess.diagram.ui/.svn/wc.db new file mode 100644 index 0000000000000000000000000000000000000000..8b1d34bf54a142e42435d02a172fee11237c50a8 Binary files /dev/null and b/org.polarsys.chess.diagram.ui/.svn/wc.db differ diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/entries b/org.polarsys.chess.properties.propertyEditor/.svn/entries new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/entries @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/format b/org.polarsys.chess.properties.propertyEditor/.svn/format new file mode 100644 index 0000000000000000000000000000000000000000..3cacc0b93c9c9c03a72da624ca28a09ba5c1336f --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/format @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/18/18a06f8a4c77351c8eefa068904d6e365c236584.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/18/18a06f8a4c77351c8eefa068904d6e365c236584.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..1a82ca4183a49cfdfdf7f9492e11ce1a765fb5a4 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/18/18a06f8a4c77351c8eefa068904d6e365c236584.svn-base @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> + <propertyTabs + contributorId="TreeOutlinePage"> + <propertyTab + afterTab="advanced" + category="Editors" + id="CustomPropertyTab" + label="PropertyEditor+"> + </propertyTab> + </propertyTabs> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections + contributorId="TreeOutlinePage"> + <propertySection + class="org.polarsys.chess.properties.propertyEditor.CustomPropertyEditorTab" + filter="org.polarsys.chess.properties.propertyEditor.PropertyEditorFilter" + id="CustomPropertyEditorSection" + tab="CustomPropertyTab"> + </propertySection> + </propertySections> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage"> + <propertyCategory + category="Editors"> + </propertyCategory> + </propertyContributor> + </extension> + +</plugin> diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/1a/1a1c5e8e62ff770fb3257122f24111565a3d0e54.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/1a/1a1c5e8e62ff770fb3257122f24111565a3d0e54.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b9879a2b3b0299649562bec962d9744161fbff64 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/1a/1a1c5e8e62ff770fb3257122f24111565a3d0e54.svn-base @@ -0,0 +1,112 @@ +/******************************************************************************* + * 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.properties.propertyEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.polarsys.chess.contracts.profile.chesscontract.FormalProperty; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.propertyEditor.propertyTab.PropertyEditorTab; + +public class CustomPropertyEditorTab extends PropertyEditorTab { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getPropertyOwnerInputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.IN_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerOutputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.OUT_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerInputOutputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.INOUT_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerAttributes(Object property) { + Element umlOwner = ((Constraint) property).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(umlOwner)); + + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + + } + + @Override + public Object returnProperty(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + Constraint umlConstraint = (Constraint) selectedUmlElement; + if (contractEntityUtil.isFormalProperty(umlConstraint)) { + return umlConstraint; + } + } + + return null; + } + + @Override + public Resource getResourceFromProperty(Object formalProperty) { + + return ((Constraint) formalProperty).eResource(); + } + + @Override + public void propertyEditorchanged(Object property, String textChanged) { + contractEntityUtil.saveFormalProperty(contractEntityUtil.getFormalProperty((Constraint) property), textChanged); + } + + public String getPropertyName(Object property) { + if (property != null) { + return ((Constraint) property).getQualifiedName(); + } + return null; + } + + public String getStrFromProperty(Object property) { + FormalProperty formalProperty = contractEntityUtil.getFormalProperty((Constraint) property); + return contractEntityUtil.getPropertyStr(formalProperty); + } + + @Override + public String[] getEnumValuesFromPropertyOwnerPorts(Object formalProperty) { + Class element = (Class) ((Constraint) formalProperty).getOwner(); + return entityUtil.getEnumValuesFromComponentPorts(element); + } + +} diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..6f20375d6c7d98fbc80bb5da99be9866b1fe2f73 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/3c/3cbebaa7f54b0cb886240fc79028e5df4f4d2f71.svn-base @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/4f/4f2829bd93d4b7b7b01d2750de95e1254f346427.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/4f/4f2829bd93d4b7b7b01d2750de95e1254f346427.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..3ae0d639e9dee3ba6506559c252a997699aca3d6 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/4f/4f2829bd93d4b7b7b01d2750de95e1254f346427.svn-base @@ -0,0 +1,105 @@ +/******************************************************************************* + * 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.properties.propertyEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.polarsys.chess.contracts.profile.chesscontract.FormalProperty; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.EntityUtil; +import org.polarsys.chess.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.propertyEditor.propertyTab.PropertyEditorTab; + +public class CustomPropertyEditorTab extends PropertyEditorTab { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getPropertyOwnerInputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.IN_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerOutputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.OUT_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerInputOutputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.INOUT_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerAttributes(Object property) { + Element umlOwner = ((Constraint) property).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(umlOwner)); + + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + + } + + @Override + public Object returnProperty(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + Constraint umlConstraint = (Constraint) selectedUmlElement; + if (contractEntityUtil.isFormalProperty(umlConstraint)) { + return umlConstraint; + } + } + + return null; + } + + @Override + public Resource getResourceFromProperty(Object formalProperty) { + + return ((Constraint) formalProperty).eResource(); + } + + @Override + public void propertyEditorchanged(Object property, String textChanged) { + contractEntityUtil.saveFormalProperty(contractEntityUtil.getFormalProperty((Constraint) property), textChanged); + } + + public String getPropertyName(Object property) { + if (property != null) { + return ((Constraint) property).getQualifiedName(); + } + return null; + } + + public String getStrFromProperty(Object property) { + FormalProperty formalProperty = contractEntityUtil.getFormalProperty((Constraint) property); + return contractEntityUtil.getPropertyStr(formalProperty); + } + +} diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..295926d964165896ea8aa7c1b1b3c9d3d3caa77e --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/51/512bd49c4ba767010f32a54ef22de71e83bd7e1e.svn-base @@ -0,0 +1,7 @@ +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 diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/56/56aa55ddcaaee896cd73c7f4a212fab9f6b86ade.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/56/56aa55ddcaaee896cd73c7f4a212fab9f6b86ade.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..3c0ccc254a828d8fdc18e764f86965b48c6f8095 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/56/56aa55ddcaaee896cd73c7f4a212fab9f6b86ade.svn-base @@ -0,0 +1,105 @@ +/******************************************************************************* + * 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.properties.propertyEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.polarsys.chess.contracts.profile.chesscontract.FormalProperty; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.core.util.uml.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.propertyEditor.propertyTab.PropertyEditorTab; + +public class CustomPropertyEditorTab extends PropertyEditorTab { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getPropertyOwnerInputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.IN_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerOutputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.OUT_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerInputOutputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.INOUT_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerAttributes(Object property) { + Element umlOwner = ((Constraint) property).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(umlOwner)); + + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + + } + + @Override + public Object returnProperty(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + Constraint umlConstraint = (Constraint) selectedUmlElement; + if (contractEntityUtil.isFormalProperty(umlConstraint)) { + return umlConstraint; + } + } + + return null; + } + + @Override + public Resource getResourceFromProperty(Object formalProperty) { + + return ((Constraint) formalProperty).eResource(); + } + + @Override + public void propertyEditorchanged(Object property, String textChanged) { + contractEntityUtil.saveFormalProperty(contractEntityUtil.getFormalProperty((Constraint) property), textChanged); + } + + public String getPropertyName(Object property) { + if (property != null) { + return ((Constraint) property).getQualifiedName(); + } + return null; + } + + public String getStrFromProperty(Object property) { + FormalProperty formalProperty = contractEntityUtil.getFormalProperty((Constraint) property); + return contractEntityUtil.getPropertyStr(formalProperty); + } + +} diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/58/5856c1c9a92d9921638be8b75a52208db7d2760e.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/58/5856c1c9a92d9921638be8b75a52208db7d2760e.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..23a9f1ae5647ce93f0c6b10ebab8d57d87440943 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/58/5856c1c9a92d9921638be8b75a52208db7d2760e.svn-base @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.properties.propertyEditor; + +import org.eclipse.uml2.uml.Constraint; +import org.polarsys.chess.utils.ContractEntityUtil; +import org.polarsys.chess.utils.SelectionUtil; + +public class PropertyEditorFilter implements org.eclipse.jface.viewers.IFilter { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + + @Override + public boolean select(Object selection) { + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + if (contractEntityUtil.isFormalProperty((Constraint) selectedUmlElement)) { + return true; + } + } + + return false; + } +} diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/5c/5c0421855513837a9f7f768df7fc032a56d84600.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/5c/5c0421855513837a9f7f768df7fc032a56d84600.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..acdf322b4e19f50790b71cb8696fdb757e51c252 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/5c/5c0421855513837a9f7f768df7fc032a56d84600.svn-base @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.polarsys.chess.properties.propertyEditor</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> diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/81/817e4980b4e55afe7436fb708720f588e2733c27.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/81/817e4980b4e55afe7436fb708720f588e2733c27.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..bc4cbf796cba711ad2d11acb5dd7d8138ee705ab --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/81/817e4980b4e55afe7436fb708720f588e2733c27.svn-base @@ -0,0 +1,105 @@ +/******************************************************************************* + * 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.properties.propertyEditor; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.polarsys.chess.contracts.profile.chesscontract.FormalProperty; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +import eu.fbk.eclipse.standardtools.propertyEditor.propertyTab.PropertyEditorTab; + +public class CustomPropertyEditorTab extends PropertyEditorTab { + + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private EntityUtil entityUtil = EntityUtil.getInstance(); + + @Override + public String[] getPropertyOwnerInputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.IN_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerOutputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.OUT_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerInputOutputPorts(Object formalProperty) { + Element umlOwner = entityUtil.getOwner((Constraint) formalProperty); + int direction = FlowDirection.INOUT_VALUE; + return entityUtil.getPortsNames(umlOwner, direction); + } + + @Override + public String[] getPropertyOwnerAttributes(Object property) { + Element umlOwner = ((Constraint) property).getOwner(); + EList<String> attrArr = new BasicEList<String>(); + + attrArr.addAll(entityUtil.getBooleanAttributesNamesExceptsPorts(umlOwner)); + + String[] attributesStrArr = new String[attrArr.size()]; + return attrArr.toArray(attributesStrArr); + + } + + @Override + public Object returnProperty(ISelection selection) { + + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + Constraint umlConstraint = (Constraint) selectedUmlElement; + if (contractEntityUtil.isFormalProperty(umlConstraint)) { + return umlConstraint; + } + } + + return null; + } + + @Override + public Resource getResourceFromProperty(Object formalProperty) { + + return ((Constraint) formalProperty).eResource(); + } + + @Override + public void propertyEditorchanged(Object property, String textChanged) { + contractEntityUtil.saveFormalProperty(contractEntityUtil.getFormalProperty((Constraint) property), textChanged); + } + + public String getPropertyName(Object property) { + if (property != null) { + return ((Constraint) property).getQualifiedName(); + } + return null; + } + + public String getStrFromProperty(Object property) { + FormalProperty formalProperty = contractEntityUtil.getFormalProperty((Constraint) property); + return contractEntityUtil.getPropertyStr(formalProperty); + } + +} diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..b862a296d38fe04269faeee6c9d77d11ff77380d --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/84/840bb71c03bf83525100c2e64ed14e864bbbba56.svn-base @@ -0,0 +1,7 @@ +<?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> diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/c7/c7b12fd196d5f1da852b2499aade83e29a8e9be3.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/c7/c7b12fd196d5f1da852b2499aade83e29a8e9be3.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..a94fed554e228c0ce23ce0575c7489fe1258110e --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/c7/c7b12fd196d5f1da852b2499aade83e29a8e9be3.svn-base @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.properties.propertyEditor +Bundle-SymbolicName: org.polarsys.chess.properties.propertyEditor;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.papyrus.infra.core, + org.eclipse.ui.views.properties.tabbed, + eu.fbk.eclipse.standardtools.propertyEditor.core, + org.polarsys.chess.chessmlprofile;bundle-version="0.9.0", + org.polarsys.chess.utils +Import-Package: org.eclipse.gef, + org.eclipse.gmf.runtime.diagram.ui.editparts, + org.eclipse.papyrus.infra.emf.utils, + org.eclipse.papyrus.uml.diagram.common.edit.part, + org.eclipse.uml2.uml +Bundle-Vendor: Fondazione Bruno Kessler diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..ae3c1726048cd06b9a143e0376ed46dd9b9a8d53 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/ce/ceb68d84ab6670ae76b7b442439794fe1e756c07.svn-base @@ -0,0 +1 @@ +/bin/ diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/e9/e9b73ba497796085d5c909a5ecad8fe3c97d5dc0.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/e9/e9b73ba497796085d5c909a5ecad8fe3c97d5dc0.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..7c3b9d8090fc00a2164defc6afff8c6cde33c2e0 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/e9/e9b73ba497796085d5c909a5ecad8fe3c97d5dc0.svn-base @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.polarsys.chess.properties.propertyEditor +Bundle-SymbolicName: org.polarsys.chess.properties.propertyEditor;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.papyrus.infra.core, + org.eclipse.ui.views.properties.tabbed, + eu.fbk.eclipse.standardtools.propertyEditor.core, + org.polarsys.chess.chessmlprofile;bundle-version="0.9.0", + org.polarsys.chess.contracts.profile, + org.polarsys.chess.service, + org.polarsys.chess.core +Import-Package: org.eclipse.gef, + org.eclipse.gmf.runtime.diagram.ui.editparts, + org.eclipse.papyrus.infra.emf.utils, + org.eclipse.papyrus.uml.diagram.common.edit.part, + org.eclipse.uml2.uml +Bundle-Vendor: Fondazione Bruno Kessler diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/ef/ef968e72cc9356480a03399e240f459b8e7cb301.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/ef/ef968e72cc9356480a03399e240f459b8e7cb301.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..d04ae136a4c3ff43e14ed3c09be006ce688c8fb8 --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/ef/ef968e72cc9356480a03399e240f459b8e7cb301.svn-base @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> + <propertyTabs + contributorId="TreeOutlinePage"> + <propertyTab + afterTab="advanced" + category="Editors" + id="CustomPropertyTab" + label="CustomPropertyEditor"> + </propertyTab> + </propertyTabs> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections + contributorId="TreeOutlinePage"> + <propertySection + class="org.polarsys.chess.properties.propertyEditor.CustomPropertyEditorTab" + filter="org.polarsys.chess.properties.propertyEditor.PropertyEditorFilter" + id="CustomPropertyEditorSection" + tab="CustomPropertyTab"> + </propertySection> + </propertySections> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="TreeOutlinePage"> + <propertyCategory + category="Editors"> + </propertyCategory> + </propertyContributor> + </extension> + +</plugin> diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/pristine/f5/f542b7f2ddd54cdb03656b82385d3273f5f8fb09.svn-base b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/f5/f542b7f2ddd54cdb03656b82385d3273f5f8fb09.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..97c990cf5d2e261088f070fa40cd9d05430095da --- /dev/null +++ b/org.polarsys.chess.properties.propertyEditor/.svn/pristine/f5/f542b7f2ddd54cdb03656b82385d3273f5f8fb09.svn-base @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.properties.propertyEditor; + +import org.eclipse.uml2.uml.Constraint; +import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil; +import org.polarsys.chess.service.internal.utils.SelectionUtil; + +public class PropertyEditorFilter implements org.eclipse.jface.viewers.IFilter { + + private SelectionUtil selectionUtil = SelectionUtil.getInstance(); + private ContractEntityUtil contractEntityUtil = ContractEntityUtil.getInstance(); + + @Override + public boolean select(Object selection) { + + Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection); + + if (selectedUmlElement instanceof Constraint) { + if (contractEntityUtil.isFormalProperty((Constraint) selectedUmlElement)) { + return true; + } + } + + return false; + } +} diff --git a/org.polarsys.chess.properties.propertyEditor/.svn/wc.db b/org.polarsys.chess.properties.propertyEditor/.svn/wc.db new file mode 100644 index 0000000000000000000000000000000000000000..ec124168828c9cf5403bb21c105fe36b2d6857a6 Binary files /dev/null and b/org.polarsys.chess.properties.propertyEditor/.svn/wc.db differ diff --git a/org.polarsys.chess.smvExport/META-INF/MANIFEST.MF b/org.polarsys.chess.smvExport/META-INF/MANIFEST.MF index 1c2b97ee699bea3d05a1080ac7bd055b3d3ac686..cf4887323ca270211c7590125ce3055433cc8555 100644 --- a/org.polarsys.chess.smvExport/META-INF/MANIFEST.MF +++ b/org.polarsys.chess.smvExport/META-INF/MANIFEST.MF @@ -8,7 +8,6 @@ Bundle-Vendor: Fondazione Bruno Kessler Require-Bundle: org.eclipse.papyrus.infra.gmfdiag.common, eu.fbk.eclipse.standardtools.utils, org.polarsys.chess.service, - org.polarsys.chess.diagram.ui, org.eclipse.uml2.uml, org.polarsys.chess.contracts.profile;bundle-version="0.9.0", eu.fbk.eclipse.standardtools.StateMachineTranslatorToSmv;bundle-version="1.0.0", diff --git a/org.polarsys.chess.smvExport/src/org/polarsys/chess/smvExport/commands/ExportNominalSMsToSmvFilesCommand.java b/org.polarsys.chess.smvExport/src/org/polarsys/chess/smvExport/commands/ExportNominalSMsToSmvFilesCommand.java index ded66bcb50c9eb7fc01f722e6efbc3cfc16a9e19..8c2245ce52f5973e8d924e5d771d2a9db9c9de41 100644 --- a/org.polarsys.chess.smvExport/src/org/polarsys/chess/smvExport/commands/ExportNominalSMsToSmvFilesCommand.java +++ b/org.polarsys.chess.smvExport/src/org/polarsys/chess/smvExport/commands/ExportNominalSMsToSmvFilesCommand.java @@ -15,14 +15,14 @@ import java.util.Collection; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.uml2.uml.StateMachine; -import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +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 SelectionUtil selectionUtil = SelectionUtil.getInstance(); - private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + private DialogUtils exportDialogUtils = DialogUtils.getInstance(); //private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); private SmvExportService smvExportService = SmvExportService.getInstance(); diff --git a/org.polarsys.chess.smvExport/src/org/polarsys/chess/smvExport/commands/ExportSelectedNominalSMsToSmvFilesCommand.java b/org.polarsys.chess.smvExport/src/org/polarsys/chess/smvExport/commands/ExportSelectedNominalSMsToSmvFilesCommand.java index 60cf7395128cdb58f11c56fd2fb86a8ebae83f1e..ad87cfc01023d7d474ab56d64058ec8bf2fb7a82 100644 --- a/org.polarsys.chess.smvExport/src/org/polarsys/chess/smvExport/commands/ExportSelectedNominalSMsToSmvFilesCommand.java +++ b/org.polarsys.chess.smvExport/src/org/polarsys/chess/smvExport/commands/ExportSelectedNominalSMsToSmvFilesCommand.java @@ -15,7 +15,7 @@ import java.util.Collection; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.uml2.uml.StateMachine; -import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +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; @@ -24,7 +24,7 @@ import org.eclipse.uml2.uml.Class; public class ExportSelectedNominalSMsToSmvFilesCommand extends AbstractJobCommand { private SelectionUtil selectionUtil = SelectionUtil.getInstance(); - private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + private DialogUtils dialogUtils = DialogUtils.getInstance(); //private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); private SmvExportService smvExportService = SmvExportService.getInstance(); @@ -42,7 +42,7 @@ public class ExportSelectedNominalSMsToSmvFilesCommand extends AbstractJobComma public void execGUIOperations(ExecutionEvent event, IProgressMonitor monitor) throws Exception { umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); - outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + outputDirectoryName = dialogUtils.getDirectoryNameFromDialog(); //currentProjectName = directoryUtils.getCurrentProjectName(); showPopups = true; stateMachines = smvExportService.getNominalStateMachines(umlSelectedComponent); diff --git a/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/commands/ExportModelToDocumentCommand.java b/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/commands/ExportModelToDocumentCommand.java index 66f8ebd673062c5da2f0d69c29be0fcf0f1e07f3..e1274e2218464d8d52720849b0301e65e382e67e 100644 --- a/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/commands/ExportModelToDocumentCommand.java +++ b/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/commands/ExportModelToDocumentCommand.java @@ -16,6 +16,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; import org.polarsys.chess.diagram.ui.docGenerators.CHESSInternalBlockDiagramModel; import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; +import org.polarsys.chess.service.utils.DialogUtils; import org.polarsys.chess.service.utils.SelectionUtil; import eu.fbk.eclipse.standardtools.commands.AbstractAsyncJobCommand; @@ -36,6 +37,7 @@ public class ExportModelToDocumentCommand extends AbstractAsyncJobCommand { private SelectionUtil selectionUtil = SelectionUtil.getInstance(); private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + private DialogUtils dialogUtils = DialogUtils.getInstance(); //private OCRAComponentToImage ocraComponentToImage = OCRAComponentToImage.getInstance(); private DocumentGeneratorService documentGeneratorService = DocumentGeneratorService.getInstance(CHESSInternalBlockDiagramModel.getInstance()); @@ -63,7 +65,7 @@ public class ExportModelToDocumentCommand extends AbstractAsyncJobCommand { } // setShowLeafComponents(showLeafComponents); - String outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + String outputDirectoryName = dialogUtils.getDirectoryNameFromDialog(); // setDirectoryName(directoryName); if ((outputDirectoryName == null) || outputDirectoryName.isEmpty()) { return; diff --git a/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/commands/GenerateDocumentCommand.java b/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/commands/GenerateDocumentCommand.java index 01285024651870bd5c5041415427d424d206e551..f431ab9b3e1c5c5221292b863bb6dfdbfe7d4dcb 100644 --- a/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/commands/GenerateDocumentCommand.java +++ b/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/commands/GenerateDocumentCommand.java @@ -26,6 +26,7 @@ import org.polarsys.chess.diagram.ui.docGenerators.CHESSInternalBlockDiagramMode import org.polarsys.chess.diagram.ui.services.CHESSDiagramsGeneratorService; import org.polarsys.chess.diagram.ui.utils.ExportDialogUtils; import org.polarsys.chess.service.internal.model.ChessSystemModel; +import org.polarsys.chess.service.utils.DialogUtils; import org.polarsys.chess.service.utils.SelectionUtil; import eu.fbk.eclipse.standardtools.ModelTranslatorToOcra.services.OCRATranslatorService; @@ -44,6 +45,7 @@ public class GenerateDocumentCommand extends AbstractJobCommand { private ChessSystemModel chessToOCRAModelTranslator = ChessSystemModel.getInstance(); private OCRATranslatorService ocraTranslatorService = OCRATranslatorService.getInstance(chessToOCRAModelTranslator); private ExportDialogUtils exportDialogUtils = ExportDialogUtils.getInstance(); + private DialogUtils dialogUtils = DialogUtils.getInstance(); private CHESSDiagramsGeneratorService chessDiagramsGeneratorService = CHESSDiagramsGeneratorService .getInstance(CHESSInternalBlockDiagramModel.getInstance(), CHESSBlockDefinitionDiagramModel.getInstance()); @@ -72,7 +74,7 @@ public class GenerateDocumentCommand extends AbstractJobCommand { public void execGUIOperations(ExecutionEvent event,IProgressMonitor monitor) throws Exception { umlSelectedComponent = selectionUtil.getUmlComponentFromSelectedObject(event); isDiscreteTime = MessageTimeModelDialog.openQuestion(); - outputDirectoryName = exportDialogUtils.getDirectoryNameFromDialog(); + outputDirectoryName = dialogUtils.getDirectoryNameFromDialog(); currentProjectName = directoryUtils.getCurrentProjectName(); chessDiagrams = chessDiagramsGeneratorService.getDiagrams(); diff --git a/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/utils/ExportDialogUtils.java b/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/utils/ExportDialogUtils.java index 90c4165264927bc893582c4f4a09807a51fc697e..21b6c77ca8a6ccb2ca11b5b1aa2d27b6c11a2227 100644 --- a/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/utils/ExportDialogUtils.java +++ b/plugins/org.polarsys.chess.diagram.ui/src/org/polarsys/chess/diagram/ui/utils/ExportDialogUtils.java @@ -52,22 +52,22 @@ public class ExportDialogUtils { }); } - public String getDirectoryNameFromDialog() throws Exception { + /*public String getDirectoryNameFromDialog() throws Exception { final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final DirectoryDialog directoryDialog = new DirectoryDialog(shell); directoryDialog.setText("Select the directory"); // try { directoryDialog.setFilterPath(directoryUtils.getCurrentProjectDir()); - /* + * } catch(Exception e) { e.printStackTrace(); } - */ + // dd.setFilterPath(getWorkspace().getRoot().getLocation().toString()); String directoryName = directoryDialog.open(); return directoryName; - } + }*/ public String openImageDialog(String projectDir, String imageName) { //Shell shell2 = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); diff --git a/plugins/org.polarsys.chess.service/src/org/polarsys/chess/service/utils/DialogUtils.java b/plugins/org.polarsys.chess.service/src/org/polarsys/chess/service/utils/DialogUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..65c883b18e8ae66bb68812bcb8448f46b899981a --- /dev/null +++ b/plugins/org.polarsys.chess.service/src/org/polarsys/chess/service/utils/DialogUtils.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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.service.utils; + +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import eu.fbk.eclipse.standardtools.utils.DirectoryUtil; + +/** + * + * + */ +public class DialogUtils { + + private DirectoryUtil directoryUtils = DirectoryUtil.getInstance(); + private static DialogUtils exportDialogUtils; + + public static DialogUtils getInstance() { + if (exportDialogUtils == null) { + exportDialogUtils = new DialogUtils(); + } + return exportDialogUtils; + } + + + + public String getDirectoryNameFromDialog() throws Exception { + final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + final DirectoryDialog directoryDialog = new DirectoryDialog(shell); + directoryDialog.setText("Select the directory"); + directoryDialog.setFilterPath(directoryUtils.getCurrentProjectDir()); + String directoryName = directoryDialog.open(); + + return directoryName; + } + + +}