diff options
author | Camille Letavernier | 2014-08-21 11:43:07 +0000 |
---|---|---|
committer | Camille Letavernier | 2014-08-21 13:50:25 +0000 |
commit | dbc038b44bcbb890ae256d15eb09eb285512f020 (patch) | |
tree | 757e736583eea3ae352ad9ac91a81df7e59b79ff /plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org | |
parent | ea48a20561464c3cbb7895d430583669a9f82fcc (diff) | |
download | org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.tar.gz org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.tar.xz org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.zip |
[Code style] Apply clean-up and formatter on Main plug-ins
Diffstat (limited to 'plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org')
83 files changed, 935 insertions, 857 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/Activator.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/Activator.java index c8358dc9801..da0e7aff563 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/Activator.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/Activator.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -33,7 +33,7 @@ public class Activator extends AbstractUIPlugin { /** Default constructor */ public Activator() { - + } /* @@ -41,6 +41,7 @@ public class Activator extends AbstractUIPlugin { * * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; @@ -52,6 +53,7 @@ public class Activator extends AbstractUIPlugin { * * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ + @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); @@ -59,7 +61,7 @@ public class Activator extends AbstractUIPlugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static Activator getDefault() { diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/command/SetNestedPathCommand.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/command/SetNestedPathCommand.java index 1d2a87c1dba..b909f77573b 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/command/SetNestedPathCommand.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/command/SetNestedPathCommand.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * + * * CEA LIST - Initial API and implementation * *****************************************************************************/ @@ -60,20 +60,25 @@ public class SetNestedPathCommand extends EditElementCommand { public final static int NESTED_TARGET = 2; /** - * Indicates whether or not the source of the target of the {@link Connector} is nested. + * Indicates whether or not the source of the target of the {@link Connector} is nested. * One of {@link #NESTED_SOURCE} or {@link #NESTED_TARGET}. */ private final int nestedEndDirection; /** - * + * * Constructor. * - * @param label the command label. - * @param elementToEdit the element to edit. - * @param request the request this command contribute to ({@link CreateRelationshipRequest} or {@link ReorientRelationshipRequest}) - * @param nestedPath the property path to set (in {@link NestedConnectorEnd#getPropertyPath()} ). - * @param nestedEndDirection the direction ({@link #NESTED_SOURCE} or {@link #NESTED_TARGET}) of the {@link ConnectorEnd} to modify. + * @param label + * the command label. + * @param elementToEdit + * the element to edit. + * @param request + * the request this command contribute to ({@link CreateRelationshipRequest} or {@link ReorientRelationshipRequest}) + * @param nestedPath + * the property path to set (in {@link NestedConnectorEnd#getPropertyPath()} ). + * @param nestedEndDirection + * the direction ({@link #NESTED_SOURCE} or {@link #NESTED_TARGET}) of the {@link ConnectorEnd} to modify. */ public SetNestedPathCommand(String label, EObject elementToEdit, IEditCommandRequest request, List<Property> nestedPath, int nestedEndDirection) { super(label, elementToEdit, request); @@ -84,59 +89,62 @@ public class SetNestedPathCommand extends EditElementCommand { /** * Test whether the command can be executed or not. */ + @Override public boolean canExecute() { // Verify the kind of request - if(! (getRequest() instanceof CreateRelationshipRequest) - && ! (getRequest() instanceof ReorientRelationshipRequest)) { - + if (!(getRequest() instanceof CreateRelationshipRequest) + && !(getRequest() instanceof ReorientRelationshipRequest)) { + return false; } // Verify (basic) that the related Connector well-formed. // In case of Connector creation, the connector is most probably not created yet if ((getConnector() != null) - && (getConnector().getEnds().size() != 2)) { - + && (getConnector().getEnds().size() != 2)) { + return false; // binary connector expected. } - + return true; } + @Override protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if(!canExecute()) { + if (!canExecute()) { throw new ExecutionException("Unexecutable command."); //$NON-NLS-1$ } ConnectorEnd modifiedEnd = getModifiedConnectorEnd(); NestedConnectorEnd nestedConnectorEnd = UMLUtil.getStereotypeApplication(modifiedEnd, NestedConnectorEnd.class); - if(nestedPath.isEmpty()) { + if (nestedPath.isEmpty()) { // Remove stereotype if applied - if(nestedConnectorEnd != null) { + if (nestedConnectorEnd != null) { EcoreUtil.delete(nestedConnectorEnd, true); } } else { // Add stereotype if not applied and set new path if different from existing - if(nestedConnectorEnd == null) { + if (nestedConnectorEnd == null) { // apply stereotype - nestedConnectorEnd = (NestedConnectorEnd)StereotypeApplicationHelper.INSTANCE.applyStereotype(modifiedEnd, BlocksPackage.eINSTANCE.getNestedConnectorEnd()); + nestedConnectorEnd = (NestedConnectorEnd) StereotypeApplicationHelper.INSTANCE.applyStereotype(modifiedEnd, BlocksPackage.eINSTANCE.getNestedConnectorEnd()); } // Set path - if(!nestedConnectorEnd.getPropertyPath().equals(nestedPath)) { + if (!nestedConnectorEnd.getPropertyPath().equals(nestedPath)) { nestedConnectorEnd.getPropertyPath().clear(); nestedConnectorEnd.getPropertyPath().addAll(nestedPath); } } - + return CommandResult.newOKCommandResult(getConnector()); } /** * Get the {@link ConnectorEnd} currently modified by the command. + * * @return the modified {@link ConnectorEnd}. */ private ConnectorEnd getModifiedConnectorEnd() { @@ -145,16 +153,17 @@ public class SetNestedPathCommand extends EditElementCommand { /** * Get the {@link Connector} currently under creation or re-orient that hold {@link ConnectorEnd} to update. + * * @return the related {@link Connector}. */ private Connector getConnector() { Connector connector = null; - if(getRequest() instanceof CreateRelationshipRequest) { - connector = (Connector)((CreateRelationshipRequest)getRequest()).getNewElement(); + if (getRequest() instanceof CreateRelationshipRequest) { + connector = (Connector) ((CreateRelationshipRequest) getRequest()).getNewElement(); } - if(getRequest() instanceof ReorientRelationshipRequest) { - connector = (Connector)((ReorientRelationshipRequest)getRequest()).getRelationship(); + if (getRequest() instanceof ReorientRelationshipRequest) { + connector = (Connector) ((ReorientRelationshipRequest) getRequest()).getRelationship(); } return connector; } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/handlers/AbstractSysmlCreateCommandHandler.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/handlers/AbstractSysmlCreateCommandHandler.java index e3d23cd7930..c6f4b83145a 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/handlers/AbstractSysmlCreateCommandHandler.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/handlers/AbstractSysmlCreateCommandHandler.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2013 CEA LIST. - * + * * 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 @@ -16,15 +16,16 @@ import org.eclipse.papyrus.uml.service.types.filter.ICommandFilter; import org.eclipse.papyrus.uml.service.types.handlers.AbstractCreateCommandHandler; /** - * + * * Abstract handler for every creation command for Sysml elements * used in the ModelExplorer contextual ("Create new child") menu - * + * */ public abstract class AbstractSysmlCreateCommandHandler extends AbstractCreateCommandHandler { private static final ICommandFilter filter = SysmlCommandFilter.INSTANCE; + @Override public ICommandFilter getCommandFilter() { return filter; } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/AbstractPropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/AbstractPropertyEditHelperAdvice.java index f341bbb284b..c6034515965 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/AbstractPropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/AbstractPropertyEditHelperAdvice.java @@ -1,5 +1,5 @@ /** - * + * */ package org.eclipse.papyrus.sysml.service.types.helper; @@ -31,7 +31,7 @@ import org.eclipse.uml2.uml.Property; * Abstract edit helper advice for SysML specific Properties: part and reference */ public abstract class AbstractPropertyEditHelperAdvice extends AbstractEditHelperAdvice { - + /** * {@inheritDoc} */ @@ -39,54 +39,56 @@ public abstract class AbstractPropertyEditHelperAdvice extends AbstractEditHelpe protected ICommand getBeforeDuplicateCommand(DuplicateElementsRequest request) { Object targetContainer = request.getParameter("Target_Owner"); // additional element should be a set of elements that will be duplicated. If this is null, the request will be ignored. - if(!(targetContainer instanceof EObject)) { + if (!(targetContainer instanceof EObject)) { return super.getBeforeDuplicateCommand(request); } Property propertyToBeDuplicated = getDuplicatedProperty(request); - if(propertyToBeDuplicated == null) { + if (propertyToBeDuplicated == null) { return super.getBeforeDuplicateCommand(request); } - Property newPart = (Property)request.getAllDuplicatedElementsMap().get(propertyToBeDuplicated); - if(newPart == null) { + Property newPart = (Property) request.getAllDuplicatedElementsMap().get(propertyToBeDuplicated); + if (newPart == null) { Activator.log.debug("Trying to create a command for a new sysml property which has not been created yet"); return super.getBeforeDuplicateCommand(request); } // check association has not be duplicated yet Association originalAssociation = propertyToBeDuplicated.getAssociation(); - Association newAssociation = (Association)request.getAllDuplicatedElementsMap().get(originalAssociation); - if(newAssociation != null && newAssociation.equals(newPart.getAssociation())) { + Association newAssociation = (Association) request.getAllDuplicatedElementsMap().get(originalAssociation); + if (newAssociation != null && newAssociation.equals(newPart.getAssociation())) { return super.getBeforeDuplicateCommand(request); } TransactionalEditingDomain editingDomain = getEditingDomain(propertyToBeDuplicated); - if(editingDomain == null) { + if (editingDomain == null) { return super.getBeforeDuplicateCommand(request); } - Package targetPackage = getTargetContainer((EObject)targetContainer, propertyToBeDuplicated, newPart, request.getAllDuplicatedElementsMap()); + Package targetPackage = getTargetContainer((EObject) targetContainer, propertyToBeDuplicated, newPart, request.getAllDuplicatedElementsMap()); return new DuplicatePapyrusAssociationCommand(editingDomain, "Duplicate Association", originalAssociation, request.getAllDuplicatedElementsMap(), targetPackage); } /** * Returns the duplicate Part or Reference. - * @param request the duplicate request for which we try to find the property + * + * @param request + * the duplicate request for which we try to find the property * @return the found Property */ protected abstract Property getDuplicatedProperty(DuplicateElementsRequest request); /** * Computes the target container for the new association - * + * * @param targetContainer - * the target container of the association creation request + * the target container of the association creation request * @param partToBeDuplicated - * the part which was duplicated + * the part which was duplicated * @param newPart - * the new part linked to the association + * the new part linked to the association * @param allDuplicatedElementsMap - * the map of all duplicated elements + * the map of all duplicated elements * @return the target {@link Package} for the new association or <code>null</code> if no package was found */ protected Package getTargetContainer(EObject targetContainer, Property partToBeDuplicated, Property newPart, Map allDuplicatedElementsMap) { @@ -97,23 +99,23 @@ public abstract class AbstractPropertyEditHelperAdvice extends AbstractEditHelpe // 4. look for the nearest package of the target container Package result = newPart.getNearestPackage(); - if(result != null) { + if (result != null) { return result; } Package originalPackage = partToBeDuplicated.getNearestPackage(); // look for its equivalent in the list of duplicated objects Object o = allDuplicatedElementsMap.get(originalPackage); - if(o instanceof Package) { - return (Package)o; + if (o instanceof Package) { + return (Package) o; } - if(targetContainer instanceof Package) { - return ((Package)targetContainer); + if (targetContainer instanceof Package) { + return ((Package) targetContainer); } - if(targetContainer instanceof Element) { - return ((Element)targetContainer).getNearestPackage(); + if (targetContainer instanceof Element) { + return ((Element) targetContainer).getNearestPackage(); } return null; @@ -121,14 +123,14 @@ public abstract class AbstractPropertyEditHelperAdvice extends AbstractEditHelpe /** * Get the editing domain from an {@link EObject} - * + * * @param eObject * @return */ protected TransactionalEditingDomain getEditingDomain(EObject eObject) { EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(eObject); - if(editingDomain instanceof TransactionalEditingDomain) { - return (TransactionalEditingDomain)editingDomain; + if (editingDomain instanceof TransactionalEditingDomain) { + return (TransactionalEditingDomain) editingDomain; } return null; } @@ -150,17 +152,17 @@ public abstract class AbstractPropertyEditHelperAdvice extends AbstractEditHelpe * list of EObjects. Also sets the list of affected files to be the files, * where the targetContainer is stored. Target container specifies the * eObject into which the duplicated eObjects will be added. - * + * * @param editingDomain - * the editing domain through which model changes are made + * the editing domain through which model changes are made * @param label - * The label for the new command. + * The label for the new command. * @param originalAssociation - * <code>Association</code> to be duplicated. + * <code>Association</code> to be duplicated. * @param allDuplicatedObjectsMap - * An empty map to be populated with the duplicated objects. + * An empty map to be populated with the duplicated objects. * @param targetContainer - * target package + * target package */ public DuplicatePapyrusAssociationCommand(TransactionalEditingDomain editingDomain, String label, Association originalAssociation, Map allDuplicatedObjectsMap, Package targetContainer) { super(editingDomain, label, Collections.singletonList(originalAssociation), allDuplicatedObjectsMap, targetContainer); @@ -182,12 +184,12 @@ public abstract class AbstractPropertyEditHelperAdvice extends AbstractEditHelpe copier.copy(associationToDuplicate); copier.copyReferences(); - Association newAssociation = (Association)copier.get(associationToDuplicate); - if(newAssociation == null) { + Association newAssociation = (Association) copier.get(associationToDuplicate); + if (newAssociation == null) { return CommandResult.newErrorCommandResult("Impossible to find the copied association"); } - // note: can be executed only if targetcontainer is instanceof package, this means that there is no need to tests for null targetContainer + // note: can be executed only if targetcontainer is instanceof package, this means that there is no need to tests for null targetContainer newAssociation.setPackage(targetContainer); String associationName = NamedElementHelper.getDefaultNameWithIncrementFromBase("Association", targetContainer.eContents()); //$NON-NLS-1$ newAssociation.setName(associationName); diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ActorPartPropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ActorPartPropertyEditHelperAdvice.java index 2d84151b780..9aa9604a62b 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ActorPartPropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ActorPartPropertyEditHelperAdvice.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * + * * CEA LIST - Initial API and implementation * *****************************************************************************/ @@ -36,9 +36,9 @@ public class ActorPartPropertyEditHelperAdvice extends AbstractEditHelperAdvice /** * Check if the creation context is a {@link Block}. - * + * * @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * + * * @param request * @return true if the request is approved */ @@ -46,17 +46,17 @@ public class ActorPartPropertyEditHelperAdvice extends AbstractEditHelperAdvice public boolean approveRequest(IEditCommandRequest request) { boolean isApproved = super.approveRequest(request); - if((request != null) && (request instanceof GetEditContextRequest)) { + if ((request != null) && (request instanceof GetEditContextRequest)) { // Retrieve the edit context from request - GetEditContextRequest editContextRequest = (GetEditContextRequest)request; + GetEditContextRequest editContextRequest = (GetEditContextRequest) request; // Test if the edit context is a Block - if(editContextRequest.getEditContext() instanceof Element) { - Element contextElement = (Element)editContextRequest.getEditContext(); + if (editContextRequest.getEditContext() instanceof Element) { + Element contextElement = (Element) editContextRequest.getEditContext(); IElementMatcher matcher = new BlockMatcher(); - if(!matcher.matches(contextElement)) { + if (!matcher.matches(contextElement)) { isApproved = false; } } @@ -71,9 +71,10 @@ public class ActorPartPropertyEditHelperAdvice extends AbstractEditHelperAdvice return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Property element = (Property)request.getElementToConfigure(); - if(element != null) { + Property element = (Property) request.getElementToConfigure(); + if (element != null) { // Set default name String initializedName = NamedElementHelper.getDefaultNameWithIncrementFromBase("actorPart", element.eContainer().eContents()); //$NON-NLS-1$ diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/AllocateEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/AllocateEditHelperAdvice.java index 53f5309c793..32da3bb44dd 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/AllocateEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/AllocateEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -38,9 +38,10 @@ public class AllocateEditHelperAdvice extends AbstractStereotypedElementEditHelp return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, AllocationsPackage.eINSTANCE.getAllocate()); // Set default name diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/BlockEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/BlockEditHelperAdvice.java index e7ea9c782dd..a6008b5b1b8 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/BlockEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/BlockEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -51,9 +51,9 @@ public class BlockEditHelperAdvice extends AbstractStereotypedElementEditHelperA /** * Check if the creation context is allowed. - * + * * @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * + * * @param request * @return true if the request is approved */ @@ -61,26 +61,26 @@ public class BlockEditHelperAdvice extends AbstractStereotypedElementEditHelperA public boolean approveRequest(IEditCommandRequest request) { boolean isApproved = super.approveRequest(request); - if((request != null) && (request instanceof GetEditContextRequest)) { + if ((request != null) && (request instanceof GetEditContextRequest)) { // Retrieve the edit context from request - GetEditContextRequest editContextRequest = (GetEditContextRequest)request; + GetEditContextRequest editContextRequest = (GetEditContextRequest) request; // Test context type - if(editContextRequest.getEditContext() instanceof Element) { - Element contextElement = (Element)editContextRequest.getEditContext(); + if (editContextRequest.getEditContext() instanceof Element) { + Element contextElement = (Element) editContextRequest.getEditContext(); IElementMatcher matcher; // Cannot create a nested Block in FlowSpecification matcher = new FlowSpecificationMatcher(); - if(matcher.matches(contextElement)) { + if (matcher.matches(contextElement)) { isApproved = false; } // Cannot create a nested Block in Requirement matcher = new RequirementMatcher(); - if(matcher.matches(contextElement)) { + if (matcher.matches(contextElement)) { isApproved = false; } } @@ -95,9 +95,10 @@ public class BlockEditHelperAdvice extends AbstractStereotypedElementEditHelperA return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, BlocksPackage.eINSTANCE.getBlock()); // Set default name @@ -109,13 +110,13 @@ public class BlockEditHelperAdvice extends AbstractStereotypedElementEditHelperA } }; } - + @Override protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) { // test if the creation is for a SysML association IElementType type = request.getElementType(); - if(hasSuperType(type, SysMLElementTypes.ASSOCIATION)) { + if (hasSuperType(type, SysMLElementTypes.ASSOCIATION)) { // test source and target... EObject source = request.getSource(); // The source of an association cannot be read-only. @@ -126,20 +127,20 @@ public class BlockEditHelperAdvice extends AbstractStereotypedElementEditHelperA return super.getBeforeCreateRelationshipCommand(request); } - + protected boolean hasSuperType(IElementType elementType, IElementType typeToTest) { - if(elementType == null || typeToTest == null) { + if (elementType == null || typeToTest == null) { return false; } - if(elementType.equals(typeToTest)) { + if (elementType.equals(typeToTest)) { return true; } List<IElementType> superTypes = Arrays.asList(elementType.getAllSuperTypes()); - if(superTypes.contains(typeToTest)) { - return true; - } + if (superTypes.contains(typeToTest)) { + return true; + } return false; } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConformEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConformEditHelperAdvice.java index 7d80d788b16..40d5847d74a 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConformEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConformEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -38,9 +38,10 @@ public class ConformEditHelperAdvice extends AbstractStereotypedElementEditHelpe return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, ModelelementsPackage.eINSTANCE.getConform()); // Set default name diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintBlockEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintBlockEditHelperAdvice.java index 1ce81ce68c6..784ac347e8d 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintBlockEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintBlockEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -38,7 +38,7 @@ public class ConstraintBlockEditHelperAdvice extends AbstractStereotypedElementE /** * Restriction on ConstraintBlock owned Structural and Behavioral features. - * + * * {@inheritDoc} */ @Override @@ -46,8 +46,8 @@ public class ConstraintBlockEditHelperAdvice extends AbstractStereotypedElementE IElementType elementToCreate = request.getElementType(); - if(UMLElementTypes.STRUCTURAL_FEATURE.getEClass().isSuperTypeOf(elementToCreate.getEClass())) { - if(elementToCreate != SysMLElementTypes.CONSTRAINT_PROPERTY && elementToCreate != UMLElementTypes.PROPERTY) { + if (UMLElementTypes.STRUCTURAL_FEATURE.getEClass().isSuperTypeOf(elementToCreate.getEClass())) { + if (elementToCreate != SysMLElementTypes.CONSTRAINT_PROPERTY && elementToCreate != UMLElementTypes.PROPERTY) { return null; } } @@ -57,7 +57,7 @@ public class ConstraintBlockEditHelperAdvice extends AbstractStereotypedElementE /** * Complete creation process by applying the expected stereotype - * + * * {@inheritDoc} */ @Override @@ -65,9 +65,10 @@ public class ConstraintBlockEditHelperAdvice extends AbstractStereotypedElementE return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, ConstraintsPackage.eINSTANCE.getConstraintBlock()); // Set default name diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintBlockPropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintBlockPropertyEditHelperAdvice.java index 242195f840b..5e58bd9c58d 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintBlockPropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintBlockPropertyEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -30,7 +30,7 @@ public class ConstraintBlockPropertyEditHelperAdvice extends AbstractEditHelperA /** * Every {@link Property} created in the context of a {@link ConstraintBlock} is Composite. - * + * * {@inheritDoc} */ @Override @@ -38,12 +38,13 @@ public class ConstraintBlockPropertyEditHelperAdvice extends AbstractEditHelperA return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Property element = (Property)request.getElementToConfigure(); - if(element != null) { - + Property element = (Property) request.getElementToConfigure(); + if (element != null) { + Element owner = element.getOwner(); - if (((ISpecializationType)SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches(owner)) { + if (((ISpecializationType) SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches(owner)) { element.setAggregation(AggregationKind.COMPOSITE_LITERAL); } } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintParameterEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintParameterEditHelperAdvice.java index 1916681d448..54fc3b1d89a 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintParameterEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintParameterEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -73,6 +73,7 @@ public class ConstraintParameterEditHelperAdvice extends AbstractEditHelperAdvic if (type != null && type instanceof Class && UMLUtil.getStereotypeApplication(type, ConstraintBlock.class) != null) { return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { NamedElement element = (NamedElement) request.getElementToConfigure(); if (element != null) { diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintPropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintPropertyEditHelperAdvice.java index 34c51d36859..a8d5909b2a4 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintPropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintPropertyEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -53,9 +53,10 @@ public class ConstraintPropertyEditHelperAdvice extends AbstractStereotypedEleme return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, ConstraintsPackage.eINSTANCE.getConstraintProperty()); // Set default name @@ -64,7 +65,7 @@ public class ConstraintPropertyEditHelperAdvice extends AbstractStereotypedEleme element.setName(initializedName); // SysML constraint : self.ownedAttribute->forAll(p | p.type.oclIsKindOf(ConstraintBlock) implies p.aggregation = #composite) if (element instanceof Property) { - ((Property)element).setAggregation(AggregationKind.COMPOSITE_LITERAL); + ((Property) element).setAggregation(AggregationKind.COMPOSITE_LITERAL); } } return CommandResult.newOKCommandResult(element); @@ -79,15 +80,15 @@ public class ConstraintPropertyEditHelperAdvice extends AbstractStereotypedEleme protected ICommand getBeforeSetCommand(SetRequest request) { // Only allow ConstraintBlock or null as new type - if(UMLPackage.eINSTANCE.getTypedElement_Type().equals(request.getFeature())) { - if(request.getValue() != null) { + if (UMLPackage.eINSTANCE.getTypedElement_Type().equals(request.getFeature())) { + if (request.getValue() != null) { - if(!(request.getValue() instanceof Element)) { + if (!(request.getValue() instanceof Element)) { return UnexecutableCommand.INSTANCE; } - ConstraintBlock constraint = UMLUtil.getStereotypeApplication((Element)request.getValue(), ConstraintBlock.class); - if(constraint == null) { + ConstraintBlock constraint = UMLUtil.getStereotypeApplication((Element) request.getValue(), ConstraintBlock.class); + if (constraint == null) { return UnexecutableCommand.INSTANCE; } } @@ -107,11 +108,11 @@ public class ConstraintPropertyEditHelperAdvice extends AbstractStereotypedEleme @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Property sourcePart = (Property)request.getElementToConfigure(); - if((sourcePart != null) && (sourcePart.eContainer() != null)) { + Property sourcePart = (Property) request.getElementToConfigure(); + if ((sourcePart != null) && (sourcePart.eContainer() != null)) { sourcePart.setAggregation(AggregationKind.COMPOSITE_LITERAL); - + // Create association between element owner and element type Type sourceType = resolveTypeContainer(sourcePart); Package associationContainer = sourceType.getNearestPackage(); @@ -143,7 +144,7 @@ public class ConstraintPropertyEditHelperAdvice extends AbstractStereotypedEleme eContainer = ((Property) eContainer).getType(); } if (eContainer instanceof Type) { - return (Type)eContainer; + return (Type) eContainer; } return null; } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/CopyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/CopyEditHelperAdvice.java index d3d717aee98..04c26310b9b 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/CopyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/CopyEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -38,9 +38,10 @@ public class CopyEditHelperAdvice extends AbstractStereotypedElementEditHelperAd return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, RequirementsPackage.eINSTANCE.getCopy()); // Set default name diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/DeriveReqtEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/DeriveReqtEditHelperAdvice.java index 207c5c55e92..71874152bf7 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/DeriveReqtEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/DeriveReqtEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -40,9 +40,10 @@ public class DeriveReqtEditHelperAdvice extends AbstractStereotypedElementEditHe return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, RequirementsPackage.eINSTANCE.getDeriveReqt()); // Set default name diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/DimensionEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/DimensionEditHelperAdvice.java index 0ebc9defc52..45e730f1f94 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/DimensionEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/DimensionEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -39,9 +39,10 @@ public class DimensionEditHelperAdvice extends AbstractStereotypedElementEditHel return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, BlocksPackage.eINSTANCE.getDimension()); // Set default name diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortEditHelperAdvice.java index 551a9500ca4..8decfb9c53d 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -50,9 +50,9 @@ public class FlowPortEditHelperAdvice extends AbstractStereotypedElementEditHelp /** * Check if the creation context is a Block. - * + * * @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * + * * @param request * @return true if the request is approved */ @@ -60,17 +60,17 @@ public class FlowPortEditHelperAdvice extends AbstractStereotypedElementEditHelp public boolean approveRequest(IEditCommandRequest request) { boolean isApproved = super.approveRequest(request); - if((request != null) && (request instanceof GetEditContextRequest)) { + if ((request != null) && (request instanceof GetEditContextRequest)) { // Retrieve the edit context from request - GetEditContextRequest editContextRequest = (GetEditContextRequest)request; + GetEditContextRequest editContextRequest = (GetEditContextRequest) request; // Test if the edit context is a Block - if(editContextRequest.getEditContext() instanceof Element) { - Element contextElement = (Element)editContextRequest.getEditContext(); + if (editContextRequest.getEditContext() instanceof Element) { + Element contextElement = (Element) editContextRequest.getEditContext(); IElementMatcher matcher = new BlockMatcher(); - if(!matcher.matches(contextElement)) { + if (!matcher.matches(contextElement)) { isApproved = false; } } @@ -85,10 +85,11 @@ public class FlowPortEditHelperAdvice extends AbstractStereotypedElementEditHelp return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Port port = (Port)request.getElementToConfigure(); - if(port != null) { + Port port = (Port) request.getElementToConfigure(); + if (port != null) { // Apply FlowPort stereotype StereotypeApplicationHelper.INSTANCE.applyStereotype(port, PortandflowsPackage.eINSTANCE.getFlowPort()); @@ -111,15 +112,15 @@ public class FlowPortEditHelperAdvice extends AbstractStereotypedElementEditHelp protected ICommand getBeforeSetCommand(SetRequest request) { // Only allow null, Block, Signal, DataType or ValueType as the new type - if(UMLPackage.eINSTANCE.getTypedElement_Type().equals(request.getFeature())) { - if(request.getValue() != null) { + if (UMLPackage.eINSTANCE.getTypedElement_Type().equals(request.getFeature())) { + if (request.getValue() != null) { - if(!(request.getValue() instanceof Element)) { + if (!(request.getValue() instanceof Element)) { return UnexecutableCommand.INSTANCE; // Should not happen } - Element value = (Element)request.getValue(); - if((value instanceof DataType) || (value instanceof Signal)) { + Element value = (Element) request.getValue(); + if ((value instanceof DataType) || (value instanceof Signal)) { return null; // accept these types } @@ -127,7 +128,7 @@ public class FlowPortEditHelperAdvice extends AbstractStereotypedElementEditHelp Block block = UMLUtil.getStereotypeApplication(value, Block.class); FlowSpecification flowspecification = UMLUtil.getStereotypeApplication(value, FlowSpecification.class); - if((block != null) || (valueType != null) || (flowspecification != null)) { + if ((block != null) || (valueType != null) || (flowspecification != null)) { return null; // accept these types } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortInEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortInEditHelperAdvice.java index 2e9654be3a4..6450c43b05f 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortInEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortInEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -41,11 +41,12 @@ public class FlowPortInEditHelperAdvice extends AbstractStereotypedElementEditHe return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Port port = (Port)request.getElementToConfigure(); + Port port = (Port) request.getElementToConfigure(); FlowPort flowPort = UMLUtil.getStereotypeApplication(port, FlowPort.class); - if(flowPort != null) { + if (flowPort != null) { flowPort.setDirection(FlowDirection.IN); } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortInOutEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortInOutEditHelperAdvice.java index 0f093669ba8..78bc0dd262c 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortInOutEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortInOutEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -41,11 +41,12 @@ public class FlowPortInOutEditHelperAdvice extends AbstractStereotypedElementEdi return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Port port = (Port)request.getElementToConfigure(); + Port port = (Port) request.getElementToConfigure(); FlowPort flowPort = UMLUtil.getStereotypeApplication(port, FlowPort.class); - if(flowPort != null) { + if (flowPort != null) { flowPort.setDirection(FlowDirection.INOUT); } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortNAEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortNAEditHelperAdvice.java index fe18de89d98..72db9e0b489 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortNAEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortNAEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -40,12 +40,13 @@ public class FlowPortNAEditHelperAdvice extends AbstractStereotypedElementEditHe return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Port port = (Port)request.getElementToConfigure(); - + Port port = (Port) request.getElementToConfigure(); + // Ensure the type is a FlowSpecification - if((port != null) && (port.getType() != null)) { + if ((port != null) && (port.getType() != null)) { if (UMLUtil.getStereotypeApplication(port.getType(), FlowSpecification.class) != null) { return CommandResult.newOKCommandResult(port); } @@ -55,5 +56,5 @@ public class FlowPortNAEditHelperAdvice extends AbstractStereotypedElementEditHe } }; } - + } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortOutEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortOutEditHelperAdvice.java index cccf6d78d25..8efd45f3903 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortOutEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPortOutEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -41,11 +41,12 @@ public class FlowPortOutEditHelperAdvice extends AbstractStereotypedElementEditH return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Port port = (Port)request.getElementToConfigure(); + Port port = (Port) request.getElementToConfigure(); FlowPort flowPort = UMLUtil.getStereotypeApplication(port, FlowPort.class); - if(flowPort != null) { + if (flowPort != null) { flowPort.setDirection(FlowDirection.OUT); } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPropertyEditHelperAdvice.java index c7bfe313c81..8b3b54faafd 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowPropertyEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -50,9 +50,9 @@ public class FlowPropertyEditHelperAdvice extends AbstractStereotypedElementEdit /** * Check if the creation context is a FlowSpecification. - * + * * @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * + * * @param request * @return true if the request is approved */ @@ -60,18 +60,18 @@ public class FlowPropertyEditHelperAdvice extends AbstractStereotypedElementEdit public boolean approveRequest(IEditCommandRequest request) { boolean isApproved = super.approveRequest(request); - if((request != null) && (request instanceof GetEditContextRequest)) { + if ((request != null) && (request instanceof GetEditContextRequest)) { // Retrieve the edit context from request - GetEditContextRequest editContextRequest = (GetEditContextRequest)request; + GetEditContextRequest editContextRequest = (GetEditContextRequest) request; // Test if the edit context is a FlowSpecification - if(editContextRequest.getEditContext() instanceof Element) { - Element contextElement = (Element)editContextRequest.getEditContext(); + if (editContextRequest.getEditContext() instanceof Element) { + Element contextElement = (Element) editContextRequest.getEditContext(); IElementMatcher matcher = new FlowSpecificationMatcher(); IElementMatcher blockMatcher = new BlockMatcher(); - if(!matcher.matches(contextElement) && !blockMatcher.matches(contextElement)) { + if (!matcher.matches(contextElement) && !blockMatcher.matches(contextElement)) { isApproved = false; } } @@ -86,9 +86,10 @@ public class FlowPropertyEditHelperAdvice extends AbstractStereotypedElementEdit return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, PortandflowsPackage.eINSTANCE.getFlowProperty()); // Set default name @@ -108,22 +109,22 @@ public class FlowPropertyEditHelperAdvice extends AbstractStereotypedElementEdit protected ICommand getBeforeSetCommand(SetRequest request) { // Only allow null, FlowSpecification, Block, Signal, DataType or ValueType as new type. - if(UMLPackage.eINSTANCE.getTypedElement_Type().equals(request.getFeature())) { - if(request.getValue() != null) { + if (UMLPackage.eINSTANCE.getTypedElement_Type().equals(request.getFeature())) { + if (request.getValue() != null) { - if(!(request.getValue() instanceof Element)) { + if (!(request.getValue() instanceof Element)) { return UnexecutableCommand.INSTANCE; // Should not happen } - Element value = (Element)request.getValue(); - if((value instanceof DataType) || (value instanceof Signal)) { + Element value = (Element) request.getValue(); + if ((value instanceof DataType) || (value instanceof Signal)) { return null; // accept these types } ValueType valueType = UMLUtil.getStereotypeApplication(value, ValueType.class); Block block = UMLUtil.getStereotypeApplication(value, Block.class); - if((block != null) || (valueType != null)) { + if ((block != null) || (valueType != null)) { return null; // accept these types } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowSpecificationEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowSpecificationEditHelperAdvice.java index 995a215c69e..155146bb616 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowSpecificationEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/FlowSpecificationEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -58,16 +58,16 @@ public class FlowSpecificationEditHelperAdvice extends AbstractStereotypedElemen IElementType elementToCreate = request.getElementType(); // [1] Flow specifications cannot own operations or receptions (they can only own FlowProperties). - if(elementToCreate == UMLElementTypes.OPERATION) { + if (elementToCreate == UMLElementTypes.OPERATION) { return UnexecutableCommand.INSTANCE; } - if(elementToCreate == UMLElementTypes.RECEPTION) { + if (elementToCreate == UMLElementTypes.RECEPTION) { return UnexecutableCommand.INSTANCE; } // [2] Every “ownedAttribute” of a FlowSpecification must be a FlowProperty. - if(UMLElementTypes.PROPERTY.getEClass().isSuperTypeOf(elementToCreate.getEClass())) { - if((elementToCreate != SysMLElementTypes.FLOW_PROPERTY) && !(Arrays.asList(elementToCreate.getAllSuperTypes()).contains(SysMLElementTypes.FLOW_PROPERTY))) { + if (UMLElementTypes.PROPERTY.getEClass().isSuperTypeOf(elementToCreate.getEClass())) { + if ((elementToCreate != SysMLElementTypes.FLOW_PROPERTY) && !(Arrays.asList(elementToCreate.getAllSuperTypes()).contains(SysMLElementTypes.FLOW_PROPERTY))) { return UnexecutableCommand.INSTANCE; } } @@ -77,9 +77,9 @@ public class FlowSpecificationEditHelperAdvice extends AbstractStereotypedElemen /** * Check if the creation context is allowed. - * + * * @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * + * * @param request * @return true if the request is approved */ @@ -87,26 +87,26 @@ public class FlowSpecificationEditHelperAdvice extends AbstractStereotypedElemen public boolean approveRequest(IEditCommandRequest request) { boolean isApproved = super.approveRequest(request); - if((request != null) && (request instanceof GetEditContextRequest)) { + if ((request != null) && (request instanceof GetEditContextRequest)) { // Retrieve the edit context from request - GetEditContextRequest editContextRequest = (GetEditContextRequest)request; + GetEditContextRequest editContextRequest = (GetEditContextRequest) request; // Test context type - if(editContextRequest.getEditContext() instanceof Element) { - Element contextElement = (Element)editContextRequest.getEditContext(); + if (editContextRequest.getEditContext() instanceof Element) { + Element contextElement = (Element) editContextRequest.getEditContext(); IElementMatcher matcher; // Cannot create a nested FlowSpecification in FlowSpecification matcher = new FlowSpecificationMatcher(); - if(matcher.matches(contextElement)) { + if (matcher.matches(contextElement)) { isApproved = false; } // Cannot create a nested FlowSpecification in Requirement matcher = new RequirementMatcher(); - if(matcher.matches(contextElement)) { + if (matcher.matches(contextElement)) { isApproved = false; } } @@ -121,9 +121,10 @@ public class FlowSpecificationEditHelperAdvice extends AbstractStereotypedElemen return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, PortandflowsPackage.eINSTANCE.getFlowSpecification()); // Set default name diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ItemFlowEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ItemFlowEditHelperAdvice.java index 6a40252176b..f4ebfdf4168 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ItemFlowEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ItemFlowEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -38,9 +38,10 @@ public class ItemFlowEditHelperAdvice extends AbstractStereotypedElementEditHelp return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - if(element != null) { + NamedElement element = (NamedElement) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, PortandflowsPackage.eINSTANCE.getItemFlow()); // Set default name diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/PartPropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/PartPropertyEditHelperAdvice.java index 473a9534cd7..eb1b474d965 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/PartPropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/PartPropertyEditHelperAdvice.java @@ -1,14 +1,14 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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: - * + * * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation * *****************************************************************************/ @@ -46,9 +46,9 @@ public class PartPropertyEditHelperAdvice extends AbstractPropertyEditHelperAdvi /** * Check if the creation context is a {@link Block}. - * + * * @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * + * * @param request * @return true if the request is approved */ @@ -56,17 +56,17 @@ public class PartPropertyEditHelperAdvice extends AbstractPropertyEditHelperAdvi public boolean approveRequest(IEditCommandRequest request) { boolean isApproved = super.approveRequest(request); - if((request != null) && (request instanceof GetEditContextRequest)) { + if ((request != null) && (request instanceof GetEditContextRequest)) { // Retrieve the edit context from request - GetEditContextRequest editContextRequest = (GetEditContextRequest)request; + GetEditContextRequest editContextRequest = (GetEditContextRequest) request; // Test if the edit context is a Block - if(editContextRequest.getEditContext() instanceof Element) { - Element contextElement = (Element)editContextRequest.getEditContext(); + if (editContextRequest.getEditContext() instanceof Element) { + Element contextElement = (Element) editContextRequest.getEditContext(); IElementMatcher matcher = new BlockMatcher(); - if(!matcher.matches(contextElement)) { + if (!matcher.matches(contextElement)) { isApproved = false; } } @@ -83,8 +83,8 @@ public class PartPropertyEditHelperAdvice extends AbstractPropertyEditHelperAdvi @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Property element = (Property)request.getElementToConfigure(); - if(element != null) { + Property element = (Property) request.getElementToConfigure(); + if (element != null) { // Set default name String initializedName = NamedElementHelper.getDefaultNameWithIncrementFromBase("part", element.eContainer().eContents()); //$NON-NLS-1$ @@ -108,12 +108,12 @@ public class PartPropertyEditHelperAdvice extends AbstractPropertyEditHelperAdvi @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Property sourcePart = (Property)request.getElementToConfigure(); - if((sourcePart != null) && (sourcePart.getType() != null)) { + Property sourcePart = (Property) request.getElementToConfigure(); + if ((sourcePart != null) && (sourcePart.getType() != null)) { // Create association between element owner and element type Type sourceType = sourcePart.getClass_(); - //Type targetType = sourcePart.getType(); + // Type targetType = sourcePart.getType(); Package associationContainer = sourceType.getNearestPackage(); // Create targetProperty @@ -138,24 +138,25 @@ public class PartPropertyEditHelperAdvice extends AbstractPropertyEditHelperAdvi } }; } - + /** * Returns the Part to be duplicated - * + * * @return the Part to be duplicated or <code>null</code> if this is not a part */ + @Override protected Property getDuplicatedProperty(DuplicateElementsRequest request) { List<Object> elementsToBeDuplicated = request.getElementsToBeDuplicated(); - if(elementsToBeDuplicated == null || elementsToBeDuplicated.isEmpty()) { + if (elementsToBeDuplicated == null || elementsToBeDuplicated.isEmpty()) { return null; } Object firstElement = elementsToBeDuplicated.get(0); // there should be only one element here - if(!(firstElement instanceof Property)) { + if (!(firstElement instanceof Property)) { return null; } PartPropertyMatcher matcher = new PartPropertyMatcher(); - return matcher.matches((Property)firstElement) ? (Property)firstElement : null; + return matcher.matches((Property) firstElement) ? (Property) firstElement : null; } - + } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ProblemEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ProblemEditHelperAdvice.java index e823543e635..f926187349f 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ProblemEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ProblemEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -37,9 +37,10 @@ public class ProblemEditHelperAdvice extends AbstractStereotypedElementEditHelpe return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Element element = (Element)request.getElementToConfigure(); - if(element != null) { + Element element = (Element) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, ModelelementsPackage.eINSTANCE.getProblem()); } return CommandResult.newOKCommandResult(element); diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/RationaleEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/RationaleEditHelperAdvice.java index d499887bb29..b616439bead 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/RationaleEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/RationaleEditHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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 @@ -37,9 +37,10 @@ public class RationaleEditHelperAdvice extends AbstractStereotypedElementEditHel return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Element element = (Element)request.getElementToConfigure(); - if(element != null) { + Element element = (Element) request.getElementToConfigure(); + if (element != null) { StereotypeApplicationHelper.INSTANCE.applyStereotype(element, ModelelementsPackage.eINSTANCE.getRationale()); } return CommandResult.newOKCommandResult(element); diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ReferencePropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ReferencePropertyEditHelperAdvice.java index d6507b5e382..70bf740d259 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ReferencePropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ReferencePropertyEditHelperAdvice.java @@ -1,14 +1,14 @@ /***************************************************************************** * Copyright (c) 2010 CEA LIST. * - * + * * 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: - * + * * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation * *****************************************************************************/ @@ -46,9 +46,9 @@ public class ReferencePropertyEditHelperAdvice extends AbstractPropertyEditHelpe /** * Check if the creation context is a {@link Block}. - * + * * @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * + * * @param request * @return true if the request is approved */ @@ -56,17 +56,17 @@ public class ReferencePropertyEditHelperAdvice extends AbstractPropertyEditHelpe public boolean approveRequest(IEditCommandRequest request) { boolean isApproved = super.approveRequest(request); - if((request != null) && (request instanceof GetEditContextRequest)) { + if ((request != null) && (request instanceof GetEditContextRequest)) { // Retrieve the edit context from request - GetEditContextRequest editContextRequest = (GetEditContextRequest)request; + GetEditContextRequest editContextRequest = (GetEditContextRequest) request; // Test if the edit context is a Block - if(editContextRequest.getEditContext() instanceof Element) { - Element contextElement = (Element)editContextRequest.getEditContext(); + if (editContextRequest.getEditContext() instanceof Element) { + Element contextElement = (Element) editContextRequest.getEditContext(); IElementMatcher matcher = new BlockMatcher(); - if(!matcher.matches(contextElement)) { + if (!matcher.matches(contextElement)) { isApproved = false; } } @@ -81,9 +81,10 @@ public class ReferencePropertyEditHelperAdvice extends AbstractPropertyEditHelpe return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Property element = (Property)request.getElementToConfigure(); - if(element != null) { + Property element = (Property) request.getElementToConfigure(); + if (element != null) { // Set default name String initializedName = NamedElementHelper.getDefaultNameWithIncrementFromBase("reference", element.eContainer().eContents()); @@ -105,13 +106,14 @@ public class ReferencePropertyEditHelperAdvice extends AbstractPropertyEditHelpe return new ConfigureElementCommand(request) { + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - Property sourcePart = (Property)request.getElementToConfigure(); - if((sourcePart != null) && (sourcePart.getType() != null)) { + Property sourcePart = (Property) request.getElementToConfigure(); + if ((sourcePart != null) && (sourcePart.getType() != null)) { // Create association between element owner and element type Type sourceType = sourcePart.getClass_(); - //Type targetType = sourcePart.getType(); + // Type targetType = sourcePart.getType(); Package associationContainer = sourceType.getNearestPackage(); // Create targetProperty @@ -143,14 +145,14 @@ public class ReferencePropertyEditHelperAdvice extends AbstractPropertyEditHelpe @Override protected Property getDuplicatedProperty(DuplicateElementsRequest request) { List<Object> elementsToBeDuplicated = request.getElementsToBeDuplicated(); - if(elementsToBeDuplicated == null || elementsToBeDuplicated.isEmpty()) { + if (elementsToBeDuplicated == null || elementsToBeDuplicated.isEmpty()) { return null; } Object firstElement = elementsToBeDuplicated.get(0); // there should be only one element here - if(!(firstElement instanceof Property)) { + if (!(firstElement instanceof Property)) { return null; } ReferencePropertyMatcher matcher = new ReferencePropertyMatcher(); - return matcher.matches((Property)firstElement) ? (Property)firstElement : null; + return matcher.matches((Property) firstElement) ? (Property) firstElement : null; } } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/RequirementEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/RequirementEditHelperAdvice.java index 8f3a88c2a08..27d9ce83dfa 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/RequirementEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/RequirementEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -41,9 +41,9 @@ public class RequirementEditHelperAdvice extends AbstractStereotypedElementEditH /**
* Check if the creation context is allowed.
- *
+ *
* @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
- *
+ *
* @param request
* @return true if the request is approved
*/
@@ -51,20 +51,20 @@ public class RequirementEditHelperAdvice extends AbstractStereotypedElementEditH public boolean approveRequest(IEditCommandRequest request) {
boolean isApproved = super.approveRequest(request);
- if((request != null) && (request instanceof GetEditContextRequest)) {
+ if ((request != null) && (request instanceof GetEditContextRequest)) {
// Retrieve the edit context from request
- GetEditContextRequest editContextRequest = (GetEditContextRequest)request;
+ GetEditContextRequest editContextRequest = (GetEditContextRequest) request;
// Test context type
- if(editContextRequest.getEditContext() instanceof Element) {
- Element contextElement = (Element)editContextRequest.getEditContext();
+ if (editContextRequest.getEditContext() instanceof Element) {
+ Element contextElement = (Element) editContextRequest.getEditContext();
IElementMatcher matcher;
// Cannot create a nested requirement in FlowSpecification
matcher = new FlowSpecificationMatcher();
- if(matcher.matches(contextElement)) {
+ if (matcher.matches(contextElement)) {
isApproved = false;
}
}
@@ -79,9 +79,10 @@ public class RequirementEditHelperAdvice extends AbstractStereotypedElementEditH return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- NamedElement element = (NamedElement)request.getElementToConfigure();
- if(element != null) {
+ NamedElement element = (NamedElement) request.getElementToConfigure();
+ if (element != null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(element, RequirementsPackage.eINSTANCE.getRequirement());
// Set default name
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/SatisfyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/SatisfyEditHelperAdvice.java index 455e60ef1ff..ff0ffb82ed6 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/SatisfyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/SatisfyEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -41,9 +41,10 @@ public class SatisfyEditHelperAdvice extends AbstractStereotypedElementEditHelpe return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- NamedElement element = (NamedElement)request.getElementToConfigure();
- if(element != null) {
+ NamedElement element = (NamedElement) request.getElementToConfigure();
+ if (element != null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(element, RequirementsPackage.eINSTANCE.getSatisfy());
// Set default name
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/UnitEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/UnitEditHelperAdvice.java index 313f9fd9186..0042fa06b2d 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/UnitEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/UnitEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -38,9 +38,10 @@ public class UnitEditHelperAdvice extends AbstractStereotypedElementEditHelperAd return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- NamedElement element = (NamedElement)request.getElementToConfigure();
- if(element != null) {
+ NamedElement element = (NamedElement) request.getElementToConfigure();
+ if (element != null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(element, BlocksPackage.eINSTANCE.getUnit());
// Set default name
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ValuePropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ValuePropertyEditHelperAdvice.java index 1906a6431f7..257af7fdc6c 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ValuePropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ValuePropertyEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -36,9 +36,9 @@ public class ValuePropertyEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Check if the creation context is a {@link Block}.
- *
+ *
* @see org.eclipse.papyrus.sysml.service.types.helper.AbstractStereotypedElementEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
- *
+ *
* @param request
* @return true if the request is approved
*/
@@ -46,17 +46,17 @@ public class ValuePropertyEditHelperAdvice extends AbstractEditHelperAdvice { public boolean approveRequest(IEditCommandRequest request) {
boolean isApproved = super.approveRequest(request);
- if((request != null) && (request instanceof GetEditContextRequest)) {
+ if ((request != null) && (request instanceof GetEditContextRequest)) {
// Retrieve the edit context from request
- GetEditContextRequest editContextRequest = (GetEditContextRequest)request;
+ GetEditContextRequest editContextRequest = (GetEditContextRequest) request;
// Test if the edit context is a Block
- if(editContextRequest.getEditContext() instanceof Element) {
- Element contextElement = (Element)editContextRequest.getEditContext();
+ if (editContextRequest.getEditContext() instanceof Element) {
+ Element contextElement = (Element) editContextRequest.getEditContext();
IElementMatcher matcher = new BlockMatcher();
- if(!matcher.matches(contextElement)) {
+ if (!matcher.matches(contextElement)) {
isApproved = false;
}
}
@@ -71,9 +71,10 @@ public class ValuePropertyEditHelperAdvice extends AbstractEditHelperAdvice { return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- Property element = (Property)request.getElementToConfigure();
- if(element != null) {
+ Property element = (Property) request.getElementToConfigure();
+ if (element != null) {
// Set default name
String initializedName = NamedElementHelper.getDefaultNameWithIncrementFromBase("value", element.eContainer().eContents());
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ValueTypeEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ValueTypeEditHelperAdvice.java index 9debed1f5d6..2105d0ded29 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ValueTypeEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ValueTypeEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -38,9 +38,10 @@ public class ValueTypeEditHelperAdvice extends AbstractStereotypedElementEditHel return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- NamedElement element = (NamedElement)request.getElementToConfigure();
- if(element != null) {
+ NamedElement element = (NamedElement) request.getElementToConfigure();
+ if (element != null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(element, BlocksPackage.eINSTANCE.getValueType());
// Set default name
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/VerifyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/VerifyEditHelperAdvice.java index 8cb2f15efdf..ea146ac64d8 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/VerifyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/VerifyEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -41,9 +41,10 @@ public class VerifyEditHelperAdvice extends AbstractStereotypedElementEditHelper return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- NamedElement element = (NamedElement)request.getElementToConfigure();
- if(element != null) {
+ NamedElement element = (NamedElement) request.getElementToConfigure();
+ if (element != null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(element, RequirementsPackage.eINSTANCE.getVerify());
// Set default name
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ViewEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ViewEditHelperAdvice.java index d9ce3818013..1bfeb9fa5bf 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ViewEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ViewEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -39,9 +39,10 @@ public class ViewEditHelperAdvice extends AbstractStereotypedElementEditHelperAd return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- NamedElement element = (NamedElement)request.getElementToConfigure();
- if(element != null) {
+ NamedElement element = (NamedElement) request.getElementToConfigure();
+ if (element != null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(element, ModelelementsPackage.eINSTANCE.getView());
// Set default name
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ViewPointEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ViewPointEditHelperAdvice.java index bd83a71bdf2..19bf9f213fa 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ViewPointEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ViewPointEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -38,9 +38,10 @@ public class ViewPointEditHelperAdvice extends AbstractStereotypedElementEditHel return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
- NamedElement element = (NamedElement)request.getElementToConfigure();
- if(element != null) {
+ NamedElement element = (NamedElement) request.getElementToConfigure();
+ if (element != null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(element, ModelelementsPackage.eINSTANCE.getViewPoint());
// Set default name
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ActorEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ActorEditHelperAdvice.java index 219363b33e4..8e8733a3543 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ActorEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ActorEditHelperAdvice.java @@ -1,6 +1,6 @@ /*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* 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
@@ -32,18 +32,18 @@ public class ActorEditHelperAdvice extends AbstractEditHelperAdvice { /**
* {@inheritDoc}
- *
+ *
* In case of {@link Association} creation, it should not be possible to have an {@link Actor} as source.
*/
@Override
protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) {
IElementType type = request.getElementType();
- if(SysMLElementTypes.ASSOCIATION.equals(type)) {
+ if (SysMLElementTypes.ASSOCIATION.equals(type)) {
return UnexecutableCommand.INSTANCE;
}
- if(type != null) {
+ if (type != null) {
List<IElementType> superTypes = Arrays.asList(type.getAllSuperTypes());
- if(superTypes.contains(SysMLElementTypes.ASSOCIATION)) {
+ if (superTypes.contains(SysMLElementTypes.ASSOCIATION)) {
return UnexecutableCommand.INSTANCE;
}
@@ -52,16 +52,16 @@ public class ActorEditHelperAdvice extends AbstractEditHelperAdvice { }
protected boolean hasSuperType(IElementType elementType, IElementType typeToTest) {
- if(elementType == null || typeToTest == null) {
+ if (elementType == null || typeToTest == null) {
return false;
}
- if(elementType.equals(typeToTest)) {
+ if (elementType.equals(typeToTest)) {
return true;
}
List<IElementType> superTypes = Arrays.asList(elementType.getAllSuperTypes());
- if(superTypes.contains(typeToTest)) {
+ if (superTypes.contains(typeToTest)) {
return true;
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeDirectedEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeDirectedEditHelperAdvice.java index 6fb4e8e68c3..919a6aae8cd 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeDirectedEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeDirectedEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2011 CEA LIST.
*
- *
+ *
* 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
@@ -15,7 +15,7 @@ import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
-/**
+/**
* Edit helper advice for {@link Association} with "aggregation = composition" (used for creation purpose only).
*/
public class AssociationCompositeDirectedEditHelperAdvice extends AssociationCompositeEditHelperAdvice {
@@ -24,11 +24,11 @@ public class AssociationCompositeDirectedEditHelperAdvice extends AssociationCom * <pre>
* {@inheritDoc}
*
- * The currently created {@link Association} is Composite (manage by super class), and directed
+ * The currently created {@link Association} is Composite (manage by super class), and directed
* (meaning navigable in one direction only) which in SysML means the target end is owned by the association itself.
*
- * Moreover this end name should not be set in that case, this latter rule is not followed here for now.
- *
+ * Moreover this end name should not be set in that case, this latter rule is not followed here for now.
+ *
* </pre>
*/
@Override
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeEditHelperAdvice.java index ae723f7dd76..fe0e7c96833 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationCompositeEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2011 CEA LIST.
*
- *
+ *
* 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
@@ -14,8 +14,8 @@ import org.eclipse.uml2.uml.Association; import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Property;
-/**
- * Edit helper advice for {@link Association} with "aggregation = composition" and navigable in one way (used for creation purpose only).
+/**
+ * Edit helper advice for {@link Association} with "aggregation = composition" and navigable in one way (used for creation purpose only).
*/
public class AssociationCompositeEditHelperAdvice extends AssociationNoneEditHelperAdvice {
@@ -24,7 +24,7 @@ public class AssociationCompositeEditHelperAdvice extends AssociationNoneEditHel * {@inheritDoc}
*
* The currently created {@link Association} is Composite (manage by super class):
- * it source {@link Property} aggregation is set to Composite kind.
+ * it source {@link Property} aggregation is set to Composite kind.
*
* The currently created {@link Association} is bidirectional (navigable in both directions):
* it source and target {@link Property} are owned by the {@link Classifier} (target and source end types),
@@ -32,7 +32,7 @@ public class AssociationCompositeEditHelperAdvice extends AssociationNoneEditHel * </pre>
*/
@Override
- protected void configureSourceProperty(Property sourceProperty) {
+ protected void configureSourceProperty(Property sourceProperty) {
sourceProperty.setIsComposite(true);
}
}
\ No newline at end of file diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java index 1e37c5367db..23526ad4c1c 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationEditHelperAdvice.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -40,6 +40,7 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
@@ -60,18 +61,18 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { * {@inheritDoc}
*
* avoid creation of association on another association
- *
+ *
* </pre>
*/
@Override
protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) {
IElementType type = request.getElementType();
- if(SysMLElementTypes.ASSOCIATION.equals(type)) {
+ if (SysMLElementTypes.ASSOCIATION.equals(type)) {
return UnexecutableCommand.INSTANCE;
}
- if(type != null) {
+ if (type != null) {
List<IElementType> superTypes = Arrays.asList(type.getAllSuperTypes());
- if(superTypes.contains(SysMLElementTypes.ASSOCIATION)) {
+ if (superTypes.contains(SysMLElementTypes.ASSOCIATION)) {
return UnexecutableCommand.INSTANCE;
}
@@ -85,24 +86,24 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { * {@inheritDoc}
*
* Add a command to destroy {@link Association} when only 1 end remains.
- *
+ *
* </pre>
*/
@Override
protected ICommand getBeforeDestroyReferenceCommand(DestroyReferenceRequest request) {
ICommand gmfCommand = super.getBeforeDestroyReferenceCommand(request);
- Association association = (Association)request.getContainer();
- if((request.getContainingFeature() == UMLPackage.eINSTANCE.getAssociation_MemberEnd()) && (association.getMemberEnds().contains(request.getReferencedObject()))) {
+ Association association = (Association) request.getContainer();
+ if ((request.getContainingFeature() == UMLPackage.eINSTANCE.getAssociation_MemberEnd()) && (association.getMemberEnds().contains(request.getReferencedObject()))) {
Set<Property> ends = new HashSet<Property>();
ends.addAll(association.getMemberEnds());
ends.remove(request.getReferencedObject());
- if(ends.size() <= 2) {
+ if (ends.size() <= 2) {
DestroyElementRequest destroyRequest = new DestroyElementRequest(association, false);
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(association);
- if(provider != null) {
+ if (provider != null) {
ICommand destroyCommand = provider.getEditCommand(destroyRequest);
gmfCommand = CompositeCommand.compose(gmfCommand, destroyCommand);
}
@@ -118,16 +119,17 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { * {@inheritDoc}
*
* Add SysML Nature on the {@link Association}.
- *
+ *
* </pre>
*/
@Override
protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
- final Association association = (Association)request.getElementToConfigure();
+ final Association association = (Association) request.getElementToConfigure();
return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
// Add SysML Nature on the new Association
@@ -142,9 +144,9 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { * <pre>
* {@inheritDoc}
*
- * Add a command to destroy {@link Association} ends referenced by the {@link Association}
+ * Add a command to destroy {@link Association} ends referenced by the {@link Association}
* to delete.
- *
+ *
* </pre>
*/
@Override
@@ -153,15 +155,15 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { List<EObject> dependentsToKeep = (RequestParameterUtils.getDependentsToKeep(req) != null) ? RequestParameterUtils.getDependentsToKeep(req) : new ArrayList<EObject>();
- Association association = (Association)req.getElementToDestroy();
- for(Property end : association.getMemberEnds()) {
+ Association association = (Association) req.getElementToDestroy();
+ for (Property end : association.getMemberEnds()) {
if (!dependentsToKeep.contains(end)) {
dependentsToDestroy.add(end);
}
}
- // Return command to destroy dependents ends
- if(!dependentsToDestroy.isEmpty()) {
+ // Return command to destroy dependents ends
+ if (!dependentsToDestroy.isEmpty()) {
return req.getDestroyDependentsCommand(dependentsToDestroy);
}
@@ -173,7 +175,7 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { * {@inheritDoc}
*
* Add a command to related association end during re-orient.
- *
+ *
* </pre>
*/
@Override
@@ -185,19 +187,19 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { SetRequest setTypeRequest = null;
// Retrieve re-oriented association and add it to the list of re-factored elements
- Association association = (Association)request.getRelationship();
+ Association association = (Association) request.getRelationship();
List<EObject> currentlyRefactoredElements = (RequestParameterUtils.getAssociationRefactoredElements(request) != null) ? RequestParameterUtils.getAssociationRefactoredElements(request) : new ArrayList<EObject>();
- if(currentlyRefactoredElements.contains(association)) {
- // Abort - already treated
+ if (currentlyRefactoredElements.contains(association)) {
+ // Abort - already treated
return null;
} else {
RequestParameterUtils.addAssociationRefactoredElement(request, association);
}
- // not possible to have an association on another association, so reorient is forbidden here
- if(request.getNewRelationshipEnd() instanceof Association) {
+ // not possible to have an association on another association, so reorient is forbidden here
+ if (request.getNewRelationshipEnd() instanceof Association) {
return UnexecutableCommand.INSTANCE;
}
@@ -208,8 +210,8 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { EObject modifiedPropertyType = null;
- if(request.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) {
- if(!association.getOwnedEnds().contains(semanticSource)) {
+ if (request.getDirection() == ReorientRequest.REORIENT_SOURCE) {
+ if (!association.getOwnedEnds().contains(semanticSource)) {
moveRequest = new MoveRequest(request.getNewRelationshipEnd(), semanticSource);
}
@@ -217,8 +219,8 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { setTypeRequest = new SetRequest(modifiedPropertyType, UMLPackage.eINSTANCE.getTypedElement_Type(), request.getNewRelationshipEnd());
}
- if(request.getDirection() == ReorientRelationshipRequest.REORIENT_TARGET) {
- if(!association.getOwnedEnds().contains(semanticTarget)) {
+ if (request.getDirection() == ReorientRequest.REORIENT_TARGET) {
+ if (!association.getOwnedEnds().contains(semanticTarget)) {
moveRequest = new MoveRequest(request.getNewRelationshipEnd(), semanticTarget);
}
@@ -226,22 +228,22 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { setTypeRequest = new SetRequest(modifiedPropertyType, UMLPackage.eINSTANCE.getTypedElement_Type(), request.getNewRelationshipEnd());
}
- if(moveRequest != null) {
+ if (moveRequest != null) {
// Propagate parameters to the move request
moveRequest.addParameters(request.getParameters());
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(request.getNewRelationshipEnd());
- if(provider != null) {
+ if (provider != null) {
ICommand moveCommand = provider.getEditCommand(moveRequest);
gmfCommand = CompositeCommand.compose(gmfCommand, moveCommand);
}
}
- if(setTypeRequest != null) {
+ if (setTypeRequest != null) {
// Propagate parameters to the set request
setTypeRequest.addParameters(request.getParameters());
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(modifiedPropertyType);
- if(provider != null) {
+ if (provider != null) {
ICommand setTypeCommand = provider.getEditCommand(setTypeRequest);
gmfCommand = CompositeCommand.compose(gmfCommand, setTypeCommand);
}
@@ -251,8 +253,8 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { Set<View> viewsToDestroy = new HashSet<View>();
viewsToDestroy.addAll(getViewsToDestroy(association, request));
- //return the command to destroy all these views
- if(!viewsToDestroy.isEmpty()) {
+ // return the command to destroy all these views
+ if (!viewsToDestroy.isEmpty()) {
DestroyDependentsRequest ddr = new DestroyDependentsRequest(request.getEditingDomain(), request.getRelationship(), false);
ddr.setClientContext(request.getClientContext());
ddr.addParameters(request.getParameters());
@@ -260,7 +262,7 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { gmfCommand = CompositeCommand.compose(gmfCommand, destroyViewsCommand);
}
- if(gmfCommand != null) {
+ if (gmfCommand != null) {
gmfCommand.reduce();
}
return gmfCommand;
@@ -268,18 +270,18 @@ public class AssociationEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Returns all views referencing Association except the view currently re-oriented.
- *
+ *
* @param association
- * the association referenced by views
+ * the association referenced by views
* @param request
- * the re-orient relationship request
+ * the re-orient relationship request
* @return the list of views to be destroy
*/
private Set<View> getViewsToDestroy(Association association, ReorientRelationshipRequest request) {
Set<View> viewsToDestroy = new HashSet<View>();
// Find all views representing the Associations
- EReference[] refs = new EReference[]{ NotationPackage.eINSTANCE.getView_Element() };
+ EReference[] refs = new EReference[] { NotationPackage.eINSTANCE.getView_Element() };
@SuppressWarnings("unchecked")
Collection<View> associationViews = EMFCoreUtil.getReferencers(association, refs);
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneDirectedEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneDirectedEditHelperAdvice.java index e9cd6d98115..cb9156b1175 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneDirectedEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneDirectedEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2011 CEA LIST.
*
- *
+ *
* 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
@@ -15,8 +15,8 @@ import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
-/**
- * Edit helper advice for {@link Association} with "aggregation = none" and navigable in one way (used for creation purpose only).
+/**
+ * Edit helper advice for {@link Association} with "aggregation = none" and navigable in one way (used for creation purpose only).
*/
public class AssociationNoneDirectedEditHelperAdvice extends AssociationNoneEditHelperAdvice {
@@ -24,11 +24,11 @@ public class AssociationNoneDirectedEditHelperAdvice extends AssociationNoneEdit * <pre>
* {@inheritDoc}
*
- * The currently created {@link Association} in the default case (aggregation = none), and directed
+ * The currently created {@link Association} in the default case (aggregation = none), and directed
* (meaning navigable in one direction only) which in SysML means the target end is owned by the association itself.
*
- * Moreover this end name should not be set in that case, this latter rule is not followed here for now.
- *
+ * Moreover this end name should not be set in that case, this latter rule is not followed here for now.
+ *
* </pre>
*/
@Override
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java index 2b9587b3122..7052dda10d2 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationNoneEditHelperAdvice.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -46,14 +46,14 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice /**
* This method provides the source type provided as {@link ConfigureRequest} parameter.
- *
+ *
* @return the target role
*/
protected Classifier getSourceOwnerType(ConfigureRequest req) {
Classifier result = null;
Object paramObject = req.getParameter(CreateRelationshipRequest.SOURCE);
- if(paramObject instanceof Classifier) {
- result = (Classifier)paramObject;
+ if (paramObject instanceof Classifier) {
+ result = (Classifier) paramObject;
}
return result;
@@ -61,14 +61,14 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice /**
* This method provides the target type provided as {@link ConfigureRequest} parameter.
- *
+ *
* @return the target role
*/
protected Classifier getTargetOwnerType(ConfigureRequest req) {
Classifier result = null;
Object paramObject = req.getParameter(CreateRelationshipRequest.TARGET);
- if(paramObject instanceof Classifier) {
- result = (Classifier)paramObject;
+ if (paramObject instanceof Classifier) {
+ result = (Classifier) paramObject;
}
return result;
@@ -76,30 +76,32 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice /**
* Creates a new {@link Property} from the propertyType in the propertyContainer
- *
+ *
* @param propertyContainer
- * the container of the {@link Property}
+ * the container of the {@link Property}
* @param propertyType
- * the type of the {@link Property}
+ * the type of the {@link Property}
* @return the new {@link Property}
- * @throws ExecutionException
- */
- protected Property createTargetProperty(Property targetProperty, Classifier propertyContainer, Type propertyType, Association association, TransactionalEditingDomain editingDomain, IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ * @throws ExecutionException
+ */
+ protected Property createTargetProperty(Property targetProperty, Classifier propertyContainer, Type propertyType, Association association, TransactionalEditingDomain editingDomain, IProgressMonitor progressMonitor, IAdaptable info)
+ throws ExecutionException {
setPropertyType(targetProperty, propertyType, editingDomain, progressMonitor, info);
setPropertyName(targetProperty);
return targetProperty;
}
-
- protected Property createSourceProperty(Property sourceProperty, Classifier propertyContainer, Type propertyType, Association association, TransactionalEditingDomain editingDomain, IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+
+ protected Property createSourceProperty(Property sourceProperty, Classifier propertyContainer, Type propertyType, Association association, TransactionalEditingDomain editingDomain, IProgressMonitor progressMonitor, IAdaptable info)
+ throws ExecutionException {
setPropertyType(sourceProperty, propertyType, editingDomain, progressMonitor, info);
setPropertyName(sourceProperty);
return sourceProperty;
}
-
+
protected void setPropertyType(Property property, Type propertyType, TransactionalEditingDomain editingDomain, IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
// Set type using all AdviceHelper (use ServiceEdit instead of manually set)
SetRequest request = new SetRequest(property, UMLPackage.eINSTANCE.getTypedElement_Type(), propertyType);
- request.setEditingDomain(editingDomain);
+ request.setEditingDomain(editingDomain);
IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(property);
ICommand editCommand = commandProvider.getEditCommand(request);
editCommand.execute(progressMonitor, info);
@@ -109,7 +111,7 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice String baseName = property.getType().getName().toLowerCase();
Element owner = property.getOwner();
if (owner instanceof Classifier) {
- List<Property> ownedAttributes = ClassifierUtils.getOwnedAttributes((Classifier)owner);
+ List<Property> ownedAttributes = ClassifierUtils.getOwnedAttributes((Classifier) owner);
String defaultNameWithIncrementFromBase = NamedElementHelper.getDefaultNameWithIncrementFromBase(
property.getType().getName().toLowerCase(), ownedAttributes, "_");
property.setName(defaultNameWithIncrementFromBase);
@@ -122,17 +124,19 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice /**
* This method has to be specialized by subclasses (AggregationKind)
+ *
* @param sourceProperty
- * The property to configure
+ * The property to configure
*/
- protected void configureSourceProperty(Property sourceProperty) {
+ protected void configureSourceProperty(Property sourceProperty) {
// do nothing
}
/**
* This method has to be specialized by subclasses (AggregationKind)
+ *
* @param sourceProperty
- * The property to configure
+ * The property to configure
*/
protected void configureTargetProperty(Property targetProperty) {
// do nothing
@@ -140,42 +144,42 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice /**
* This method has to be specialized by subclasses (owner)
- *
+ *
* @param sourceEnd
- * the semantic end
+ * the semantic end
* @param owner
- * the end container
+ * the end container
* @param targetType
- * the target type
+ * the target type
* @param association
- * the association
+ * the association
* @throws UnsupportedOperationException
*/
protected void addSourceInModel(final Property sourceEnd, Classifier owner, Type targetType, Association association) throws UnsupportedOperationException {
// set the container in order to allow Stereotype appliance
- boolean added = ClassifierUtils.addOwnedAttribute(owner, sourceEnd);
- if(!added) {
+ boolean added = ClassifierUtils.addOwnedAttribute(owner, sourceEnd);
+ if (!added) {
throw new UnsupportedOperationException("Cannot add a Property on Classifier " + owner.getQualifiedName());
}
}
/**
* This method has to be specialized by subclasses (owner)
- *
+ *
* @param targetEnd
- * the semantic end
+ * the semantic end
* @param owner
- * the end container
+ * the end container
* @param sourceType
- * the source type
+ * the source type
* @param association
- * the association
+ * the association
* @throws UnsupportedOperationException
*/
protected void addTargetInModel(Property targetEnd, Classifier owner, Type sourceType, Association association) {
// set the container in order to allow Stereotype appliance
- boolean added = ClassifierUtils.addOwnedAttribute(owner, targetEnd);
- if(!added) {
+ boolean added = ClassifierUtils.addOwnedAttribute(owner, targetEnd);
+ if (!added) {
throw new UnsupportedOperationException("Cannot add a Property on Classifier " + owner.getQualifiedName());
}
}
@@ -185,22 +189,23 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice * {@inheritDoc}
*
* Complete the {@link Association} creation by setting its ends.
- *
+ *
* </pre>
*/
@Override
protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
- final Association association = (Association)request.getElementToConfigure();
+ final Association association = (Association) request.getElementToConfigure();
final Classifier sourceType = getSourceOwnerType(request);
final Classifier targetType = getTargetOwnerType(request);
- if((sourceType == null) || (targetType == null)) {
+ if ((sourceType == null) || (targetType == null)) {
return UnexecutableCommand.INSTANCE;
}
return new ConfigureElementCommand(request) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
try {
@@ -220,7 +225,7 @@ public class AssociationNoneEditHelperAdvice extends AssociationEditHelperAdvice configureSourceProperty(targetProperty);
createSourceProperty(sourceProperty, targetType, sourceType, association, request.getEditingDomain(), progressMonitor, info);
configureTargetProperty(sourceProperty);
-
+
} catch (Exception e) {
Activator.log.error(e);
return CommandResult.newCancelledCommandResult();
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedDirectedEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedDirectedEditHelperAdvice.java index b2a121d4ee9..9daeee609f3 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedDirectedEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedDirectedEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2011 CEA LIST.
*
- *
+ *
* 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
@@ -15,7 +15,7 @@ import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
-/**
+/**
* Edit helper advice for {@link Association} with "aggregation = shared" and navigable in one way (used for creation purpose only).
*/
public class AssociationSharedDirectedEditHelperAdvice extends AssociationSharedEditHelperAdvice {
@@ -24,11 +24,11 @@ public class AssociationSharedDirectedEditHelperAdvice extends AssociationShared * <pre>
* {@inheritDoc}
*
- * The currently created {@link Association} is Shared (manage by super class), and directed
+ * The currently created {@link Association} is Shared (manage by super class), and directed
* (meaning navigable in one direction only) which in SysML means the target end is owned by the association itself.
*
- * Moreover this end name should not be set in that case, this latter rule is not followed here for now.
- *
+ * Moreover this end name should not be set in that case, this latter rule is not followed here for now.
+ *
* </pre>
*/
@Override
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedEditHelperAdvice.java index 76afbbc68cf..af22069ebdd 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/AssociationSharedEditHelperAdvice.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2011 CEA LIST.
*
- *
+ *
* 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
@@ -15,7 +15,7 @@ import org.eclipse.uml2.uml.Association; import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Property;
-/**
+/**
* Edit helper advice for {@link Association} with "aggregation = shared" (used for creation purpose only).
*/
public class AssociationSharedEditHelperAdvice extends AssociationNoneEditHelperAdvice {
@@ -25,7 +25,7 @@ public class AssociationSharedEditHelperAdvice extends AssociationNoneEditHelper * {@inheritDoc}
*
* The currently created {@link Association} is Shared (manage by super class):
- * it source {@link Property} aggregation is set to Shared kind.
+ * it source {@link Property} aggregation is set to Shared kind.
*
* The currently created {@link Association} is bidirectional (navigable in both directions):
* it source and target {@link Property} are owned by the {@link Classifier} (target and source end types),
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/BlockConnectorEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/BlockConnectorEditHelperAdvice.java index 90237b7c6cd..75017f0163a 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/BlockConnectorEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/BlockConnectorEditHelperAdvice.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * + * * CEA LIST - Initial API and implementation * *****************************************************************************/ @@ -34,7 +34,7 @@ import org.eclipse.uml2.uml.Property; /** * <pre> - * This HelperAdvice completes {@link Block} edit commands with SysML + * This HelperAdvice completes {@link Block} edit commands with SysML * specific {@link Connector} related actions: * - Block::isEncapsulated management * - NestedPropertyEnd management @@ -43,67 +43,67 @@ import org.eclipse.uml2.uml.Property; public class BlockConnectorEditHelperAdvice extends AbstractEditHelperAdvice { private ConnectorUtils utils = new ConnectorUtils(); - + @Override protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) { - + EObject source = request.getSource(); EObject target = request.getTarget(); View sourceView = RequestParameterUtils.getSourceView(request); View targetView = RequestParameterUtils.getTargetView(request); // Restrict this advice action to the end of Connector creation gesture (before clicking on target) - // in order to add SysML specific constraint - if((request.getElementType() == UMLElementTypes.CONNECTOR) - && (request.getSource() != null) && (request.getTarget() != null) && (request.getContainer() != null)) { - + // in order to add SysML specific constraint + if ((request.getElementType() == UMLElementTypes.CONNECTOR) + && (request.getSource() != null) && (request.getTarget() != null) && (request.getContainer() != null)) { + // Restrict action to SysML Connector (meaning owned by Block) - if(((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(request.getContainer())) { + if (((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches(request.getContainer())) { - // If the source or target view is enclosed in a structure encapsulated view, forbid creation. - if(utils.isCrossingEncapsulation(sourceView, targetView) - || utils.isCrossingEncapsulation(targetView, sourceView)) { + // If the source or target view is enclosed in a structure encapsulated view, forbid creation. + if (utils.isCrossingEncapsulation(sourceView, targetView) + || utils.isCrossingEncapsulation(targetView, sourceView)) { return UnexecutableCommand.INSTANCE; } if (ConnectorUtils.canCreate(source, target, sourceView, targetView)) { - request.setParameter( org.eclipse.papyrus.uml.service.types.utils.RequestParameterConstants.UML_STRICT, false); + request.setParameter(org.eclipse.papyrus.uml.service.types.utils.RequestParameterConstants.UML_STRICT, false); } } } - + return super.getBeforeCreateRelationshipCommand(request); } - + @Override protected ICommand getAfterCreateRelationshipCommand(CreateRelationshipRequest request) { - + ICommand defaultCommand = super.getAfterCreateRelationshipCommand(request); - + View sourceView = RequestParameterUtils.getSourceView(request); View targetView = RequestParameterUtils.getTargetView(request); // Restrict this advice action to the end of Connector creation gesture (before clicking on target) - // in order to add SysML specific constraint - if((request.getElementType() == UMLElementTypes.CONNECTOR) - && (request.getSource() != null) && (request.getTarget() != null) && (request.getContainer() != null)) { - + // in order to add SysML specific constraint + if ((request.getElementType() == UMLElementTypes.CONNECTOR) + && (request.getSource() != null) && (request.getTarget() != null) && (request.getContainer() != null)) { + // Restrict action to SysML Connector (meaning owned by Block) - if(((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(request.getContainer())) { - + if (((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches(request.getContainer())) { + // Check if source view is nested - if(utils.isNestedConnectableElement(sourceView, targetView)){ + if (utils.isNestedConnectableElement(sourceView, targetView)) { List<Property> nestedPath = utils.getNestedPropertyPath(sourceView, targetView); - defaultCommand = CompositeCommand.compose(defaultCommand, new SetNestedPathCommand("Set connector nested source path", request.getNewElement(), request, nestedPath, SetNestedPathCommand.NESTED_SOURCE)); //$NON-NLS-0$ + defaultCommand = CompositeCommand.compose(defaultCommand, new SetNestedPathCommand("Set connector nested source path", request.getNewElement(), request, nestedPath, SetNestedPathCommand.NESTED_SOURCE)); } // Check if target view is nested - if(utils.isNestedConnectableElement(targetView, sourceView)){ + if (utils.isNestedConnectableElement(targetView, sourceView)) { List<Property> nestedPath = utils.getNestedPropertyPath(targetView, sourceView); - defaultCommand = CompositeCommand.compose(defaultCommand, new SetNestedPathCommand("Set connector nested source path", request.getNewElement(), request, nestedPath, SetNestedPathCommand.NESTED_TARGET)); //$NON-NLS-0$ + defaultCommand = CompositeCommand.compose(defaultCommand, new SetNestedPathCommand("Set connector nested source path", request.getNewElement(), request, nestedPath, SetNestedPathCommand.NESTED_TARGET)); } } } - + return defaultCommand; } } diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ClassifierEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ClassifierEditHelperAdvice.java index 0c873791d84..5bc74c8cdbb 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ClassifierEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ClassifierEditHelperAdvice.java @@ -1,13 +1,13 @@ /*****************************************************************************
* Copyright (c) 2011 CEA LIST.
- *
+ *
* 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:
- *
+ *
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
*
*****************************************************************************/
@@ -24,6 +24,7 @@ import org.eclipse.gmf.runtime.common.core.command.ICommand; import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
@@ -49,7 +50,7 @@ public class ClassifierEditHelperAdvice extends AbstractEditHelperAdvice { *
* While moving a {@link Property} to a Classifier:
* - add possibly required (sysML) association re-factor command when needed.
- *
+ *
* </pre>
*/
@Override
@@ -59,51 +60,52 @@ public class ClassifierEditHelperAdvice extends AbstractEditHelperAdvice { // Treat related associations that required a re-factor action
// Retrieve elements already under re-factor.
- List<EObject> currentlyRefactoredElements = (request.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS) != null) ? (List<EObject>)request.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS) : new ArrayList<EObject>();
+ List<EObject> currentlyRefactoredElements = (request.getParameter(org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS) != null) ? (List<EObject>) request
+ .getParameter(org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS) : new ArrayList<EObject>();
// Find Associations related to any moved Property
- for(Object movedObject : request.getElementsToMove().keySet()) {
+ for (Object movedObject : request.getElementsToMove().keySet()) {
// Select Property (excluding Port) in the list of moved elements
- if(!(movedObject instanceof Property) || (movedObject instanceof Port)) {
+ if (!(movedObject instanceof Property) || (movedObject instanceof Port)) {
continue;
}
- Property movedProperty = (Property)movedObject;
+ Property movedProperty = (Property) movedObject;
Association relatedAssociation = movedProperty.getAssociation();
// The moved property has to be related to a SysML association
- if((relatedAssociation == null) || !(ElementUtil.hasNature(relatedAssociation, SysMLElementTypes.SYSML_NATURE))) {
+ if ((relatedAssociation == null) || !(ElementUtil.hasNature(relatedAssociation, SysMLElementTypes.SYSML_NATURE))) {
continue;
}
// Make sure the target differs from current container
- if((movedProperty.eContainer() == request.getTargetContainer()) && (movedProperty.eContainingFeature() == request.getTargetFeature(movedProperty))) {
+ if ((movedProperty.eContainer() == request.getTargetContainer()) && (movedProperty.eContainingFeature() == request.getTargetFeature(movedProperty))) {
continue;
}
// Make sure the target differs from related association (this move does not imply a re-factor, but simply an ownership change of an association end)
- if((relatedAssociation == request.getTargetContainer()) && ((request.getTargetFeature(movedProperty) == null) || (UMLPackage.eINSTANCE.getAssociation_OwnedEnd() == request.getTargetFeature(movedProperty)))) {
- continue; // This is a SysML Property#isNavigable update which does not require an Association refactoring action
+ if ((relatedAssociation == request.getTargetContainer()) && ((request.getTargetFeature(movedProperty) == null) || (UMLPackage.eINSTANCE.getAssociation_OwnedEnd() == request.getTargetFeature(movedProperty)))) {
+ continue; // This is a SysML Property#isNavigable update which does not require an Association refactoring action
}
- if((getOppositeAssociationEnd(movedProperty).getType() == request.getTargetContainer())) {
- continue; // This is a SysML Property#isNavigable update which does not require an Association refactoring action
+ if ((getOppositeAssociationEnd(movedProperty).getType() == request.getTargetContainer())) {
+ continue; // This is a SysML Property#isNavigable update which does not require an Association refactoring action
}
// Moved element already under re-factor ?
- if(currentlyRefactoredElements.contains(movedObject) || currentlyRefactoredElements.contains(relatedAssociation)) {
+ if (currentlyRefactoredElements.contains(movedObject) || currentlyRefactoredElements.contains(relatedAssociation)) {
continue;
} else {
- currentlyRefactoredElements.add((EObject)movedObject);
- request.getParameters().put(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS, currentlyRefactoredElements);
+ currentlyRefactoredElements.add((EObject) movedObject);
+ request.getParameters().put(org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS, currentlyRefactoredElements);
}
ICommand refactorCommand = getAssociationRefactoringCommand(movedProperty, relatedAssociation, request);
gmfCommand = CompositeCommand.compose(gmfCommand, refactorCommand);
}
- if(gmfCommand != null) {
+ if (gmfCommand != null) {
gmfCommand = gmfCommand.reduce();
}
@@ -112,13 +114,13 @@ public class ClassifierEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Create a re-factoring command related to a Property move.
- *
+ *
* @param movedProperty
- * the moved property
+ * the moved property
* @param associationToRefactor
- * the association to re-factor (re-orient action)
+ * the association to re-factor (re-orient action)
* @param request
- * the original move request
+ * the original move request
* @return the re-factoring command
*/
private ICommand getAssociationRefactoringCommand(Property movedProperty, Association associationToRefactor, MoveRequest request) {
@@ -126,16 +128,16 @@ public class ClassifierEditHelperAdvice extends AbstractEditHelperAdvice { Association relatedAssociation = movedProperty.getAssociation(); // Should not be null, test before calling method.
// Re-orient the related association (do not use edit service to avoid infinite loop here)
- int direction = ReorientRelationshipRequest.REORIENT_TARGET;
- if(movedProperty == associationToRefactor.getMemberEnds().get(0)) {
- direction = ReorientRelationshipRequest.REORIENT_SOURCE;
+ int direction = ReorientRequest.REORIENT_TARGET;
+ if (movedProperty == associationToRefactor.getMemberEnds().get(0)) {
+ direction = ReorientRequest.REORIENT_SOURCE;
}
ReorientRelationshipRequest reorientRequest = new ReorientRelationshipRequest(relatedAssociation, request.getTargetContainer(), movedProperty.eContainer(), direction);
reorientRequest.addParameters(request.getParameters());
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(relatedAssociation);
- if(provider != null) {
+ if (provider != null) {
return provider.getEditCommand(reorientRequest);
}
@@ -144,15 +146,15 @@ public class ClassifierEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Get the opposite end of an AssociationEnd (binary association assumed).
- *
+ *
* @param associationEnd
- * the association end
+ * the association end
* @return the opposite association end or null
*/
private Property getOppositeAssociationEnd(Property associationEnd) {
Property oppositeEnd = null;
- if(associationEnd.getAssociation() != null) {
+ if (associationEnd.getAssociation() != null) {
Association association = associationEnd.getAssociation();
Set<Property> ends = new HashSet<Property>();
ends.addAll(association.getMemberEnds());
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ConnectorEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ConnectorEditHelperAdvice.java index 14fd4fe1c5c..d737443989c 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ConnectorEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/ConnectorEditHelperAdvice.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -57,9 +57,9 @@ public class ConnectorEditHelperAdvice extends AbstractEditHelperAdvice { private ConnectorUtils utils = new ConnectorUtils();
/**
- *
+ *
* @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeReorientRelationshipCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest)
- *
+ *
* @param request
* @return
*/
@@ -67,44 +67,44 @@ public class ConnectorEditHelperAdvice extends AbstractEditHelperAdvice { protected ICommand getBeforeReorientRelationshipCommand(final ReorientRelationshipRequest request) {
final CompositeCommand compositeCommand = new CompositeCommand("Destroy Connector View Command");
- //the UML Connector Edit Helper Advice destroys connector views when roles changes
- //Here, we destroys connectors views, when the path changes
+ // the UML Connector Edit Helper Advice destroys connector views when roles changes
+ // Here, we destroys connectors views, when the path changes
final EObject editedElement = request.getRelationship();
- if(editedElement instanceof Connector) {
+ if (editedElement instanceof Connector) {
- if(applySysMLRules(((Connector)editedElement).getOwner())) {
- final Connector connector = (Connector)editedElement;
- //verify the path now
+ if (applySysMLRules(((Connector) editedElement).getOwner())) {
+ final Connector connector = (Connector) editedElement;
+ // verify the path now
int reorientDirection = request.getDirection();
Edge reorientedEdgeView = RequestParameterUtils.getReconnectedEdge(request);
View newEndView = RequestParameterUtils.getReconnectedEndView(request);
View oppositeEndView = null;
- if(reorientedEdgeView != null) {
- oppositeEndView = (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) ? reorientedEdgeView.getTarget() : reorientedEdgeView.getSource();
+ if (reorientedEdgeView != null) {
+ oppositeEndView = (reorientDirection == ReorientRequest.REORIENT_SOURCE) ? reorientedEdgeView.getTarget() : reorientedEdgeView.getSource();
}
List<Property> newNestedPath = null;
- if(reorientedEdgeView != null && newEndView != null) {
- //we are working with a 'graphical' reconnect request
+ if (reorientedEdgeView != null && newEndView != null) {
+ // we are working with a 'graphical' reconnect request
newNestedPath = utils.getNestedPropertyPath(newEndView, oppositeEndView);
} else {
- newNestedPath = (List<Property>)request.getParameter(ConnectorUtils.NESTED_CONNECTOR_END_PATH);
+ newNestedPath = (List<Property>) request.getParameter(ConnectorUtils.NESTED_CONNECTOR_END_PATH);
}
final Set<View> viewsToDestroy = utils.getViewsRepresentingConnector(connector);
final Iterator<View> iter = viewsToDestroy.iterator();
- while(iter.hasNext()) {
- final Edge current = (Edge)iter.next();
- if(current != reorientedEdgeView) {
+ while (iter.hasNext()) {
+ final Edge current = (Edge) iter.next();
+ if (current != reorientedEdgeView) {
View oldEndView = null;
- if(reorientDirection == ReorientReferenceRelationshipRequest.REORIENT_SOURCE) {
+ if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
oldEndView = current.getSource();
- } else if(reorientDirection == ReorientReferenceRelationshipRequest.REORIENT_TARGET) {
+ } else if (reorientDirection == ReorientRequest.REORIENT_TARGET) {
oldEndView = current.getTarget();
}
- if(oppositeEndView != null) {
+ if (oppositeEndView != null) {
final List<Property> oldNestedPath = utils.getNestedPropertyPath(oldEndView, oppositeEndView);
- if(!newNestedPath.equals(oldNestedPath)) {
+ if (!newNestedPath.equals(oldNestedPath)) {
final DestroyElementRequest destroyRequest = new DestroyElementRequest(request.getEditingDomain(), current, false);
final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(current);
compositeCommand.add(commandProvider.getEditCommand(destroyRequest));
@@ -112,7 +112,7 @@ public class ConnectorEditHelperAdvice extends AbstractEditHelperAdvice { }
}
}
- if(!compositeCommand.isEmpty()) {
+ if (!compositeCommand.isEmpty()) {
return compositeCommand;
}
}
@@ -121,9 +121,9 @@ public class ConnectorEditHelperAdvice extends AbstractEditHelperAdvice { }
/**
- *
+ *
* @param connectorOwner
- * the owner of the connector
+ * the owner of the connector
* @return
*/
protected boolean applySysMLRules(final Element connectorOwner) {
@@ -132,7 +132,7 @@ public class ConnectorEditHelperAdvice extends AbstractEditHelperAdvice { @Override
protected ICommand getAfterReorientRelationshipCommand(final ReorientRelationshipRequest request) {
- //we set the new value for the nested path
+ // we set the new value for the nested path
ICommand defaultCommand = super.getAfterReorientRelationshipCommand(request);
int reorientDirection = request.getDirection();
@@ -140,63 +140,63 @@ public class ConnectorEditHelperAdvice extends AbstractEditHelperAdvice { // Restrict this advice action to the end of Connector creation gesture (before clicking on target)
// in order to add SysML specific constraint
- Connector connector = (Connector)request.getRelationship();
- //get the direction
+ Connector connector = (Connector) request.getRelationship();
+ // get the direction
// Restrict action to SysML Connector (meaning owned by Block)
- if(((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(connector.eContainer())) {
+ if (((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches(connector.eContainer())) {
List<Property> tmpNestedPath = null;
Edge reorientedEdgeView = RequestParameterUtils.getReconnectedEdge(request);
View newEndView = RequestParameterUtils.getReconnectedEndView(request);
View oppositeEndView = null;
- //graphical case : verify encapsulation and get the new path
+ // graphical case : verify encapsulation and get the new path
StructuredClassifier newOwner;
- if(reorientedEdgeView != null) {
+ if (reorientedEdgeView != null) {
- oppositeEndView = (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) ? reorientedEdgeView.getTarget() : reorientedEdgeView.getSource();
+ oppositeEndView = (reorientDirection == ReorientRequest.REORIENT_SOURCE) ? reorientedEdgeView.getTarget() : reorientedEdgeView.getSource();
Assert.isNotNull(oppositeEndView);
Assert.isNotNull(newEndView);
- if(newEndView != null && oppositeEndView != null) {
+ if (newEndView != null && oppositeEndView != null) {
// If the source or target view is enclosed in a structure encapsulated view, forbid creation.
- if(utils.isCrossingEncapsulation(newEndView, oppositeEndView) || utils.isCrossingEncapsulation(oppositeEndView, newEndView)) {
+ if (utils.isCrossingEncapsulation(newEndView, oppositeEndView) || utils.isCrossingEncapsulation(oppositeEndView, newEndView)) {
return UnexecutableCommand.INSTANCE;
}
- // newOwner = utils.deduceContainer(newEndView, oppositeEndView);
+ // newOwner = utils.deduceContainer(newEndView, oppositeEndView);
tmpNestedPath = utils.getNestedPropertyPath(newEndView, oppositeEndView);
}
} else {
- //we are in the semantic case
- tmpNestedPath = ((List<Property>)request.getParameter(ConnectorUtils.NESTED_CONNECTOR_END_PATH));
+ // we are in the semantic case
+ tmpNestedPath = ((List<Property>) request.getParameter(ConnectorUtils.NESTED_CONNECTOR_END_PATH));
- //we need to verify encapsulation
- if(ConnectorUtils.isCrossingEncapuslation(tmpNestedPath)) {
+ // we need to verify encapsulation
+ if (ConnectorUtils.isCrossingEncapuslation(tmpNestedPath)) {
return UnexecutableCommand.INSTANCE;
}
}
final List<ConnectableElement> oppositeFullNestedPath = new ArrayList<ConnectableElement>();
final List<ConnectableElement> newFullNestedPath = new ArrayList<ConnectableElement>(tmpNestedPath);
- ConnectableElement newRole = (Property)request.getNewRelationshipEnd();
+ ConnectableElement newRole = (Property) request.getNewRelationshipEnd();
final ConnectorEnd oppositeEnd;
- if(reorientDirection == ReorientRequest.REORIENT_SOURCE) {
- oppositeEnd = ((Connector)request.getRelationship()).getEnds().get(1);
+ if (reorientDirection == ReorientRequest.REORIENT_SOURCE) {
+ oppositeEnd = ((Connector) request.getRelationship()).getEnds().get(1);
} else {
- oppositeEnd = ((Connector)request.getRelationship()).getEnds().get(0);
+ oppositeEnd = ((Connector) request.getRelationship()).getEnds().get(0);
}
final NestedConnectorEnd nestedConnectorEnd = UMLUtil.getStereotypeApplication(oppositeEnd, NestedConnectorEnd.class);
- if(nestedConnectorEnd != null) {
+ if (nestedConnectorEnd != null) {
oppositeFullNestedPath.addAll(nestedConnectorEnd.getPropertyPath());
}
oppositeFullNestedPath.add(oppositeEnd.getRole());
newFullNestedPath.add(newRole);
- //TODO : we should recalculate a new owner according to the new nested path, then update these nested path according to the new owner
- //we don't do it now, because we have some troubles with connector
- //final EncapsulatedClassifier newOwner = deduceNewConnectorOwner(oppositeFullNestedPath, newFullNestedPath);
-
- int tmpNestedPathDirection = (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) ? SetNestedPathCommand.NESTED_SOURCE : SetNestedPathCommand.NESTED_TARGET;
- defaultCommand = CompositeCommand.compose(defaultCommand, new SetNestedPathCommand("Set connector nested source path", request.getRelationship(), request, tmpNestedPath, tmpNestedPathDirection)); //$NON-NLS-0$
+ // TODO : we should recalculate a new owner according to the new nested path, then update these nested path according to the new owner
+ // we don't do it now, because we have some troubles with connector
+ // final EncapsulatedClassifier newOwner = deduceNewConnectorOwner(oppositeFullNestedPath, newFullNestedPath);
+
+ int tmpNestedPathDirection = (reorientDirection == ReorientRequest.REORIENT_SOURCE) ? SetNestedPathCommand.NESTED_SOURCE : SetNestedPathCommand.NESTED_TARGET;
+ defaultCommand = CompositeCommand.compose(defaultCommand, new SetNestedPathCommand("Set connector nested source path", request.getRelationship(), request, tmpNestedPath, tmpNestedPathDirection));
}
return defaultCommand;
@@ -204,53 +204,53 @@ public class ConnectorEditHelperAdvice extends AbstractEditHelperAdvice { - // /**
- // * @param fullNestedPathWithrole1
- // * @param fullNestedPathWithRole2
- // * @return
- // * the new owner for the connector
- // */
- //doesnt work currently
- // public static final EncapsulatedClassifier deduceNewConnectorOwner(final List<ConnectableElement> fullNestedPathWithrole1, final List<ConnectableElement> fullNestedPathWithRole2) {
- // final ConnectableElement firstElementPath = fullNestedPathWithrole1.get(0);
- // //case of encapsulation of the part
- // if(fullNestedPathWithRole2.get(0) == firstElementPath) {
- // if(fullNestedPathWithRole2.size() > 1) {
- // fullNestedPathWithrole1.remove(0);
- // fullNestedPathWithRole2.remove(0);
- // return deduceNewConnectorOwner(fullNestedPathWithrole1, fullNestedPathWithRole2);
- // } else {
- // return (EncapsulatedClassifier)firstElementPath.getOwner();
- // }
- // } else {
- // final ConnectableElement firstElementPath2 = fullNestedPathWithRole2.get(0);
- // if(firstElementPath.getOwner() == firstElementPath2.getOwner()) {
- // return (EncapsulatedClassifier)firstElementPath.getOwner();
- // } else {
- // final List<ConnectableElement> biggestList;
- // final List<ConnectableElement> smallestList;
- // if(fullNestedPathWithrole1.size() > fullNestedPathWithRole2.size()) {
- // biggestList = fullNestedPathWithrole1;
- // smallestList = fullNestedPathWithRole2;
- // } else {
- // biggestList = fullNestedPathWithRole2;
- // smallestList = fullNestedPathWithrole1;
- // }
- // for(int i = 0; i < biggestList.size(); i++) {
- // final ConnectableElement current = biggestList.get(i);
- // if(smallestList.contains(current) && i > 0) {
- // return (EncapsulatedClassifier)biggestList.get(i - 1).getOwner();
- // }
- // }
- // }
- // }
- // return null;
- // // throw new RuntimeException("error");
+ // /**
+ // * @param fullNestedPathWithrole1
+ // * @param fullNestedPathWithRole2
+ // * @return
+ // * the new owner for the connector
+ // */
+ // doesnt work currently
+ // public static final EncapsulatedClassifier deduceNewConnectorOwner(final List<ConnectableElement> fullNestedPathWithrole1, final List<ConnectableElement> fullNestedPathWithRole2) {
+ // final ConnectableElement firstElementPath = fullNestedPathWithrole1.get(0);
+ // //case of encapsulation of the part
+ // if(fullNestedPathWithRole2.get(0) == firstElementPath) {
+ // if(fullNestedPathWithRole2.size() > 1) {
+ // fullNestedPathWithrole1.remove(0);
+ // fullNestedPathWithRole2.remove(0);
+ // return deduceNewConnectorOwner(fullNestedPathWithrole1, fullNestedPathWithRole2);
+ // } else {
+ // return (EncapsulatedClassifier)firstElementPath.getOwner();
+ // }
+ // } else {
+ // final ConnectableElement firstElementPath2 = fullNestedPathWithRole2.get(0);
+ // if(firstElementPath.getOwner() == firstElementPath2.getOwner()) {
+ // return (EncapsulatedClassifier)firstElementPath.getOwner();
+ // } else {
+ // final List<ConnectableElement> biggestList;
+ // final List<ConnectableElement> smallestList;
+ // if(fullNestedPathWithrole1.size() > fullNestedPathWithRole2.size()) {
+ // biggestList = fullNestedPathWithrole1;
+ // smallestList = fullNestedPathWithRole2;
+ // } else {
+ // biggestList = fullNestedPathWithRole2;
+ // smallestList = fullNestedPathWithrole1;
+ // }
+ // for(int i = 0; i < biggestList.size(); i++) {
+ // final ConnectableElement current = biggestList.get(i);
+ // if(smallestList.contains(current) && i > 0) {
+ // return (EncapsulatedClassifier)biggestList.get(i - 1).getOwner();
+ // }
+ // }
+ // }
+ // }
+ // return null;
+ // // throw new RuntimeException("error");
//
//
//
//
//
- // }
+ // }
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PackageEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PackageEditHelperAdvice.java index 3dcb6fa5621..aafb47c5d69 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PackageEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PackageEditHelperAdvice.java @@ -1,6 +1,6 @@ /*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* 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
@@ -33,7 +33,7 @@ public class PackageEditHelperAdvice extends AbstractEditHelperAdvice { /**
* {@inheritDoc}
- *
+ *
* In case of {@link Association} creation, it should not be possible to target an association as target end.
*/
@Override
@@ -41,16 +41,16 @@ public class PackageEditHelperAdvice extends AbstractEditHelperAdvice { // test if the creation is for a SysML association
IElementType type = request.getElementType();
- if(hasSuperType(type, SysMLElementTypes.ASSOCIATION)) {
+ if (hasSuperType(type, SysMLElementTypes.ASSOCIATION)) {
// test source and target...
EObject target = request.getTarget();
- if(target instanceof Association || target == null) {
+ if (target instanceof Association || target == null) {
return UnexecutableCommand.INSTANCE;
}
if (!(hasSuperType(type, SysMLElementTypes.ASSOCIATION_NONE_DIRECTED) || hasSuperType(type, SysMLElementTypes.ASSOCIATION_COMPOSITE_DIRECTED) || hasSuperType(type, SysMLElementTypes.ASSOCIATION_SHARED_DIRECTED))) {
// The association is bidirectional. Check if that is possible.
-
+
// The target can be read-only only if the association is directed.
if (EMFUtil.isReadOnly(target)) {
return UnexecutableCommand.INSTANCE;
@@ -60,25 +60,25 @@ public class PackageEditHelperAdvice extends AbstractEditHelperAdvice { return UnexecutableCommand.INSTANCE;
}
}
-
+
}
return super.getBeforeCreateRelationshipCommand(request);
}
protected boolean hasSuperType(IElementType elementType, IElementType typeToTest) {
- if(elementType == null || typeToTest == null) {
+ if (elementType == null || typeToTest == null) {
return false;
}
- if(elementType.equals(typeToTest)) {
+ if (elementType.equals(typeToTest)) {
return true;
}
List<IElementType> superTypes = Arrays.asList(elementType.getAllSuperTypes());
- if(superTypes.contains(typeToTest)) {
- return true;
- }
+ if (superTypes.contains(typeToTest)) {
+ return true;
+ }
return false;
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java index d028b869d48..3834a62738a 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
* Christian W. Damus (CEA) - bug 402525
*
@@ -34,6 +34,7 @@ import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
@@ -87,19 +88,19 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { ICommand gmfCommand = super.getBeforeSetCommand(request);
EObject elementToEdit = request.getElementToEdit();
- if((elementToEdit instanceof Property) && !(elementToEdit instanceof Port) && (request.getFeature() == UMLPackage.eINSTANCE.getTypedElement_Type()) && (request.getValue() instanceof Type)) {
+ if ((elementToEdit instanceof Property) && !(elementToEdit instanceof Port) && (request.getFeature() == UMLPackage.eINSTANCE.getTypedElement_Type()) && (request.getValue() instanceof Type)) {
- Property propertyToEdit = (Property)elementToEdit;
+ Property propertyToEdit = (Property) elementToEdit;
// SysML specification : all property typed by a ConstraintBlock must have a ContraintProperty stereotype applied
- if(request.getValue() instanceof org.eclipse.uml2.uml.Class) {
- ICommand stereotypeApplicationCommand = getConstraintPropertyStereotypeApplicationCommand(propertyToEdit, (org.eclipse.uml2.uml.Class)request.getValue(), request);
+ if (request.getValue() instanceof org.eclipse.uml2.uml.Class) {
+ ICommand stereotypeApplicationCommand = getConstraintPropertyStereotypeApplicationCommand(propertyToEdit, (org.eclipse.uml2.uml.Class) request.getValue(), request);
gmfCommand = CompositeCommand.compose(gmfCommand, stereotypeApplicationCommand);
}
- // Exclude ConstraintParameter (simple property without ConstraintProperty stereotype owned by a ConstraintBlock)
- if(propertyToEdit.eContainer() instanceof org.eclipse.uml2.uml.Class && UMLUtil.getStereotypeApplication((Element)propertyToEdit.eContainer(), ConstraintBlock.class) != null) {
- if(UMLUtil.getStereotypeApplication(propertyToEdit, ConstraintProperty.class) == null) {
+ // Exclude ConstraintParameter (simple property without ConstraintProperty stereotype owned by a ConstraintBlock)
+ if (propertyToEdit.eContainer() instanceof org.eclipse.uml2.uml.Class && UMLUtil.getStereotypeApplication((Element) propertyToEdit.eContainer(), ConstraintBlock.class) != null) {
+ if (UMLUtil.getStereotypeApplication(propertyToEdit, ConstraintProperty.class) == null) {
return gmfCommand;
}
}
@@ -107,14 +108,15 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { Association relatedAssociation = propertyToEdit.getAssociation();
// The edited property has to be related to a SysML association
- if((relatedAssociation == null) || !(ElementUtil.hasNature(relatedAssociation, SysMLElementTypes.SYSML_NATURE))) {
+ if ((relatedAssociation == null) || !(ElementUtil.hasNature(relatedAssociation, SysMLElementTypes.SYSML_NATURE))) {
- // If no association exist and the new type is a Block
+ // If no association exist and the new type is a Block
// (not a ConstraintBlock => a property typed by a ConstraintBlock is a ConstraintProperty, not a Part neither a Reference),
// add the association
- if((relatedAssociation == null) && ((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches((Type)request.getValue()) && !((ISpecializationType)SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches((Type)request.getValue()) && ((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(propertyToEdit.eContainer())) {
+ if ((relatedAssociation == null) && ((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches((Type) request.getValue()) && !((ISpecializationType) SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches((Type) request.getValue())
+ && ((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches(propertyToEdit.eContainer())) {
- ICommand addAssociationCommand = getCreatePartAssociationCommand((org.eclipse.uml2.uml.Class)propertyToEdit.eContainer(), propertyToEdit, (org.eclipse.uml2.uml.Class)request.getValue());
+ ICommand addAssociationCommand = getCreatePartAssociationCommand((org.eclipse.uml2.uml.Class) propertyToEdit.eContainer(), propertyToEdit, (org.eclipse.uml2.uml.Class) request.getValue());
gmfCommand = CompositeCommand.compose(gmfCommand, addAssociationCommand);
}
@@ -123,13 +125,14 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { // Setting new type can be related to an association re-orient (or trigger the association re-orient)
// Retrieve elements already under re-factor.
- List<EObject> currentlyRefactoredElements = (request.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS) != null) ? (List<EObject>)request.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS) : new ArrayList<EObject>();
- if(!currentlyRefactoredElements.contains(propertyToEdit)) {
+ List<EObject> currentlyRefactoredElements = (request.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS) != null) ? (List<EObject>) request.getParameter(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS)
+ : new ArrayList<EObject>();
+ if (!currentlyRefactoredElements.contains(propertyToEdit)) {
currentlyRefactoredElements.add(propertyToEdit);
request.getParameters().put(RequestParameterConstants.ASSOCIATION_REFACTORED_ELEMENTS, currentlyRefactoredElements);
// Current association already under re-factor ?
- if(currentlyRefactoredElements.contains(relatedAssociation)) {
+ if (currentlyRefactoredElements.contains(relatedAssociation)) {
return gmfCommand;
}
}
@@ -137,7 +140,7 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { // If the new type is not a block, destroy related association
// This must be done only if the setting of the property type is not part of an association re-orient (hence after the previous code-block),
// otherwise there is no legitimate reason to destroy the existing association while re-orienting it.
- if(!((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches((Type)request.getValue()) && propertyToEdit.getType() != null) {
+ if (!((ISpecializationType) SysMLElementTypes.BLOCK).getMatcher().matches((Type) request.getValue()) && propertyToEdit.getType() != null) {
ICommand destroyCommand = getDestroyPartAssociationCommand(relatedAssociation, propertyToEdit);
gmfCommand = CompositeCommand.compose(gmfCommand, destroyCommand);
@@ -148,7 +151,7 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { gmfCommand = CompositeCommand.compose(gmfCommand, refactorCommand);
}
- if(gmfCommand != null) {
+ if (gmfCommand != null) {
gmfCommand = gmfCommand.reduce();
}
@@ -156,9 +159,9 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { }
/**
- *
+ *
* @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)
- *
+ *
* @param setRequest
* @return
*/
@@ -166,16 +169,16 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { protected ICommand getAfterSetCommand(SetRequest setRequest) {
ICommand afterSetCommand = super.getAfterSetCommand(setRequest);
EObject elementToEdit = setRequest.getElementToEdit();
- if((elementToEdit instanceof Property) && !(elementToEdit instanceof Port) && (setRequest.getFeature() == UMLPackage.eINSTANCE.getTypedElement_Type()) && (setRequest.getValue() instanceof Type)) {
- afterSetCommand = getDestroyAssociatedNestedConnectorCommand((Property)elementToEdit, afterSetCommand);
+ if ((elementToEdit instanceof Property) && !(elementToEdit instanceof Port) && (setRequest.getFeature() == UMLPackage.eINSTANCE.getTypedElement_Type()) && (setRequest.getValue() instanceof Type)) {
+ afterSetCommand = getDestroyAssociatedNestedConnectorCommand((Property) elementToEdit, afterSetCommand);
}
return afterSetCommand;
}
/**
- *
+ *
* @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest)
- *
+ *
* @param destroyDependentsRequest
* @return
*/
@@ -183,27 +186,27 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { protected ICommand getAfterDestroyDependentsCommand(DestroyDependentsRequest destroyDependentsRequest) {
ICommand afterDestroyDependentsCommand = super.getAfterDestroyDependentsCommand(destroyDependentsRequest);
EObject elementToDestroy = destroyDependentsRequest.getElementToDestroy();
- if(elementToDestroy instanceof Property) {
- afterDestroyDependentsCommand = getDestroyAssociatedNestedConnectorCommand((Property)elementToDestroy, afterDestroyDependentsCommand);
+ if (elementToDestroy instanceof Property) {
+ afterDestroyDependentsCommand = getDestroyAssociatedNestedConnectorCommand((Property) elementToDestroy, afterDestroyDependentsCommand);
}
return afterDestroyDependentsCommand;
}
/**
* Create a destroy command for all connectors that have this property in their <NestedConnectorEnd> property path.
- *
+ *
* @param property
- * the part to be destroyed
+ * the part to be destroyed
* @param command
* @return
*/
private ICommand getDestroyAssociatedNestedConnectorCommand(Property property, ICommand command) {
Package rootPackage = PackageUtil.getRootPackage(property);
- // When creating a property in a new-element dialog, it is not attached to the model, yet. So, there will be no need to worry about connectors
- if(rootPackage != null) {
+ // When creating a property in a new-element dialog, it is not attached to the model, yet. So, there will be no need to worry about connectors
+ if (rootPackage != null) {
List<Connector> instancesFilteredByType = org.eclipse.papyrus.uml.tools.utils.ElementUtil.getInstancesFilteredByType(rootPackage, Connector.class, null);
- List<Connector> connectorToDestroy = ConnectorUtils.filterConnectorByPropertyInNestedConnectorEnd(instancesFilteredByType, (Property)property);
- for(Connector connector : connectorToDestroy) {
+ List<Connector> connectorToDestroy = ConnectorUtils.filterConnectorByPropertyInNestedConnectorEnd(instancesFilteredByType, property);
+ for (Connector connector : connectorToDestroy) {
ICommand destroyConnectorCommand = getDestroyConnectorCommand(connector);
command = CompositeCommand.compose(command, destroyConnectorCommand);
}
@@ -213,46 +216,46 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Create a connector destroy command.
- *
+ *
* @param connector
* @return the connector destroy command
*/
private ICommand getDestroyConnectorCommand(Connector connector) {
DestroyElementRequest request = new DestroyElementRequest(connector, false);
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(connector.eContainer());
- if(provider == null) {
+ if (provider == null) {
return null;
}
return provider.getEditCommand(request);
}
-
+
/**
* Create a re-factoring command related to a Property move.
- *
+ *
* @param setProperty
- * the property which type is set
+ * the property which type is set
* @param associationToRefactor
- * the association to re-factor (re-orient action)
+ * the association to re-factor (re-orient action)
* @param request
- * the original set request
+ * the original set request
* @return the re-factoring command
*/
private ICommand getAssociationRefactoringCommand(Property setProperty, Association associationToRefactor, SetRequest request) {
Association relatedAssociation = setProperty.getAssociation(); // Should not be null, test before calling method.
- if(associationToRefactor.getMemberEnds().size() >= 2) {
+ if (associationToRefactor.getMemberEnds().size() >= 2) {
// Re-orient the related association (do not use edit service to avoid infinite loop here)
- int direction = ReorientRelationshipRequest.REORIENT_TARGET;
- if(setProperty == associationToRefactor.getMemberEnds().get(1)) {
- direction = ReorientRelationshipRequest.REORIENT_SOURCE;
+ int direction = ReorientRequest.REORIENT_TARGET;
+ if (setProperty == associationToRefactor.getMemberEnds().get(1)) {
+ direction = ReorientRequest.REORIENT_SOURCE;
}
- ReorientRelationshipRequest reorientRequest = new ReorientRelationshipRequest(relatedAssociation, (Type)request.getValue(), setProperty.eContainer(), direction);
+ ReorientRelationshipRequest reorientRequest = new ReorientRelationshipRequest(relatedAssociation, (Type) request.getValue(), setProperty.eContainer(), direction);
reorientRequest.addParameters(request.getParameters());
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(relatedAssociation);
- if(provider != null) {
+ if (provider != null) {
return provider.getEditCommand(reorientRequest);
}
}
@@ -262,7 +265,7 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Create a part association creation command.
- *
+ *
* @return the part association creation command
*/
private ICommand getCreatePartAssociationCommand(final org.eclipse.uml2.uml.Class sourceBlock, final Property sourceProperty, final org.eclipse.uml2.uml.Class targetBlock) {
@@ -286,7 +289,7 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { Association association = UMLFactory.eINSTANCE.createAssociation();
// Add the association in the model
- org.eclipse.uml2.uml.Package container = (org.eclipse.uml2.uml.Package)EMFCoreUtil.getLeastCommonContainer(Arrays.asList(new EObject[]{ sourceBlock, targetBlock }), UMLPackage.eINSTANCE.getPackage());
+ org.eclipse.uml2.uml.Package container = (org.eclipse.uml2.uml.Package) EMFCoreUtil.getLeastCommonContainer(Arrays.asList(new EObject[] { sourceBlock, targetBlock }), UMLPackage.eINSTANCE.getPackage());
container.getPackagedElements().add(association);
// Use existing Property as source...
@@ -311,7 +314,7 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Apply/remove the ConstraintProperty stereotype application
- *
+ *
* @return the ConstraintProperty stereotype application command
*/
private ICommand getConstraintPropertyStereotypeApplicationCommand(final Property sourceProperty, final org.eclipse.uml2.uml.Class targetBlock, final SetRequest request) {
@@ -322,27 +325,30 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
// SysML specification : all property typed by a ConstraintBlock must have a ContraintProperty stereotype applied
ConstraintProperty constraintPropertyApplication = UMLUtil.getStereotypeApplication(sourceProperty, ConstraintProperty.class);
- if(UMLUtil.getStereotypeApplication(targetBlock, ConstraintBlock.class) != null) {
- if(constraintPropertyApplication == null) {
+ if (UMLUtil.getStereotypeApplication(targetBlock, ConstraintBlock.class) != null) {
+ if (constraintPropertyApplication == null) {
StereotypeApplicationHelper.INSTANCE.applyStereotype(sourceProperty, ConstraintsPackage.eINSTANCE.getConstraintProperty());
// Remove representations
Set<View> memberViewsToDestroy = CrossReferencerUtil.getCrossReferencingViews(sourceProperty, null);
- if(memberViewsToDestroy.size() != 0) {
+ if (memberViewsToDestroy.size() != 0) {
final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
final String DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY = "displayMessageForTypingActionPreferenceKey";
boolean contains = store.contains(DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY);
- if(!contains) {
+ if (!contains) {
store.setValue(DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY, MessageDialogWithToggle.NEVER);
store.setDefault(DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY, MessageDialogWithToggle.NEVER);
}
final String hideValue = store.getString(DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY);
- if(!hideValue.equals(MessageDialogWithToggle.ALWAYS)) {
+ if (!hideValue.equals(MessageDialogWithToggle.ALWAYS)) {
int size = memberViewsToDestroy.size();
- MessageDialogWithToggle.openInformation(Display.getDefault().getActiveShell(), "Change Type Action", "WARNING! Typing a Property by a ConstraintBlock make this property become a ConstraintProperty. ConstraintProperty have a specific representation. " + "\nSo all representations of this property will be removed from the model (" + size + " occurence" + ((size > 1) ? "s" : "") + ").", "Don't show this dialog the next time", false, store, DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY);
+ MessageDialogWithToggle.openInformation(Display.getDefault().getActiveShell(), "Change Type Action",
+ "WARNING! Typing a Property by a ConstraintBlock make this property become a ConstraintProperty. ConstraintProperty have a specific representation. "
+ + "\nSo all representations of this property will be removed from the model (" + size + " occurence" + ((size > 1) ? "s" : "") + ").", "Don't show this dialog the next time", false, store,
+ DISPLAY_MESSAGE_FOR_TYPING_ACTION_PREFERENCE_KEY);
}
}
- for(View view : memberViewsToDestroy) {
+ for (View view : memberViewsToDestroy) {
final DestroyElementRequest destroyRequest = new DestroyElementRequest(request.getEditingDomain(), view, false);
final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(view);
ICommand editCommand = commandProvider.getEditCommand(destroyRequest);
@@ -350,7 +356,7 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { }
}
} else {
- if(constraintPropertyApplication != null) {
+ if (constraintPropertyApplication != null) {
StereotypeApplicationHelper.INSTANCE.removeFromContainmentList(sourceProperty, constraintPropertyApplication);
}
}
@@ -361,18 +367,18 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Create a part association destroy command.
- *
+ *
* @return the part association destroy command
*/
@SuppressWarnings("unchecked")
private ICommand getDestroyPartAssociationCommand(Association partAssociation, Property propertyToEdit) {
DestroyElementRequest request = new DestroyElementRequest(partAssociation, false);
- List<EObject> dependentsToKeep = Arrays.asList(new EObject[]{ propertyToEdit });
+ List<EObject> dependentsToKeep = Arrays.asList(new EObject[] { propertyToEdit });
request.getParameters().put(RequestParameterConstants.DEPENDENTS_TO_KEEP, dependentsToKeep);
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(partAssociation.eContainer());
- if(provider == null) {
+ if (provider == null) {
return null;
}
ICommand destroyCommand = provider.getEditCommand(request);
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ActorPartPropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ActorPartPropertyMatcher.java index ac1d3a030af..19d5f2a25a8 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ActorPartPropertyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ActorPartPropertyMatcher.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -24,22 +24,22 @@ import org.eclipse.uml2.uml.Property; * Test if current {@link Property} is a {@link Actor} Part
*/
public class ActorPartPropertyMatcher implements IElementMatcher {
-
+
/**
* {@inheritDoc}
*/
public boolean matches(EObject eObject) {
boolean isMatch = false;
- if((eObject instanceof Property) && !(eObject instanceof Port)) {
+ if ((eObject instanceof Property) && !(eObject instanceof Port)) {
+
+ Property element = (Property) eObject;
- Property element = (Property)eObject;
-
// The property is necessary a composition and has a type
if ((element.getType() != null) && (element.getAggregation() == AggregationKind.COMPOSITE_LITERAL)) {
-
+
// Moreover its type has to be a Actor
- if(element.getType() instanceof Actor) {
+ if (element.getType() instanceof Actor) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/AllocateMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/AllocateMatcher.java index f8dad2bcbb4..44d4b8e29a2 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/AllocateMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/AllocateMatcher.java @@ -23,10 +23,10 @@ public class AllocateMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Abstraction) {
+ if (eObject instanceof Abstraction) {
- Abstraction element = (Abstraction)eObject;
- if(UMLUtil.getStereotypeApplication(element, Allocate.class) != null) {
+ Abstraction element = (Abstraction) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Allocate.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/AssociationMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/AssociationMatcher.java index 1ddebafa827..31063869b6d 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/AssociationMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/AssociationMatcher.java @@ -22,27 +22,27 @@ import org.eclipse.uml2.uml.Element; * This nature is used to:
* - distinguish between UML and SysML expected behavior for {@link Association}
* - decide whether and {@link Association} can be dropped and used in a specific diagram
- * - select the property view to use
+ * - select the property view to use
* </pre>
*/
public class AssociationMatcher implements IElementMatcher {
-
+
/** Test is the eObject is a SysML Association */
public boolean matches(EObject eObject) {
boolean isMatch = false;
if (eObject instanceof Association) {
-
+
Association association = (Association) eObject;
if (hasValidNature(association)) {
isMatch = true;
}
}
-
+
return isMatch;
}
-
+
/** Valid nature is SysML Nature */
private boolean hasValidNature(Element element) {
return ElementUtil.hasNature(element, SysMLElementTypes.SYSML_NATURE);
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/BlockMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/BlockMatcher.java index 44942f86aff..7dfc419fd8e 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/BlockMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/BlockMatcher.java @@ -23,10 +23,10 @@ public class BlockMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Class) {
+ if (eObject instanceof Class) {
- Class element = (Class)eObject;
- if(UMLUtil.getStereotypeApplication(element, Block.class) != null) {
+ Class element = (Class) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Block.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConformMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConformMatcher.java index 855222ebb81..4da31863355 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConformMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConformMatcher.java @@ -23,10 +23,10 @@ public class ConformMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Dependency) {
+ if (eObject instanceof Dependency) {
- Dependency element = (Dependency)eObject;
- if(UMLUtil.getStereotypeApplication(element, Conform.class) != null) {
+ Dependency element = (Dependency) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Conform.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintBlockMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintBlockMatcher.java index e0389a12cbd..f294cca846c 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintBlockMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintBlockMatcher.java @@ -23,10 +23,10 @@ public class ConstraintBlockMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Class) {
+ if (eObject instanceof Class) {
- Class element = (Class)eObject;
- if(UMLUtil.getStereotypeApplication(element, ConstraintBlock.class) != null) {
+ Class element = (Class) eObject;
+ if (UMLUtil.getStereotypeApplication(element, ConstraintBlock.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java index cc9d68f79db..676cc0ed6b0 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java @@ -23,10 +23,10 @@ public class ConstraintPropertyMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Property) {
+ if (eObject instanceof Property) {
Property element = (Property) eObject;
- if(UMLUtil.getStereotypeApplication(element, ConstraintProperty.class) != null) {
+ if (UMLUtil.getStereotypeApplication(element, ConstraintProperty.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/CopyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/CopyMatcher.java index f796413cb4d..74c51ab3f8a 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/CopyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/CopyMatcher.java @@ -23,10 +23,10 @@ public class CopyMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Abstraction) {
+ if (eObject instanceof Abstraction) {
- Abstraction element = (Abstraction)eObject;
- if(UMLUtil.getStereotypeApplication(element, Copy.class) != null) {
+ Abstraction element = (Abstraction) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Copy.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/DeriveReqtMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/DeriveReqtMatcher.java index 320d26593bd..b88f0de6593 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/DeriveReqtMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/DeriveReqtMatcher.java @@ -23,10 +23,10 @@ public class DeriveReqtMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Abstraction) {
+ if (eObject instanceof Abstraction) {
- Abstraction element = (Abstraction)eObject;
- if(UMLUtil.getStereotypeApplication(element, DeriveReqt.class) != null) {
+ Abstraction element = (Abstraction) eObject;
+ if (UMLUtil.getStereotypeApplication(element, DeriveReqt.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/DimensionMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/DimensionMatcher.java index b1c8556d992..479f2fcc8a0 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/DimensionMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/DimensionMatcher.java @@ -23,10 +23,10 @@ public class DimensionMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof InstanceSpecification) {
+ if (eObject instanceof InstanceSpecification) {
- InstanceSpecification element = (InstanceSpecification)eObject;
- if(UMLUtil.getStereotypeApplication(element, Dimension.class) != null) {
+ InstanceSpecification element = (InstanceSpecification) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Dimension.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortInMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortInMatcher.java index 79afdc05690..2aaa65be6ed 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortInMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortInMatcher.java @@ -25,12 +25,12 @@ public class FlowPortInMatcher implements IElementMatcher { boolean isFlowPort_IN = false;
- if(eObject instanceof Port) {
+ if (eObject instanceof Port) {
- Port port = (Port)eObject;
+ Port port = (Port) eObject;
FlowPort flowPort = UMLUtil.getStereotypeApplication(port, FlowPort.class);
- if((flowPort != null) && (flowPort.getDirection() == FlowDirection.IN)) {
+ if ((flowPort != null) && (flowPort.getDirection() == FlowDirection.IN)) {
isFlowPort_IN = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortInOutMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortInOutMatcher.java index 47d357e8d91..3ae4e13f393 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortInOutMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortInOutMatcher.java @@ -25,12 +25,12 @@ public class FlowPortInOutMatcher implements IElementMatcher { boolean isFlowPort_INOUT = false;
- if(eObject instanceof Port) {
+ if (eObject instanceof Port) {
- Port port = (Port)eObject;
+ Port port = (Port) eObject;
FlowPort flowPort = UMLUtil.getStereotypeApplication(port, FlowPort.class);
- if((flowPort != null) && (flowPort.getDirection() == FlowDirection.INOUT)) {
+ if ((flowPort != null) && (flowPort.getDirection() == FlowDirection.INOUT)) {
isFlowPort_INOUT = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortMatcher.java index 90294bf2964..e5411ac7f52 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortMatcher.java @@ -23,10 +23,10 @@ public class FlowPortMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isFlowPort = false;
- if(eObject instanceof Port) {
+ if (eObject instanceof Port) {
- Port port = (Port)eObject;
- if(UMLUtil.getStereotypeApplication(port, FlowPort.class) != null) {
+ Port port = (Port) eObject;
+ if (UMLUtil.getStereotypeApplication(port, FlowPort.class) != null) {
isFlowPort = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortNAMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortNAMatcher.java index 87f38de218f..100b21b739f 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortNAMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortNAMatcher.java @@ -24,12 +24,12 @@ public class FlowPortNAMatcher implements IElementMatcher { boolean isFlowPort_NA = false;
- if(eObject instanceof Port) {
+ if (eObject instanceof Port) {
- Port port = (Port)eObject;
+ Port port = (Port) eObject;
FlowPort flowPort = UMLUtil.getStereotypeApplication(port, FlowPort.class);
- if((flowPort != null) && (! flowPort.isAtomic())) {
+ if ((flowPort != null) && (!flowPort.isAtomic())) {
isFlowPort_NA = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortOutMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortOutMatcher.java index 4fe81a1afa7..9de3c167516 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortOutMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPortOutMatcher.java @@ -25,12 +25,12 @@ public class FlowPortOutMatcher implements IElementMatcher { boolean isFlowPort_OUT = false;
- if(eObject instanceof Port) {
+ if (eObject instanceof Port) {
- Port port = (Port)eObject;
+ Port port = (Port) eObject;
FlowPort flowPort = UMLUtil.getStereotypeApplication(port, FlowPort.class);
- if((flowPort != null) && (flowPort.getDirection() == FlowDirection.OUT)) {
+ if ((flowPort != null) && (flowPort.getDirection() == FlowDirection.OUT)) {
isFlowPort_OUT = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java index a384b9fa163..38c9ff296e5 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java @@ -23,10 +23,10 @@ public class FlowPropertyMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isFlowProperty = false;
- if(eObject instanceof Property) {
+ if (eObject instanceof Property) {
- Property element = (Property)eObject;
- if(UMLUtil.getStereotypeApplication(element, FlowProperty.class) != null) {
+ Property element = (Property) eObject;
+ if (UMLUtil.getStereotypeApplication(element, FlowProperty.class) != null) {
isFlowProperty = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowSpecificationMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowSpecificationMatcher.java index 75de23621dc..8268b4e4e7f 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowSpecificationMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowSpecificationMatcher.java @@ -23,10 +23,10 @@ public class FlowSpecificationMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isFlowSpec = false;
- if(eObject instanceof Interface) {
+ if (eObject instanceof Interface) {
- Interface element = (Interface)eObject;
- if(UMLUtil.getStereotypeApplication(element, FlowSpecification.class) != null) {
+ Interface element = (Interface) eObject;
+ if (UMLUtil.getStereotypeApplication(element, FlowSpecification.class) != null) {
isFlowSpec = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ItemFlowMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ItemFlowMatcher.java index 85a4f09af02..1e7466038e0 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ItemFlowMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ItemFlowMatcher.java @@ -23,10 +23,10 @@ public class ItemFlowMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof InformationFlow) {
+ if (eObject instanceof InformationFlow) {
- InformationFlow element = (InformationFlow)eObject;
- if(UMLUtil.getStereotypeApplication(element, ItemFlow.class) != null) {
+ InformationFlow element = (InformationFlow) eObject;
+ if (UMLUtil.getStereotypeApplication(element, ItemFlow.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java index c1161f8ce4d..b0828daa4bf 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java @@ -21,22 +21,22 @@ import org.eclipse.uml2.uml.util.UMLUtil; * Test if current {@link Property} is a {@link Block} Part
*/
public class PartPropertyMatcher implements IElementMatcher {
-
+
/**
* {@inheritDoc}
*/
public boolean matches(EObject eObject) {
boolean isMatch = false;
- if((eObject instanceof Property) && !(eObject instanceof Port)) {
+ if ((eObject instanceof Property) && !(eObject instanceof Port)) {
+
+ Property element = (Property) eObject;
- Property element = (Property)eObject;
-
// The property is necessary a composition and has a type
if ((element.getType() != null) && (element.getAggregation() == AggregationKind.COMPOSITE_LITERAL)) {
-
+
// Moreover its type has to be a Block
- if(UMLUtil.getStereotypeApplication(element.getType(), Block.class) != null) {
+ if (UMLUtil.getStereotypeApplication(element.getType(), Block.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ProblemMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ProblemMatcher.java index 4bcea041202..e106e83044b 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ProblemMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ProblemMatcher.java @@ -23,10 +23,10 @@ public class ProblemMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Comment) {
+ if (eObject instanceof Comment) {
- Comment element = (Comment)eObject;
- if(UMLUtil.getStereotypeApplication(element, Problem.class) != null) {
+ Comment element = (Comment) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Problem.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/RationaleMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/RationaleMatcher.java index 29e755e784d..ba129dd61a8 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/RationaleMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/RationaleMatcher.java @@ -23,10 +23,10 @@ public class RationaleMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Comment) {
+ if (eObject instanceof Comment) {
- Comment element = (Comment)eObject;
- if(UMLUtil.getStereotypeApplication(element, Rationale.class) != null) {
+ Comment element = (Comment) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Rationale.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java index 03d8a670920..604574d1a6f 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java @@ -28,15 +28,15 @@ public class ReferencePropertyMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if((eObject instanceof Property) && !(eObject instanceof Port)) {
+ if ((eObject instanceof Property) && !(eObject instanceof Port)) {
+
+ Property element = (Property) eObject;
- Property element = (Property)eObject;
-
// The property is not a composition and has a type
if ((element.getType() != null) && (element.getAggregation() != AggregationKind.COMPOSITE_LITERAL)) {
-
+
// Moreover its type has to be a Block
- if(UMLUtil.getStereotypeApplication(element.getType(), Block.class) != null) {
+ if (UMLUtil.getStereotypeApplication(element.getType(), Block.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/RequirementMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/RequirementMatcher.java index 0995d6f21e2..d30d2745113 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/RequirementMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/RequirementMatcher.java @@ -23,10 +23,10 @@ public class RequirementMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Class) {
+ if (eObject instanceof Class) {
- Class element = (Class)eObject;
- if(UMLUtil.getStereotypeApplication(element, Requirement.class) != null) {
+ Class element = (Class) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Requirement.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/SatisfyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/SatisfyMatcher.java index 9535b83016c..1e11e82ccf4 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/SatisfyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/SatisfyMatcher.java @@ -23,10 +23,10 @@ public class SatisfyMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Abstraction) {
+ if (eObject instanceof Abstraction) {
- Abstraction element = (Abstraction)eObject;
- if(UMLUtil.getStereotypeApplication(element, Satisfy.class) != null) {
+ Abstraction element = (Abstraction) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Satisfy.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/UnitMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/UnitMatcher.java index 9adbc265c5d..a7afda41799 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/UnitMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/UnitMatcher.java @@ -23,10 +23,10 @@ public class UnitMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof InstanceSpecification) {
+ if (eObject instanceof InstanceSpecification) {
- InstanceSpecification element = (InstanceSpecification)eObject;
- if(UMLUtil.getStereotypeApplication(element, Unit.class) != null) {
+ InstanceSpecification element = (InstanceSpecification) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Unit.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValuePropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValuePropertyMatcher.java index 655a99f65dd..5ebf3f74c1d 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValuePropertyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValuePropertyMatcher.java @@ -29,18 +29,18 @@ public class ValuePropertyMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if((eObject instanceof Property) && !(eObject instanceof Port)) {
+ if ((eObject instanceof Property) && !(eObject instanceof Port)) {
+
+ Property element = (Property) eObject;
- Property element = (Property)eObject;
-
// The property is necessary a composition and has a type
if ((element.getType() != null) && (element.getAggregation() == AggregationKind.COMPOSITE_LITERAL)) {
-
+
// Moreover its type has either to be a DataType or a ValueType
- if(UMLUtil.getStereotypeApplication(element.getType(), ValueType.class) != null) {
+ if (UMLUtil.getStereotypeApplication(element.getType(), ValueType.class) != null) {
isMatch = true;
}
- if(element.getType() instanceof DataType) {
+ if (element.getType() instanceof DataType) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypeEnumerationMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypeEnumerationMatcher.java index 81b73fe7512..5b98c8073ba 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypeEnumerationMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypeEnumerationMatcher.java @@ -23,10 +23,10 @@ public class ValueTypeEnumerationMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Enumeration) {
+ if (eObject instanceof Enumeration) {
- Enumeration element = (Enumeration)eObject;
- if(UMLUtil.getStereotypeApplication(element, ValueType.class) != null) {
+ Enumeration element = (Enumeration) eObject;
+ if (UMLUtil.getStereotypeApplication(element, ValueType.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypeMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypeMatcher.java index e3e4b2a44fe..48aae2bc7d7 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypeMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypeMatcher.java @@ -23,10 +23,10 @@ public class ValueTypeMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof DataType) {
+ if (eObject instanceof DataType) {
- DataType element = (DataType)eObject;
- if(UMLUtil.getStereotypeApplication(element, ValueType.class) != null) {
+ DataType element = (DataType) eObject;
+ if (UMLUtil.getStereotypeApplication(element, ValueType.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypePrimitiveTypeMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypePrimitiveTypeMatcher.java index 00c89f2a0d7..b61e4cfd6b3 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypePrimitiveTypeMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ValueTypePrimitiveTypeMatcher.java @@ -23,10 +23,10 @@ public class ValueTypePrimitiveTypeMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof PrimitiveType) {
+ if (eObject instanceof PrimitiveType) {
- PrimitiveType element = (PrimitiveType)eObject;
- if(UMLUtil.getStereotypeApplication(element, ValueType.class) != null) {
+ PrimitiveType element = (PrimitiveType) eObject;
+ if (UMLUtil.getStereotypeApplication(element, ValueType.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/VerifyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/VerifyMatcher.java index d9e52e59daa..e3f67bf23a4 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/VerifyMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/VerifyMatcher.java @@ -23,10 +23,10 @@ public class VerifyMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Abstraction) {
+ if (eObject instanceof Abstraction) {
- Abstraction element = (Abstraction)eObject;
- if(UMLUtil.getStereotypeApplication(element, Verify.class) != null) {
+ Abstraction element = (Abstraction) eObject;
+ if (UMLUtil.getStereotypeApplication(element, Verify.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ViewMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ViewMatcher.java index 69e22c18fda..0a732ebd188 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ViewMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ViewMatcher.java @@ -23,10 +23,10 @@ public class ViewMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Package) {
+ if (eObject instanceof Package) {
- Package element = (Package)eObject;
- if(UMLUtil.getStereotypeApplication(element, View.class) != null) {
+ Package element = (Package) eObject;
+ if (UMLUtil.getStereotypeApplication(element, View.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ViewPointMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ViewPointMatcher.java index 80df0478472..b917cce651a 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ViewPointMatcher.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ViewPointMatcher.java @@ -23,10 +23,10 @@ public class ViewPointMatcher implements IElementMatcher { public boolean matches(EObject eObject) {
boolean isMatch = false;
- if(eObject instanceof Class) {
+ if (eObject instanceof Class) {
- Class element = (Class)eObject;
- if(UMLUtil.getStereotypeApplication(element, ViewPoint.class) != null) {
+ Class element = (Class) eObject;
+ if (UMLUtil.getStereotypeApplication(element, ViewPoint.class) != null) {
isMatch = true;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/menu/AbstractCreateSysmlChildMenu.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/menu/AbstractCreateSysmlChildMenu.java index bacaa503732..5bd56d38b13 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/menu/AbstractCreateSysmlChildMenu.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/menu/AbstractCreateSysmlChildMenu.java @@ -1,6 +1,6 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
- *
+ *
* 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
@@ -24,7 +24,7 @@ public abstract class AbstractCreateSysmlChildMenu extends AbstractCreateMenuFro /**
* Constructor.
- *
+ *
*/
public AbstractCreateSysmlChildMenu() {
super(SYSML_CREATION_COMMAND_CATEGORY);
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/stereotype/helper/advice/BlockEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/stereotype/helper/advice/BlockEditHelperAdvice.java index 0c69eca800f..1cf68fda908 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/stereotype/helper/advice/BlockEditHelperAdvice.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/stereotype/helper/advice/BlockEditHelperAdvice.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
@@ -37,7 +37,7 @@ import org.eclipse.uml2.uml.UMLPackage; /**
* <pre>
- * This advice is used to remove inconsistent {@link Connector} when a related {@link Block}
+ * This advice is used to remove inconsistent {@link Connector} when a related {@link Block}
* is set as encapsulated ({@link Block#isEncapsulated()} property).
* </pre>
*/
@@ -49,12 +49,12 @@ public class BlockEditHelperAdvice extends AbstractEditHelperAdvice { *
* Returns the command to destroy any {@link Connector} breaking encapsulation rules.
* </pre>
- *
+ *
* @param request
- * the request to modify the model
+ * the request to modify the model
* @return
* the command to destroy the views of the parts which are not owned by the new type
- *
+ *
*/
@Override
protected ICommand getBeforeSetCommand(SetRequest request) {
@@ -62,18 +62,18 @@ public class BlockEditHelperAdvice extends AbstractEditHelperAdvice { Set<Connector> connectorToDelete = new HashSet<Connector>();
EObject elementToEdit = request.getElementToEdit();
- if((elementToEdit instanceof Block) && (request.getFeature() == BlocksPackage.eINSTANCE.getBlock_IsEncapsulated())) {
+ if ((elementToEdit instanceof Block) && (request.getFeature() == BlocksPackage.eINSTANCE.getBlock_IsEncapsulated())) {
+
+ Block blockApp = (Block) elementToEdit;
+ Boolean setAsEncapsulated = (request.getValue() instanceof Boolean) ? (Boolean) request.getValue() : false;
+ if (!blockApp.isEncapsulated() && setAsEncapsulated) {
- Block blockApp = (Block)elementToEdit;
- Boolean setAsEncapsulated = (request.getValue() instanceof Boolean) ? (Boolean)request.getValue() : false;
- if(!blockApp.isEncapsulated() && setAsEncapsulated) {
-
for (Property property : getPropertyTypedByBlock(blockApp)) {
for (NestedConnectorEnd nestedEnd : getRelatedNestedConnectorEnd(property)) {
ConnectorEnd end = nestedEnd.getBase_ConnectorEnd();
Connector connector = (end != null) ? (Connector) end.eContainer() : null;
if (connector != null) {
- connectorToDelete.add(connector);
+ connectorToDelete.add(connector);
}
}
}
@@ -81,12 +81,12 @@ public class BlockEditHelperAdvice extends AbstractEditHelperAdvice { }
// Add connector destroy command if needed
- if(!(connectorToDelete.isEmpty())) {
+ if (!(connectorToDelete.isEmpty())) {
DestroyDependentsRequest req = new DestroyDependentsRequest(request.getEditingDomain(), elementToEdit, false);
req.setClientContext(request.getClientContext());
req.addParameters(request.getParameters());
ICommand connectorDestroyCommand = req.getDestroyDependentsCommand(connectorToDelete);
- if(connectorDestroyCommand != null) {
+ if (connectorDestroyCommand != null) {
setCommand = CompositeCommand.compose(connectorDestroyCommand, setCommand);
}
}
@@ -96,27 +96,31 @@ public class BlockEditHelperAdvice extends AbstractEditHelperAdvice { /**
* Get any {@link Property} typed by the given {@link Block} (its base class).
- * @param block the block.
- * @return a collection of {@link Property}
+ *
+ * @param block
+ * the block.
+ * @return a collection of {@link Property}
*/
@SuppressWarnings("unchecked")
private Collection<Property> getPropertyTypedByBlock(Block block) {
- EReference[] eRefs = new EReference[]{ UMLPackage.eINSTANCE.getTypedElement_Type() };
-
- Collection<Property> references = (Collection<Property>) EMFCoreUtil.getReferencers(block.getBase_Class(), eRefs);
+ EReference[] eRefs = new EReference[] { UMLPackage.eINSTANCE.getTypedElement_Type() };
+
+ Collection<Property> references = EMFCoreUtil.getReferencers(block.getBase_Class(), eRefs);
return (references != null) ? references : Collections.unmodifiableList(new ArrayList<Property>());
}
-
+
/**
* Get any {@link NestedConnectorEnd} stereotype application that holds the property in its path.
- * @param property the property that should be in the path.
- * @return a collection of {@link NestedConnectorEnd}
+ *
+ * @param property
+ * the property that should be in the path.
+ * @return a collection of {@link NestedConnectorEnd}
*/
@SuppressWarnings("unchecked")
private Collection<NestedConnectorEnd> getRelatedNestedConnectorEnd(Property property) {
- EReference[] eRefs = new EReference[]{ BlocksPackage.eINSTANCE.getNestedConnectorEnd_PropertyPath() };
-
- Collection<NestedConnectorEnd> references = (Collection<NestedConnectorEnd>) EMFCoreUtil.getReferencers(property, eRefs);
+ EReference[] eRefs = new EReference[] { BlocksPackage.eINSTANCE.getNestedConnectorEnd_PropertyPath() };
+
+ Collection<NestedConnectorEnd> references = EMFCoreUtil.getReferencers(property, eRefs);
return (references != null) ? references : Collections.unmodifiableList(new ArrayList<NestedConnectorEnd>());
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java index af7de2bfed2..3bf674d4879 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java +++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/utils/ConnectorUtils.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * + * * CEA LIST - Initial API and implementation * *****************************************************************************/ @@ -58,25 +58,26 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Gets the encapsulated container. * - * @param view the view + * @param view + * the view * @return the nearest encapsulated structure container or null */ public View getEncapsulatedContainer(View view) { View encapsulatedContainer = null; - for(View containerView : getStructureContainers(view)) { + for (View containerView : getStructureContainers(view)) { - if(view == containerView) { + if (view == containerView) { continue; } - if((view.getElement() instanceof Port) && (containerView.getChildren().contains(view))) { + if ((view.getElement() instanceof Port) && (containerView.getChildren().contains(view))) { continue; } StructuredClassifier structuredClassifier = getStructuredClassifier(containerView); Block block = UMLUtil.getStereotypeApplication(structuredClassifier, Block.class); - if(block.isEncapsulated()) { + if (block.isEncapsulated()) { encapsulatedContainer = containerView; break; } @@ -87,22 +88,22 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Test if an encapsulation crossing is required to connect the checked end to the opposite end. - * + * * @param checkedEnd - * the checked end view. + * the checked end view. * @param oppositeEnd - * the opposite end view. + * the opposite end view. * @return true if the gesture break encapsulation rule. */ public boolean isCrossingEncapsulation(View checkedEnd, View oppositeEnd) { boolean isCrossingEncapsulation = false; View encapsulatedContainer = new ConnectorUtils().getEncapsulatedContainer(checkedEnd); - if(encapsulatedContainer != null) { + if (encapsulatedContainer != null) { View containerView = new ConnectorUtils().deduceViewContainer(checkedEnd, oppositeEnd); List<View> containers = new ConnectorUtils().getStructureContainers(checkedEnd); - if(containers.indexOf(encapsulatedContainer) < containers.indexOf(containerView)) { + if (containers.indexOf(encapsulatedContainer) < containers.indexOf(containerView)) { isCrossingEncapsulation = true; } } @@ -112,22 +113,22 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Get the path of structure views crossed by the checked end. - * + * * @param checkedEnd - * the checked end view. + * the checked end view. * @param oppositeEnd - * the opposite end view. + * the opposite end view. * @return the list of crossed structure views. */ public List<View> getNestedPath(View checkedEnd, View oppositeEnd) { List<View> isNestedConnectableElement = new ArrayList<View>(); View nearestContainer = new ConnectorUtils().getNearestStructureContainer(checkedEnd); - if(nearestContainer != null) { + if (nearestContainer != null) { View containerView = new ConnectorUtils().deduceViewContainer(checkedEnd, oppositeEnd); List<View> containers = new ConnectorUtils().getStructureContainers(checkedEnd); - if(containers.indexOf(nearestContainer) < containers.indexOf(containerView)) { + if (containers.indexOf(nearestContainer) < containers.indexOf(containerView)) { isNestedConnectableElement = containers.subList(containers.indexOf(nearestContainer), containers.indexOf(containerView)); } } @@ -140,27 +141,27 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Get the path of structure views crossed by the checked end. - * + * * @param checkedEnd - * the checked end view. + * the checked end view. * @param oppositeEnd - * the opposite end view. + * the opposite end view. * @return the list of crossed structure views. */ public List<Property> getNestedPropertyPath(View checkedEnd, View oppositeEnd) { List<Property> nestedPropertyPath = new ArrayList<Property>(); List<View> nestedPath = getNestedPath(checkedEnd, oppositeEnd); - for(View view : nestedPath) { - if((view.getElement() != null) && (view.getElement() instanceof Property)) { - nestedPropertyPath.add((Property)view.getElement()); + for (View view : nestedPath) { + if ((view.getElement() != null) && (view.getElement() instanceof Property)) { + nestedPropertyPath.add((Property) view.getElement()); } } // if end is a port, and the list is not empty, add the property from the check view in the list - if(!nestedPropertyPath.isEmpty() && checkedEnd.getElement() instanceof Port) { + if (!nestedPropertyPath.isEmpty() && checkedEnd.getElement() instanceof Port) { Property partWithPort = getPartWithPort(checkedEnd, oppositeEnd); - if(partWithPort != null) { + if (partWithPort != null) { nestedPropertyPath.add(partWithPort); } } @@ -170,11 +171,11 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Test if the checked end is nested (means it cross StructuredClassifier borders). - * + * * @param checkedEnd - * the checked end view. + * the checked end view. * @param oppositeEnd - * the opposite end view. + * the opposite end view. * @return true if the checked end is nested. */ public boolean isNestedConnectableElement(View checkedEnd, View oppositeEnd) { @@ -184,19 +185,20 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Gets the nearest structure container. * - * @param view the view + * @param view + * the view * @return the nearest structure container or null */ public View getNearestStructureContainer(View view) { View nearestStructureContainer = null; - for(View containerView : getStructureContainers(view)) { + for (View containerView : getStructureContainers(view)) { - if(view == containerView) { + if (view == containerView) { continue; } - if((view.getElement() instanceof Port) && (containerView.getChildren().contains(view))) { + if ((view.getElement() instanceof Port) && (containerView.getChildren().contains(view))) { continue; } @@ -212,25 +214,26 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Gets the role path. * - * @param end the connector end + * @param end + * the connector end * @return the role path - * the path for the role of the connector end (without using label provider) + * the path for the role of the connector end (without using label provider) */ public static final String getRolePath(final ConnectorEnd end) { final NestedConnectorEnd nestedConnectorEnd = UMLUtil.getStereotypeApplication(end, NestedConnectorEnd.class); final ConnectableElement role = end.getRole(); final StringBuilder rolePath = new StringBuilder(); - if(role != null) { - if(nestedConnectorEnd != null) { + if (role != null) { + if (nestedConnectorEnd != null) { final List<Property> properties = nestedConnectorEnd.getPropertyPath(); - for(final Property current : properties) { + for (final Property current : properties) { rolePath.append(getNameWithQuotes(current)); rolePath.append(ConnectorUtils.PART_SEPARATOR); } } else { - //when the stereotype is applied, the Property for partWithPort is included in the stereotype#path + // when the stereotype is applied, the Property for partWithPort is included in the stereotype#path final Property partWithPort = end.getPartWithPort(); - if(partWithPort != null) { + if (partWithPort != null) { rolePath.append(getNameWithQuotes(partWithPort)); rolePath.append(ConnectorUtils.PART_SEPARATOR); } @@ -244,9 +247,10 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Gets the name with quotes. * - * @param property a property + * @param property + * a property * @return the name with quotes - * the property name with name delimiter if it is required + * the property name with name delimiter if it is required */ public static final String getNameWithQuotes(final NamedElement property) { final String partName = property.getName(); @@ -254,10 +258,10 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. final Pattern pattern = Pattern.compile(ConnectorUtils.HAS_NO_WORD_CHAR_REGEX); final Matcher matcher = pattern.matcher(partName); boolean mustHaveQuote = false; - while(matcher.find() && !mustHaveQuote) { + while (matcher.find() && !mustHaveQuote) { mustHaveQuote = true; } - if(mustHaveQuote) { + if (mustHaveQuote) { partNameBuffer.append(ConnectorUtils.STRING_DELIMITER); partNameBuffer.append(partName); partNameBuffer.append(ConnectorUtils.STRING_DELIMITER); @@ -271,19 +275,19 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Checks if is crossing encapuslation. * - * @param nestedPath the nested path - * @return true, if is crossing encapuslation - * <code>true</code> if we are breaking encapsulation (see SysML rules in SysML Standard 1.2, p.44): - * isEncapsulated: Boolean [0..1] If true, then the block is treated as a black box; a part typed by this black box can only be connected - * via its ports or directly to its outer boundary. If false, or if a value is not present, then connections can be established to - * elements of its internal structure via deep-nested connector ends. + * @param nestedPath + * the nested path + * @return true, if is crossing encapuslation <code>true</code> if we are breaking encapsulation (see SysML rules in SysML Standard 1.2, p.44): + * isEncapsulated: Boolean [0..1] If true, then the block is treated as a black box; a part typed by this black box can only be connected + * via its ports or directly to its outer boundary. If false, or if a value is not present, then connections can be established to + * elements of its internal structure via deep-nested connector ends. */ public static final boolean isCrossingEncapuslation(final List<Property> nestedPath) { - for(final Property current : nestedPath) { + for (final Property current : nestedPath) { final Type type = current.getType(); - if(type != null) { + if (type != null) { final Block block = UMLUtil.getStereotypeApplication(type, Block.class); - if(block != null && block.isEncapsulated()) { + if (block != null && block.isEncapsulated()) { return true; } } @@ -294,21 +298,23 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. /** * Can display existing connector between views according to nested paths. * - * @param connector a connector existing in the model - * @param sourceView a potential source for this connector - * @param targetView a potential target for this connector - * @return true, if successful - * <code>true</code> if displaying the existing connector between this source and this target view is correct + * @param connector + * a connector existing in the model + * @param sourceView + * a potential source for this connector + * @param targetView + * a potential target for this connector + * @return true, if successful <code>true</code> if displaying the existing connector between this source and this target view is correct */ public static boolean canDisplayExistingConnectorBetweenViewsAccordingToNestedPaths(final Connector connector, final View sourceView, final View targetView) { ConnectorUtils utils = new ConnectorUtils(); final List<Property> sourcePath = utils.getNestedPropertyPath(sourceView, targetView); final List<Property> targetPath = utils.getNestedPropertyPath(targetView, sourceView); boolean hasWantedPath = true; - for(final ConnectorEnd end : connector.getEnds()) { - if(sourceView != null && end.getRole() == sourceView.getElement()) { + for (final ConnectorEnd end : connector.getEnds()) { + if (sourceView != null && end.getRole() == sourceView.getElement()) { hasWantedPath = hasWantedPath && haveSamePath(sourcePath, end); - } else if(targetView != null && end.getRole() == targetView.getElement()) { + } else if (targetView != null && end.getRole() == targetView.getElement()) { hasWantedPath = hasWantedPath && haveSamePath(targetPath, end); } } @@ -316,146 +322,153 @@ public class ConnectorUtils extends org.eclipse.papyrus.uml.service.types.utils. } - + /** * Have same path. * - * @param wantedPath the wanted nested path for the end - * @param end an end + * @param wantedPath + * the wanted nested path for the end + * @param end + * an end * @return true, if successful - * true if the end has as nested path THE wanted path + * true if the end has as nested path THE wanted path */ protected static boolean haveSamePath(final List<Property> wantedPath, final ConnectorEnd end) { Stereotype ste = end.getAppliedStereotype("SysML::Blocks::NestedConnectorEnd");//$NON-NLS-1$ - if(ste != null) { - final NestedConnectorEnd nestedConnectorEnd = (NestedConnectorEnd)end.getStereotypeApplication(ste); + if (ste != null) { + final NestedConnectorEnd nestedConnectorEnd = (NestedConnectorEnd) end.getStereotypeApplication(ste); return nestedConnectorEnd.getPropertyPath().equals(wantedPath); } else { return wantedPath.isEmpty(); } } - - - + + + /** * Can display existing connector between views according to partWithPort. * - * @param connector the connector - * @param sourceView the source view - * @param targetView the target view + * @param connector + * the connector + * @param sourceView + * the source view + * @param targetView + * the target view * @return true, if successful */ public boolean canDisplayExistingConnectorBetweenViewsAccordingToPartWithPort(final Connector connector, final View sourceView, final View targetView) { Property partWithPort = getPartWithPortFromConnector(connector); - if (partWithPort != null){ + if (partWithPort != null) { String partWithPortName = partWithPort.getName(); Type partWithPortType = partWithPort.getType(); EObject sourceContainer = ((View) sourceView.eContainer()).getElement(); - EObject targetContainer = ((View) targetView.eContainer()).getElement(); - + EObject targetContainer = ((View) targetView.eContainer()).getElement(); + boolean sameSourceType = false; - if (sourceContainer instanceof TypedElement){ - sameSourceType = partWithPortType.conformsTo(((TypedElement)sourceContainer).getType()); + if (sourceContainer instanceof TypedElement) { + sameSourceType = partWithPortType.conformsTo(((TypedElement) sourceContainer).getType()); } boolean sameSourceName = partWithPortName.equals(((NamedElement) sourceContainer).getName()); - + boolean sameTargetType = false; - if (targetContainer instanceof TypedElement){ - sameTargetType = partWithPortType.conformsTo(((TypedElement)targetContainer).getType()); + if (targetContainer instanceof TypedElement) { + sameTargetType = partWithPortType.conformsTo(((TypedElement) targetContainer).getType()); } boolean sametargetName = partWithPortName.equals(((NamedElement) targetContainer).getName()); - + return (sameSourceType && sameSourceName) || (sameTargetType && sametargetName); } return true; - } - + } + /** * Gets the partWithPort from the connector. * - * @param connector the connector + * @param connector + * the connector * @return the part with port from connector */ - public Property getPartWithPortFromConnector(final Connector connector){ - if (connector!=null && connector.getEnds() != null){ - for(final ConnectorEnd end : connector.getEnds()) { + public Property getPartWithPortFromConnector(final Connector connector) { + if (connector != null && connector.getEnds() != null) { + for (final ConnectorEnd end : connector.getEnds()) { Property partWithPort = end.getPartWithPort(); - if (partWithPort != null){ + if (partWithPort != null) { return partWithPort; } } } return null; } - + /** * Test if the relationship creation is allowed. - * + * * @param source - * the relationship source can be null + * the relationship source can be null * @param target - * the relationship target can be null + * the relationship target can be null * @param sourceView - * the relationship graphical source can be null + * the relationship graphical source can be null * @param targetView - * the relationship graphical target can be null + * the relationship graphical target can be null * @return true if the creation is allowed */ public static boolean canCreate(EObject source, EObject target, View sourceView, View targetView) { - if((source != null) && !(source instanceof ConnectableElement)) { + if ((source != null) && !(source instanceof ConnectableElement)) { return false; } - if((target != null) && !(target instanceof ConnectableElement)) { + if ((target != null) && !(target instanceof ConnectableElement)) { return false; } - if((sourceView != null) && (targetView != null)) { + if ((sourceView != null) && (targetView != null)) { // Allow to create a self connector on a view -// if(sourceView == targetView) { -// return false; -// } + // if(sourceView == targetView) { + // return false; + // } // Cannot create a connector from a view representing a Part to its own Port (or the opposite) - if((sourceView.getChildren().contains(targetView)) || (targetView.getChildren().contains(sourceView))) { + if ((sourceView.getChildren().contains(targetView)) || (targetView.getChildren().contains(sourceView))) { return false; } // Cannot connect a Part to one of its (possibly indirect) containment, must connect to one of its Port. - if(new ConnectorUtils().getStructureContainers(sourceView).contains(targetView) || new ConnectorUtils().getStructureContainers(targetView).contains(sourceView)) { + if (new ConnectorUtils().getStructureContainers(sourceView).contains(targetView) || new ConnectorUtils().getStructureContainers(targetView).contains(sourceView)) { return false; } } return true; } - - + + /** * Filter connectors that have this property in their <NestedConnectorEnd> property path. + * * @param connectors * @param part * @return connectors that have this property in their <NestedConnectorEnd> property path. */ - public static List<Connector> filterConnectorByPropertyInNestedConnectorEnd(List<Connector> connectors, Property part) { + public static List<Connector> filterConnectorByPropertyInNestedConnectorEnd(List<Connector> connectors, Property part) { List<Connector> res = new ArrayList<Connector>(); - for(Connector connector : connectors) { + for (Connector connector : connectors) { EList<ConnectorEnd> ends = connector.getEnds(); - for(ConnectorEnd connectorEnd : ends) { + for (ConnectorEnd connectorEnd : ends) { NestedConnectorEnd stereotypeApplication = UMLUtil.getStereotypeApplication(connectorEnd, NestedConnectorEnd.class); - if (stereotypeApplication != null){ + if (stereotypeApplication != null) { EList<Property> propertyPath = stereotypeApplication.getPropertyPath(); - for(Property property : propertyPath) { - if (property.equals(part)){ + for (Property property : propertyPath) { + if (property.equals(part)) { res.add(connector); } } } - } + } } return res; - } - - + } + + } |