Skip to content
Snippets Groups Projects
Commit 2d98918b authored by Stefano puri's avatar Stefano puri
Browse files

Add Java doc, minor API change.

parent bd78da3d
No related branches found
No related tags found
No related merge requests found
......@@ -20,9 +20,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>
/*******************************************************************************
* Copyright (c) 2011 -2014 Intecs.
* 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:
* Stefano Puri, Nicholas Pacini - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.commands;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.polarsys.chess.commands"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
/*******************************************************************************
* Copyright (c) 2011 -2014 Intecs.
* 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:
* Stefano Puri, Nicholas Pacini - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.commands;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
// TODO: Auto-generated Javadoc
/**
* The activator class controls the plug-in life cycle.
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
/** The Constant PLUGIN_ID. */
public static final String PLUGIN_ID = "org.polarsys.chess.commands"; //$NON-NLS-1$
// The shared instance
/** The plugin. */
private static Activator plugin;
/**
* The constructor.
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance.
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
/*******************************************************************************
* Copyright (c) 2011 -2014 Intecs.
* 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:
* Stefano Puri, Nicholas Pacini - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.commands;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.InstanceSpecification;
import org.eclipse.uml2.uml.Slot;
import org.eclipse.uml2.uml.Stereotype;
public class AssignCopy {
private static final String ASSIGN = "MARTE::MARTE_Foundations::Alloc::Assign";
private static EList<Element> tmp;
private List<String> from;
private List<String> to;
@SuppressWarnings("unchecked")
public static ArrayList<AssignCopy> toAssignCopyList(EList<Comment> list) {
ArrayList<AssignCopy> aclist = new ArrayList<AssignCopy>();
for (int i = 0; i < list.size(); i++){
Comment comm = list.get(i);
Stereotype assign = comm.getAppliedStereotype(ASSIGN);
AssignCopy ac = new AssignCopy();
List<String> fromList = new ArrayList<String>();
tmp = (EList<Element>) comm.getValue(assign, "from");
for(int j = 0; j < tmp.size(); j++){
if(tmp.get(j) instanceof InstanceSpecification){
fromList.add(((InstanceSpecification) tmp.get(j)).getName());
}
else if(tmp.get(j) instanceof Slot){
Slot s = (Slot) tmp.get(j);
String name = s.getOwningInstance().getQualifiedName() + "::" + s.getDefiningFeature().getName();
fromList.add(name);
}
}
ac.setFrom(fromList);
List<String> toList = new ArrayList<String>();
tmp = (EList<Element>) comm.getValue(assign, "to");
for(int j = 0; j < tmp.size(); j++){
if(tmp.get(j) instanceof InstanceSpecification){
toList.add(((InstanceSpecification) tmp.get(j)).getName());
}
else if(tmp.get(j) instanceof Slot){
Slot s = (Slot) tmp.get(j);
String name = s.getOwningInstance().getQualifiedName() + "::" + s.getDefiningFeature().getName();
toList.add(name);
}
}
ac.setTo(toList);
aclist.add(ac);
}
return aclist;
}
public AssignCopy() {
}
public void setFrom(List<String> from) {
this.from = from;
}
public List<String> getFrom() {
return from;
}
public void setTo(List<String> to) {
this.to = to;
}
public List<String> getTo() {
return to;
}
}
/*******************************************************************************
* Copyright (c) 2011 -2014 Intecs.
* 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:
* Stefano Puri, Nicholas Pacini - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.commands;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.InstanceSpecification;
import org.eclipse.uml2.uml.Slot;
import org.eclipse.uml2.uml.Stereotype;
/**
* The Class AssignCopy, used to store temporary information about MARTE Assign entity.
*/
public class AssignCopy {
/** The Constant ASSIGN. */
private static final String ASSIGN = "MARTE::MARTE_Foundations::Alloc::Assign";
/** The tmp. */
private static EList<Element> tmp;
/** The from. */
private List<String> from;
/** The to. */
private List<String> to;
/**
* Copy the content of the MARTE Assign to AssignCopy entities
*
* @param list the list of MARTE Assign Comment
* @return the array list
*/
@SuppressWarnings("unchecked")
public static ArrayList<AssignCopy> toAssignCopyList(EList<Comment> list) {
ArrayList<AssignCopy> aclist = new ArrayList<AssignCopy>();
for (int i = 0; i < list.size(); i++){
Comment comm = list.get(i);
Stereotype assign = comm.getAppliedStereotype(ASSIGN);
AssignCopy ac = new AssignCopy();
List<String> fromList = new ArrayList<String>();
tmp = (EList<Element>) comm.getValue(assign, "from");
for(int j = 0; j < tmp.size(); j++){
if(tmp.get(j) instanceof InstanceSpecification){
fromList.add(((InstanceSpecification) tmp.get(j)).getName());
}
else if(tmp.get(j) instanceof Slot){
Slot s = (Slot) tmp.get(j);
String name = s.getOwningInstance().getQualifiedName() + "::" + s.getDefiningFeature().getName();
fromList.add(name);
}
}
ac.setFrom(fromList);
List<String> toList = new ArrayList<String>();
tmp = (EList<Element>) comm.getValue(assign, "to");
for(int j = 0; j < tmp.size(); j++){
if(tmp.get(j) instanceof InstanceSpecification){
toList.add(((InstanceSpecification) tmp.get(j)).getName());
}
else if(tmp.get(j) instanceof Slot){
Slot s = (Slot) tmp.get(j);
String name = s.getOwningInstance().getQualifiedName() + "::" + s.getDefiningFeature().getName();
toList.add(name);
}
}
ac.setTo(toList);
aclist.add(ac);
}
return aclist;
}
/**
* Instantiates a new assign copy.
*/
public AssignCopy() {
}
/**
* Sets the from.
*
* @param from the new from
*/
public void setFrom(List<String> from) {
this.from = from;
}
/**
* Gets the from.
*
* @return the from
*/
public List<String> getFrom() {
return from;
}
/**
* Sets the to.
*
* @param to the new to
*/
public void setTo(List<String> to) {
this.to = to;
}
/**
* Gets the to.
*
* @return the to
*/
public List<String> getTo() {
return to;
}
}
......@@ -79,15 +79,38 @@ import org.polarsys.chess.service.utils.CHESSEditorUtils;
/**
* The Class BuildInstanceCommand.
* @deprecated replaced by {@link org.polarsys.chess.commands.BuildModelInstanceCommand}
*
*/
@Deprecated
public class BuildInstanceCommand extends AbstractHandler {
/** The Constant ASSIGN. */
private static final String ASSIGN = "MARTE::MARTE_Foundations::Alloc::Assign";
/** The Constant PLATFORM. */
private static final String PLATFORM = "CHESS::Core::CHGaResourcePlatform";
/** The ac list. */
private static ArrayList<AssignCopy> acList;
/** The instances list. */
private static ArrayList<InstanceSpecification> instancesList = new ArrayList<InstanceSpecification>();
/** The slot list. */
private static ArrayList<Slot> slotList = new ArrayList<Slot>();
/** The comments. */
private static EList<Comment> comments = null;
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*
*/
@Deprecated
public Object execute(ExecutionEvent event) throws ExecutionException {
final PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();
final DiagramStatus ds = CHESSEditorUtils.getDiagramStatus(editor);
......@@ -128,6 +151,13 @@ public class BuildInstanceCommand extends AbstractHandler {
return null;
}
/**
* Gets the edits the part.
*
* @return the edits the part
*
*/
@Deprecated
private Object getEditPart() {
Object ep = null;
try {
......@@ -141,15 +171,16 @@ public class BuildInstanceCommand extends AbstractHandler {
/**
* Build the prototype instance starting frmo the given Composite Structure Diagram,
* saving and restoring the information 'from' 'to' available in the Assign entities
* @param editor
* @param csd_ep
*
* @param element the semantic element
* saving and restoring the information 'from' 'to' available in the Assign entities.
*
* @param editor the editor
* @param csd_ep the csd_ep
* @param resultMsg the result msg
* @return the edit part of the element, null if it doesn't exist
* @throws Exception
*
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Deprecated
public static InstanceSpecification buildPrototypeInstanceRestoringAssigns(PapyrusMultiDiagramEditor editor, DiagramEditPart csd_ep, StringBuffer resultMsg) {
saveAssignAllocations(editor);
InstanceSpecification instance = buildPrototypeInstance(editor, csd_ep, (DiagramImpl) csd_ep.getModel(), null, null, new HashMap(), resultMsg);
......@@ -160,18 +191,20 @@ public class BuildInstanceCommand extends AbstractHandler {
/**
* Build the prototype instance starting from the given Composite Structure Diagram,
* Build the prototype instance starting from the given Composite Structure Diagram,.
*
* @param editor The current CHESS editor
* @param csd_ep The CompositeStructureDiagramEditPart, needed for the top level diagram only
* @param diagram The current diagram from which InstanceSpecifications need to be created
* @param instanceRoot The InstanceSpecification which is the context of the current diagram
* @param pack4instances The Package where InstanceSpecifications need to be created
* @param shape2instanceMap The Map owning associations between GMF shape and UML InstanceSpecification
* @param warningMsg the warning msg
* @return the InstanceSpecification which is the context of this diagram
* @throws Exception
* @see buildPrototypeInstance(CHESSEditor editor, CompositeStructureDiagramEditPart csd_ep, StringBuffer resultMsg)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Deprecated
private static InstanceSpecification buildPrototypeInstance(PapyrusMultiDiagramEditor editor, DiagramEditPart csd_ep, DiagramImpl diagram, InstanceSpecification instanceRoot, Package pack4instances, Map shape2instanceMap, StringBuffer warningMsg) {
//assert diagram != null;
......@@ -366,7 +399,17 @@ public class BuildInstanceCommand extends AbstractHandler {
}
/**
* Builds the instance4 property.
*
* @param propertyShape the property shape
* @param pack the pack
* @param parentInstance the parent instance
* @param shape2instanceMap the shape2instance map
* @return the instance specification
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Deprecated
public static InstanceSpecification buildInstance4Property(ShapeImpl propertyShape, Package pack, InstanceSpecification parentInstance, Map shape2instanceMap) {
Property property = (Property) propertyShape.getElement();
......@@ -434,7 +477,14 @@ public class BuildInstanceCommand extends AbstractHandler {
}
/**
* Gets the comments for port ep.
*
* @param portEP the port ep
* @return the comments for port ep
*/
@SuppressWarnings("rawtypes")
@Deprecated
public static List<Comment> getCommentsForPortEP(PortEditPart portEP){
List<Comment> v = new Vector<Comment>();
List targetConnsList = portEP.getTargetConnections();
......@@ -455,6 +505,13 @@ public class BuildInstanceCommand extends AbstractHandler {
return v;
}
/**
* Gets the comments for port shape.
*
* @param portShape the port shape
* @return the comments for port shape
*/
@Deprecated
public static List<Comment> getCommentsForPortShape(ShapeImpl portShape){
List<Comment> v = new Vector<Comment>();
List targetConnsList = portShape.getTargetEdges();
......@@ -474,7 +531,15 @@ public class BuildInstanceCommand extends AbstractHandler {
}
/**
* Gets the port edit part.
*
* @param propertyEP the property ep
* @param port the port
* @return the port edit part
*/
@SuppressWarnings("rawtypes")
@Deprecated
public static PortEditPart getPortEditPart(NamedElementEditPart propertyEP, Port port){
List listEP = propertyEP.getChildren();
Object temp = null;
......@@ -489,6 +554,14 @@ public class BuildInstanceCommand extends AbstractHandler {
return null;
}
/**
* Gets the port shape.
*
* @param propertyShape the property shape
* @param port the port
* @return the port shape
*/
@Deprecated
public static ShapeImpl getPortShape(ShapeImpl propertyShape, Port port){
Vector<ShapeImpl> v = getInnerPortShapes(propertyShape);
if (v.isEmpty())
......@@ -503,6 +576,14 @@ public class BuildInstanceCommand extends AbstractHandler {
return null;
}
/**
* Gets the CH rt specification.
*
* @param propertyEP the property ep
* @param port the port
* @return the CH rt specification
*/
@Deprecated
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List<Comment> getCHRtSpecification(NamedElementEditPart propertyEP, Port port){
PortEditPart portEP = getPortEditPart(propertyEP, port);
......@@ -514,6 +595,14 @@ public class BuildInstanceCommand extends AbstractHandler {
}
/**
* Gets the comments.
*
* @param propertyShape the property shape
* @param port the port
* @return the comments
*/
@Deprecated
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List<Comment> getComments(ShapeImpl propertyShape, Port port){
ShapeImpl portShape = getPortShape(propertyShape, port);
......@@ -525,11 +614,26 @@ public class BuildInstanceCommand extends AbstractHandler {
return getCommentsForPortShape(portShape);
}
/**
* Builds the inner instance4 property.
*
* @param propertyEP the property ep
* @param pack the pack
*/
@Deprecated
public static void buildInnerInstance4Property(PropertyPartEditPartCN propertyEP, Package pack){
}
/**
* Builds the port instances.
*
* @param classifier the classifier
* @param ownerInstance the owner instance
* @param propertyShape the property shape
*/
@Deprecated
private static void buildPortInstances(org.eclipse.uml2.uml.Class classifier, InstanceSpecification ownerInstance,
ShapeImpl propertyShape){
List<Port> ports = classifier.getOwnedPorts();
......@@ -588,6 +692,13 @@ public class BuildInstanceCommand extends AbstractHandler {
}
}
/**
* Gets the inner shapes.
*
* @param shape the shape
* @return the inner shapes
*/
@Deprecated
protected static EList getInnerShapes(ShapeImpl shape){
Iterator tempIter = shape.getPersistedChildren().iterator();
......@@ -603,6 +714,13 @@ public class BuildInstanceCommand extends AbstractHandler {
return null;
}
/**
* Gets the inner port shapes.
*
* @param shape the shape
* @return the inner port shapes
*/
@Deprecated
protected static Vector<ShapeImpl> getInnerPortShapes(ShapeImpl shape){
Vector<ShapeImpl> v = new Vector<ShapeImpl>();
Iterator tempIter = shape.getPersistedChildren().iterator();
......@@ -618,6 +736,13 @@ public class BuildInstanceCommand extends AbstractHandler {
}
/**
* Gets the i sash windows container.
*
* @param editor the editor
* @return the i sash windows container
*/
@Deprecated
public ISashWindowsContainer getISashWindowsContainer(PapyrusMultiDiagramEditor editor){
ServicesRegistry serviceRegistry = editor.getServicesRegistry();
......@@ -632,6 +757,14 @@ public class BuildInstanceCommand extends AbstractHandler {
return container;
}
/**
* Gets the diagram.
*
* @param editor the editor
* @param comp the comp
* @return the diagram
*/
@Deprecated
private static DiagramImpl getDiagram(PapyrusMultiDiagramEditor editor, Type comp){
ServicesRegistry serviceRegistry = editor.getServicesRegistry();
IPageManager pageMngr = null;
......@@ -658,10 +791,12 @@ public class BuildInstanceCommand extends AbstractHandler {
}
/**
*
* Checks if is decomposed component.
*
* @param comp The componenImplementation
* @return true if the given comp is decomposed, i.e. it has attributes typed with Component
*/
@Deprecated
public static boolean isDecomposedComponent(Class comp){
EList<Property> list = comp.getAttributes();
if (list.size() == 0)
......@@ -674,6 +809,13 @@ public class BuildInstanceCommand extends AbstractHandler {
return false;
}
/**
* Checks if is leaf shape.
*
* @param shape the shape
* @return true, if is leaf shape
*/
@Deprecated
public static boolean isLeafShape(ShapeImpl shape){
Iterator inners = getInnerShapes(shape).iterator();
Object obj = null;
......@@ -689,8 +831,11 @@ public class BuildInstanceCommand extends AbstractHandler {
}
/**
* set 'acList' and 'comments' self variable
* set 'acList' and 'comments' self variable.
*
* @param editor the editor
*/
@Deprecated
private static void saveAssignAllocations(PapyrusMultiDiagramEditor editor){
//saving assign allocations before destroying and regenerating instance specifications
EList<Comment> tmp = null;
......@@ -716,18 +861,14 @@ public class BuildInstanceCommand extends AbstractHandler {
acList = AssignCopy.toAssignCopyList(comments);
}
/**
* Regenerate assign allocations.
*/
@Deprecated
private static void regenerateAssignAllocations(){
//regenerating, if possible, assign allocations
Iterator<InstanceSpecification> instIt;
Iterator<Slot> slotIt;
// slotIt = slotList.iterator();
// while(slotIt.hasNext()){
// Slot s = slotIt.next();
// System.out.println(s.toString());
// System.out.println(s.getOwningInstance().getQualifiedName() +
// " " + s.getDefiningFeature().getName());
//
// }
for (int i = 0; i < acList.size(); i++){
Comment com = comments.get(i);
......@@ -797,13 +938,6 @@ public class BuildInstanceCommand extends AbstractHandler {
}
}
}
// //only to test comments
// System.out.println("AFTER");
// for (int i=0; i<comments.size(); i++){
// System.out.println(comments.get(i).getValue(comments.get(i).getAppliedStereotype(ASSIGN), "from").toString());
// System.out.println(comments.get(i).getValue(comments.get(i).getAppliedStereotype(ASSIGN), "to").toString());
// }
}
}
......@@ -67,21 +67,46 @@ import org.polarsys.chess.core.util.uml.UMLUtils;
import org.polarsys.chess.core.views.DiagramStatus;
import org.polarsys.chess.service.utils.CHESSEditorUtils;
/**
* BuildModelInstanceCommand allows to create UML InstanceSpecifications starting from a Component definition
*/
public class BuildModelInstanceCommand extends AbstractHandler implements
IHandler {
/** The Constant CHESS. */
private static final String CHESS = "CHESS::Core::CHESS";
// private static final String CHESS_COMPIMPL = "CHESS::ComponentModel::ComponentImplementation";
private static final String CHESS_CHRTSPEC = "CHESS::Predictability::RTComponentModel::CHRtSpecification";
/** The Constant CHESS_CHRTSPEC. */
private static final String CHESS_CHRTSPEC = "CHESS::Predictability::RTComponentModel::CHRtSpecification";
/** The Constant CHESS_RESPLATFORM. */
private static final String CHESS_RESPLATFORM = "CHESS::Core::CHGaResourcePlatform";
/** The Constant MARTE_CSP. */
private static final String MARTE_CSP = "MARTE::MARTE_DesignModel::GCM::ClientServerPort";
/** The Constant MARTE_RESOURCE. */
private static final String MARTE_RESOURCE = "MARTE::MARTE_Foundations::GRM::Resource";
/** The Constant MARTE_ASSIGN. */
private static final String MARTE_ASSIGN = "MARTE::MARTE_Foundations::Alloc::Assign";
/** The ac list. */
private static ArrayList<AssignCopy> acList;
/** The assigns. */
private static EList<Comment> assigns;
/** The instances list. */
private static ArrayList<InstanceSpecification> instancesList = new ArrayList<InstanceSpecification>();
/** The slot list. */
private static ArrayList<Slot> slotList = new ArrayList<Slot>();
/* (non-Javadoc)
* Launches the dialog to select the Component from which InstanceSpecifications (i.e. the object view) needs to be created
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
......@@ -166,6 +191,18 @@ public class BuildModelInstanceCommand extends AbstractHandler implements
return null;
}
/**
* Builds the instance-level representation of the given Component structure.
*
* @param pkg the Package owner of the created instance level entities
* @param comp the Component for which the instance-level representation has to be created
* @param resPlatform the MARTE CHGaResourcePlatform owning the reference to the Resource instances.
* @param parentInstance the parent instance
* @param theProp the UML property for which the instance-level representation has to be created
* @param property2InstMap the properties to instances map
* @param commList the list of CHRtSPecification from which the instance-level representation has to be created
* @return the instance specification, stereotyped as MARTE Resource
*/
private InstanceSpecification buildComponentInstance(Package pkg, Component comp, CHGaResourcePlatform resPlatform, InstanceSpecification parentInstance, Property theProp, Map<Property, InstanceSpecification> property2InstMap, List<Comment> commList) {
InstanceSpecification inst = UMLFactory.eINSTANCE.createInstanceSpecification();
if(theProp != null){
......@@ -234,6 +271,12 @@ public class BuildModelInstanceCommand extends AbstractHandler implements
}
//this method has been moved from BuildInstanceCommand (and made public)
/**
* Map stereotypes from property to instance.
*
* @param property the property
* @param instance the instance
*/
public static void mapStereotypesFromPropertyToInstance(Property property, InstanceSpecification instance){
Type type = property.getType();
EObject stereo = property.getStereotypeApplication(CHESSProfileManager.getCH_HWBus(property));
......@@ -279,6 +322,15 @@ public class BuildModelInstanceCommand extends AbstractHandler implements
}
}
/**
* Builds the connector instance.
*
* @param pkg the pkg
* @param conn the conn
* @param resPlatform the res platform
* @param parentInstance the parent instance
* @param property2InstMap the property2 inst map
*/
private void buildConnectorInstance(Package pkg, Connector conn, CHGaResourcePlatform resPlatform, InstanceSpecification parentInstance, Map<Property, InstanceSpecification> property2InstMap) {
InstanceSpecification connInst = UMLFactory.eINSTANCE.createInstanceSpecification();
String name = parentInstance.getName() + "." + conn.getName();
......@@ -313,6 +365,11 @@ public class BuildModelInstanceCommand extends AbstractHandler implements
}
}
/**
* Save assign allocations, in case the build instance command is invoked to update the instance level view
*
* @param umlModel the uml model
*/
private static void saveAssignAllocations(Model umlModel){
//save assign allocations before build instance specifications
CHESS chess = UMLUtils.getStereotypeApplication(umlModel, CHESS.class);
......@@ -327,6 +384,11 @@ public class BuildModelInstanceCommand extends AbstractHandler implements
acList = AssignCopy.toAssignCopyList(assigns);
}
/**
* Regenerate assign allocations.
*
* @param umlModel the uml model
*/
private static void regenerateAssignAllocations(Model umlModel){
//regenerate, if possible, assign allocations
Iterator<InstanceSpecification> instIt;
......
/*******************************************************************************
* Copyright (c) 2011 -2014 Intecs.
* 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:
* Stefano Puri, Nicholas Pacini - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.commands;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ComponentCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
import org.polarsys.chess.core.notifications.ResourceNotification;
import org.polarsys.chess.core.views.DiagramStatus;
import org.polarsys.chess.service.utils.CHESSEditorUtils;
public class HideRTInformationCommand extends AbstractHandler{
public Object execute(ExecutionEvent event) throws ExecutionException {
final PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();
final DiagramStatus ds = CHESSEditorUtils.getDiagramStatus(editor);
if (editor == null || ds == null)
return null;
try {
//PapyrusMultiDiagramEditor editor = (PapyrusMultiDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
Object temp = CHESSEditorUtils.getDiagramGraphicalViewer().getRootEditPart().getChildren().get(0);
if (temp == null || !(temp instanceof CompositeStructureDiagramEditPart))
return null;
final CompositeStructureDiagramEditPart csd_ep = (CompositeStructureDiagramEditPart) temp;
TransactionalEditingDomain editingDomain = csd_ep.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
protected void doExecute() {
List l = csd_ep.getChildren();
EditPart epTemp = null;
NamedElementEditPart compositeEP = null;
for (int i=0; i< l.size(); i++){
epTemp = (EditPart) l.get(i);
if (epTemp instanceof ComponentCompositeEditPart){
compositeEP = (ComponentCompositeEditPart) epTemp;
break;
}
if (epTemp instanceof ClassCompositeEditPart){
compositeEP = (ClassCompositeEditPart) epTemp;
break;
}
}
if (ShowRTInformationCommand.showHideRT((Shape)compositeEP.getModel(), false)){
ds.setUserAction(false);
}
}
});
} catch (Exception e) {
System.out.println(e.getMessage());
ResourceNotification.showInfo(e.getMessage());
ds.setUserAction(true);
}
ds.setUserAction(true);
return null;
}
}
/*******************************************************************************
* Copyright (c) 2011 -2014 Intecs.
* 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:
* Stefano Puri, Nicholas Pacini - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.commands;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ComponentCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
import org.polarsys.chess.core.notifications.ResourceNotification;
import org.polarsys.chess.core.views.DiagramStatus;
import org.polarsys.chess.service.utils.CHESSEditorUtils;
/**
* Allows to hide the CHRtSpecification Comments available on the selected Papyrus diagram
*/
public class HideRTInformationCommand extends AbstractHandler{
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
* hides CHRtSpecification Comment on the current diagram
*/
public Object hide() throws ExecutionException {
final PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();
final DiagramStatus ds = CHESSEditorUtils.getDiagramStatus(editor);
if (editor == null || ds == null)
return null;
try {
Object temp = CHESSEditorUtils.getDiagramGraphicalViewer().getRootEditPart().getChildren().get(0);
if (temp == null || !(temp instanceof CompositeStructureDiagramEditPart))
return null;
final CompositeStructureDiagramEditPart csd_ep = (CompositeStructureDiagramEditPart) temp;
TransactionalEditingDomain editingDomain = csd_ep.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
protected void doExecute() {
List l = csd_ep.getChildren();
EditPart epTemp = null;
NamedElementEditPart compositeEP = null;
for (int i=0; i< l.size(); i++){
epTemp = (EditPart) l.get(i);
if (epTemp instanceof ComponentCompositeEditPart){
compositeEP = (ComponentCompositeEditPart) epTemp;
break;
}
if (epTemp instanceof ClassCompositeEditPart){
compositeEP = (ClassCompositeEditPart) epTemp;
break;
}
}
if (ShowRTInformationCommand.showHideRT((Shape)compositeEP.getModel(), false)){
ds.setUserAction(false);
}
}
});
} catch (Exception e) {
System.out.println(e.getMessage());
ResourceNotification.showInfo(e.getMessage());
ds.setUserAction(true);
}
ds.setUserAction(true);
return null;
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// TODO Auto-generated method stub
return hide();
}
}
/*******************************************************************************
* Copyright (c) 2011 -2014 Intecs.
* 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:
* Stefano Puri, Nicholas Pacini - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.commands;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.impl.BasicCompartmentImpl;
import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ComponentCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Port;
import org.polarsys.chess.core.notifications.ResourceNotification;
import org.polarsys.chess.core.profiles.CHESSProfileManager;
import org.polarsys.chess.core.views.DiagramStatus;
import org.polarsys.chess.service.utils.CHESSEditorUtils;
public class ShowRTInformationCommand extends AbstractHandler{
public Object execute(ExecutionEvent event) throws ExecutionException {
final PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();
final DiagramStatus ds = CHESSEditorUtils.getDiagramStatus(editor);
if (editor == null || ds == null)
return null;
try {
//PapyrusMultiDiagramEditor editor = (PapyrusMultiDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
Object temp = CHESSEditorUtils.getDiagramGraphicalViewer().getRootEditPart().getChildren().get(0);
if (temp == null || !(temp instanceof CompositeStructureDiagramEditPart))
return null;
final CompositeStructureDiagramEditPart csd_ep = (CompositeStructureDiagramEditPart) temp;
TransactionalEditingDomain editingDomain = csd_ep.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
protected void doExecute() {
List l = csd_ep.getChildren();
EditPart epTemp = null;
NamedElementEditPart compositeEP = null;
for (int i=0; i< l.size(); i++){
epTemp = (EditPart) l.get(i);
if (epTemp instanceof ComponentCompositeEditPart){
compositeEP = (ComponentCompositeEditPart) epTemp;
break;
}
if (epTemp instanceof ClassCompositeEditPart){
compositeEP = (ClassCompositeEditPart) epTemp;
break;
}
}
if (showHideRT((Shape)compositeEP.getModel(), true)){
ds.setUserAction(false);
}
EditPart mainEditPart = (EditPart)(compositeEP.getRoot().getChildren().get(0));
CanonicalEditPolicy cep = (CanonicalEditPolicy)mainEditPart.getEditPolicy(EditPolicyRoles.CANONICAL_ROLE);
if (cep!=null)
cep.refresh();
}
});
} catch (Exception e) {
System.out.println(e.getMessage());
ResourceNotification.showInfo(e.getMessage());
ds.setUserAction(true);
}
ds.setUserAction(true);
return null;
}
public static boolean showHideRT(Shape shape, boolean visibility){
if (shape.getElement() instanceof Port)
return false;
if (shape.getElement() instanceof Comment){
Comment comm = (Comment) shape.getElement();
if (comm.isStereotypeApplied(CHESSProfileManager.getCHRTSpecification(comm)))
shape.setVisible(visibility);
}
Iterator iter = shape.getPersistedChildren().iterator();
Object temp = null;
while (iter.hasNext()){
temp = iter.next();
if (temp instanceof BasicCompartmentImpl){
Iterator iter2 = ((BasicCompartmentImpl) temp).getPersistedChildren().iterator();
while (iter2.hasNext()){
showHideRT((Shape)iter2.next(), visibility);
}
}
}
return true;
}
public static void hideRtForComponent(ShapeImpl propertyComponent){
int i= 0;
i +=1;
}
}
/*******************************************************************************
* Copyright (c) 2011 -2014 Intecs.
* 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:
* Stefano Puri, Nicholas Pacini - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.polarsys.chess.commands;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.impl.BasicCompartmentImpl;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ComponentCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Port;
import org.polarsys.chess.core.notifications.ResourceNotification;
import org.polarsys.chess.core.profiles.CHESSProfileManager;
import org.polarsys.chess.core.views.DiagramStatus;
import org.polarsys.chess.service.utils.CHESSEditorUtils;
/**
* Allows to show the CHRtSpecification Comments available on the selected Papyrus diagram
*/
public class ShowRTInformationCommand extends AbstractHandler{
/* (non-Javadoc)
* Allows to show the CHRtSpecification Comments available on the selected Papyrus diagram
*/
public Object show() throws ExecutionException {
final PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();
final DiagramStatus ds = CHESSEditorUtils.getDiagramStatus(editor);
if (editor == null || ds == null)
return null;
try {
Object temp = CHESSEditorUtils.getDiagramGraphicalViewer().getRootEditPart().getChildren().get(0);
if (temp == null || !(temp instanceof CompositeStructureDiagramEditPart))
return null;
final CompositeStructureDiagramEditPart csd_ep = (CompositeStructureDiagramEditPart) temp;
TransactionalEditingDomain editingDomain = csd_ep.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
protected void doExecute() {
List l = csd_ep.getChildren();
EditPart epTemp = null;
NamedElementEditPart compositeEP = null;
for (int i=0; i< l.size(); i++){
epTemp = (EditPart) l.get(i);
if (epTemp instanceof ComponentCompositeEditPart){
compositeEP = (ComponentCompositeEditPart) epTemp;
break;
}
if (epTemp instanceof ClassCompositeEditPart){
compositeEP = (ClassCompositeEditPart) epTemp;
break;
}
}
if (showHideRT((Shape)compositeEP.getModel(), true)){
ds.setUserAction(false);
}
EditPart mainEditPart = (EditPart)(compositeEP.getRoot().getChildren().get(0));
CanonicalEditPolicy cep = (CanonicalEditPolicy)mainEditPart.getEditPolicy(EditPolicyRoles.CANONICAL_ROLE);
if (cep!=null)
cep.refresh();
}
});
} catch (Exception e) {
System.out.println(e.getMessage());
ResourceNotification.showInfo(e.getMessage());
ds.setUserAction(true);
}
ds.setUserAction(true);
return null;
}
/**
* Sets the visibility on the given Comment CHRtSpecification shape
*
* @param shape the Comment CHRtSpecification shape
* @param visibility the visibility
* @return true, if successful
*/
public static boolean showHideRT(Shape shape, boolean visibility){
if (shape.getElement() instanceof Port)
return false;
if (shape.getElement() instanceof Comment){
Comment comm = (Comment) shape.getElement();
if (comm.isStereotypeApplied(CHESSProfileManager.getCHRTSpecification(comm)))
shape.setVisible(visibility);
}
Iterator iter = shape.getPersistedChildren().iterator();
Object temp = null;
while (iter.hasNext()){
temp = iter.next();
if (temp instanceof BasicCompartmentImpl){
Iterator iter2 = ((BasicCompartmentImpl) temp).getPersistedChildren().iterator();
while (iter2.hasNext()){
showHideRT((Shape)iter2.next(), visibility);
}
}
}
return true;
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
return show();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment