Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • eclipse/chess/chess
  • malowe/chess
  • aperri21897/chess
  • fihirweh8e/chess
  • wbeaton/chess
5 results
Show changes
Showing
with 461 additions and 462 deletions
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
......@@ -10,7 +10,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.editor;bundle-version="0.8.2",
org.polarsys.chess.contracts.profile;bundle-version="0.9.0",
org.eclipse.core.resources,
org.eclipse.papyrus.sysml.diagram.common;bundle-version="0.8.2",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
org.polarsys.chess.core;bundle-version="0.9.0",
org.eclipse.papyrus.infra.core,
......@@ -32,13 +31,14 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.uml.diagram.composite;bundle-version="1.0.0",
org.eclipse.papyrus.emf.facet.query.java.core,
org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="1.0.0",
org.eclipse.net4j.util.ui;bundle-version="3.6.0",
org.eclipse.jface,
eu.fbk.eclipse.standardtools.utils
eu.fbk.eclipse.standardtools.utils,
org.eclipse.papyrus.infra.core.sasheditor,
org.eclipse.papyrus.infra.ui,
org.eclipse.papyrus.uml.diagram.common,
org.eclipse.papyrus.emf.facet.custom.metamodel,
org.eclipse.papyrus.sysml16.diagram.common;bundle-version="2.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: Intecs
Import-Package: 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
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Vendor: Eclipse Chess Project
Import-Package: org.eclipse.ui.navigator.resources
......@@ -2,27 +2,35 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>November 14, 2008</p>
<h3>License</h3>
<h2>About This Content</h2>
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>November 30, 2017</p>
<h3>License</h3>
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
<p>
The Eclipse Foundation makes available all content in this plug-in
(&quot;Content&quot;). Unless otherwise indicated below, the Content
is provided to you under the terms and conditions of the Eclipse
Public License Version 2.0 (&quot;EPL&quot;). A copy of the EPL is
available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.
</p>
<p>
If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
(&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise indicated
below, the terms and conditions of the EPL still apply to any source
code in the Content and such source code may be obtained at <a
href="http://www.eclipse.org/">http://www.eclipse.org</a>.
</p>
</body>
</html>
\ No newline at end of file
......@@ -2,9 +2,9 @@
#
# Copyright (c) 2013, 2015 Intecs SpA
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
# http://www.eclipse.org/legal/epl-v20.html
#
# Contributors:
# Nicholas Pacini nicholas.pacini@intecs.it
......
......@@ -4,9 +4,9 @@
Copyright (c) 2013, 2015 Intecs SpA
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
are made available under the terms of the Eclipse Public License v2.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
http://www.eclipse.org/legal/epl-v20.html
Contributors:
Nicholas Pacini nicholas.pacini@intecs.it
......@@ -25,71 +25,22 @@
</listener>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu?after=filtersMenu">
<menu icon="icons/CHESSicon.gif" id="org.polarsys.chess.contracts.chessextension.menu1" label="Contract">
<separator name="group1">
</separator>
</menu>
<action class="org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement" enablesFor="1" id="org.polarsys.chess.contracts.chessextension.newAction" label="Set Contract Refinement" menubarPath="org.polarsys.chess.contracts.chessextension.menu1/group1">
</action>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.polarsys.chess.modelexplorerpopupmenu.id?after=additions">
<menu
icon="icons/CHESSicon.gif"
id="org.polarsys.chess.contracts.chessextension.menu2"
label="Contract">
<separator
name="group1">
</separator>
</menu>
<action class="org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement" enablesFor="1" id="org.polarsys.chess.contracts.chessextension.newAction" label="Set Contract Refinement" menubarPath="org.polarsys.chess.contracts.chessextension.menu2/group1">
</action>
</menuContribution>
</extension>
<extension point="org.eclipse.ui.popupMenus">
<objectContribution id="org.polarsys.chess.contracts.chessextension.contribution1" objectClass="org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintPropertyChildLabelEditPart">
<menu icon="icons/CHESSicon.gif" id="org.polarsys.chess.contracts.chessextension.menu1" label="Contract" path="additions">
<separator name="group1">
</separator>
</menu>
<action class="org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement" enablesFor="1" id="org.polarsys.chess.contracts.chessextension.newAction" label="Set Contract Refinement" menubarPath="org.polarsys.chess.contracts.chessextension.menu1/group1">
</action>
</objectContribution>
<objectContribution id="org.polarsys.chess.contracts.chessextension.contribution2" objectClass="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForClassEditPart">
<menu id="org.polarsys.chess.contracts.chessextension.menu1" label="Contract" path="additions">
<separator name="group1">
</separator>
</menu>
<action class="org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement" enablesFor="1" id="org.polarsys.chess.contracts.chessextension.newAction" label="Set Contract Refinement" menubarPath="org.polarsys.chess.contracts.chessextension.menu1/group1">
</action>
</objectContribution>
<objectContribution id="org.polarsys.chess.contracts.chessextension.contribution3" objectClass="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForComponentEditPart">
<menu id="org.polarsys.chess.contracts.chessextension.menu1" label="Contract" path="additions">
<separator name="group1">
</separator>
</menu>
<action class="org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement" enablesFor="1" id="org.polarsys.chess.contracts.chessextension.newAction" label="Set Contract Refinement" menubarPath="org.polarsys.chess.contracts.chessextension.menu1/group1">
</action>
</objectContribution>
<objectContribution id="org.polarsys.chess.contracts.chessextension.contribution4" objectClass="org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement">
<menu
icon="icons/CHESSicon.gif"
id="org.polarsys.chess.contracts.chessextension.menu2"
label="Contract"
path="additions2">
<separator name="group1">
</separator>
</menu>
<action class="org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement" enablesFor="1" id="org.polarsys.chess.contracts.chessextension.newAction" label="Set Contract Refinement" menubarPath="org.polarsys.chess.contracts.chessextension.menu2/group1">
</action>
</objectContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="org.polarsys.chess.contracts.chessextension.setContractRefinement"
name="Set Contract Refinement">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="org.polarsys.chess.contracts.chessextension.popup.commands.SetContractRefinement"
commandId="org.polarsys.chess.contracts.chessextension.setContractRefinement">
</handler>
</extension>
<extension point="org.eclipse.papyrus.infra.core.modelListener">
<listener name="org.polarsys.chess.contracts.chessextension.listener1" realization="org.polarsys.chess.contracts.chessextension.listeners.PapyrusModelListener">
</listener>
......@@ -104,7 +55,7 @@
<extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
<propertyTabs contributorId="TreeOutlinePage">
<propertyTab afterTab="advanced" category="ContractProperty" id="Contracts" label="Contracts"/>
<propertyTab afterTab="advanced" category="ContractProperty" id="Contracts" label="CHESSs"/>
</propertyTabs>
</extension>
......@@ -172,5 +123,22 @@
</propertySections>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
<menu
icon="icons/CHESSicon.gif"
id="org.polarsys.chess.modelexplorerpopupmenu.id"
label="CHESS">
<command
commandId="org.polarsys.chess.contracts.chessextension.setContractRefinement"
label="Set Contract Refinement"
style="push">
</command>
</menu>
</menuContribution>
</extension>
</plugin>
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......@@ -44,7 +44,7 @@ import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Property;
import org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement;
import org.polarsys.chess.contracts.chessextension.popup.commands.SetContractRefinement;
import org.polarsys.chess.contracts.profile.chesscontract.ComponentInstance;
import org.polarsys.chess.contracts.profile.chesscontract.ContractProperty;
import org.polarsys.chess.contracts.profile.chesscontract.ContractRefinement;
......
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......@@ -28,13 +28,12 @@ import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.LiteralString;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
import org.polarsys.chess.contracts.chessextension.Activator;
import org.polarsys.chess.contracts.chessextension.managers.CHESSContractProfileManager;
import org.polarsys.chess.contracts.profile.chesscontract.Contract;
import org.polarsys.chess.contracts.profile.chesscontract.FormalProperty;
import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil;
public class PapyrusModelListener implements IPapyrusListener {
......@@ -49,77 +48,70 @@ public class PapyrusModelListener implements IPapyrusListener {
@Override
public void notifyChanged(Notification notification) {
Object notifier = notification.getNotifier();
if((Workbench.getInstance() != null) && (PlatformUI.getWorkbench()!=null)&&
(PlatformUI.getWorkbench().getActiveWorkbenchWindow()!=null)
&&(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()!=null)
&&(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().isEditorAreaVisible())
&&(notifier instanceof Class)){
if ((Workbench.getInstance() != null) && (PlatformUI.getWorkbench() != null)
&& (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null)
&& (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null)
&& (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().isEditorAreaVisible())
&& (notifier instanceof Class)) {
Class cblock = (Class) notifier;
if(notification.getEventType() == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT){
if(cblock.getAppliedStereotype(CONTRACT) != null){
if (notification.getEventType() == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT) {
if (cblock.getAppliedStereotype(CONTRACT) != null) {
IEditorPart editor = null;
try {
editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().getActiveEditor();
editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
} catch (Exception e) {
}
if (editor != null){
if ((editor != null) && (notification.getNewValue() instanceof Contract)) {
AbstractUIPlugin plugin = Activator.getDefault();
ImageRegistry imageRegistry = plugin.getImageRegistry();
Image chessImage = imageRegistry.get(Activator.CHESS_IMAGE_ID);
MessageDialog md = new MessageDialog(editor.getSite().getShell(),
"Create Contract", chessImage, "Do you want to create a contract with predefined empty Assume and Guarantee FormalProperty?", MessageDialog.CONFIRM,
new String[] { "Yes", "No"}, 0);
MessageDialog md = new MessageDialog(editor.getSite().getShell(), "Create Contract", chessImage,
"Do you want to create a contract with predefined empty Assume and Guarantee FormalProperty?",
MessageDialog.CONFIRM, new String[] { "Yes", "No" }, 0);
md.setBlockOnOpen(true);
int res = md.open();
if (res ==0){ //OK
Constraint assumeConst = cblock.createOwnedRule(cblock.getName() + "_" + ASSUME);
Constraint guaranteeConst = cblock.createOwnedRule(cblock.getName() + "_" + GUARANTEE);
LiteralString assumeValue = UMLFactory.eINSTANCE.createLiteralString();
assumeValue.setName(assumeConst.getName());
assumeConst.setSpecification(assumeValue);
LiteralString guaranteeValue = UMLFactory.eINSTANCE.createLiteralString();
guaranteeValue.setName(guaranteeConst.getName());
guaranteeConst.setSpecification(guaranteeValue);
if (res == 0) { // OK
Constraint assumeConst = EntityUtil.getInstance()
.createConstraint(cblock.getName() + "_" + ASSUME, "true", "OCRA", cblock);
Constraint guaranteeConst = EntityUtil.getInstance()
.createConstraint(cblock.getName() + "_" + GUARANTEE, "true", "OCRA", cblock);
try {
Stereotype fpStereotype = CHESSContractProfileManager.getFormalProperty(cblock.eResource().getResourceSet());
Stereotype fpStereotype = CHESSContractProfileManager
.getFormalProperty(cblock.eResource().getResourceSet());
FormalProperty assume = (FormalProperty) assumeConst.applyStereotype(fpStereotype);
FormalProperty guarantee = (FormalProperty) guaranteeConst.applyStereotype(fpStereotype);
FormalProperty guarantee = (FormalProperty) guaranteeConst
.applyStereotype(fpStereotype);
Stereotype contrStereo = cblock.getAppliedStereotype(CONTRACT);
cblock.setValue(contrStereo, ASSUME, assume);
cblock.setValue(contrStereo, GUARANTEE, guarantee);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
if(notification.getEventType() == Notification.SET && notification.getFeature() instanceof EAttribute){
if(cblock.getAppliedStereotype(CONTRACT) != null){
if (notification.getEventType() == Notification.SET && notification.getFeature() instanceof EAttribute) {
if (cblock.getAppliedStereotype(CONTRACT) != null) {
EAttribute attr = (EAttribute) notification.getFeature();
if(attr.getName().equals(FEATURE_NAME)){
if (attr.getName().equals(FEATURE_NAME)) {
EList<Constraint> rules = cblock.getOwnedRules();
for (Constraint constraint : rules) {
if(constraint.getName().contains(ASSUME)){
if (constraint.getName().contains(ASSUME)) {
constraint.setName(notification.getNewStringValue() + "_" + ASSUME);
}
if(constraint.getName().contains(GUARANTEE)){
if (constraint.getName().contains(GUARANTEE)) {
constraint.setName(notification.getNewStringValue() + "_" + GUARANTEE);
}
constraint.getSpecification().setName(constraint.getName());
......
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......@@ -18,6 +18,7 @@ package org.polarsys.chess.contracts.chessextension.listeners;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage;
import org.eclipse.papyrus.infra.ui.editor.CoreMultiDiagramEditor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.PropertySheet;
......@@ -36,7 +37,7 @@ public class SelectionListener extends SelectionListenerExtra {
// lazy association
if (diagramStatus == null)
diagramStatus = CHESSEditorUtils.getDiagramStatus(getRegistry());
diagramStatus.setUserAction(true);
if (part instanceof PropertySheet) {
part = ((PropertySheet) part).getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
......
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......@@ -24,6 +24,7 @@ import org.eclipse.gef.ui.palette.PaletteViewer;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeSelection;
......@@ -32,10 +33,11 @@ import org.eclipse.ui.IEditorPart;
import org.polarsys.chess.contracts.chessextension.Activator;
import org.polarsys.chess.core.constraint.PreferenceProperties;
import org.polarsys.chess.core.profiles.CHESSProfileManager;
import org.polarsys.chess.core.util.uml.DiagramUtils;
import org.polarsys.chess.core.views.DiagramStatus;
public class PaletteManager {
protected static List<Object> lookupSelectedElements(ISelection selection) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
......@@ -46,119 +48,135 @@ public class PaletteManager {
}
return null;
}
//TODO this class should be reengineered so to have a parent one common to all the chess plugins
// TODO this class should be reengineered so to have a parent one common to
// all the chess plugins
public static void setPaletteVisibility(PapyrusMultiDiagramEditor editor, DiagramStatus ds) {
Boolean checkPalette =
org.polarsys.chess.core.Activator.getDefault().getPreferenceStore().getBoolean(PreferenceProperties.PALETTES_IN_VIEW);
Boolean checkPalette = org.polarsys.chess.core.Activator.getDefault().getPreferenceStore()
.getBoolean(PreferenceProperties.PALETTES_IN_VIEW);
if (!checkPalette)
return;
try {
IEditorPart ep = editor.getActiveEditor();
if ((ep == null)||(ep.getSite() == null)||(ep.getSite().getSelectionProvider() == null))
if ((ep == null) || (ep.getSite() == null) || (ep.getSite().getSelectionProvider() == null))
return;
ISelection selection = ep.getSite().getSelectionProvider().getSelection();
List<Object> selections = lookupSelectedElements(selection);
DiagramEditDomain de = null;
if (selections.get(0) instanceof GraphicalEditPart){
if (selections.isEmpty())
return;
if (selections.get(0) instanceof GraphicalEditPart) {
GraphicalEditPart a = (GraphicalEditPart) selections.get(0);
de = (DiagramEditDomain) a.getDiagramEditDomain();
}
else{
if (selections.get(0) instanceof ConnectionEditPart){
} else {
if (selections.get(0) instanceof ConnectionEditPart) {
ConnectionEditPart a = (ConnectionEditPart) selections.get(0);
de = (DiagramEditDomain) a.getDiagramEditDomain();
}
}
if (de == null){
Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "cannot retrieve DiagramEditDomain"));
if (de == null) {
Activator.getDefault().getLog()
.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "cannot retrieve DiagramEditDomain"));
return;
}
PaletteViewer pv = de.getPaletteViewer();
// String viewName = ds.getCurrentView().getName();
// String viewName = ds.getCurrentView().getName();`
if (ds == null)
return;
String viewName = ds.getActiveView();
//System.out.println("activew view" + viewName);
if (viewName == null) {
return;
}
// System.out.println("activew view" + viewName);
String diagramName = ds.getCurrentView().getCurrentDiagramName();
for (Object o : pv.getPaletteRoot().getChildren()){
if (o instanceof PaletteDrawer){
Diagram diagram = ds.getCurrentView().getCurrentDiagram();
for (Object o : pv.getPaletteRoot().getChildren()) {
if (o instanceof PaletteDrawer) {
PaletteDrawer d = (PaletteDrawer) o;
setPaletteVisibility(d, viewName, diagramName);
setPaletteVisibility(d, viewName, diagramName, diagram);
}
}
} catch (Exception e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));
e.printStackTrace();
}
//final List<String> hiddenPalettes = PapyrusPalettePreferences.getHiddenPalettes(part);
//PapyrusPaletteService ps = PapyrusPaletteService.getInstance();
// for(PapyrusPaletteService.ProviderDescriptor descriptor : ps.getContributingProviders(part, pv.getPaletteRoot())) {
//
// String id = descriptor.getContributionID();
// String name = descriptor.getContributionName();
// CHESSProjectSupport.printlnToCHESSConsole(id + " " + name);
// //TODO what are the palette to hide/show given the current view and diagram?
// //PapyrusPalettePreferences.changePaletteVisibility(id, editor.getActiveEditor().getClass().getName(), false);
// }
// final List<String> hiddenPalettes =
// PapyrusPalettePreferences.getHiddenPalettes(part);
// PapyrusPaletteService ps = PapyrusPaletteService.getInstance();
// for(PapyrusPaletteService.ProviderDescriptor descriptor :
// ps.getContributingProviders(part, pv.getPaletteRoot())) {
//
// String id = descriptor.getContributionID();
// String name = descriptor.getContributionName();
// CHESSProjectSupport.printlnToCHESSConsole(id + " " + name);
// //TODO what are the palette to hide/show given the current view and
// diagram?
// //PapyrusPalettePreferences.changePaletteVisibility(id,
// editor.getActiveEditor().getClass().getName(), false);
// }
}
//TODO the policy of the palette visibility should be re-engineered to allow CHESS external plugins "like
//CHESSContract, to add palettes to the ones already managed by CHESS. Now the CHESSContract palettes which regard the
//component view are managed in CHESS, not here.
private static void setPaletteVisibility(PaletteDrawer paletteDrawer, String viewName,
String diagramName) {
if (! viewName.equals(CHESSProfileManager.SYSTEM_VIEW)){
//no restriction upon the CHESS main view
// TODO the policy of the palette visibility should be re-engineered to
// allow CHESS external plugins "like
// CHESSContract, to add palettes to the ones already managed by CHESS. Now
// the CHESSContract palettes which regard the
// component view are managed in CHESS, not here.
private static void setPaletteVisibility(PaletteDrawer paletteDrawer, String viewName, String diagramName, Diagram diagram) {
if (!viewName.equals(CHESSProfileManager.SYSTEM_VIEW)) {
// no restriction upon the CHESS main view
return;
}
if (diagramName.equals("PapyrusUMLStateMachineDiagram")){
if (diagramName.equals("PapyrusUMLStateMachineDiagram")) {
return;
}
paletteDrawer.setVisible(true);
String label = paletteDrawer.getLabel();
String paletteId = paletteDrawer.getId();
if (viewName.equals(CHESSProfileManager.SYSTEM_VIEW)){
if (diagramName.compareTo("BlockDefinition")==0){
//set visibility only for the palette's functional tools
if (viewName.equals(CHESSProfileManager.SYSTEM_VIEW)) {
if (DiagramUtils.isBlockDefinitionDiagram(diagram)) {
// set visibility only for the palette's functional tools
paletteDrawer.setVisible(false);
if (paletteId.compareTo("ForeverBDDAssociationsDrawerID")==0|| paletteId.compareTo("ForeverBDDModelElementsDrawerID")==0
|| paletteId.compareTo("ForeverBDDPortAndFlowsDrawerID")==0
|| paletteId.compareTo("ForeverBDDDataTypesDrawerID")==0
|| paletteId.compareTo("ForeverBDDContractsDrawerID")==0 )
if (paletteId.compareTo("ForeverBDDAssociationsDrawerID") == 0
|| paletteId.compareTo("ForeverBDDModelElementsDrawerID") == 0
|| paletteId.compareTo("ForeverBDDPortAndFlowsDrawerID") == 0
|| paletteId.compareTo("ForeverBDDDataTypesDrawerID") == 0
|| paletteId.compareTo("ForeverBDDContractsDrawerID") == 0)
paletteDrawer.setVisible(true);
}
if (diagramName.equals("InternalBlock")){
if (DiagramUtils.isInternalBlockDiagram(diagram)) {
paletteDrawer.setVisible(false);
if (paletteId.compareTo("ForeverIBDNodesDrawerID")==0 || paletteId.compareTo("ForeverIBDEdgesDrawerID")==0)
if (paletteId.compareTo("ForeverIBDNodesDrawerID") == 0
|| paletteId.compareTo("ForeverIBDEdgesDrawerID") == 0)
paletteDrawer.setVisible(true);
}
if (diagramName.equals("PapyrusUMLClassDiagram")){
if (diagramName.equals("PapyrusUMLClassDiagram")) {
paletteDrawer.setVisible(true);
}
if (diagramName.equals("CompositeStructure")){
if (diagramName.equals("CompositeStructure")) {
paletteDrawer.setVisible(true);
}
}
}
}
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......@@ -13,25 +13,27 @@
* Initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.contracts.chessextension.popup.actions;
package org.polarsys.chess.contracts.chessextension.popup.commands;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
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.gmf.runtime.notation.Node;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.impl.EObjectTreeElementImpl;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintPropertyChildLabelEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForClassEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PropertyForComponentEditPart;
import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.DataType;
......@@ -45,7 +47,7 @@ import org.polarsys.chess.contracts.profile.chesscontract.ContractRefinement;
import eu.fbk.eclipse.standardtools.utils.ui.utils.DialogUtil;
public class SetContractRefinement implements IObjectActionDelegate {
public class SetContractRefinement extends AbstractHandler {
public static final String CONTRACT_PROPERTY = "CHESSContract::ContractProperty";
protected static final String CONTRACT_REFINEMENt = "CHESSContract::ContractRefinement";
......@@ -58,11 +60,15 @@ public class SetContractRefinement implements IObjectActionDelegate {
super();
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
shell = targetPart.getSite().getShell();
}
// public void setActivePart(IAction action, IWorkbenchPart targetPart) {
// shell = targetPart.getSite().getShell();
// }
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
shell = window.getShell();
public void run(IAction action) {
try {
setSelection();
......@@ -75,17 +81,18 @@ public class SetContractRefinement implements IObjectActionDelegate {
if (refinedByList instanceof EList<?>) {
@SuppressWarnings("unchecked")
final EList<ContractRefinement> refineList = (EList<ContractRefinement>) refinedByList;
final Class ownerClass = (Class) contrProp.getOwner();
final SetContractRefinementDialog dialog = new SetContractRefinementDialog(shell, ownerClass,refineList);
final SetContractRefinementDialog dialog = new SetContractRefinementDialog(shell, ownerClass,
refineList);
dialog.populateRefineListAndCreateDialog();
if (dialog.open() == Window.OK) {
editdomain.getCommandStack().execute(new RecordingCommand(editdomain) {
protected void doExecute() {
refineList.clear();
if ((dialog.getSelected() != null)) {
protected void doExecute() {
refineList.clear();
if ((dialog.getSelected() != null)) {
for (SetContractRefinementDialog.ContractRefinementObj currContractRefinementObj : dialog
.getSelected()) {
......@@ -121,19 +128,20 @@ public class SetContractRefinement implements IObjectActionDelegate {
}
}
}
});
}
}
});
}
} else {
// do nothing
}
} else {
// do nothing
}
} catch (Exception e) {
e.printStackTrace();
DialogUtil.getInstance().showMessage_ExceptionError(e);
}
return null;
}
private void setSelection() throws Exception {
......@@ -144,12 +152,7 @@ public class SetContractRefinement implements IObjectActionDelegate {
IStructuredSelection strucSelection = (IStructuredSelection) selection;
if (strucSelection.size() == 1) {
Object partSelected = strucSelection.iterator().next();
if (partSelected instanceof ConstraintPropertyChildLabelEditPart) {
ConstraintPropertyChildLabelEditPart sysmlEditPart = (ConstraintPropertyChildLabelEditPart) partSelected;
Node notationNode = (Node) sysmlEditPart.getModel();
contrProp = (Property) notationNode.getElement();
editdomain = sysmlEditPart.getEditingDomain();
} else if (partSelected instanceof PropertyForClassEditPart) {
if (partSelected instanceof PropertyForClassEditPart) {
PropertyForClassEditPart umlClassEditPart = (PropertyForClassEditPart) partSelected;
Node notationNode = (Node) umlClassEditPart.getModel();
contrProp = (Property) notationNode.getElement();
......@@ -173,7 +176,7 @@ public class SetContractRefinement implements IObjectActionDelegate {
}
public void selectionChanged(IAction action, ISelection selection) {
}
// public void selectionChanged(IAction action, ISelection selection) {
// }
}
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2017 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......@@ -25,8 +25,6 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockEditPart;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ComponentEditPart;
import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
......@@ -49,14 +47,13 @@ import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.LiteralString;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Stereotype;
import org.polarsys.chess.contracts.chessextension.popup.actions.SetContractRefinement;
import org.polarsys.chess.contracts.chessextension.popup.commands.SetContractRefinement;
import org.polarsys.chess.contracts.profile.chesscontract.Contract;
import org.polarsys.chess.contracts.profile.chesscontract.FormalProperty;
import org.polarsys.chess.service.gui.utils.CHESSEditorUtils;
public class BlockEditPartSection extends AbstractPropertySection {
public class BlockEditPartSection extends AbstractPropertySection{
public static final String CONTRACT = "CHESSContract::Contract";
public static final String CONTRACT_PROP = "CHESSContract::ContractProperty";
......@@ -65,120 +62,120 @@ public class BlockEditPartSection extends AbstractPropertySection{
private Text guaranteeText;
private Class contract;
private Class selectedClass;
private Class selectedClass;
private FocusListener assumeFocusListener;
private FocusListener guaranteeFocusListener;
private SelectionListener contractListListener;
private Label contractLabel;
private CCombo contractList;
private Label contractListLabel;
public BlockEditPartSection(){
public BlockEditPartSection() {
contractListListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
String selection = contractList.getItem(contractList.getSelectionIndex());
contract = getContract(selectedClass, selection);
if(contract != null){
if (contract != null) {
setContractPropertyTab(contract);
}
contractLabel.setText("Selected Class");
contractText.setText(selectedClass.getQualifiedName());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// nothing to do here
// nothing to do here
}
};
assumeFocusListener = new FocusListener() {
private String oldAssume;
@Override
public void focusLost(FocusEvent e) {
if(assumeText.getText().equals(oldAssume)){
if (assumeText.getText().equals(oldAssume)) {
return;
}
PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();
if (editor != null){
TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) editor.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
//Stereotype stereo = contract.getAppliedStereotype(CONTRACT);
Stereotype stereo = UMLUtil.getAppliedStereotype(contract, CONTRACT,false) ;
FormalProperty assumefp = (FormalProperty) contract.getValue(stereo, "Assume");
Constraint assumeConstr = assumefp.getBase_Constraint();
LiteralString assumeSpec = (LiteralString) assumeConstr.getSpecification();
assumeSpec.setValue(assumeText.getText());
assumeConstr.setSpecification(assumeSpec);
}
});
if (editor != null) {
TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) editor.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
// Stereotype stereo = contract.getAppliedStereotype(CONTRACT);
Stereotype stereo = UMLUtil.getAppliedStereotype(contract, CONTRACT, false);
FormalProperty assumefp = (FormalProperty) contract.getValue(stereo, "Assume");
Constraint assumeConstr = assumefp.getBase_Constraint();
LiteralString assumeSpec = (LiteralString) assumeConstr.getSpecification();
assumeSpec.setValue(assumeText.getText());
assumeConstr.setSpecification(assumeSpec);
}
});
}
}
@Override
public void focusGained(FocusEvent e) {
// this is to see if the text has been modified or not
oldAssume = assumeText.getText();
}
};
guaranteeFocusListener = new FocusListener() {
private String oldGuarantee;
@Override
public void focusLost(FocusEvent e) {
if(assumeText.getText().equals(oldGuarantee)){
if (assumeText.getText().equals(oldGuarantee)) {
return;
}
PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();
if (editor != null){
TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) editor.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
//Stereotype stereo = contract.getAppliedStereotype(CONTRACT);
Stereotype stereo = UMLUtil.getAppliedStereotype(contract, CONTRACT,false) ;
FormalProperty guaranteefp = (FormalProperty) contract.getValue(stereo, "Guarantee");
Constraint guaranteeConstr = guaranteefp.getBase_Constraint();
LiteralString guaranteeSpec = (LiteralString) guaranteeConstr.getSpecification();
guaranteeSpec.setValue(guaranteeText.getText());
guaranteeConstr.setSpecification(guaranteeSpec);
}
});
//}
if (editor != null) {
TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) editor.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
// Stereotype stereo = contract.getAppliedStereotype(CONTRACT);
Stereotype stereo = UMLUtil.getAppliedStereotype(contract, CONTRACT, false);
FormalProperty guaranteefp = (FormalProperty) contract.getValue(stereo, "Guarantee");
Constraint guaranteeConstr = guaranteefp.getBase_Constraint();
LiteralString guaranteeSpec = (LiteralString) guaranteeConstr.getSpecification();
guaranteeSpec.setValue(guaranteeText.getText());
guaranteeConstr.setSpecification(guaranteeSpec);
}
});
// }
}
}
@Override
public void focusGained(FocusEvent e) {
// this is to see if the text has been modified or not
oldGuarantee = guaranteeText.getText();
}
};
}
private Class getContract(Class selectedClass, String selection) {
String[] splitted = selection.split(":");
String propName = splitted[0].trim();
......@@ -188,159 +185,123 @@ public class BlockEditPartSection extends AbstractPropertySection{
boolean found = false;
while (it.hasNext() && !found) {
Property attr = (Property) it.next();
if(attr.getName().equals(propName) && attr.getAppliedStereotype(CONTRACT_PROP) != null){
if (attr.getName().equals(propName) && attr.getAppliedStereotype(CONTRACT_PROP) != null) {
found = true;
property = attr;
}
}
}
if(property == null){
if (property == null) {
return null;
}
Class contract = (Class)property.getType();
Class contract = (Class) property.getType();
return contract;
}
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
super.createControls(parent, aTabbedPropertySheetPage);
Composite composite = getWidgetFactory().createComposite(parent, SWT.NONE);
composite.setLayout(new GridLayout(4, false));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.horizontalSpan = 3;
contractText = getWidgetFactory().createText(composite, "no Contract selected");
contractText.setEditable(false);
contractText.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
contractLabel = getWidgetFactory().createLabel(composite, "Selected Contract", SWT.NONE);
contractLabel.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
contractList = getWidgetFactory().createCCombo(composite, SWT.READ_ONLY | SWT.BORDER);
contractList.setVisible(false);
gd.horizontalSpan = 3;
contractList.addSelectionListener(contractListListener);
contractList.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
contractListLabel = getWidgetFactory().createLabel(composite, "Contract List", SWT.NONE);
contractListLabel.setVisible(false);
contractListLabel.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
gd.horizontalSpan = 2;
Label assumeLabel = getWidgetFactory().createLabel(composite, "Assume", SWT.NONE);
assumeLabel.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
gd.horizontalSpan = 2;
Label guaranteeLabel = getWidgetFactory().createLabel(composite, "Guarantee", SWT.NONE);
guaranteeLabel.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
assumeText = getWidgetFactory().createText(composite, "", SWT.MULTI | SWT.H_SCROLL |SWT.V_SCROLL);
assumeText = getWidgetFactory().createText(composite, "", SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
gd.horizontalSpan = 2;
gd.verticalSpan = 25;
assumeText.addFocusListener(assumeFocusListener);
assumeText.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
guaranteeText = getWidgetFactory().createText(composite, "", SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
gd.horizontalSpan = 2;
gd.verticalSpan = 25;
guaranteeText.addFocusListener(guaranteeFocusListener);
guaranteeText.setLayoutData(gd);
}
@Override
public void setInput(IWorkbenchPart part, ISelection selection) {
super.setInput(part, selection);
if (!(selection instanceof IStructuredSelection)){
cleanPropertyTab();
return;
if (!(selection instanceof IStructuredSelection)) {
cleanPropertyTab();
return;
}
List<?> selectionList = ((IStructuredSelection) selection).toList();
if (selectionList.size() == 1) {
Object selected = selectionList.get(0);
System.out.println("BlockEditPartSection");
System.out.println("Selected: " + selected);
EObject selectedEObject = EMFHelper.getEObject(selected);
if (selectedEObject != null){
//do something
}
if(selected instanceof ConstraintBlockEditPart){
Class clazz = (Class) (((ConstraintBlockEditPart)selected).resolveSemanticElement());
//check if it's a contract
//if(clazz.getAppliedStereotype(CONTRACT) != null){
if(UMLUtil.getAppliedStereotype(clazz, CONTRACT,false)!=null){
cleanPropertyTab();
setContractPropertyTab(clazz);
}
}else if(selected instanceof BlockEditPart){;
Class clazz = (Class) (((BlockEditPart)selected).resolveSemanticElement());
initContractList(clazz);
}
else if(selected instanceof ClassEditPart){
Class clazz = (Class) (((ClassEditPart)selected).resolveSemanticElement());
//check if it's a contract
//if(clazz.getAppliedStereotype(CONTRACT) != null){
if(UMLUtil.getAppliedStereotype(clazz, CONTRACT,false)!=null){
cleanPropertyTab();
setContractPropertyTab(clazz);
}else{
initContractList(clazz);
}
}
else if(selected instanceof ComponentEditPart){
Class clazz = (Class) (((ComponentEditPart)selected).resolveSemanticElement());
initContractList(clazz);
System.out.println("selectedEObject: " + selectedEObject);
if (selectedEObject != null) {
// do something
}
else if(selectedEObject instanceof Class){
Class clazz = (Class) selectedEObject;
//if(clazz.getAppliedStereotype(CONTRACT) != null){
if(UMLUtil.getAppliedStereotype(clazz, CONTRACT,false)!=null){
cleanPropertyTab();
setContractPropertyTab(clazz);
}else{
initContractList(clazz);
}
}
else{
if (selectedEObject instanceof Class) {
setGUI(selectedEObject);
} else {
cleanPropertyTab();
}
}else{
} else {
cleanPropertyTab();
}
//fill claims list
if(contract != null){
//Stereotype stereo = contract.getAppliedStereotype(BlockEditPartSection.CONTRACT);
Stereotype stereo = UMLUtil.getAppliedStereotype(contract, BlockEditPartSection.CONTRACT,false);
// fill supportedBy artifact list
if (contract != null) {
// Stereotype stereo =
// contract.getAppliedStereotype(BlockEditPartSection.CONTRACT);
Stereotype stereo = UMLUtil.getAppliedStereotype(contract, BlockEditPartSection.CONTRACT, false);
Contract contractStereo = (Contract) contract.getStereotypeApplication(stereo);
}
//fill supportedBy artifact list
if(contract != null){
//Stereotype stereo = contract.getAppliedStereotype(BlockEditPartSection.CONTRACT);
Stereotype stereo = UMLUtil.getAppliedStereotype(contract, BlockEditPartSection.CONTRACT,false);
Contract contractStereo = (Contract) contract.getStereotypeApplication(stereo);
}
private void setGUI(EObject selectedEObject) {
Class clazz = (Class) selectedEObject;
// if(clazz.getAppliedStereotype(CONTRACT) != null){
if (UMLUtil.getAppliedStereotype(clazz, CONTRACT, false) != null) {
cleanPropertyTab();
setContractPropertyTab(clazz);
} else {
initContractList(clazz);
}
}
private void initContractList(Class clazz) {
cleanPropertyTab();
selectedClass = clazz;
......@@ -349,10 +310,10 @@ public class BlockEditPartSection extends AbstractPropertySection{
contractList.setVisible(true);
contractListLabel.setVisible(true);
for (Property prop : selectedClass.getAttributes()) {
if(prop.getAppliedStereotype(SetContractRefinement.CONTRACT_PROPERTY) != null){
if(prop.getType() == null){
if (prop.getAppliedStereotype(SetContractRefinement.CONTRACT_PROPERTY) != null) {
if (prop.getType() == null) {
contractList.add(prop.getName() + " : <TYPE NOT DEFINED>");
}else{
} else {
contractList.add(prop.getName() + " : " + prop.getType().getName());
}
}
......@@ -363,25 +324,25 @@ public class BlockEditPartSection extends AbstractPropertySection{
contract = clazz;
contractLabel.setText("Selected Contract");
contractText.setText(clazz.getQualifiedName());
//Stereotype contrStereo = clazz.getAppliedStereotype(CONTRACT);
Stereotype contrStereo = UMLUtil.getAppliedStereotype(clazz, CONTRACT,false);
// Stereotype contrStereo = clazz.getAppliedStereotype(CONTRACT);
Stereotype contrStereo = UMLUtil.getAppliedStereotype(clazz, CONTRACT, false);
FormalProperty assumefp = (FormalProperty) clazz.getValue(contrStereo, "Assume");
FormalProperty guaranteefp = (FormalProperty) clazz.getValue(contrStereo, "Guarantee");
String assume = "";
if (assumefp!= null)
assume= assumefp.getBase_Constraint().getSpecification().stringValue();
if (assumefp != null)
assume = assumefp.getBase_Constraint().getSpecification().stringValue();
String guarantee = "";
if (guaranteefp != null)
guarantee= guaranteefp.getBase_Constraint().getSpecification().stringValue();
if(assume != null){
assumeText.setText(assume);
guarantee = guaranteefp.getBase_Constraint().getSpecification().stringValue();
if (assume != null) {
assumeText.setText(assume);
}
if(guarantee != null){
if (guarantee != null) {
guaranteeText.setText(guarantee);
}
Contract contractStereo = (Contract) contract.getStereotypeApplication(contrStereo);
}
private void cleanPropertyTab() {
......@@ -393,12 +354,7 @@ public class BlockEditPartSection extends AbstractPropertySection{
contractList.removeAll();
contractList.setVisible(false);
contractListLabel.setVisible(false);
}
}
}
......@@ -2,9 +2,9 @@
*
* Copyright (c) 2013, 2015 Intecs SpA
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Nicholas Pacini nicholas.pacini@intecs.it
......@@ -22,8 +22,6 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.PropertyPartEditPartCN;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
......@@ -134,7 +132,6 @@ public class BlockPropertyCompositeEditPartSection extends AbstractPropertySecti
strongTable.setLayoutData(gd);
}
@Override
public void setInput(IWorkbenchPart part, ISelection selection) {
super.setInput(part, selection);
......@@ -144,17 +141,11 @@ public class BlockPropertyCompositeEditPartSection extends AbstractPropertySecti
List<?> selectionList = ((IStructuredSelection) selection).toList();
if (selectionList.size() == 1) {
Object selected = selectionList.get(0);
if(selected instanceof BlockPropertyCompositeEditPart){
Property prop = (Property) (((BlockPropertyCompositeEditPart)selected).resolveSemanticElement());
initContractLists(prop);
}
if(selected instanceof PropertyPartEditPartCN){
Property prop = (Property) (((PropertyPartEditPartCN)selected).resolveSemanticElement());
initContractLists(prop);
}
System.out.println("BlockPropertyCompositeEditPartSection");
System.out.println("selected: "+selected);
}
}
private void initContractLists(Property prop) {
currentProperty = prop;
List<ContractProperty> weakList = new ArrayList<ContractProperty>();
......
<?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.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
......
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.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
......@@ -3,22 +3,27 @@ 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
Bundle-RequiredExecutionEnvironment: JavaSE-11
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,
eu.fbk.eclipse.standardtools.utils,
org.polarsys.chess.service
org.polarsys.chess.service,
org.eclipse.core.commands,
org.eclipse.jface;bundle-version="3.22.100",
org.eclipse.emf.transaction,
org.eclipse.papyrus.infra.widgets,
org.eclipse.papyrus.uml.tools,
org.eclipse.papyrus.infra.ui.emf,
org.eclipse.ui.ide,
org.eclipse.ui.views.properties.tabbed
Bundle-ActivationPolicy: lazy
Bundle-Vendor: Fondazione Bruno Kessler
Bundle-Vendor: Eclipse Chess Project
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.gui.utils
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>November 30, 2017</p>
<h3>License</h3>
<p>
The Eclipse Foundation makes available all content in this plug-in
(&quot;Content&quot;). Unless otherwise indicated below, the Content
is provided to you under the terms and conditions of the Eclipse
Public License Version 2.0 (&quot;EPL&quot;). A copy of the EPL is
available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.
</p>
<p>
If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
(&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise indicated
below, the terms and conditions of the EPL still apply to any source
code in the Content and such source code may be obtained at <a
href="http://www.eclipse.org/">http://www.eclipse.org</a>.
</p>
</body>
</html>
\ No newline at end of file
/*******************************************************************************
* 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
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.contracts.contractEditor;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Property;
import org.polarsys.chess.contracts.profile.chesscontract.util.ContractEntityUtil;
......@@ -27,7 +28,7 @@ public class CustomContractEditorFilter implements org.eclipse.jface.viewers.IFi
@Override
public boolean select(Object selection) {
ExecutionEvent f;
Object selectedUmlElement = selectionUtil.getUmlSelectedObject(selection);
if (selectedUmlElement instanceof Property) {
......