Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 233707 Details for
Bug 297816
[SysML Parametric Diagram] Papyrus shall provide a parametric diagram editor.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Papyrus Parametric Diagram Git patch
org.eclipse.papyrus.sysml.diagram.parametric.All_20130717.patch (text/plain), 1.28 MB, created by
Régis Chevrel
on 2013-07-23 09:16:57 EDT
(
hide
)
Description:
Papyrus Parametric Diagram Git patch
Filename:
MIME Type:
Creator:
Régis Chevrel
Created:
2013-07-23 09:16:57 EDT
Size:
1.28 MB
patch
obsolete
>diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen >index 7c5953d..7b1b604 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen >@@ -39,6 +39,12 @@ > <affixedNodes href="UML.ReusableParts.idgen#shape_uml_port_as_affixed"/> > <borderedNodeFigure href="UML.ReusableParts.idgen#org.eclipse.papyrus.gmf.diagram.common.figure.SelectableBorderedNodeFigure"/> > </customNodes> >+ <customNodes xsi:type="idgen:CustomClassifierNode" id="shape_sysml_constraintblockproperty_as_composite" label="ConstraintBlockPropertyComposite" editPart="org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockPropertyCompositeEditPart" semanticType="org.eclipse.papyrus.sysml.PartProperty" altSemanticTypes="org.eclipse.papyrus.sysml.ReferenceProperty" tag="[#runtime-defined]" compartments="compartment_sysml_blockproperty_structure" visibleCompartments="compartment_sysml_blockproperty_structure"> >+ <labels href="UML.ReusableParts.idgen#label_uml_property_label"/> >+ <affixedNodes href="#shape_sysml_flowport_as_affixed"/> >+ <affixedNodes href="UML.ReusableParts.idgen#shape_uml_port_as_affixed"/> >+ <borderedNodeFigure href="UML.ReusableParts.idgen#org.eclipse.papyrus.gmf.diagram.common.figure.SelectableBorderedNodeFigure"/> >+ </customNodes> > <customNodes xsi:type="idgen:CustomClassifierNode" id="shape_sysml_dimension_as_classifier" label="Dimension" semanticType="org.eclipse.papyrus.sysml.Dimension" tag="dimension" labels="label_sysml_dimension_name"/> > <customNodes xsi:type="idgen:CustomClassifierNode" id="shape_sysml_constraintblock_as_classifier" label="ConstraintBlock" semanticType="org.eclipse.papyrus.sysml.ConstraintBlock" tag="constraint" labels="label_sysml_constraintblock_name" compartments="compartment_sysml_parameter_as_list compartment_sysml_constraint_as_list" visibleCompartments="compartment_sysml_parameter_as_list compartment_sysml_constraint_as_list"/> > <customNodes xsi:type="idgen:CustomClassifierNode" id="shape_sysml_flowspecification_as_classifier" label="FlowSpecification" semanticType="org.eclipse.papyrus.sysml.FlowSpecification" tag="flowSpecification" labels="label_sysml_flowspecification_name" compartments="compartment_sysml_flowproperty_as_list" visibleCompartments="compartment_sysml_flowproperty_as_list"/> >@@ -117,6 +123,7 @@ > <javaClasses qualifiedName="org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPropertyChildLabelEditPart"/> > <javaClasses qualifiedName="org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortChildLabelEditPart"/> > <javaClasses qualifiedName="org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart"/> >+ <javaClasses qualifiedName="org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockPropertyCompositeEditPart"/> > <javaClasses qualifiedName="org.eclipse.papyrus.sysml.diagram.common.edit.part.AssociationEditPart"/> > <javaClasses qualifiedName="org.eclipse.papyrus.sysml.diagram.common.figure.AssociationFigure"/> > <javaClasses qualifiedName="org.eclipse.papyrus.sysml.diagram.common.edit.policy.ConstraintParameterCompartmentSemanticEditPolicy"/> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/commands/ConstraintExtendedDirectEditionDialog.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/commands/ConstraintExtendedDirectEditionDialog.java >new file mode 100644 >index 0000000..12ec398 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/commands/ConstraintExtendedDirectEditionDialog.java >@@ -0,0 +1,16 @@ >+package org.eclipse.papyrus.sysml.diagram.common.commands; >+ >+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; >+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; >+import org.eclipse.swt.widgets.Shell; >+ >+public class ConstraintExtendedDirectEditionDialog extends ExtendedDirectEditionDialog { >+ >+ public ConstraintExtendedDirectEditionDialog(Shell parentShell, >+ Object object, String initialValue, >+ IDirectEditorConfiguration configuration) { >+ super(parentShell, object, initialValue, configuration); >+ this.title = "Edit Constraint specification"; >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/commands/CreateConstraintPropertyWithTypeConfigureCommandFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/commands/CreateConstraintPropertyWithTypeConfigureCommandFactory.java >new file mode 100644 >index 0000000..fcc3fd0 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/commands/CreateConstraintPropertyWithTypeConfigureCommandFactory.java >@@ -0,0 +1,154 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.common.commands; >+ >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.transaction.RecordingCommand; >+import org.eclipse.emf.transaction.TransactionalEditingDomain; >+import org.eclipse.gmf.runtime.common.core.command.CommandResult; >+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; >+import org.eclipse.gmf.runtime.common.core.command.ICommand; >+import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; >+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; >+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.window.Window; >+import org.eclipse.papyrus.extensionpoints.editors.Activator; >+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; >+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; >+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; >+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; >+import org.eclipse.papyrus.infra.services.edit.commands.AbstractConfigureCommandFactory; >+import org.eclipse.papyrus.infra.services.edit.commands.ConfigureFeatureCommandFactory; >+import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; >+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; >+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; >+import org.eclipse.papyrus.infra.services.edit.utils.GMFCommandUtils; >+import org.eclipse.papyrus.sysml.diagram.common.dialogs.CreateOrSelectConstraintPropertyTypeDialog; >+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.uml2.uml.Package; >+import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.UMLPackage; >+ >+/** >+ * This command factory provides a command that enable Part type to be selected or created during creation. >+ */ >+public class CreateConstraintPropertyWithTypeConfigureCommandFactory extends AbstractConfigureCommandFactory { >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ICommand create(ConfigureRequest request) { >+ >+ ICommand configureCommand = null; >+ >+ Shell shell = Display.getDefault().getActiveShell(); >+ // Start dialog to identify the new part type >+ Property part = (Property)request.getElementToConfigure(); >+ Package partPkg = part.getNearestPackage(); >+ >+ CreateOrSelectConstraintPropertyTypeDialog dialog = new CreateOrSelectConstraintPropertyTypeDialog(shell, partPkg); >+ dialog.open(); >+ if(dialog.getReturnCode() == CreateOrSelectConstraintPropertyTypeDialog.OK) { >+ >+ final ICommand typeCreationCommand = dialog.getNewTypeCreateCommand(); >+ final Type partType = (Type)dialog.getExistingType(); >+ >+ // Abort if type creation command exists but is not executable >+ if((typeCreationCommand != null) && (!typeCreationCommand.canExecute())) { >+ return cancelCommand(request); >+ } else { >+ configureCommand = CompositeCommand.compose(configureCommand, typeCreationCommand); >+ } >+ >+ // Create the configure command that will set the constraint property type >+ ICommand setTypeCommand = new ConfigureElementCommand(request) { >+ >+ @Override >+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >+ >+ Property part = (Property)getElementToEdit(); >+ if(partType != null) { >+ part.setType(partType); >+ } else { >+ Type newType = (Type)GMFCommandUtils.getCommandEObjectResult(typeCreationCommand); >+ createConstraintBlockConstraint(newType, monitor, info); >+ part.setType(newType); >+ } >+ return CommandResult.newOKCommandResult(part); >+ } >+ >+ private void createConstraintBlockConstraint(Type newType, IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >+ // Create the constraint attached to the ConstraintBlock >+ IElementEditService commandService = ElementEditServiceUtils.getCommandProvider(newType); >+ if(commandService != null) { >+ CreateElementRequest createTypeRequest = new CreateElementRequest(newType, UMLElementTypes.CONSTRAINT); >+ createTypeRequest.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, >+ new ConfigureFeatureCommandFactory(UMLPackage.eINSTANCE.getNamedElement_Name(), newType.getName() + "Specification")); >+ ICommand newConstraintCreateCommand = commandService.getEditCommand(createTypeRequest); >+ if (newConstraintCreateCommand.canExecute()) { >+ newConstraintCreateCommand.execute(monitor, info); >+ Object newObject = newConstraintCreateCommand.getCommandResult().getReturnValue(); >+ // Create the constraint specification >+ if (newObject instanceof EObject) { >+ final EObject newElement = (EObject)newObject; >+ final IDirectEditorConfiguration configuration = initExtendedEditorConfiguration(newElement); >+ Dialog dialog = new ConstraintExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), newElement, configuration.getTextToEdit(newElement), configuration); >+ final Dialog finalDialog = dialog; >+ if(Window.OK == dialog.open()) { >+ TransactionalEditingDomain domain = getEditingDomain(); >+ RecordingCommand command = new RecordingCommand(domain, "Edit Constraint specification") { >+ @Override >+ protected void doExecute() { >+ configuration.postEditAction(newElement, ((ILabelEditorDialog)finalDialog).getValue()); >+ } >+ }; >+ domain.getCommandStack().execute(command); >+ } >+ } >+ >+ } >+ } >+ } >+ }; >+ >+ configureCommand = CompositeCommand.compose(configureCommand, setTypeCommand); >+ return configureCommand; >+ } >+ >+ return cancelCommand(request); >+ } >+ >+ /** >+ * Initializes the extended editor configuration >+ */ >+ protected IDirectEditorConfiguration initExtendedEditorConfiguration(EObject element) { >+ IDirectEditorConfiguration configuration; >+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + element.eClass().getInstanceClassName()); >+ if(languagePreferred != null && !languagePreferred.equals("")) { >+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, element.eClass().getInstanceClassName()); >+ } else { >+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, element.eClass().getInstanceClassName()); >+ } >+ return configuration; >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/dialogs/CreateOrSelectConstraintPropertyTypeDialog.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/dialogs/CreateOrSelectConstraintPropertyTypeDialog.java >new file mode 100644 >index 0000000..069c18f >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/dialogs/CreateOrSelectConstraintPropertyTypeDialog.java >@@ -0,0 +1,122 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.common.dialogs; >+ >+import org.eclipse.papyrus.sysml.constraints.ConstraintsPackage; >+import org.eclipse.papyrus.sysml.diagram.common.messages.Messages; >+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; >+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.uml2.uml.NamedElement; >+import org.eclipse.uml2.uml.UMLPackage; >+ >+/** >+ * Dialog for initialization of Part (Property) type (the type is either selected or created). >+ */ >+public class CreateOrSelectConstraintPropertyTypeDialog extends CreateOrSelectTypeDialog { >+ >+ /** Constructor */ >+ public CreateOrSelectConstraintPropertyTypeDialog(Shell shell, NamedElement owner) { >+ super(shell, owner, SysMLElementTypes.CONSTRAINT_BLOCK, UMLPackage.eINSTANCE.getTypedElement_Type(), ConstraintsPackage.eINSTANCE.getConstraintBlock(), UMLElementTypes.PACKAGE, UMLPackage.eINSTANCE.getPackage_PackagedElement(), null); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getDialogTitle() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_DialogTitle; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getSelectionSectionTitle() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_SelectionSectionTitle; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getSelectionSectionRadioLabel() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_SelectionSectionRadioLabel; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getCreationSectionTitle() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_CreationSectionTitle; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getCreationSectionRadioLabel() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_CreationSectionRadioLabel; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getNewTypeNameLabel() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_NewTypeNameLabel; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getNewTypeContainerNameLabel() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_NewTypeContainerNameLabel; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getNewTypeContainerDialogTitle() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_SelectNewTypeContainerDialogTitle; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getNewTypeContainerDialogMessage() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_SelectNewTypeContainerDialogMessage; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getTypeDialogTitle() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_SelectTypeDialogTitle; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getTypeDialogMessage() { >+ return Messages.CreateOrSelectConstraintPropertyTypeDialog_SelectTypeDialogMessage; >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/part/ConstraintBlockPropertyCompositeEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/part/ConstraintBlockPropertyCompositeEditPart.java >new file mode 100644 >index 0000000..a7521f8 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/part/ConstraintBlockPropertyCompositeEditPart.java >@@ -0,0 +1,222 @@ >+/***************************************************************************** >+ * Copyright (c) 2011-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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.common.edit.part; >+ >+import java.util.List; >+ >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.PositionConstants; >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gef.EditPart; >+import org.eclipse.gef.EditPolicy; >+import org.eclipse.gef.Request; >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.editpolicies.NonResizableEditPolicy; >+import org.eclipse.gef.requests.CreateRequest; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy; >+import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; >+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.figure.SelectableBorderedNodeFigure; >+import org.eclipse.papyrus.sysml.diagram.common.edit.policy.BlockPropertyCompositeSemanticEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.common.figure.ConstraintBlockPropertyCompositeFigure; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConstraintNodeLabelEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConstraintParameterAffixedNodeEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PortAffixedNodeEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PropertyNodeLabelEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.policy.EncapsulatedClassifierResizableShapeEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.edit.policy.StructuredClassifierCreationEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AffixedNodeAlignmentEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideRelatedContentsEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure; >+import org.eclipse.papyrus.uml.diagram.common.locator.ConstraintParameterPositionLocator; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.UMLPackage; >+ >+public class ConstraintBlockPropertyCompositeEditPart extends AbstractElementEditPart { >+ >+ public ConstraintBlockPropertyCompositeEditPart(View view) { >+ super(view); >+ } >+ >+ @Override >+ protected void createDefaultEditPolicies() { >+ super.createDefaultEditPolicies(); >+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new BlockPropertyCompositeSemanticEditPolicy()); >+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); >+ installEditPolicy(ShowHideRelatedContentsEditPolicy.SHOW_HIDE_RELATED_CONTENTS_POLICY, new ShowHideRelatedContentsEditPolicy()); >+ installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); >+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); >+ installEditPolicy(AffixedNodeAlignmentEditPolicy.AFFIXED_CHILD_ALIGNMENT_ROLE, new AffixedNodeAlignmentEditPolicy()); >+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new StructuredClassifierCreationEditPolicy()); >+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new EncapsulatedClassifierResizableShapeEditPolicy()); >+ } >+ >+ @Override >+ protected LayoutEditPolicy createLayoutEditPolicy() { >+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { >+ >+ @Override >+ protected EditPolicy createChildEditPolicy(EditPart child) { >+ if(child instanceof IBorderItemEditPart) { >+ return new BorderItemResizableEditPolicy(); >+ } >+ >+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >+ if(result == null) { >+ result = new NonResizableEditPolicy(); >+ } >+ return result; >+ } >+ >+ @Override >+ protected Command getMoveChildrenCommand(Request request) { >+ return null; >+ } >+ >+ @Override >+ protected Command getCreateCommand(CreateRequest request) { >+ return null; >+ } >+ }; >+ return lep; >+ } >+ >+ @Override >+ protected boolean addFixedChild(EditPart childEditPart) { >+ >+ if(childEditPart instanceof PropertyNodeLabelEditPart) { >+ ((PropertyNodeLabelEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); >+ return true; >+ } >+ if(childEditPart instanceof ConstraintNodeLabelEditPart) { >+ ((ConstraintNodeLabelEditPart)childEditPart).setLabel((((ConstraintBlockPropertyCompositeFigure)getPrimaryShape()).getConstraintLabel())); >+ return true; >+ } >+ >+ if(childEditPart instanceof ConstraintParameterAffixedNodeEditPart) { >+ IBorderItemLocator locator = new ConstraintParameterPositionLocator(getMainFigure(), PositionConstants.NONE); >+ getBorderedFigure().getBorderItemContainer().add(((ConstraintParameterAffixedNodeEditPart)childEditPart).getFigure(), locator); >+ return true; >+ } >+ >+ return false; >+ } >+ >+ @Override >+ protected boolean removeFixedChild(EditPart childEditPart) { >+ >+ if(childEditPart instanceof PropertyNodeLabelEditPart) { >+ return true; >+ } >+ >+ if(childEditPart instanceof FlowPortAffixedNodeEditPart) { >+ getBorderedFigure().getBorderItemContainer().remove(((FlowPortAffixedNodeEditPart)childEditPart).getFigure()); >+ return true; >+ } >+ if(childEditPart instanceof PortAffixedNodeEditPart) { >+ getBorderedFigure().getBorderItemContainer().remove(((PortAffixedNodeEditPart)childEditPart).getFigure()); >+ return true; >+ } >+ >+ return false; >+ } >+ >+ @Override >+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { >+ if(editPart instanceof IBorderItemEditPart) { >+ return getBorderedFigure().getBorderItemContainer(); >+ } >+ >+ return getContentPane(); >+ } >+ >+ @Override >+ protected NodeFigure createNodeFigure() { >+ return new SelectableBorderedNodeFigure(createMainFigure()); >+ } >+ >+ @Override >+ protected IFigure createNodeShape() { >+ primaryShape = new ConstraintBlockPropertyCompositeFigure(); >+ return primaryShape; >+ } >+ >+ >+ @Override >+ public NodeNamedElementFigure getPrimaryShape() { >+ return (NodeNamedElementFigure)primaryShape; >+ } >+ >+ @Override >+ public EditPart getPrimaryChildEditPart() { >+ return getChildBySemanticHint(UMLGraphicalTypes.LABEL_UML_PROPERTY_LABEL_ID); >+ } >+ >+ @SuppressWarnings("rawtypes") >+ @Override >+ protected void refreshVisuals() { >+ super.refreshVisuals(); >+ List children = getChildren(); >+ for (Object editPart : children) { >+ if (editPart instanceof EditPart) { >+ ((EditPart) editPart).refresh(); >+ } >+ } >+ } >+ >+ /** >+ * <pre> >+ * >+ * {@inheritDoc} >+ * </pre> >+ */ >+ @Override >+ protected void handleNotificationEvent(Notification event) { >+ >+ // A visual refresh may also be needed when the following properties are changing : aggregation, type, or the related association. >+ if(resolveSemanticElement() != null) { >+ EObject element = resolveSemanticElement(); >+ >+ if((element != null) && (element.equals(event.getNotifier())) && (element instanceof Property)) { >+ >+ if(UMLPackage.eINSTANCE.getProperty_Aggregation().equals(event.getFeature())) { >+ refreshVisuals(); >+ } >+ >+ if(UMLPackage.eINSTANCE.getTypedElement_Type().equals(event.getFeature())) { >+ refreshVisuals(); >+ } >+ >+ if(UMLPackage.eINSTANCE.getProperty_Association().equals(event.getFeature())) { >+ refreshVisuals(); >+ } >+ } >+ } >+ super.handleNotificationEvent(event); >+ refresh(); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/BlockPropertyStructureCompartmentSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/BlockPropertyStructureCompartmentSemanticEditPolicy.java >index 93daef1..5bcd7e7 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/BlockPropertyStructureCompartmentSemanticEditPolicy.java >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/BlockPropertyStructureCompartmentSemanticEditPolicy.java >@@ -23,6 +23,7 @@ > import org.eclipse.papyrus.gmf.diagram.common.edit.policy.CompartmentSemanticEditPolicy; > import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateActorPartWithTypeConfigureCommandFactory; >+import org.eclipse.papyrus.sysml.diagram.common.commands.CreateConstraintPropertyWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreatePartWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateReferenceWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateValueWithTypeConfigureCommandFactory; >@@ -72,6 +73,11 @@ > if(UMLElementTypes.PROPERTY == req.getElementType()) { > req.setContainer(type); > } >+ >+ if(SysMLElementTypes.CONSTRAINT_PROPERTY == req.getElementType()) { >+ req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateConstraintPropertyWithTypeConfigureCommandFactory()); >+ } >+ > > } else if ((UMLElementTypes.PROPERTY == req.getElementType()) || (Arrays.asList(req.getElementType().getAllSuperTypes()).contains(UMLElementTypes.PROPERTY))) { > // Forbid Property::qualifier creation >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java >index 6c557f5..622dd60 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PartCompartmentSemanticEditPolicy.java >@@ -17,6 +17,7 @@ > import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; > import org.eclipse.papyrus.gmf.diagram.common.edit.policy.CompartmentSemanticEditPolicy; > import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; >+import org.eclipse.papyrus.sysml.diagram.common.commands.CreateConstraintPropertyWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreatePartWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; > >@@ -35,6 +36,10 @@ > req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreatePartWithTypeConfigureCommandFactory()); > } > >+ if(SysMLElementTypes.CONSTRAINT_PROPERTY == req.getElementType()) { >+ req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateConstraintPropertyWithTypeConfigureCommandFactory()); >+ } >+ > return super.getCreateCommand(req); > } > } >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PropertyCompartmentSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PropertyCompartmentSemanticEditPolicy.java >index 823e18e..ed79565 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PropertyCompartmentSemanticEditPolicy.java >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/PropertyCompartmentSemanticEditPolicy.java >@@ -18,6 +18,7 @@ > import org.eclipse.papyrus.gmf.diagram.common.edit.policy.CompartmentSemanticEditPolicy; > import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateActorPartWithTypeConfigureCommandFactory; >+import org.eclipse.papyrus.sysml.diagram.common.commands.CreateConstraintPropertyWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateFlowPortWithFlowSpecificationConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreatePartWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateReferenceWithTypeConfigureCommandFactory; >@@ -50,7 +51,10 @@ > if(SysMLElementTypes.FLOW_PORT_NA == req.getElementType()) { > req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateFlowPortWithFlowSpecificationConfigureCommandFactory()); > } >- >+ if(SysMLElementTypes.CONSTRAINT_PROPERTY == req.getElementType()) { >+ req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateConstraintPropertyWithTypeConfigureCommandFactory()); >+ } >+ > return super.getCreateCommand(req); > } > } >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java >index 2552f15..f045b89 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/edit/policy/StructureCompartmentSemanticEditPolicy.java >@@ -18,6 +18,7 @@ > import org.eclipse.papyrus.gmf.diagram.common.edit.policy.CompartmentSemanticEditPolicy; > import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateActorPartWithTypeConfigureCommandFactory; >+import org.eclipse.papyrus.sysml.diagram.common.commands.CreateConstraintPropertyWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreatePartWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateReferenceWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.diagram.common.commands.CreateValueWithTypeConfigureCommandFactory; >@@ -50,6 +51,10 @@ > req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateValueWithTypeConfigureCommandFactory()); > } > >+ if(SysMLElementTypes.CONSTRAINT_PROPERTY == req.getElementType()) { >+ req.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateConstraintPropertyWithTypeConfigureCommandFactory()); >+ } >+ > return super.getCreateCommand(req); > } > } >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/messages/Messages.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/messages/Messages.java >index 5be5e2b..ab9ee37 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/messages/Messages.java >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/messages/Messages.java >@@ -61,6 +61,28 @@ > > public static String CreateOrSelectBlockPropertyTypeDialog_SelectNewTypeContainerDialogMessage; > >+ public static String CreateOrSelectConstraintPropertyTypeDialog_DialogTitle; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_SelectionSectionTitle; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_SelectionSectionRadioLabel; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_CreationSectionTitle; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_CreationSectionRadioLabel; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_NewTypeNameLabel; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_NewTypeContainerNameLabel; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_SelectTypeDialogTitle; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_SelectTypeDialogMessage; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_SelectNewTypeContainerDialogTitle; >+ >+ public static String CreateOrSelectConstraintPropertyTypeDialog_SelectNewTypeContainerDialogMessage; >+ > public static String CreateOrSelectActorPartTypeDialog_DialogTitle; > > public static String CreateOrSelectActorPartTypeDialog_SelectionSectionTitle; >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/messages/messages.properties b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/messages/messages.properties >index cece3d4..a5d917c 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/messages/messages.properties >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/messages/messages.properties >@@ -29,6 +29,22 @@ > CreateOrSelectBlockPropertyTypeDialog_SelectNewTypeContainerDialogTitle=Type container selection > CreateOrSelectBlockPropertyTypeDialog_SelectNewTypeContainerDialogMessage=Select the container for the new Block > >+CreateOrSelectConstraintPropertyTypeDialog_DialogTitle=ConstraintProperty type initialization >+CreateOrSelectConstraintPropertyTypeDialog_SelectionSectionTitle=Select an existing type (ConstraintBlock) >+CreateOrSelectConstraintPropertyTypeDialog_SelectionSectionRadioLabel=ConstraintBlock (type) selection mode >+ >+CreateOrSelectConstraintPropertyTypeDialog_CreationSectionTitle=Create a new type (ConstraintBlock) >+CreateOrSelectConstraintPropertyTypeDialog_CreationSectionRadioLabel=ConstraintBlock (type) creation mode >+CreateOrSelectConstraintPropertyTypeDialog_NewTypeNameLabel=Select new ConstraintBlock name >+CreateOrSelectConstraintPropertyTypeDialog_NewTypeContainerNameLabel=Select new ConstraintBlock container >+ >+CreateOrSelectConstraintPropertyTypeDialog_SelectTypeDialogTitle=Type selection >+CreateOrSelectConstraintPropertyTypeDialog_SelectTypeDialogMessage=Select a ConstraintBlock to use as new element type >+ >+CreateOrSelectConstraintPropertyTypeDialog_SelectNewTypeContainerDialogTitle=Type container selection >+CreateOrSelectConstraintPropertyTypeDialog_SelectNewTypeContainerDialogMessage=Select the container for the new ConstraintBlock >+ >+ > CreateOrSelectActorPartTypeDialog_DialogTitle=ActorPart type initialization > CreateOrSelectActorPartTypeDialog_SelectionSectionTitle=Select an existing type (Actor) > CreateOrSelectActorPartTypeDialog_SelectionSectionRadioLabel=Actor (type) selection mode >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintNodeLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintNodeLabelEditPart.java >new file mode 100644 >index 0000000..0b592db >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintNodeLabelEditPart.java >@@ -0,0 +1,70 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.uml.diagram.common.edit.part; >+ >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; >+import org.eclipse.uml2.uml.Constraint; >+ >+/** >+ * Abstract non-diagram specific edit part for node label representing {@link Constraint}. >+ * This class is adapted from edit parts generated by GMF Tooling. >+ */ >+public class ConstraintNodeLabelEditPart extends AbstractElementNodeLabelEditPart { >+ >+ protected static final String LEFT_BRACE = "{"; >+ protected static final String RIGHT_BRACE = "}"; >+ >+ public ConstraintNodeLabelEditPart(View view) { >+ super(view); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getLabelRole() { >+ return "Label"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getIconPathRole() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ @Override >+ protected void refreshVisuals() { >+ super.refreshVisuals(); >+ IFigure figure = getFigure(); >+ if (figure instanceof WrappingLabel) { >+ EObject resolveSemanticElement = resolveSemanticElement(); >+ if (resolveSemanticElement instanceof Constraint) { >+ String specificationValue = ValueSpecificationUtil.getSpecificationValue(((Constraint) resolveSemanticElement).getSpecification()); >+ specificationValue = (specificationValue == null ? "" : specificationValue); >+ ((WrappingLabel) figure).setText(LEFT_BRACE + specificationValue + RIGHT_BRACE); >+ } >+ } >+ } >+ >+ @Override >+ protected void handleNotificationEvent(Notification event) { >+ // do nothing else refresh >+ refresh(); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/factory/ConstraintBlockPropertyCompositeClassifierViewFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/factory/ConstraintBlockPropertyCompositeClassifierViewFactory.java >new file mode 100644 >index 0000000..203ac67 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/factory/ConstraintBlockPropertyCompositeClassifierViewFactory.java >@@ -0,0 +1,83 @@ >+package org.eclipse.papyrus.sysml.diagram.common.factory; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.diagram.core.services.ViewService; >+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.factory.ShapeViewFactory; >+import org.eclipse.papyrus.infra.emf.utils.EMFHelper; >+import org.eclipse.papyrus.sysml.constraints.ConstraintBlock; >+import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.uml2.uml.Class; >+import org.eclipse.uml2.uml.Constraint; >+import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.util.UMLUtil; >+ >+public class ConstraintBlockPropertyCompositeClassifierViewFactory extends ShapeViewFactory { >+ >+ /** >+ * Creates ConstraintBlockPropertyComposite view and add Label and Compartment nodes >+ */ >+ @Override >+ protected void decorateView(View containerView, View view, IAdaptable element, String semanticHint, int index, boolean persisted) { >+ >+ getViewService().createNode(element, view, UMLGraphicalTypes.LABEL_UML_PROPERTY_LABEL_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); >+ getViewService().createNode(element, view, SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); >+ >+ if (element != null) { >+ EObject newElement = EMFHelper.getEObject(element); >+ if (newElement instanceof Property && UMLUtil.getStereotypeApplication((Property)newElement, ConstraintProperty.class) != null) { >+ Property constraintProperty = (Property) newElement; >+ >+ ViewService.createNode(view, getConstraint(constraintProperty), UMLGraphicalTypes.SHAPE_UML_CONSTRAINT_AS_LABEL_ID, getPreferencesHint()); >+ >+ >+ List<Property> constraintParameters = getConstraintParameters(constraintProperty); >+ for (Property constraintParameter : constraintParameters) { >+ ViewService.createNode(view, constraintParameter, UMLGraphicalTypes.SHAPE_UML_PROPERTY_AS_AFFIXED_ID, getPreferencesHint()); >+ } >+ } >+ } >+ >+ // this action needs to be done after the compartments creation >+ super.decorateView(containerView, view, element, semanticHint, index, persisted); >+ } >+ >+ private List<Property> getConstraintParameters(Property constraintProperty) { >+ List<Property> constraintParameters = new ArrayList<Property>(); >+ Type type = constraintProperty.getType(); >+ if (type instanceof Class && UMLUtil.getStereotypeApplication(type, ConstraintBlock.class) != null) { // instanceof ensure type is not null >+ Class constraintBlock = (Class)type; >+ EList<Property> ownedAttributes = constraintBlock.getOwnedAttributes(); >+ for (Property property : ownedAttributes) { >+ if (property.getAppliedStereotypes().isEmpty()) { >+ constraintParameters.add(property); >+ } >+ } >+ } >+ return constraintParameters; >+ } >+ >+ private Constraint getConstraint(Property constraintProperty) { >+ Type type = constraintProperty.getType(); >+ if (type instanceof Class && UMLUtil.getStereotypeApplication(type, ConstraintBlock.class) != null) { // instanceof ensure type is not null >+ Class constraintBlock = (Class)type; >+ EList<Constraint> ownedRules = constraintBlock.getOwnedRules(); >+ for (Constraint constraint : ownedRules) { >+ return constraint; >+ } >+ } >+ return null; >+ } >+ >+ // Start of user code preferences >+ // End of user code >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/figure/ConstraintBlockPropertyCompositeFigure.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/figure/ConstraintBlockPropertyCompositeFigure.java >new file mode 100644 >index 0000000..8d4475c >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/figure/ConstraintBlockPropertyCompositeFigure.java >@@ -0,0 +1,49 @@ >+package org.eclipse.papyrus.sysml.diagram.common.figure; >+ >+import org.eclipse.draw2d.PositionConstants; >+import org.eclipse.draw2d.text.FlowPage; >+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >+import org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusRoundedNodeFigure; >+ >+public class ConstraintBlockPropertyCompositeFigure extends PapyrusRoundedNodeFigure { >+ >+ protected WrappingLabel constraintLabel; >+ >+ /** main flow page */ >+ protected FlowPage page; >+ >+ public ConstraintBlockPropertyCompositeFigure() { >+ super(); >+ corner = 50; >+ >+ nameLabel = new WrappingLabel(); >+ nameLabel.setOpaque(false); >+ nameLabel.setAlignment(PositionConstants.MIDDLE); >+ add(nameLabel); >+ >+ >+ constraintLabel = new WrappingLabel(); >+ constraintLabel.setAlignment(PositionConstants.RIGHT); >+ add(constraintLabel); >+ } >+ >+ /** >+ * >+ * @see org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeNamedElementFigure#getNameLabel() >+ * >+ * @return >+ */ >+ public WrappingLabel getNameLabel() { >+ return nameLabel; >+ } >+ >+ /** >+ * >+ * @return the textflow of the constraint that contain the string of the >+ * specification >+ */ >+ public WrappingLabel getConstraintLabel() { >+ return constraintLabel; >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/figure/SysMLDiagramFrameFigure.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/figure/SysMLDiagramFrameFigure.java >new file mode 100644 >index 0000000..7278e6b >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/figure/SysMLDiagramFrameFigure.java >@@ -0,0 +1,151 @@ >+/***************************************************************************** >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.common.figure; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.draw2d.Graphics; >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.MarginBorder; >+import org.eclipse.draw2d.OrderedLayout; >+import org.eclipse.draw2d.RectangleFigure; >+import org.eclipse.draw2d.ToolbarLayout; >+import org.eclipse.draw2d.geometry.Dimension; >+import org.eclipse.draw2d.geometry.Rectangle; >+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >+import org.eclipse.papyrus.uml.diagram.common.draw2d.InteractionFigure; >+import org.eclipse.papyrus.uml.diagram.common.draw2d.LeftToolbarLayout; >+import org.eclipse.papyrus.uml.diagram.common.figure.node.AutomaticCompartmentLayoutManager; >+import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure; >+ >+public class SysMLDiagramFrameFigure extends NodeNamedElementFigure { >+ >+ private WrappingLabel frameLabel; >+ >+ private RectangleFigure frameLabelContainerFigure; >+ >+ private RectangleFigure structureCompartmentFigure; >+ >+ >+ public SysMLDiagramFrameFigure() { >+ super(); >+ createContents(); >+ } >+ >+ protected void createContents() { >+ add(createInteractionFigureHeader()); >+ add(createStructureCompartmentFigures()); >+ setLayoutManager(new SysMLLayoutLayoutManager()); >+ } >+ >+ protected RectangleFigure createInteractionFigureHeader() { >+ if (this.frameLabel == null) { >+ this.frameLabel = new WrappingLabel() { >+ >+ @Override >+ public Dimension getPreferredSize(final int wHint, final int hHint) { >+ final Dimension preferredSize = super.getPreferredSize(wHint, hHint); >+ if(preferredSize.width == 0) { >+ return preferredSize; >+ } >+ return new Dimension(preferredSize.width + 2, preferredSize.height + 2); >+ } >+ }; >+ } >+ >+ final InteractionFigure interactionFigure = new InteractionFigure(); >+ interactionFigure.setBorder(new MarginBorder(3, 3, 3, 3)); >+ interactionFigure.setLayoutManager(new LeftToolbarLayout()); >+ interactionFigure.add(frameLabel); >+ >+ frameLabelContainerFigure = new RectangleFigure(); >+ frameLabelContainerFigure.setOutline(false); >+ frameLabelContainerFigure.setFill(false); >+ frameLabelContainerFigure.setLayoutManager(new ToolbarLayout(false)); >+ frameLabelContainerFigure.setLineStyle(Graphics.LINE_DASHDOTDOT); >+ frameLabelContainerFigure.add(interactionFigure, OrderedLayout.ALIGN_CENTER); >+ return frameLabelContainerFigure; >+ } >+ >+ @Override >+ public WrappingLabel getNameLabel() { >+ if (frameLabel == null) { >+ createInteractionFigureHeader(); >+ } >+ return frameLabel; >+ } >+ >+ public RectangleFigure getLabelContainer() { >+ return frameLabelContainerFigure; >+ } >+ >+ public IFigure getStructureCompartmentFigure() { >+ if (structureCompartmentFigure == null) { >+ createStructureCompartmentFigures(); >+ } >+ return structureCompartmentFigure; >+ } >+ >+ public IFigure createStructureCompartmentFigures() { >+ structureCompartmentFigure = new RectangleFigure(); >+ structureCompartmentFigure.setFill(false); >+ >+ return structureCompartmentFigure; >+ } >+ >+ /** >+ * this is the layout manager in charge to place element in the enumeration >+ * >+ */ >+ private class SysMLLayoutLayoutManager extends AutomaticCompartmentLayoutManager { >+ >+ /** >+ * >+ * {@inheritDoc} >+ */ >+ public void layout(final IFigure container) { >+ List<IFigure> figuresToRemove = new ArrayList<IFigure>(); >+ for(int i = 0; i < container.getChildren().size(); i++) { >+ IFigure currentCompartment = (IFigure)container.getChildren().get(i); >+ // this is a visible compartment >+ if(currentCompartment == structureCompartmentFigure) { >+ Rectangle bound = new Rectangle(currentCompartment.getBounds()); >+ currentCompartment.invalidate(); >+ Dimension pref = currentCompartment.getPreferredSize(); >+ currentCompartment.invalidate(); >+ Dimension prefConstraint = currentCompartment.getPreferredSize(container.getBounds().width - 40, -1); >+ if(pref.width < prefConstraint.width) { >+ bound.setSize(pref); >+ } else { >+ bound.setSize(prefConstraint); >+ } >+ int offset = 24; >+ bound.x = container.getBounds().x; >+ bound.y = container.getBounds().y + offset; >+ bound.width = container.getBounds().width; >+ bound.height = container.getBounds().height - offset; >+ currentCompartment.setBounds(bound); >+ } else if (currentCompartment == frameLabelContainerFigure) { >+ Rectangle boundLabel = new Rectangle(frameLabelContainerFigure.getBounds()); >+ boundLabel.setSize(frameLabelContainerFigure.getPreferredSize()); >+ frameLabelContainerFigure.setBounds(boundLabel); >+ } else { >+ // remove other figure >+ figuresToRemove.add(currentCompartment); >+ } >+ } >+ for (IFigure iFigure : figuresToRemove) { >+ container.getChildren().remove(iFigure); >+ } >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLGraphicalTypes.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLGraphicalTypes.java >index f43a4dd..eaa7b09 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLGraphicalTypes.java >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/sysml/diagram/common/utils/SysMLGraphicalTypes.java >@@ -25,6 +25,8 @@ > > public static final String SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID = "shape_sysml_blockproperty_as_composite"; //$NON-NLS-1$ > >+ public static final String SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID = "shape_sysml_constraintblockproperty_as_composite"; //$NON-NLS-1$ >+ > public static final String SHAPE_SYSML_DIMENSION_AS_CLASSIFIER_ID = "shape_sysml_dimension_as_classifier"; //$NON-NLS-1$ > > public static final String SHAPE_SYSML_CONSTRAINTBLOCK_AS_CLASSIFIER_ID = "shape_sysml_constraintblock_as_classifier"; //$NON-NLS-1$ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorEditPart.java >index 1728af0..7888408 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorEditPart.java >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorEditPart.java >@@ -17,8 +17,13 @@ > import org.eclipse.gef.EditPart; > import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; > import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultSemanticEditPolicy; >+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; >+import org.eclipse.papyrus.sysml.blocks.BindingConnector; >+import org.eclipse.papyrus.sysml.blocks.BlocksPackage; > import org.eclipse.papyrus.uml.diagram.common.figure.ConnectorEdgeFigure; >+import org.eclipse.papyrus.uml.tools.utils.UMLUtil; >+import org.eclipse.uml2.uml.Connector; >+import org.eclipse.uml2.uml.Element; > > public class ConnectorEditPart extends AbstractElementLinkEditPart { > >@@ -91,33 +96,14 @@ > return (ConnectorEdgeFigure)getFigure(); > } > >- /** >- * {@inheritDoc} >- */ > @Override >- protected void refreshLineType() { >- // Start of user code custom line type >- super.refreshLineType(); >- // End of user code >+ protected void refreshLineWidth() { >+ if (org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication((Element)resolveSemanticElement(), BindingConnector.class) != null) { >+ setLineWidth(2); >+ } >+ else { >+ setLineWidth(1); >+ } > } > >- /** >- * {@inheritDoc} >- */ >- @Override >- protected void refreshArrowSource() { >- // Start of user code custom source decoration >- super.refreshArrowSource(); >- // End of user code >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- protected void refreshArrowTarget() { >- // Start of user code custom target decoration >- super.refreshArrowTarget(); >- // End of user code >- } > } >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintParameterAffixedNodeEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintParameterAffixedNodeEditPart.java >new file mode 100644 >index 0000000..a450a7d >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintParameterAffixedNodeEditPart.java >@@ -0,0 +1,201 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.uml.diagram.common.edit.part; >+ >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.LayoutListener; >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.gef.EditPart; >+import org.eclipse.gef.EditPolicy; >+import org.eclipse.gef.GraphicalEditPart; >+import org.eclipse.gef.Request; >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.editpolicies.LayoutEditPolicy; >+import org.eclipse.gef.editpolicies.NonResizableEditPolicy; >+import org.eclipse.gef.handles.MoveHandle; >+import org.eclipse.gef.requests.CreateRequest; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; >+import org.eclipse.gmf.runtime.notation.NotationPackage; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.edit.policy.ExternalLabelPrimaryDragRoleEditPolicy; >+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeIconlDisplayEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideLabelEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.figure.node.AffixedNamedElementFigure; >+import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure; >+import org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+ >+public class ConstraintParameterAffixedNodeEditPart extends AbstractElementBorderEditPart { >+ >+ private LayoutListener.Stub layoutInitializationListener; >+ >+ public ConstraintParameterAffixedNodeEditPart(View view) { >+ super(view); >+ } >+ >+ >+ @Override >+ protected EditPart createChild(Object model) { >+ return super.createChild(model); >+ } >+ >+ >+ protected void createDefaultEditPolicies() { >+ super.createDefaultEditPolicies(); >+ installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeIconlDisplayEditPolicy() { >+ >+ /** >+ * <pre> >+ * {@inheritDoc} >+ * >+ * This modifies the edit policy in order to call refreshVisuals() whenever the stereotype image to show is null. >+ * (required to show the Port default image correctly). >+ * </pre> >+ */ >+ @Override >+ protected void refreshStereotypeDisplay() { >+ if(getHost() instanceof IPapyrusEditPart) { >+ IFigure figure = ((IPapyrusEditPart)getHost()).getPrimaryShape(); >+ >+ if((figure instanceof IPapyrusUMLElementFigure) && (stereotypeIconToDisplay() != null)) { >+ ((IPapyrusUMLElementFigure)figure).setStereotypeDisplay(null, stereotypeIconToDisplay()); >+ } else { >+ refreshVisuals(); >+ } >+ } >+ } >+ >+ }); >+ >+ installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy()); >+ } >+ >+ @Override >+ protected LayoutEditPolicy createLayoutEditPolicy() { >+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { >+ >+ protected EditPolicy createChildEditPolicy(EditPart child) { >+ if(child instanceof IBorderItemEditPart) { // External labels >+ return new ExternalLabelPrimaryDragRoleEditPolicy() { >+ >+ @SuppressWarnings("rawtypes") >+ protected List createSelectionHandles() { >+ MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); >+ mh.setBorder(null); >+ return Collections.singletonList(mh); >+ } >+ }; >+ } >+ >+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >+ if(result == null) { >+ result = new NonResizableEditPolicy(); >+ } >+ return result; >+ } >+ >+ protected Command getMoveChildrenCommand(Request request) { >+ return null; >+ } >+ >+ protected Command getCreateCommand(CreateRequest request) { >+ return null; >+ } >+ }; >+ return lep; >+ } >+ >+ @Override >+ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { >+ IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); >+ borderItemContainer.add(borderItemEditPart.getFigure(), locator); >+ return; >+ } >+ >+ @Override >+ public EditPart getPrimaryChildEditPart() { >+ return getChildBySemanticHint(UMLGraphicalTypes.AFFIXEDLABEL_UML_PORT_LABEL_ID); >+ } >+ >+ /** >+ * <pre> >+ * Calls the figure refresh when a change event is detected on >+ * UMLPackage.eINSTANCE.getProperty_Aggregation(). >+ * >+ * {@inheritDoc} >+ * </pre> >+ */ >+ @Override >+ protected void handleNotificationEvent(Notification event) { >+ >+ // When the constraint parameter position changes, its position on parent side may change and requires a visual refresh. >+ Object feature = event.getFeature(); >+ if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { >+ refreshVisuals(); >+ } >+ >+ super.handleNotificationEvent(event); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected IFigure createNodeShape() { >+ return primaryShape = new AffixedNamedElementFigure(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public AffixedNamedElementFigure getPrimaryShape() { >+ return (AffixedNamedElementFigure)primaryShape; >+ } >+ >+ /** >+ * <pre> >+ * A post layout listener is added during activate and remove the first time the layout occurs. >+ * This is required in order to be able to find the side of this border item on its parent when opening the model. >+ * Without this, the locator is unable to guess the parent side because the parent constraint is not set yet. >+ * >+ * Once the initialization is done, the listener become useless and can be removed. >+ * >+ * {@inheritDoc} >+ * </pre> >+ */ >+ @Override >+ public void activate() { >+ >+ layoutInitializationListener = new LayoutListener.Stub() { >+ >+ @Override >+ public void postLayout(IFigure container) { >+ refreshVisuals(); >+ //getBorderedFigure().getBorderItemContainer().removeLayoutListener(layoutInitializationListener); >+ layoutInitializationListener = null; >+ } >+ }; >+ getBorderedFigure().getBorderItemContainer().addLayoutListener(layoutInitializationListener); >+ >+ super.activate(); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/factory/ConstraintPropertyAffixedNodeViewFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/factory/ConstraintPropertyAffixedNodeViewFactory.java >new file mode 100644 >index 0000000..7e61a30 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/factory/ConstraintPropertyAffixedNodeViewFactory.java >@@ -0,0 +1,19 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.uml.diagram.common.factory; >+ >+ >+ >+public class ConstraintPropertyAffixedNodeViewFactory extends PortAffixedNodeViewFactory { >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/utils/UMLGraphicalTypes.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/utils/UMLGraphicalTypes.java >index 6cec91a..068f7c0 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/utils/UMLGraphicalTypes.java >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-gen/org/eclipse/papyrus/uml/diagram/common/utils/UMLGraphicalTypes.java >@@ -33,6 +33,8 @@ > > public static final String SHAPE_UML_PORT_AS_AFFIXED_ID = "shape_uml_port_as_affixed"; //$NON-NLS-1$ > >+ public static final String SHAPE_UML_PROPERTY_AS_AFFIXED_ID = "shape_uml_property_as_affixed"; //$NON-NLS-1$ >+ > /** Custom label nodes */ > public static final String SHAPE_UML_CONSTRAINT_AS_LABEL_ID = "shape_uml_constraint_as_label"; //$NON-NLS-1$ > >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.classpath b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.classpath >index f6326c8..ed2585f 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.classpath >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.classpath >@@ -1,8 +1,8 @@ > <?xml version="1.0" encoding="UTF-8"?> > <classpath> >- <classpathentry kind="src" path="src"/> >- <classpathentry kind="src" path="custom-src"/> > <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> > <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> >+ <classpathentry kind="src" path="src"/> >+ <classpathentry kind="src" path="src-gen"/> > <classpathentry kind="output" path="bin"/> > </classpath> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.options b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.options >deleted file mode 100644 >index 429092f..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.options >+++ /dev/null >@@ -1,7 +0,0 @@ >-# Tracing options for the org.eclipse.papyrus.sysml.diagram.parametric plug-in >- >-# Common issues >-org.eclipse.papyrus.sysml.diagram.parametric/debug=false >- >-# Visual IDs >-org.eclipse.papyrus.sysml.diagram.parametric/debug/visualID=false >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.settings/Parametric.gmfgen.prefs b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.settings/Parametric.gmfgen.prefs >deleted file mode 100644 >index 1bf4160..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.settings/Parametric.gmfgen.prefs >+++ /dev/null >@@ -1,8 +0,0 @@ >-#Fri Apr 22 15:21:30 CEST 2011 >-dynamic_figure_templates=platform\:/resource/org.eclipse.papyrus.def/dynamic-templates3.5/codegen >-eclipse.preferences.version=1 >-generate_rcp=false >-ignore_gmfgen_validation=true >-ignore_mapmodel_validation=true >-use_map_mode=true >-use_runtime_figures=true >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.settings/org.eclipse.jdt.core.prefs b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.settings/org.eclipse.jdt.core.prefs >index 86564f5..44217f8 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.settings/org.eclipse.jdt.core.prefs >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.settings/org.eclipse.jdt.core.prefs >@@ -1,4 +1,3 @@ >-#Tue Dec 01 16:58:52 CET 2009 > eclipse.preferences.version=1 > org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled > org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.svnignore b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.svnignore >deleted file mode 100644 >index c5e82d7..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/.svnignore >+++ /dev/null >@@ -1 +0,0 @@ >-bin >\ No newline at end of file >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/META-INF/MANIFEST.MF b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/META-INF/MANIFEST.MF >index 418680d..4dd2aff 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/META-INF/MANIFEST.MF >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/META-INF/MANIFEST.MF >@@ -1,69 +1,51 @@ >-Manifest-Version: 1.0 >-Export-Package: org.eclipse.papyrus.sysml.diagram.parametric, >- org.eclipse.papyrus.sysml.diagram.parametric.edit.commands, >- org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers, >- org.eclipse.papyrus.sysml.diagram.parametric.edit.parts, >- org.eclipse.papyrus.sysml.diagram.parametric.edit.policies, >- org.eclipse.papyrus.sysml.diagram.parametric.navigator, >- org.eclipse.papyrus.sysml.diagram.parametric.parsers, >- org.eclipse.papyrus.sysml.diagram.parametric.part, >- org.eclipse.papyrus.sysml.diagram.parametric.preferences, >- org.eclipse.papyrus.sysml.diagram.parametric.providers, >- org.eclipse.papyrus.sysml.diagram.parametric.sheet >-Bundle-ActivationPolicy: lazy >-Bundle-ClassPath: . >-Bundle-Name: %pluginName >-Bundle-Localization: plugin >-Bundle-RequiredExecutionEnvironment: J2SE-1.5 >-Require-Bundle: org.eclipse.ui, >- org.eclipse.core.runtime, >- org.eclipse.core.resources, >- org.eclipse.core.expressions, >- org.eclipse.jface, >- org.eclipse.ui.ide, >- org.eclipse.ui.views, >- org.eclipse.ui.navigator, >- org.eclipse.ui.navigator.resources, >- org.eclipse.emf.ecore, >- org.eclipse.emf.ecore.xmi, >- org.eclipse.emf.edit.ui, >- org.eclipse.gmf.runtime.emf.core, >- org.eclipse.gmf.runtime.emf.commands.core, >- org.eclipse.gmf.runtime.emf.ui.properties, >- org.eclipse.gmf.runtime.diagram.ui, >- org.eclipse.gmf.runtime.diagram.ui.properties, >- org.eclipse.gmf.runtime.diagram.ui.providers, >- org.eclipse.gmf.runtime.diagram.ui.providers.ide, >- org.eclipse.gmf.runtime.diagram.ui.render, >- org.eclipse.gmf.runtime.diagram.ui.resources.editor, >- org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide, >- org.eclipse.draw2d;visibility:=reexport, >- org.eclipse.papyrus.sysml;bundle-version="0.10.1";visibility:=reexport, >- org.eclipse.papyrus.sysml.edit;bundle-version="0.10.1";visibility:=reexport, >- org.eclipse.emf.ecore;visibility:=reexport, >- org.eclipse.emf.ecore.edit;visibility:=reexport, >- org.eclipse.uml2.uml;visibility:=reexport, >- org.eclipse.uml2.uml.edit;visibility:=reexport, >- org.eclipse.papyrus.resource;bundle-version="0.10.1";visibility:=reexport, >- org.eclipse.papyrus.resource.edit;bundle-version="0.10.1";visibility:=reexport, >- org.eclipse.gef, >- org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="0.10.1", >- org.eclipse.papyrus.extensionpoints.editors;bundle-version="0.10.1", >- org.eclipse.papyrus.uml.diagram.common;bundle-version="0.10.1", >- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.1", >- org.eclipse.papyrus.uml.standard;bundle-version="0.10.1";visibility:=reexport, >- org.eclipse.papyrus.uml.standard.edit;bundle-version="0.10.1";visibility:=reexport, >- org.eclipse.gmf.runtime.draw2d.ui;visibility:=reexport, >- org.eclipse.papyrus.parsers;bundle-version="0.10.1", >- org.eclipse.ocl.ecore;visibility:=reexport, >- org.eclipse.emf.validation;visibility:=reexport, >- org.eclipse.papyrus.infra.emf.appearance;bundle-version="0.10.1" >-Bundle-Vendor: %providerName >-Eclipse-LazyStart: true >-Bundle-Version: 0.10.1.qualifier >-Bundle-ManifestVersion: 2 >-Bundle-Activator: org.eclipse.papyrus.sysml.diagram.parametric.part.Sy >- smlDiagramEditorPlugin >-Bundle-SymbolicName: org.eclipse.papyrus.sysml.diagram.parametric;sing >- leton:=true >- >+Manifest-Version: 1.0 >+Require-Bundle: org.eclipse.ui, >+ org.eclipse.core.runtime, >+ org.eclipse.papyrus.sysml;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.1", >+ org.eclipse.emf.common.ui;bundle-version="2.5.0", >+ org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0", >+ org.eclipse.papyrus.uml.diagram.composite;bundle-version="0.10.1", >+ org.eclipse.gmf.runtime.diagram.ui.providers;bundle-version="1.3.0", >+ org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="0.10.1", >+ org.eclipse.core.expressions, >+ org.eclipse.papyrus.sysml.service.types;bundle-version="0.10.1", >+ org.eclipse.papyrus.uml.service.types;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.widgets;bundle-version="0.10.1", >+ org.eclipse.gmf.runtime.diagram.core;bundle-version="1.4.1", >+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0", >+ org.eclipse.papyrus.uml.tools;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.core;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.core.sasheditor;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.services.edit;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.gmfdiag.navigation;bundle-version="0.10.1", >+ org.eclipse.ui.ide;bundle-version="3.8.0", >+ org.eclipse.papyrus.uml.tools.utils;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.1", >+ org.eclipse.uml2.uml;bundle-version="4.0.0", >+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.2.0", >+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.1", >+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.1", >+ org.eclipse.gmf.tooling.runtime;bundle-version="3.1.0", >+ org.eclipse.papyrus.sysml.diagram.internalblock;bundle-version="0.10.1", >+ org.eclipse.papyrus.uml.diagram.common;bundle-version="0.10.1", >+ org.eclipse.papyrus.sysml.diagram.common;bundle-version="0.10.1" >+Bundle-ManifestVersion: 2 >+Bundle-ActivationPolicy: lazy >+Bundle-Name: %pluginName >+Bundle-Localization: plugin >+Bundle-SymbolicName: org.eclipse.papyrus.sysml.diagram.parametric;singleton:=true >+Bundle-Version: 0.10.1.qualifier >+Bundle-Vendor: %providerName >+Bundle-Activator: org.eclipse.papyrus.sysml.diagram.parametric.Activator >+Bundle-RequiredExecutionEnvironment: J2SE-1.5 >+Export-Package: org.eclipse.papyrus.sysml.diagram.parametric, >+ org.eclipse.papyrus.sysml.diagram.parametric.edit.part, >+ org.eclipse.papyrus.sysml.diagram.parametric.edit.policy, >+ org.eclipse.papyrus.sysml.diagram.parametric.factory, >+ org.eclipse.papyrus.sysml.diagram.parametric.figures, >+ org.eclipse.papyrus.sysml.diagram.parametric.part, >+ org.eclipse.papyrus.sysml.diagram.parametric.preferences, >+ org.eclipse.papyrus.sysml.diagram.parametric.provider, >+ org.eclipse.papyrus.sysml.diagram.parametric.utils >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/about.html b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/about.html >index 50d9eae..d35d5ae 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/about.html >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/about.html >@@ -1,28 +1,28 @@ >-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >-<html xmlns="http://www.w3.org/1999/xhtml"> >-<head> >-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> >-<title>About</title> >-</head> >-<body lang="EN-US"> >-<h2>About This Content</h2> >- >-<p>December 15, 2009</p> >-<h3>License</h3> >- >-<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise >-indicated below, the Content is provided to you under the terms and conditions of the >-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available >-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. >-For purposes of the EPL, "Program" will mean the Content.</p> >- >-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is >-being redistributed by another party ("Redistributor") and different terms and conditions may >-apply to your use of any object code in the Content. Check the Redistributor's license that was >-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise >-indicated below, the terms and conditions of the EPL still apply to any source code in the Content >-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> >- >-</body> >-</html> >\ No newline at end of file >+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >+<html xmlns="http://www.w3.org/1999/xhtml"> >+<head> >+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> >+<title>About</title> >+</head> >+<body lang="EN-US"> >+<h2>About This Content</h2> >+ >+<p>June 5, 2007</p> >+<h3>License</h3> >+ >+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise >+indicated below, the Content is provided to you under the terms and conditions of the >+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available >+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. >+For purposes of the EPL, "Program" will mean the Content.</p> >+ >+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is >+being redistributed by another party ("Redistributor") and different terms and conditions may >+apply to your use of any object code in the Content. Check the Redistributor's license that was >+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise >+indicated below, the terms and conditions of the EPL still apply to any source code in the Content >+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> >+ >+</body> >+</html> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/build.properties b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/build.properties >index 5dc0d74..86b9c49 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/build.properties >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/build.properties >@@ -1,15 +1,7 @@ >-# >-#Mon Sep 12 09:30:14 CEST 2011 >+source.. = src/,\ >+ src-gen/ >+output.. = bin/ > bin.includes = META-INF/,\ > .,\ >- plugin.xml,\ >- messages.properties,\ >- icons/,\ > plugin.properties,\ >- .options,\ >- about.html >-output..=bin/ >-jars.compile.order=. >-src.includes = about.html >-source..=src/,custom-src/ >-bin..=bin/ >+ plugin.xml >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramCommand.java >deleted file mode 100644 >index 545b68c..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramCommand.java >+++ /dev/null >@@ -1,136 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >-import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand; >-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; >-import org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler; >-import org.eclipse.papyrus.infra.core.utils.EditorUtils; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.util.SysmlResource; >-import org.eclipse.papyrus.uml.tools.utils.PackageUtil; >-import org.eclipse.uml2.uml.Class; >-import org.eclipse.uml2.uml.Element; >-import org.eclipse.uml2.uml.Model; >-import org.eclipse.uml2.uml.Profile; >- >-public class CreateParametricDiagramCommand extends AbstractPapyrusGmfCreateDiagramCommandHandler { >- >- /** the Block containing the diagram */ >- private Class selectedElement = null; >- >- @Override >- protected String getDiagramNotationID() { >- return ParametricEditPart.MODEL_ID; >- } >- >- @Override >- protected PreferencesHint getPreferenceHint() { >- return SysmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT; >- } >- >- @Override >- protected String getDefaultDiagramName() { >- return "ParametricDiagram"; >- } >- >- // @Override >- // protected EObject createRootElement() { >- // return UMLFactory.eINSTANCE.createModel(); >- // } >- // >- // @Override >- // protected void initializeModel(EObject owner) { >- // EObject eObject = getSelectedElement(); >- // if(eObject == null) { >- // eObject = owner; >- // } >- // >- // if(eObject instanceof Class) { >- // this.selectedElement = (Class)eObject; >- // } >- // } >- >- @Override >- protected void initializeDiagram(EObject diagram) { >- if(diagram instanceof Diagram) { >- Diagram diag = (Diagram)diagram; >- // test if the selected class is a block >- if(selectedElement != null && selectedElement.getAppliedStereotype(SysmlResource.BLOCK_ID) != null) { >- // YT : Not sure to understand why the selected element is tested to be a Block instead of Block || BlockConstraint >- diag.setElement(selectedElement); >- createParametricGraph(selectedElement, diag); >- } >- } >- } >- >- @Override >- protected Diagram createDiagram(Resource diagramResource, EObject owner, String name) { >- Diagram diagram = null; >- >- // FIXME : Dead code below, owner cannot be a Model due to ParametricDiagramCondition >- // which restricts possible owner to Class only (Block or ConstraintBlock). >- if(owner instanceof Model) { >- Model model = (Model)owner; >- >- if((model.getAppliedProfile(SysmlResource.SYSML_ID, true) == null) || (model.getAppliedProfile(SysmlResource.BLOCKS_ID, true) == null)) { >- // Retrieve SysML profile and apply with sub-profiles >- Profile sysml = (Profile)PackageUtil.loadPackage(URI.createURI(SysmlResource.SYSML_PROFILE_URI), model.eResource().getResourceSet()); >- PackageUtil.applyProfile(model, sysml, true); >- } >- >- Class ownedClass = model.createOwnedClass("Parametric", false); >- ownedClass.applyStereotype(ownedClass.getApplicableStereotype(SysmlResource.BLOCK_ID)); >- diagram = super.createDiagram(diagramResource, ownedClass, name); >- >- } else if(owner instanceof Class) { >- diagram = super.createDiagram(diagramResource, owner, name); >- } >- return diagram; >- } >- >- /** >- * Complete a Parametric diagram with required graphical elements. >- * >- * @param element >- * the element to which the diagram is associated >- * @param diagram >- * the diagram to complete >- */ >- private void createParametricGraph(Element element, Diagram diagram) { >- /* >- * This method implementation allow you to create graphical nodes if required. You may >- * delete it if not necessary. >- */ >- TransactionalEditingDomain editingdomain = EditorUtils.getTransactionalEditingDomain(); >- IAdaptable elementAdapter = new EObjectAdapter(element); >- ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, null, ViewUtil.APPEND, true, SysmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); >- >- CreateCommand nodeCreationCommand = new CreateCommand(editingdomain, descriptor, diagram); >- >- editingdomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(nodeCreationCommand)); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramWithNavigationHandler.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramWithNavigationHandler.java >deleted file mode 100644 >index d316e42..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramWithNavigationHandler.java >+++ /dev/null >@@ -1,25 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2011 Atos Origin. >- * >- * >- * 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: >- * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric; >- >-import org.eclipse.papyrus.infra.gmfdiag.navigation.CreateDiagramWithNavigationHandler; >- >- >-public class CreateParametricDiagramWithNavigationHandler extends CreateDiagramWithNavigationHandler { >- >- public CreateParametricDiagramWithNavigationHandler() { >- super(new CreateParametricDiagramCommand(), new ParametricDiagramCondition()); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCondition.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCondition.java >deleted file mode 100644 >index 355e25e..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCondition.java >+++ /dev/null >@@ -1,40 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric; >- >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.papyrus.infra.core.extension.commands.PerspectiveContextDependence; >-import org.eclipse.papyrus.sysml.util.SysmlResource; >-import org.eclipse.uml2.uml.Class; >- >-/** >- * ParametricDiagramCondition to set conditions for the diagram creation >- */ >-public class ParametricDiagramCondition extends PerspectiveContextDependence { >- >- /** >- * {@inheritDoc} >- */ >- public boolean create(EObject selectedElement) { >- if(super.create(selectedElement)) { >- if(selectedElement instanceof org.eclipse.uml2.uml.Class) { >- Class clazz = (org.eclipse.uml2.uml.Class)selectedElement; >- if(clazz.getAppliedStereotype(SysmlResource.BLOCK_ID) != null || clazz.getAppliedStereotype(SysmlResource.CONSTRAINT_BLOCK_ID) != null) { >- return true; >- } >- } >- } >- return false; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramEditorFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramEditorFactory.java >deleted file mode 100644 >index 9f55e97..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramEditorFactory.java >+++ /dev/null >@@ -1,27 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric; >- >-import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >- >-public class ParametricDiagramEditorFactory extends GmfEditorFactory { >- >- /** >- * Instantiates a new use case diagram editor factory. >- */ >- public ParametricDiagramEditorFactory() { >- super(ParametricDiagramForMultiEditor.class, ParametricEditPart.MODEL_ID); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramForMultiEditor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramForMultiEditor.java >deleted file mode 100644 >index 7477764..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramForMultiEditor.java >+++ /dev/null >@@ -1,114 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.emf.common.ui.URIEditorInput; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.jface.dialogs.ErrorDialog; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.papyrus.infra.core.editor.BackboneException; >-import org.eclipse.papyrus.infra.core.services.ServiceException; >-import org.eclipse.papyrus.infra.core.services.ServicesRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditor; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.IEditorInput; >-import org.eclipse.ui.IEditorSite; >-import org.eclipse.ui.PartInitException; >- >-public class ParametricDiagramForMultiEditor extends SysmlDiagramEditor { >- >- /** >- * The location of diagram icon in the plug-in >- */ >- private static final String DIAG_IMG_PATH = "icons/obj16/Diagram_Parametric.gif"; >- >- /** >- * The image descriptor of the diagram icon >- */ >- private static final ImageDescriptor DIAG_IMG_DESC = SysmlDiagramEditorPlugin.getBundledImageDescriptor(ParametricDiagramForMultiEditor.DIAG_IMG_PATH); >- >- /** The editor splitter. */ >- private Composite splitter; >- >- /** >- * Constructor for SashSystem v2. Context and required objects are retrieved >- * from the ServiceRegistry. >- * >- * @throws BackboneException >- * @throws ServiceException >- * >- */ >- public ParametricDiagramForMultiEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws ServiceException { >- super(servicesRegistry, diagram); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public void init(IEditorSite site, IEditorInput input) throws PartInitException { >- super.init(site, input); >- setPartName(getDiagram().getName()); >- setTitleImage(DIAG_IMG_DESC.createImage()); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public void setInput(IEditorInput input) { >- try { >- // Provide an URI with fragment in order to reuse the same Resource >- // and set the diagram to the fragment. >- URIEditorInput uriInput = new URIEditorInput(EcoreUtil.getURI(getDiagram())); >- doSetInput(uriInput, true); >- } catch (CoreException x) { >- String title = "Problem opening"; >- String msg = "Cannot open input element:"; >- Shell shell = getSite().getShell(); >- ErrorDialog.openError(shell, title, msg, x.getStatus()); >- } >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- protected void createGraphicalViewer(Composite parent) { >- splitter = parent; >- super.createGraphicalViewer(parent); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public void setFocus() { >- splitter.setFocus(); >- super.setFocus(); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public String getEditingDomainID() { >- return "org.eclipse.papyrus.sysml.diagram.parametric.EditingDomain"; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/actions/RestoreRelatedLinksAction.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/actions/RestoreRelatedLinksAction.java >deleted file mode 100644 >index 153c2d3..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/actions/RestoreRelatedLinksAction.java >+++ /dev/null >@@ -1,83 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008 Obeo. >- * 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: >- * Obeo - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.actions; >- >-import java.util.List; >- >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.gef.commands.CompoundCommand; >-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.diagram.parametric.command.RestoreRelatedLinksCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.uml.diagram.common.actions.AbstractAction; >- >-/** >- * Restore related links to selected element >- * >- * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a> >- */ >-public class RestoreRelatedLinksAction extends AbstractAction { >- >- public static String ID = "papyrus.restoreRelatedLinksAction"; >- >- public RestoreRelatedLinksAction() { >- setId(ID); >- setText("Restore Related Elements"); >- setToolTipText("Restore Related Elements"); >- // setImageDescriptor(Plugin.getBundledImageDescriptor("icons/*.gif")); >- } >- >- /** >- * @return >- */ >- protected String getDiagramNotationID() { >- return ParametricEditPart.MODEL_ID; >- } >- >- /** >- * @see org.eclipse.jface.action.Action#isEnabled() >- */ >- @Override >- public boolean isEnabled() { >- Diagram currentDiagram = getCurrentDiagram(); >- if(currentDiagram != null) { >- return (!getSelection().isEmpty() && getDiagramNotationID().equals(currentDiagram.getType())); >- } >- return false; >- } >- >- /** >- * @see org.eclipse.jface.action.Action#run() >- */ >- @Override >- public void run() { >- List<View> selection = getSelection(); >- >- if(selection.isEmpty()) { >- return; >- } >- >- if(false == getHost() instanceof DiagramEditPart) { >- return; >- } >- DiagramEditPart diagramEditPart = (DiagramEditPart)getHost(); >- >- final DiagramCommandStack commandStack = getHost().getDiagramEditDomain().getDiagramCommandStack(); >- CompoundCommand cmd = new CompoundCommand("Restore Related Links"); >- cmd.add(new ICommandProxy(new RestoreRelatedLinksCommand(diagramEditPart, selection))); >- commandStack.execute(cmd, new NullProgressMonitor()); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/CreateConstraintPropertyCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/CreateConstraintPropertyCommand.java >deleted file mode 100644 >index c2d5a2f..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/CreateConstraintPropertyCommand.java >+++ /dev/null >@@ -1,16 +0,0 @@ >-package org.eclipse.papyrus.sysml.diagram.parametric.command; >- >-import java.util.List; >- >-import org.eclipse.gmf.runtime.diagram.ui.commands.CreateOrSelectElementCommand; >-import org.eclipse.swt.widgets.Shell; >- >- >-public class CreateConstraintPropertyCommand extends CreateOrSelectElementCommand { >- >- public CreateConstraintPropertyCommand(Shell parentShell, List content) { >- super(parentShell, content); >- // TODO Auto-generated constructor stub >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/CreateParameterViewCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/CreateParameterViewCommand.java >deleted file mode 100644 >index 6291c50..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/CreateParameterViewCommand.java >+++ /dev/null >@@ -1,123 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.command; >- >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.commands.CompoundCommand; >-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >-import org.eclipse.gmf.runtime.emf.type.core.IHintedType; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.commands.Property2CreateCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >- >-public class CreateParameterViewCommand extends Command { >- >- /** The compartment which graphically contains the Constraint to create */ >- private ConstraintPropertyEditPart compartment = null; >- >- /** The command to create the Constraint element */ >- private ICommandProxy elementCreationCommand = null; >- >- /** The command to create corresponding views (constraint view and link view) */ >- private CompoundCommand viewsCreationCommand = null; >- >- /** The type of local condition to create */ >- private IHintedType type; >- >- public CreateParameterViewCommand() { >- super(); >- } >- >- public CreateParameterViewCommand(String label) { >- super(label); >- } >- >- /** >- * Constructor a new action to create the local condition and corresponding views. >- * >- * @param conditionType >- * the type of the local condition : precondition (Constraint_3011) or postcondition >- * (Constraint_3012) >- * @param graphicalParent >- * the parent edit part which graphically contains the condition >- * @param containerAction >- * the action which owns the local condition to create >- * @param actionPart >- * the part of the action owning the condition >- */ >- public CreateParameterViewCommand(IHintedType conditionType, ConstraintPropertyEditPart graphicalParent, EObject containerAction, EditPart actionPart) { >- elementCreationCommand = getElementCreationCommand(containerAction, conditionType); >- compartment = graphicalParent; >- type = conditionType; >- } >- >- /** >- * Get the Command to create the constraint element >- * >- * @param containerAction >- * the action which owns the local condition to create >- * @param conditionType >- * the type of the local condition : precondition (Constraint_3011) or postcondition >- * (Constraint_3012) >- * @return the command to create model element or null >- */ >- private static ICommandProxy getElementCreationCommand(EObject containerAction, IHintedType conditionType) { >- CreateElementRequest createElementReq = new CreateElementRequest(containerAction, conditionType); >- if(SysmlElementTypes.Property_3002.equals(conditionType)) { >- Property2CreateCommand cmd = new Property2CreateCommand(createElementReq); >- return new ICommandProxy(cmd); >- } else { >- return null; >- } >- } >- >- @Override >- public boolean canExecute() { >- return elementCreationCommand != null && elementCreationCommand.canExecute(); >- } >- >- /** >- * Execute the command : create the model element, then the corresponding views >- * >- * @see org.eclipse.gef.commands.Command#execute() >- */ >- @Override >- public void execute() { >- super.execute(); >- // Object property = null; >- // if (elementCreationCommand != null) { >- // elementCreationCommand.execute(); >- // property = elementCreationCommand.getICommand().getCommandResult().getReturnValue(); >- // } >- } >- >- /** >- * Undo model and views creation >- * >- * @see org.eclipse.gef.commands.Command#undo() >- */ >- @Override >- public void undo() { >- if(viewsCreationCommand != null) { >- viewsCreationCommand.undo(); >- } >- if(elementCreationCommand != null) { >- elementCreationCommand.undo(); >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/RestoreRelatedLinksCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/RestoreRelatedLinksCommand.java >deleted file mode 100644 >index c06ca61..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/command/RestoreRelatedLinksCommand.java >+++ /dev/null >@@ -1,335 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008 Obeo. >- * 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: >- * Obeo - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.command; >- >-import java.util.Collection; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.common.util.EList; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.diagram.core.commands.SetPropertyCommand; >-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.internal.properties.Properties; >-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.Edge; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramUpdater; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlLinkDescriptor; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil; >- >-/** >- * Restore related links to selected element >- * >- * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a> >- */ >-// Inspired from EcoreTools source code >-public class RestoreRelatedLinksCommand extends AbstractTransactionalCommand { >- >- protected List<?> adapters; >- >- protected Diagram diagram; >- >- protected DiagramEditPart host; >- >- public RestoreRelatedLinksCommand(DiagramEditPart diagramEditPart, List<?> selection) { >- super(diagramEditPart.getEditingDomain(), "Restore related links", null); >- this.host = diagramEditPart; >- this.diagram = host.getDiagramView(); >- this.adapters = selection; >- } >- >- private void cleanAdd(Collection<SysmlLinkDescriptor> result, View view, List<?> descriptors) { >- for(Object object : descriptors) { >- if(false == object instanceof SysmlLinkDescriptor) { >- continue; >- } >- SysmlLinkDescriptor descriptor = (SysmlLinkDescriptor)object; >- if(cleanContains(result, descriptor)) { >- continue; >- } >- // check owner >- if(!isOwner(view, descriptor)) { >- continue; >- } >- result.add(descriptor); >- } >- } >- >- /** >- * Detect if similar descriptor already exist in given collection. >- * >- * @param collection >- * the collection of unique ingoing and outgoing links descriptors >- * @param sysmlLinkDescriptor >- * the descriptor to search >- * @return true if already exist >- */ >- private boolean cleanContains(Collection<? extends SysmlLinkDescriptor> collection, SysmlLinkDescriptor sysmlLinkDescriptor) { >- for(Object object : collection) { >- if(object instanceof SysmlLinkDescriptor) { >- SysmlLinkDescriptor descriptor = (SysmlLinkDescriptor)object; >- if(descriptor.getModelElement() == sysmlLinkDescriptor.getModelElement() && descriptor.getSource() == sysmlLinkDescriptor.getSource() && descriptor.getDestination() == sysmlLinkDescriptor.getDestination() && descriptor.getVisualID() == sysmlLinkDescriptor.getVisualID()) { >- return true; >- } >- } >- } >- >- return false; >- } >- >- /** >- * Collects all related links for view >- * >- * @param view >- * @param domain2NotationMap >- * >- * @return linkdescriptors >- */ >- protected Collection<? extends SysmlLinkDescriptor> collectPartRelatedLinks(View view, Map<EObject, View> domain2NotationMap) { >- Collection<SysmlLinkDescriptor> result = new LinkedList<SysmlLinkDescriptor>(); >- if(!domain2NotationMap.containsKey(view.getElement())) { >- // We must prevent duplicate descriptors >- List<?> outgoingDescriptors = SysmlDiagramUpdater.getOutgoingLinks(view); >- cleanAdd(result, view, outgoingDescriptors); >- >- List<?> incomingDescriptors = SysmlDiagramUpdater.getIncomingLinks(view); >- cleanAdd(result, view, incomingDescriptors); >- } >- if(!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$ >- domain2NotationMap.put(view.getElement(), view); >- } >- return result; >- } >- >- /** >- * Create related links corresponding to linkDescriptions >- * >- * @param linkDescriptors >- * @param domain2NotationMap >- */ >- protected void createRelatedLinks(Collection<? extends SysmlLinkDescriptor> linkDescriptors, Map<EObject, View> domain2NotationMap) { >- // map diagram >- mapModel(diagram, domain2NotationMap); >- >- for(SysmlLinkDescriptor nextLinkDescriptor : linkDescriptors) { >- EditPart sourceEditPart = getEditPart(nextLinkDescriptor.getSource(), domain2NotationMap); >- EditPart targetEditPart = getEditPart(nextLinkDescriptor.getDestination(), domain2NotationMap); >- >- // If the parts are still null... >- if(sourceEditPart == null || targetEditPart == null) { >- continue; >- } >- CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(nextLinkDescriptor.getSemanticAdapter(), null, ViewUtil.APPEND, false, host.getDiagramPreferencesHint()); >- CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(descriptor); >- ccr.setType(RequestConstants.REQ_CONNECTION_START); >- ccr.setSourceEditPart(sourceEditPart); >- sourceEditPart.getCommand(ccr); >- ccr.setTargetEditPart(targetEditPart); >- ccr.setType(RequestConstants.REQ_CONNECTION_END); >- Command cmd = targetEditPart.getCommand(ccr); >- if(cmd != null && cmd.canExecute()) { >- CommandUtil.executeCommand(cmd, host); >- } >- } >- >- } >- >- /** >- * >- * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, >- * org.eclipse.core.runtime.IAdaptable) >- */ >- @Override >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- // To register all EditPart in the global visualIDRegistry >- host().refresh(); >- >- for(Object object : adapters) { >- if(object instanceof IAdaptable) { >- IAdaptable ad = (IAdaptable)object; >- View view = (View)ad.getAdapter(View.class); >- if(view != null) { >- refreshRelatedLinks(view); >- } >- } else if(object instanceof View) { >- refreshRelatedLinks((View)object); >- } >- >- } >- >- return CommandResult.newOKCommandResult(); >- } >- >- /** >- * Retrieves editpart corresponding to domainModelElement >- * >- * @param domainModelElement >- * @param domain2NotationMap >- */ >- protected EditPart getEditPart(EObject domainModelElement, Map<? extends EObject, ? extends View> domain2NotationMap) { >- View view = domain2NotationMap.get(domainModelElement); >- if(view != null) { >- return (EditPart)host.getViewer().getEditPartRegistry().get(view); >- } >- return null; >- } >- >- /** >- * Get linkdescriptors of the related links for graphicalEditPart >- * >- * @param graphicalEditPart >- * @param domain2NotationMap >- * >- * @return linkDescritors >- */ >- protected Collection<? extends SysmlLinkDescriptor> getLinkDescriptorToProcess(View notationView, Map<EObject, View> domain2NotationMap) { >- // Collect all related link from semantic model >- Collection<? extends SysmlLinkDescriptor> linkDescriptors = collectPartRelatedLinks(notationView, domain2NotationMap); >- >- // Collect all related link from graphical model >- Collection<Edge> existingLinks = new LinkedList<Edge>(); >- for(Object edge : notationView.getTargetEdges()) { >- if(edge instanceof Edge && false == existingLinks.contains(edge)) { >- existingLinks.add((Edge)edge); >- } >- } >- for(Object edge : notationView.getSourceEdges()) { >- if(edge instanceof Edge && false == existingLinks.contains(edge)) { >- existingLinks.add((Edge)edge); >- } >- } >- >- // Set all existing related link visible >- setViewVisible(existingLinks); >- >- // Remove already existing links >- for(Iterator<Edge> linksIterator = existingLinks.iterator(); linksIterator.hasNext();) { >- Edge nextDiagramLink = linksIterator.next(); >- int diagramLinkVisualID = SysmlVisualIDRegistry.getVisualID(nextDiagramLink); >- if(diagramLinkVisualID == -1) { >- if(nextDiagramLink.getSource() != null && nextDiagramLink.getTarget() != null) { >- linksIterator.remove(); >- } >- continue; >- } >- EObject diagramLinkObject = nextDiagramLink.getElement(); >- EObject diagramLinkSrc = nextDiagramLink.getSource().getElement(); >- EObject diagramLinkDst = nextDiagramLink.getTarget().getElement(); >- for(Iterator<? extends SysmlLinkDescriptor> LinkDescriptorsIterator = linkDescriptors.iterator(); LinkDescriptorsIterator.hasNext();) { >- SysmlLinkDescriptor nextLinkDescriptor = LinkDescriptorsIterator.next(); >- if(diagramLinkObject == nextLinkDescriptor.getModelElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) { >- linksIterator.remove(); >- LinkDescriptorsIterator.remove(); >- } >- } >- } >- return linkDescriptors; >- } >- >- /** >- * @return <code>(IGraphicalEditPart)host()</code>. >- */ >- protected final IGraphicalEditPart host() { >- return host; >- } >- >- private boolean isOwner(View view, SysmlLinkDescriptor descriptor) { >- EObject source = descriptor.getSource(); >- EObject dest = descriptor.getDestination(); >- if(source != null && source.equals(view.getElement())) { >- return true; >- } >- if(dest != null && dest.equals(view.getElement())) { >- return true; >- } >- return false; >- } >- >- /** >- * Maps view >- * >- * @param view >- * @param domain2NotationMap >- */ >- protected void mapModel(View view, Map<EObject, View> domain2NotationMap) { >- if(!ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID(view))) { >- return; >- } >- >- // register the view if its type allows incoming or outgoing links >- if(!SysmlDiagramUpdater.getOutgoingLinks(view).isEmpty() || !SysmlDiagramUpdater.getIncomingLinks(view).isEmpty()) { >- if(!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { >- domain2NotationMap.put(view.getElement(), view); >- } >- } >- >- @SuppressWarnings("unchecked") >- EList<View> children = view.getChildren(); >- for(View child : children) { >- mapModel(child, domain2NotationMap); >- } >- @SuppressWarnings("unchecked") >- EList<View> sourceEdges = view.getSourceEdges(); >- for(View edge : sourceEdges) { >- mapModel(edge, domain2NotationMap); >- } >- } >- >- /** >- * Refresh related links for graphicalEditPart >- * >- * @param graphicalEditPart >- */ >- protected void refreshRelatedLinks(View notationView) { >- Map<EObject, View> domain2NotationMap = new HashMap<EObject, View>(); >- >- // Create related links >- Collection<? extends SysmlLinkDescriptor> linkDescriptors = getLinkDescriptorToProcess(notationView, domain2NotationMap); >- createRelatedLinks(linkDescriptors, domain2NotationMap); >- } >- >- /** >- * Set view visible >- * >- * @param part >- * @param views >- */ >- protected void setViewVisible(Collection<? extends View> views) { >- for(View view : views) { >- if(view.isVisible()) { >- continue; >- } >- SetPropertyCommand cmd = new SetPropertyCommand(host.getEditingDomain(), "Restore related linksCommand show view", new EObjectAdapter(view), Properties.ID_ISVISIBLE, Boolean.TRUE); >- if(cmd != null && cmd.canExecute()) { >- CommandUtil.executeCommand(new ICommandProxy(cmd), host); >- } >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/CreateParameterEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/CreateParameterEditPolicy.java >deleted file mode 100644 >index 37d3314..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/CreateParameterEditPolicy.java >+++ /dev/null >@@ -1,56 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.RequestConstants; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.commands.UnexecutableCommand; >-import org.eclipse.gef.editpolicies.AbstractEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >- >-/** >- * Custom CreateParameterEditPolicy. >- */ >-public class CreateParameterEditPolicy extends AbstractEditPolicy { >- >- public CreateParameterEditPolicy() { >- super(); >- } >- >- @Override >- public Command getCommand(Request request) { >- if(RequestConstants.REQ_CREATE.equals(request.getType()) && request instanceof CreateUnspecifiedTypeRequest) { >- CreateUnspecifiedTypeRequest creationRequest = (CreateUnspecifiedTypeRequest)request; >- EditPart parentEditPart = getHost(); >- if(parentEditPart instanceof ConstraintPropertyEditPart) { >- //ConstraintPropertyEditPart compartementPart = (ConstraintPropertyEditPart) parentEditPart; >- //EObject action = ViewUtil.resolveSemanticElement((View) getHost().getModel()); >- for(Object obj : creationRequest.getElementTypes()) { >- if(SysmlElementTypes.Property_3002.equals(obj)) { >- // do nothing or display WarningAndLinkDialog >- return UnexecutableCommand.INSTANCE; >- // return new CreateParameterViewCommand((IHintedType) SysmlElementTypes.Property_3002, >- // compartementPart, action, getHost()); >- } >- } >- } >- } >- return super.getCommand(request); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/CustomDiagramDragDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/CustomDiagramDragDropEditPolicy.java >deleted file mode 100644 >index 1dc70ff..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/CustomDiagramDragDropEditPolicy.java >+++ /dev/null >@@ -1,258 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.Collection; >-import java.util.HashSet; >-import java.util.List; >-import java.util.Set; >- >-import org.eclipse.emf.ecore.EClass; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.commands.UnexecutableCommand; >-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; >-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.sysml.constraints.ConstraintsPackage; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.helper.ConnectorLinkMappingHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.sysml.diagram.parametric.utils.PropertyLinkedToClassifier; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.OldCommonDiagramDragDropEditPolicy; >-import org.eclipse.uml2.uml.Classifier; >-import org.eclipse.uml2.uml.ConnectableElement; >-import org.eclipse.uml2.uml.ConnectorEnd; >-import org.eclipse.uml2.uml.Element; >-import org.eclipse.uml2.uml.Property; >- >-/** >- * This class is used to execute the drag and drop from the outline. It can manage the drop of nodes >- * and binary links. To manage specific drop the method >- * CommonDiagramDragDropEditPolicy.getSpecificDropCommand has to be implemented >- */ >-public class CustomDiagramDragDropEditPolicy extends OldCommonDiagramDragDropEditPolicy { >- >- /** The container view where the drop is done */ >- private View containerView; >- >- /** >- * Instantiates a new custom diagram drag drop edit policy with the right link mapping helper. >- */ >- public CustomDiagramDragDropEditPolicy() { >- super(ConnectorLinkMappingHelper.getInstance()); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- protected Set<Integer> getDroppableElementVisualId() { >- Set<Integer> droppableElementsVisualId = new HashSet<Integer>(); >- droppableElementsVisualId.add(ConnectorEditPart.VISUAL_ID); >- droppableElementsVisualId.add(ConstraintPropertyEditPart.VISUAL_ID); >- droppableElementsVisualId.add(PropertyEditPart.VISUAL_ID); >- return droppableElementsVisualId; >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public IElementType getUMLElementType(int elementID) { >- return SysmlElementTypes.getElementType(elementID); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public int getNodeVisualID(View containerView, EObject domainElement) { >- this.containerView = containerView; >- if(domainElement instanceof Element) { >- EObject e = getApplication(domainElement); >- if(e != null) { >- if(e instanceof ConstraintProperty) { >- return ConstraintPropertyEditPart.VISUAL_ID; >- } >- // others cases for stereotyped elements >- } >- } >- return SysmlVisualIDRegistry.getNodeVisualID(containerView, domainElement); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public int getLinkWithClassVisualID(EObject domainElement) { >- return SysmlVisualIDRegistry.getLinkWithClassVisualID(domainElement); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- protected Command getSpecificDropCommand(DropObjectsRequest dropRequest, Element semanticLink, int nodeVISUALID, int linkVISUALID) { >- if(nodeVISUALID != -1) { >- switch(nodeVISUALID) { >- case ConstraintPropertyEditPart.VISUAL_ID: >- return dropConstraintProperty(dropRequest, semanticLink, nodeVISUALID); >- case PropertyEditPart.VISUAL_ID: >- return dropProperty(dropRequest, semanticLink, nodeVISUALID); >- default: >- return super.getSpecificDropCommand(dropRequest, semanticLink, nodeVISUALID, linkVISUALID); >- } >- } else if(linkVISUALID != -1) { >- switch(linkVISUALID) { >- case ConnectorEditPart.VISUAL_ID: >- return dropConnector(dropRequest, semanticLink, linkVISUALID); >- default: >- return super.getSpecificDropCommand(dropRequest, semanticLink, nodeVISUALID, linkVISUALID); >- } >- } else { >- return UnexecutableCommand.INSTANCE; >- } >- } >- >- /** >- * Specific drop action for connector. >- * >- * @param dropRequest >- * the drop request >- * @param semanticLink >- * the semantic link >- * @param linkVISUALID >- * the link visual Sid >- * >- * @return the command for connector >- */ >- protected Command dropConnector(DropObjectsRequest dropRequest, Element semanticLink, int linkVISUALID) { >- Collection<?> sources = ConnectorLinkMappingHelper.getInstance().getSource(semanticLink); >- Collection<?> targets = ConnectorLinkMappingHelper.getInstance().getTarget(semanticLink); >- if(sources.size() == 1 && targets.size() == 1) { >- ConnectorEnd sourceConnector = (ConnectorEnd)sources.toArray()[0]; >- ConnectorEnd targetConnector = (ConnectorEnd)targets.toArray()[0]; >- ConnectableElement source = sourceConnector.getRole(); >- ConnectableElement target = targetConnector.getRole(); >- return new ICommandProxy(dropBinaryLink(new CompositeCommand("drop Connector"), source, target, linkVISUALID, dropRequest.getLocation(), semanticLink)); >- } else { >- return UnexecutableCommand.INSTANCE; >- } >- } >- >- /** >- * Specific drop for constraint property. >- * >- * @param dropRequest >- * the drop request >- * @param semanticElement >- * the semantic link >- * @param nodeVISUALID >- * the node visual id >- * >- * @return the default drop node command for Constraint Property object >- */ >- private Command dropConstraintProperty(DropObjectsRequest dropRequest, Element semanticElement, int nodeVISUALID) { >- CompositeCommand cc = new CompositeCommand("Drop"); >- EObject droppedObject = getApplication(semanticElement); >- if(droppedObject != null) { >- cc = getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), droppedObject); >- return new ICommandProxy(cc); >- } >- return UnexecutableCommand.INSTANCE; >- } >- >- /** >- * Specific drop for property. Check if the property is linked to the classifier we want to >- * drag&drop on >- * >- * @param dropRequest >- * the drop request >- * @param semanticElement >- * the semantic element >- * @param nodeVISUALID >- * the node visual id >- * >- * @return the command >- */ >- private Command dropProperty(DropObjectsRequest dropRequest, Element semanticElement, int nodeVISUALID) { >- EObject eObject = containerView.getElement(); >- if(eObject instanceof Classifier) { >- PropertyLinkedToClassifier propertyLinkedToClassifier = new PropertyLinkedToClassifier((Classifier)eObject, (Property)semanticElement); >- if(propertyLinkedToClassifier.isLinkedToClassifier()) { >- CompositeCommand cc = new CompositeCommand("Drop"); >- cc = getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), semanticElement); >- return new ICommandProxy(cc); >- } >- } >- return UnexecutableCommand.INSTANCE; >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- protected boolean isEditPartTypeSuitableForEClass(Class<? extends GraphicalEditPart> editPartClass, EClass eClass) { >- // avoid selecting a label instead of the activity node >- return !LabelEditPart.class.isAssignableFrom(editPartClass); >- } >- >- /** >- * Gets stereotype application element for a specified domain element. >- * >- * @param domainElement >- * the domain element >- * >- * @return the stereotype application object >- */ >- private EObject getApplication(EObject domainElement) { >- if(getStereotypeAvailable(domainElement) != null && domainElement instanceof Element) { >- Element element = (Element)domainElement; >- List<EObject> applications = element.getStereotypeApplications(); >- for(EObject eObject : applications) { >- if(getStereotypeAvailable(domainElement).equals(eObject.eClass())) { >- return eObject; >- } >- } >- } >- return null; >- } >- >- /** >- * Gets the available stereotype EClass for a specified EObject >- * >- * @param eObject >- * the e object >- * >- * @return the stereotype available >- */ >- private EClass getStereotypeAvailable(EObject eObject) { >- if(eObject instanceof Property) { >- return ConstraintsPackage.Literals.CONSTRAINT_PROPERTY; >- } >- return null; >- } >- >- >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/NoDeleteFromDiagramEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/NoDeleteFromDiagramEditPolicy.java >deleted file mode 100644 >index 603177f..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/NoDeleteFromDiagramEditPolicy.java >+++ /dev/null >@@ -1,52 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Atos Origin - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.commands.UnexecutableCommand; >-import org.eclipse.gef.editpolicies.AbstractEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >- >-/** >- * This edit policy disables the graphical deletion of a diagram element. >- */ >-public class NoDeleteFromDiagramEditPolicy extends AbstractEditPolicy { >- >- /** >- * Returns true when the request is a graphical delete >- * >- * @see org.eclipse.gef.EditPolicy#understandsRequest(Request) >- */ >- @Override >- public boolean understandsRequest(Request req) { >- return RequestConstants.REQ_DELETE.equals(req.getType()); >- } >- >- /** >- * Returns an unexecutable command for graphical delete. >- * >- * @see org.eclipse.gef.EditPolicy#getCommand(Request) >- */ >- @Override >- public Command getCommand(Request request) { >- if(RequestConstants.REQ_DELETE.equals(request.getType())) { >- return UnexecutableCommand.INSTANCE; >- } else if(EditPolicy.DIRECT_EDIT_ROLE.equals(request.getType())) { >- return UnexecutableCommand.INSTANCE; >- } >- return super.getCommand(request); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/NoDeleteFromModelEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/NoDeleteFromModelEditPolicy.java >deleted file mode 100644 >index 5f348e1..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/NoDeleteFromModelEditPolicy.java >+++ /dev/null >@@ -1,61 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Atos Origin - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import org.eclipse.gef.Request; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.commands.UnexecutableCommand; >-import org.eclipse.gef.editpolicies.AbstractEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; >- >-/** >- * This edit policy disables the graphical deletion of a diagram element. >- */ >-public class NoDeleteFromModelEditPolicy extends AbstractEditPolicy { >- >- /** >- * Returns true when the request is a graphical delete >- * >- * @see org.eclipse.gef.EditPolicy#understandsRequest(Request) >- */ >- @Override >- public boolean understandsRequest(Request req) { >- if(RequestConstants.REQ_SEMANTIC_WRAPPER.equals(req.getType()) && req instanceof EditCommandRequestWrapper) { >- IEditCommandRequest wrappedRequest = ((EditCommandRequestWrapper)req).getEditCommandRequest(); >- if(wrappedRequest instanceof DestroyElementRequest) { >- return true; >- } >- } >- return false; >- } >- >- /** >- * Returns an unexecutable command for graphical delete. >- * >- * @see org.eclipse.gef.EditPolicy#getCommand(Request) >- */ >- @Override >- public Command getCommand(Request request) { >- if(RequestConstants.REQ_SEMANTIC_WRAPPER.equals(request.getType()) && request instanceof EditCommandRequestWrapper) { >- IEditCommandRequest wrappedRequest = ((EditCommandRequestWrapper)request).getEditCommandRequest(); >- if(wrappedRequest instanceof DestroyElementRequest) { >- return UnexecutableCommand.INSTANCE; >- } >- } >- return super.getCommand(request); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/figures/CenteredWrappedLabel.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/figures/CenteredWrappedLabel.java >deleted file mode 100644 >index 8c35279..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/figures/CenteredWrappedLabel.java >+++ /dev/null >@@ -1,34 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Atos Origin - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.figures; >- >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >- >-/** >- * This class is a {@link WrappingLabel}, which default behavior is set differently : >- * >- * The text is centered and automatically wraps on several lines. >- */ >-public class CenteredWrappedLabel extends WrappingLabel { >- >- /** >- * Construct an empty wrapping label with customized alignment. >- */ >- public CenteredWrappedLabel() { >- super(); >- setTextJustification(WrappingLabel.CENTER); >- setAlignment(WrappingLabel.CENTER); >- setTextWrap(true); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/ConnectorLinkMappingHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/ConnectorLinkMappingHelper.java >deleted file mode 100644 >index 2db374f..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/ConnectorLinkMappingHelper.java >+++ /dev/null >@@ -1,90 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.helper; >- >-import java.util.Collection; >-import java.util.Collections; >- >-import org.eclipse.emf.common.util.EList; >-import org.eclipse.papyrus.uml.diagram.common.helper.ILinkMappingHelper; >-import org.eclipse.papyrus.uml.diagram.common.helper.LinkMappingHelper; >-import org.eclipse.papyrus.uml.diagram.common.helper.LinkMappingHelper.CommonSourceUMLSwitch; >-import org.eclipse.papyrus.uml.diagram.common.helper.LinkMappingHelper.CommonTargetUMLSwitch; >-import org.eclipse.uml2.uml.ConnectorEnd; >-import org.eclipse.uml2.uml.Element; >- >-/** >- * Specialization of the link mapping helper for the Connector >- * >- * @author eperico >- */ >-public class ConnectorLinkMappingHelper implements ILinkMappingHelper { >- >- /** >- * SingletonHolder is loaded at the first execution of getInstance() method >- */ >- private static class SingletonHolder { >- >- private final static ConnectorLinkMappingHelper instance = new ConnectorLinkMappingHelper(); >- } >- >- /** >- * Gets the single instance of ConnectorLinkMappingHelper. >- * >- * @return single instance of ConnectorLinkMappingHelper >- */ >- public static ConnectorLinkMappingHelper getInstance() { >- return SingletonHolder.instance; >- } >- >- /** >- * private constructor >- */ >- private ConnectorLinkMappingHelper() { >- // do nothing >- } >- >- /** >- * {@inheritDoc} >- */ >- public Collection<?> getSource(Element link) { >- return LinkMappingHelper.getSource(link, new CommonSourceUMLSwitch() { >- >- public java.util.Collection<?> caseConnector(org.eclipse.uml2.uml.Connector object) { >- EList<ConnectorEnd> ends = object.getEnds(); >- if(ends != null && !ends.isEmpty()) { >- return Collections.singleton(object.getEnds().get(0)); >- } >- return Collections.emptyList(); >- }; >- }); >- } >- >- /** >- * {@inheritDoc} >- */ >- public Collection<?> getTarget(Element link) { >- return LinkMappingHelper.getTarget(link, new CommonTargetUMLSwitch() { >- >- public java.util.Collection<?> caseConnector(org.eclipse.uml2.uml.Connector object) { >- EList<ConnectorEnd> ends = object.getEnds(); >- if(ends != null && !ends.isEmpty() && ends.size() > 0) { >- return Collections.singleton(object.getEnds().get(1)); >- } >- return Collections.emptyList(); >- }; >- }); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/ModelValidationHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/ModelValidationHelper.java >deleted file mode 100644 >index 5009610..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/ModelValidationHelper.java >+++ /dev/null >@@ -1,150 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.helper; >- >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.emf.validation.EMFEventType; >-import org.eclipse.emf.validation.IValidationContext; >-import org.eclipse.papyrus.resource.Resource; >-import org.eclipse.papyrus.resource.util.ResourceUtil; >-import org.eclipse.papyrus.sysml.blocks.BlocksFactory; >-import org.eclipse.papyrus.sysml.blocks.NestedConnectorEnd; >-import org.eclipse.papyrus.sysml.diagram.parametric.utils.PropertyLinkedToClassifier; >-import org.eclipse.uml2.uml.Classifier; >-import org.eclipse.uml2.uml.ConnectableElement; >-import org.eclipse.uml2.uml.Connector; >-import org.eclipse.uml2.uml.ConnectorEnd; >-import org.eclipse.uml2.uml.Element; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.Stereotype; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * The Class ModelValidationHelper >- */ >-public class ModelValidationHelper { >- >- private static final String NESTED_CONNECTOR_END_STEREOTYPE = "SysML::Blocks::NestedConnectorEnd"; >- >- /** >- * Validate connector end. >- * >- * @param connector >- * @param ctx >- * @return the status >- */ >- public static IStatus validateConnector(Connector connector, IValidationContext ctx) { >- if((EMFEventType.ADD.equals(ctx.getEventType()) || EMFEventType.ADD_MANY.equals(ctx.getEventType())) && UMLPackage.eINSTANCE.getConnector_End().equals(ctx.getFeature())) { >- // do nothing >- } >- return ctx.createSuccessStatus(); >- } >- >- /** >- * Validate property. >- * >- * @param property >- * @param ctx >- * @return the status >- */ >- public static IStatus validateProperty(Property property, IValidationContext ctx) { >- // TODO this validator will manage connectorEnd update when source/target property is moved into and IBD >- if((EMFEventType.MOVE.equals(ctx.getEventType())) || (EMFEventType.SET.equals(ctx.getEventType()))) { >- // only update if property is linked to connector end >- for(ConnectorEnd end : property.getEnds()) { >- if(end.getOwner() != null && end.getOwner() instanceof Connector) { >- Element owner = ((Connector)end.getOwner()).getOwner(); >- if(owner instanceof Classifier) { >- PropertyLinkedToClassifier link = new PropertyLinkedToClassifier((Classifier)owner, property); >- if(link.isLinkedWithMultiLevelPath()) { >- createNestedConnectorEnd(end); >- } else { >- Stereotype appliedStereotype = end.getAppliedStereotype(NESTED_CONNECTOR_END_STEREOTYPE); >- if(appliedStereotype != null) { >- end.unapplyStereotype(appliedStereotype); >- } >- } >- } >- } >- } >- } >- return ctx.createSuccessStatus(); >- } >- >- /** >- * Validate connector end. >- * >- * @param connectorEnd >- * @param ctx >- * @return the status >- */ >- public static IStatus validateConnectorEnd(ConnectorEnd connectorEnd, IValidationContext ctx) { >- if((EMFEventType.SET.equals(ctx.getEventType())) && UMLPackage.eINSTANCE.getConnectorEnd_Role().equals(ctx.getFeature())) { >- ConnectableElement connectableElement = connectorEnd.getRole(); >- Element connector = connectorEnd.getOwner(); >- if(connector != null && connector.getOwner() instanceof Classifier) { >- Classifier owner = (Classifier)connector.getOwner(); >- PropertyLinkedToClassifier link = new PropertyLinkedToClassifier((Classifier)owner, (Property)connectableElement); >- if(link.isLinkedWithMultiLevelPath()) { >- // create a nested connector end >- NestedConnectorEnd end = createNestedConnectorEnd(connectorEnd); >- if(!link.getAvailableRoutes().isEmpty()) { >- end.getPropertyPath().addAll(link.getAvailableRoutes().get(0).getProperties()); >- } >- } else { >- Stereotype appliedStereotype = connectorEnd.getAppliedStereotype(NESTED_CONNECTOR_END_STEREOTYPE); >- if(appliedStereotype != null) { >- connectorEnd.unapplyStereotype(appliedStereotype); >- } >- } >- } >- } >- return ctx.createSuccessStatus(); >- } >- >- /** >- * Validate nested connector end. >- * >- * @param connectorEnd >- * @param ctx >- * @return the status >- */ >- public static IStatus validateNestedConnectorEnd(NestedConnectorEnd connectorEnd, IValidationContext ctx) { >- // TODO setBase_ConnectorEnd should be set to null when connector is deleted, fix problem >- // with delete from model command >- // there are dangling references after this command >- // if (EMFEventType.SET.equals(ctx.getEventType())) { >- // ResourceUtil.getResource(connectorEnd).getEobjects().remove(connectorEnd); >- // } >- return ctx.createSuccessStatus(); >- } >- >- /** >- * Creates the nested connector end for a connector end >- * >- * @param connectorEnd >- * the connector end >- * @return the nested connector end >- */ >- private static NestedConnectorEnd createNestedConnectorEnd(ConnectorEnd connectorEnd) { >- NestedConnectorEnd nested = BlocksFactory.eINSTANCE.createNestedConnectorEnd(); >- Resource res = ResourceUtil.getResource(connectorEnd); >- if(res != null) { >- res.getEobjects().add(nested); >- nested.setBase_ConnectorEnd(connectorEnd); >- } >- return nested; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/SelfCompartmentNotificationHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/SelfCompartmentNotificationHelper.java >deleted file mode 100644 >index 0b14d5d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/helper/SelfCompartmentNotificationHelper.java >+++ /dev/null >@@ -1,223 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Atos Origin - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.helper; >- >-import java.util.ArrayList; >-import java.util.HashSet; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Set; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.common.notify.Notifier; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand; >-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand; >-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >-import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand; >-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.emf.type.core.IHintedType; >-import org.eclipse.gmf.runtime.notation.Edge; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; >-import org.eclipse.papyrus.infra.core.utils.EditorUtils; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.uml.diagram.common.helper.NotificationHelper; >-import org.eclipse.papyrus.uml.diagram.common.providers.UIAdapterImpl; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * SelfCompartmentNotificationHelper is a particular NotificationHelper which manages the editparts >- * drawn in a particular compartment for a particular feature. It automatically add or remove >- * appropriate parts when model is modified, so that all contained elements are represented once. >- */ >-public class SelfCompartmentNotificationHelper extends NotificationHelper { >- >- /** The UI adapter that listens model update */ >- private UIAdapter adapter = new UIAdapter(); >- >- /** The compartment part. */ >- private final ConstraintPropertyEditPart compartmentPart; >- >- /** The child feature. */ >- private final EStructuralFeature childFeature; >- >- /** The child type. */ >- private final IHintedType childType; >- >- private static CompositeTransactionalCommand command; >- >- /** >- * Instantiates a new self compartment notification helper. >- * >- * @param compartmentPart >- * the compartment part >- * @param childFeature >- * the child feature >- * @param childType >- * the child type >- */ >- public SelfCompartmentNotificationHelper(final ConstraintPropertyEditPart compartmentPart, final EStructuralFeature childFeature, final IHintedType childType) { >- this.compartmentPart = compartmentPart; >- this.childFeature = childFeature; >- this.childType = childType; >- this.setModelListener(adapter); >- } >- >- /** >- * private class UIAdapter. >- */ >- private class UIAdapter extends UIAdapterImpl { >- >- @Override >- protected void safeNotifyChanged(Notification msg) { >- if(UMLPackage.eINSTANCE.getTypedElement_Type().equals(msg.getFeature())) { >- // listen type once it's set >- listenObject((Notifier)msg.getNewValue()); >- updatePropertiesParts(compartmentPart, childFeature, childType); >- } else if(UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute().equals(msg.getFeature())) { >- updatePropertiesParts(compartmentPart, childFeature, childType); >- } >- } >- } >- >- /** >- * Update children edit parts so that each child is represented once >- * >- * @param compartmentPart >- * the compartment part containing children >- * @param childFeature >- * the feature containing children >- * @param childType >- * the children's IHintedType represented as Node >- */ >- // TODO refactor this method >- public static void updatePropertiesParts(ConstraintPropertyEditPart compartmentPart, EStructuralFeature childFeature, IHintedType childType) { >- if(compartmentPart == null || childFeature == null || childType == null) { >- return; >- } >- command = new CompositeTransactionalCommand(EditorUtils.getTransactionalEditingDomain(), "update children"); >- command.setTransactionNestingEnabled(false); >- if(compartmentPart.getModel() instanceof View) { >- View compartmentView = (View)compartmentPart.getModel(); >- EObject containerObject = compartmentView.getElement(); >- if(containerObject instanceof ConstraintProperty) { >- Property baseProperty = ((ConstraintProperty)containerObject).getBase_Property(); >- if(baseProperty != null && baseProperty.getType() != null) { >- Object untypedOwnedObjects = baseProperty.getType().eGet(childFeature); >- if(untypedOwnedObjects instanceof List<?>) { >- List<?> ownedEObjectChildren = (List<?>)untypedOwnedObjects; >- Set<EObject> drawnEObjectChildren = new HashSet<EObject>(ownedEObjectChildren.size()); >- >- // list children already drawn and remove old children >- for(Iterator<?> iterator = compartmentView.getPersistedChildren().iterator(); iterator.hasNext();) { >- EObject childView = (EObject)iterator.next(); >- if(childView instanceof View && ((View)childView).getElement() != null) { >- EObject child = ((View)childView).getElement(); >- switch(SysmlVisualIDRegistry.getVisualID((View)childView)) { >- >- case Property2EditPart.VISUAL_ID: >- // property already drawn >- if(ownedEObjectChildren.contains(child)) { >- drawnEObjectChildren.add(child); >- } else { >- // delete old connectors >- deleteConnectorsViews(command, (View)childView); >- // remove remaining property if any >- iterator.remove(); >- } >- break; >- >- case ConstraintPropertyEditPart.VISUAL_ID: >- // property doesn't exist in the model, remove the view >- iterator.remove(); >- break; >- >- default: >- break; >- } >- } >- } >- // draw remaining children >- List<Object> childrenToDraw = new ArrayList<Object>(ownedEObjectChildren); >- childrenToDraw.removeAll(drawnEObjectChildren); >- for(Object child : childrenToDraw) { >- if(child instanceof EObject) { >- IAdaptable adapter = new EObjectAdapter((EObject)child); >- ViewDescriptor descriptor = new ViewDescriptor(adapter, Node.class, childType.getSemanticHint(), ViewUtil.APPEND, true, compartmentPart.getDiagramPreferencesHint()); >- CreateCommand nodeCreationCommand = new CreateCommand(compartmentPart.getEditingDomain(), descriptor, compartmentView); >- command.add(nodeCreationCommand); >- } >- } >- } >- } else { >- // constraint property type is set to null, remove old children >- for(Iterator<?> iterator = compartmentView.getPersistedChildren().iterator(); iterator.hasNext();) { >- EObject childView = (EObject)iterator.next(); >- if((childView instanceof View) && SysmlVisualIDRegistry.getVisualID((View)childView) == Property2EditPart.VISUAL_ID) { >- // delete old connectors >- deleteConnectorsViews(command, (View)childView); >- // delete parameter view >- iterator.remove(); >- } >- } >- } >- // execute transactional command >- execute(); >- } >- } >- } >- >- /** >- * Execute command. >- */ >- private static void execute() { >- if(!command.isEmpty()) { >- command.getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(command)); >- } >- } >- >- /** >- * Delete source and target connectors of the deleted parameter view >- * >- * @param cmd >- * the cmd >- * @param propertyView >- * the property view >- */ >- private static void deleteConnectorsViews(ICompositeCommand cmd, View propertyView) { >- for(Iterator<?> it = propertyView.getTargetEdges().iterator(); it.hasNext();) { >- Edge incomingLink = (Edge)it.next(); >- if(SysmlVisualIDRegistry.getVisualID(incomingLink) == ConnectorEditPart.VISUAL_ID) { >- cmd.add(new DeleteCommand(incomingLink)); >- } >- } >- for(Iterator<?> it = propertyView.getSourceEdges().iterator(); it.hasNext();) { >- Edge outgoingLink = (Edge)it.next(); >- if(SysmlVisualIDRegistry.getVisualID(outgoingLink) == ConnectorEditPart.VISUAL_ID) { >- cmd.add(new DeleteCommand(outgoingLink)); >- } >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/locator/ParameterPositionLocator.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/locator/ParameterPositionLocator.java >deleted file mode 100644 >index 8716abf..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/locator/ParameterPositionLocator.java >+++ /dev/null >@@ -1,82 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.locator; >- >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.geometry.Dimension; >-import org.eclipse.draw2d.geometry.Point; >-import org.eclipse.draw2d.geometry.Rectangle; >-import org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator; >- >-/** >- * The Class ParameterPositionLocator that manages position of property on constraint property >- */ >-public class ParameterPositionLocator extends AdvancedBorderItemLocator { >- >- /** Constructor **/ >- public ParameterPositionLocator(IFigure parentFigure) { >- super(parentFigure); >- } >- >- /** Constructor **/ >- public ParameterPositionLocator(IFigure borderItem, IFigure parentFigure, Rectangle constraint) { >- super(borderItem, parentFigure, constraint); >- } >- >- /** Constructor **/ >- public ParameterPositionLocator(IFigure parentFigure, int preferredSide) { >- super(parentFigure, preferredSide); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) { >- Rectangle realLocation = new Rectangle(proposedLocation); >- realLocation.width = Math.max(realLocation.width, realLocation.height); >- realLocation.height = realLocation.width; >- int side = findClosestSideOfParent(proposedLocation, getParentBorder()); >- Point newTopLeft = locateOnBorder(realLocation.getTopLeft(), side, 0, borderItem); >- realLocation.setLocation(newTopLeft); >- return realLocation; >- } >- >- /** >- * Re-arrange the location of the border item. >- * >- * @see org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator#relocate(org.eclipse.draw2d.IFigure) >- * >- * @param borderItem >- */ >- @Override >- public void relocate(IFigure borderItem) { >- // reset bounds of borderItem >- Dimension size = getSize(borderItem); >- Rectangle rectSuggested = getConstraint().getCopy(); >- if(rectSuggested.getTopLeft().x == 0 && rectSuggested.getTopLeft().y == 0) { >- rectSuggested.setLocation(getPreferredLocation(borderItem)); >- } else { >- // recovered constraint must be translated with the parent location to be absolute >- rectSuggested.setLocation(rectSuggested.getLocation().translate(getParentBorder().getTopLeft())); >- } >- rectSuggested.setSize(size); >- Rectangle validLocation = getValidLocation(rectSuggested, borderItem); >- // the constraint is not reset, but the item bounds are >- borderItem.setBounds(validLocation); >- // ensure the side property is correctly set >- setCurrentSideOfParent(findClosestSideOfParent(borderItem.getBounds(), getParentBorder())); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConnectorLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConnectorLabelParser.java >deleted file mode 100644 >index dbabe0c..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConnectorLabelParser.java >+++ /dev/null >@@ -1,136 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.parsers; >- >-import java.text.FieldPosition; >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EAttribute; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.uml2.uml.Connector; >-import org.eclipse.uml2.uml.Element; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * A specific parser for displaying a connector. This parser refreshes the text >- * displayed for the connector. >- */ >-public class ConnectorLabelParser extends MessageFormatParser implements ISemanticParser { >- >- /** The String format for displaying a parameter with its type */ >- private static final String TYPED_PARAMETER_FORMAT = "%s: %s"; >- >- /** The String format for displaying a parameter with no type */ >- private static final String UNTYPED_PARAMETER_FORMAT = "%s"; >- >- public ConnectorLabelParser(EAttribute[] features, EAttribute[] editableFeatures) { >- super(features, editableFeatures); >- } >- >- public ConnectorLabelParser(EAttribute[] features) { >- super(features); >- } >- >- public ConnectorLabelParser() { >- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }); >- } >- >- protected EStructuralFeature getEStructuralFeature(Object notification) { >- EStructuralFeature featureImpl = null; >- if(notification instanceof Notification) { >- Object feature = ((Notification)notification).getFeature(); >- if(feature instanceof EStructuralFeature) { >- featureImpl = (EStructuralFeature)feature; >- } >- } >- return featureImpl; >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean isAffectingEvent(Object event, int flags) { >- EStructuralFeature feature = getEStructuralFeature(event); >- return isValidFeature(feature); >- >- } >- >- /** >- * {@inheritDoc} >- */ >- public String getPrintString(IAdaptable element, int flags) { >- Object obj = element.getAdapter(EObject.class); >- Connector connector = (Connector)obj; >- String name = connector.getName(); >- if(name == null) { >- name = " "; >- } >- if(connector.getType() != null) { >- String type = connector.getType().getName(); >- if(type == null) { >- type = ""; >- } >- return String.format(TYPED_PARAMETER_FORMAT, name, type); >- } else { >- return String.format(UNTYPED_PARAMETER_FORMAT, name); >- } >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean areSemanticElementsAffected(EObject listener, Object notification) { >- EStructuralFeature feature = getEStructuralFeature(notification); >- return isValidFeature(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- public List<?> getSemanticElementsBeingParsed(EObject element) { >- List<Element> semanticElementsBeingParsed = new ArrayList<Element>(); >- Connector connector = (Connector)element; >- semanticElementsBeingParsed.add(connector); >- if(connector.getType() != null) { >- semanticElementsBeingParsed.add(connector.getType()); >- } >- return semanticElementsBeingParsed; >- } >- >- /** >- * Determines if the given feature has to be taken into account in this parser >- * >- * @param feature >- * the feature to test >- * @return true if is valid, false otherwise >- */ >- private boolean isValidFeature(EStructuralFeature feature) { >- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getConnector_Type().equals(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public String getEditString(IAdaptable adapter, int flags) { >- EObject element = (EObject)adapter.getAdapter(EObject.class); >- return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new FieldPosition(0)).toString(); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConstraintLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConstraintLabelParser.java >deleted file mode 100644 >index 44833a1..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConstraintLabelParser.java >+++ /dev/null >@@ -1,182 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.parsers; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EAttribute; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.transaction.util.TransactionUtil; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; >-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.uml.diagram.common.commands.SetValueSpecificationValueCommand; >-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; >-import org.eclipse.uml2.uml.Element; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.UMLPackage; >-import org.eclipse.uml2.uml.ValueSpecification; >- >-/** >- * The Class ConstraintLabelParser that manages constraint label of a constraintProperty >- */ >-public class ConstraintLabelParser extends MessageFormatParser implements ISemanticParser { >- >- /** The String format for displaying a ConstraintProperty with no type */ >- private static final String CONSTRAINT_LABEL__FORMAT = "{%s}"; >- >- public ConstraintLabelParser(EAttribute[] features, EAttribute[] editableFeatures) { >- super(features, editableFeatures); >- } >- >- public ConstraintLabelParser(EAttribute[] features) { >- super(features); >- } >- >- public ConstraintLabelParser() { >- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }); >- } >- >- /** >- * Gets the e structural feature. >- * >- * @param notification >- * the notification >- * @return the e structural feature >- */ >- protected EStructuralFeature getEStructuralFeature(Object notification) { >- EStructuralFeature featureImpl = null; >- if(notification instanceof Notification) { >- Object feature = ((Notification)notification).getFeature(); >- if(feature instanceof EStructuralFeature) { >- featureImpl = (EStructuralFeature)feature; >- } >- } >- return featureImpl; >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean isAffectingEvent(Object event, int flags) { >- EStructuralFeature feature = getEStructuralFeature(event); >- return isValidFeature(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- public String getPrintString(IAdaptable element, int flags) { >- String result = ""; >- Object obj = element.getAdapter(EObject.class); >- if(obj instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)obj).getBase_Property(); >- if(property != null) { >- // manage constraint >- if(property.getDefaultValue() != null) { >- ValueSpecification valueSpecification = property.getDefaultValue(); >- String specificationValue = ValueSpecificationUtil.getSpecificationValue(valueSpecification); >- if(specificationValue != null && specificationValue.length() > 0) { >- result = String.format(CONSTRAINT_LABEL__FORMAT, specificationValue); >- } >- } >- } >- } >- return result; >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean areSemanticElementsAffected(EObject listener, Object notification) { >- EStructuralFeature feature = getEStructuralFeature(notification); >- return isValidFeature(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- public List<?> getSemanticElementsBeingParsed(EObject element) { >- List<Element> semanticElementsBeingParsed = new ArrayList<Element>(); >- if(element instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)element).getBase_Property(); >- if(property != null) { >- semanticElementsBeingParsed.add(property); >- if(property.getDefaultValue() != null) { >- semanticElementsBeingParsed.add(property.getDefaultValue()); >- } >- } >- } >- return semanticElementsBeingParsed; >- } >- >- /** >- * Determines if the given feature has to be taken into account in this parser >- * >- * @param feature >- * the feature to test >- * @return true if is valid, false otherwise >- */ >- private boolean isValidFeature(EStructuralFeature feature) { >- return UMLPackage.eINSTANCE.getProperty_DefaultValue().equals(feature) || UMLPackage.eINSTANCE.getProperty_DefaultValue().equals(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public String getEditString(IAdaptable adapter, int flags) { >- String result = ""; >- EObject element = (EObject)adapter.getAdapter(EObject.class); >- if(element instanceof ConstraintProperty) { >- element = ((ConstraintProperty)element).getBase_Property(); >- if(element instanceof Property) { >- ValueSpecification defaultValue = ((Property)element).getDefaultValue(); >- result = ValueSpecificationUtil.getSpecificationValue(defaultValue); >- } >- } >- return result; >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) { >- Object obj = adapter.getAdapter(EObject.class); >- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj); >- >- if(editingDomain != null && obj instanceof ConstraintProperty) { >- obj = ((ConstraintProperty)obj).getBase_Property(); >- if(obj instanceof Property) { >- ValueSpecification valueSpec = ((Property)obj).getDefaultValue(); >- if(valueSpec != null) { >- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); >- command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString))); >- return command; >- } >- } >- } >- return UnexecutableCommand.INSTANCE; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConstraintPropertyLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConstraintPropertyLabelParser.java >deleted file mode 100644 >index 15bf7d8..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/ConstraintPropertyLabelParser.java >+++ /dev/null >@@ -1,230 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.parsers; >- >-import java.text.FieldPosition; >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.common.util.EList; >-import org.eclipse.emf.ecore.EAttribute; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.transaction.util.TransactionUtil; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; >-import org.eclipse.uml2.uml.Element; >-import org.eclipse.uml2.uml.InstanceValue; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.UMLPackage; >-import org.eclipse.uml2.uml.ValueSpecification; >- >-/** >- * A specific parser for displaying a ConstraintProperty label. This parser refreshes the text >- * displayed for the ConstraintProperty. >- */ >-public class ConstraintPropertyLabelParser extends MessageFormatParser implements ISemanticParser { >- >- /** The String format for displaying a ConstraintProperty with no type */ >- private static final String UNTYPED_PARAMETER_FORMAT = "%s"; >- >- /** The String format for displaying a ConstraintProperty with its type */ >- private static final String TYPED_PARAMETER_FORMAT = "%s: %s"; >- >- /** The String format for displaying a ConstraintProperty with multiplicity */ >- private static final String MULTIPLICITY_PARAMETER_FORMAT = "%s [%s..%s]"; >- >- /** The String format for displaying a ConstraintProperty with default value */ >- private static final String DEFAULT_VALUE_PARAMETER_FORMAT = "%s= %s"; >- >- /** The String format for displaying a ConstraintProperty with attribute */ >- private static final String MODIFIER_PARAMETER_FORMAT = "%s{%s}"; >- >- public ConstraintPropertyLabelParser(EAttribute[] features, EAttribute[] editableFeatures) { >- super(features, editableFeatures); >- } >- >- public ConstraintPropertyLabelParser(EAttribute[] features) { >- super(features); >- } >- >- public ConstraintPropertyLabelParser() { >- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }); >- } >- >- protected EStructuralFeature getEStructuralFeature(Object notification) { >- EStructuralFeature featureImpl = null; >- if(notification instanceof Notification) { >- Object feature = ((Notification)notification).getFeature(); >- if(feature instanceof EStructuralFeature) { >- featureImpl = (EStructuralFeature)feature; >- } >- } >- return featureImpl; >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean isAffectingEvent(Object event, int flags) { >- EStructuralFeature feature = getEStructuralFeature(event); >- return isValidFeature(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- public String getPrintString(IAdaptable element, int flags) { >- String result = ""; >- Object obj = element.getAdapter(EObject.class); >- Property property = null; >- if(obj instanceof ConstraintProperty) { >- property = ((ConstraintProperty)obj).getBase_Property(); >- } >- if(property != null) { >- String name = property.isDerived() ? "/ " + property.getName() : property.getName(); >- result = String.format(UNTYPED_PARAMETER_FORMAT, name); >- // manage type >- if(property.getType() != null) { >- String type = property.getType().getName(); >- result = String.format(TYPED_PARAMETER_FORMAT, name, type); >- } >- // manage multiplicity >- if(property.getLower() != 1 || property.getUpper() != 1) { >- result = String.format(MULTIPLICITY_PARAMETER_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(property.getLowerValue()), ValueSpecificationUtil.getSpecificationValue(property.getUpperValue())); >- } >- // manage initial values >- if(property.getDefaultValue() != null) { >- ValueSpecification valueSpecification = property.getDefaultValue(); >- if(valueSpecification instanceof InstanceValue && property.getType().equals(valueSpecification.getType())) { >- result = String.format(DEFAULT_VALUE_PARAMETER_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification)); >- } >- } >- // manage modifier >- StringBuffer sb = new StringBuffer(); >- if(property.isReadOnly()) { >- sb.append(sb.length() == 0 ? "readOnly" : ", readOnly"); >- } >- if(property.isOrdered()) { >- sb.append(sb.length() == 0 ? "ordered" : ", ordered"); >- } >- if(property.isUnique()) { >- sb.append(sb.length() == 0 ? "unique" : ", unique"); >- } >- if(property.isDerivedUnion()) { >- sb.append(sb.length() == 0 ? "union" : ", union"); >- } >- EList<Property> redefinedProperties = property.getRedefinedProperties(); >- if(redefinedProperties != null && !redefinedProperties.isEmpty()) { >- for(Property p : redefinedProperties) { >- sb.append(sb.length() == 0 ? p.getName() : ", redefines " + p.getName()); >- } >- } >- if(sb.length() != 0) { >- result = String.format(MODIFIER_PARAMETER_FORMAT, result, sb.toString()); >- } >- } >- return result; >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean areSemanticElementsAffected(EObject listener, Object notification) { >- EStructuralFeature feature = getEStructuralFeature(notification); >- return isValidFeature(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- public List<?> getSemanticElementsBeingParsed(EObject element) { >- List<Element> semanticElementsBeingParsed = new ArrayList<Element>(); >- Property property = null; >- if(element instanceof ConstraintProperty) { >- property = ((ConstraintProperty)element).getBase_Property(); >- } >- if(property != null) { >- semanticElementsBeingParsed.add(property); >- if(property.getType() != null) { >- semanticElementsBeingParsed.add(property.getType()); >- } >- if(property.getLowerValue() != null) { >- semanticElementsBeingParsed.add(property.getLowerValue()); >- } >- if(property.getUpperValue() != null) { >- semanticElementsBeingParsed.add(property.getUpperValue()); >- } >- if(property.getDefaultValue() != null) { >- semanticElementsBeingParsed.add(property.getDefaultValue()); >- } >- } >- return semanticElementsBeingParsed; >- } >- >- /** >- * Determines if the given feature has to be taken into account in this parser >- * >- * @param feature >- * the feature to test >- * @return true if is valid, false otherwise >- */ >- private boolean isValidFeature(EStructuralFeature feature) { >- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getInstanceValue_Instance().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_IsOrdered().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_IsUnique().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue().equals(feature) || UMLPackage.eINSTANCE.getStructuralFeature_IsReadOnly().equals(feature) || UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature) || UMLPackage.eINSTANCE.getProperty_IsDerived().equals(feature) || UMLPackage.eINSTANCE.getProperty_IsDerivedUnion().equals(feature) || UMLPackage.eINSTANCE.getProperty_RedefinedProperty().equals(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public String getEditString(IAdaptable adapter, int flags) { >- EObject element = (EObject)adapter.getAdapter(EObject.class); >- if(element instanceof ConstraintProperty) { >- element = ((ConstraintProperty)element).getBase_Property(); >- } >- return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new FieldPosition(0)).toString(); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- protected ICommand getParseCommand(IAdaptable adapter, Object[] values, int flags) { >- if(values == null || validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) { >- return UnexecutableCommand.INSTANCE; >- } >- EObject element = (EObject)adapter.getAdapter(EObject.class); >- if(element instanceof ConstraintProperty) { >- element = ((ConstraintProperty)element).getBase_Property(); >- } >- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element); >- if(editingDomain == null) { >- return UnexecutableCommand.INSTANCE; >- } >- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$ >- for(int i = 0; i < values.length; i++) { >- command.compose(getModificationCommand(element, editableFeatures[i], values[i])); >- } >- return command; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/PropertyLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/PropertyLabelParser.java >deleted file mode 100644 >index e34218f..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/PropertyLabelParser.java >+++ /dev/null >@@ -1,223 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.parsers; >- >-import java.text.FieldPosition; >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.common.util.EList; >-import org.eclipse.emf.ecore.EAttribute; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.papyrus.sysml.diagram.parametric.utils.PropertyLinkedToClassifierNode; >-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; >-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; >-import org.eclipse.uml2.uml.Classifier; >-import org.eclipse.uml2.uml.Element; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.UMLPackage; >-import org.eclipse.uml2.uml.ValueSpecification; >- >-/** >- * A specific parser for displaying an property. This parser refreshes the text displayed for the >- * Property. >- */ >-public class PropertyLabelParser extends MessageFormatParser implements ISemanticParser { >- >- /** The String format for displaying a ConstraintProperty with no type */ >- private static final String UNTYPED_PARAMETER_FORMAT = "%s"; >- >- /** The String format for displaying a ConstraintProperty with its type */ >- private static final String TYPED_PARAMETER_FORMAT = "%s: %s"; >- >- /** The String format for displaying a ConstraintProperty with multiplicity */ >- private static final String MULTIPLICITY_PARAMETER_FORMAT = "%s [%s..%s]"; >- >- /** The String format for displaying a ConstraintProperty with default value */ >- private static final String DEFAULT_VALUE_PARAMETER_FORMAT = "%s= %s"; >- >- /** The String format for displaying a ConstraintProperty with attribute */ >- private static final String MODIFIER_PARAMETER_FORMAT = "%s{%s}"; >- >- /** Class to compute property name depth */ >- PropertyLinkedToClassifierNode propertyLinkedToClassifier; >- >- /** The classifier, container view of the property */ >- private Classifier classifier; >- >- public PropertyLabelParser(EAttribute[] features, EAttribute[] editableFeatures) { >- super(features, editableFeatures); >- } >- >- public PropertyLabelParser(EAttribute[] features) { >- super(features); >- } >- >- public PropertyLabelParser() { >- super(new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }); >- } >- >- protected EStructuralFeature getEStructuralFeature(Object notification) { >- EStructuralFeature featureImpl = null; >- if(notification instanceof Notification) { >- Object feature = ((Notification)notification).getFeature(); >- if(feature instanceof EStructuralFeature) { >- featureImpl = (EStructuralFeature)feature; >- } >- } >- return featureImpl; >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean isAffectingEvent(Object event, int flags) { >- EStructuralFeature feature = getEStructuralFeature(event); >- return isValidFeature(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- public String getPrintString(IAdaptable element, int flags) { >- String result = ""; >- Property property = null; >- Object adapter = element.getAdapter(EObject.class); >- if(adapter instanceof Property) { >- property = (Property)adapter; >- String name = property.isDerived() ? "/ " + property.getName() : property.getName(); >- result = String.format(UNTYPED_PARAMETER_FORMAT, name); >- // Perform property depth to set the name >- for(Object obj : DiagramEditPartsUtil.getEObjectViews(property)) { >- if(obj instanceof Node && classifier != null) { >- propertyLinkedToClassifier = new PropertyLinkedToClassifierNode(classifier, property, (Node)obj); >- propertyLinkedToClassifier.refresh(); >- name = propertyLinkedToClassifier.getName(); >- result = String.format(UNTYPED_PARAMETER_FORMAT, name); >- } >- } >- // manage type >- if(property.getType() != null) { >- String type = property.getType().getName(); >- result = String.format(TYPED_PARAMETER_FORMAT, name, type); >- } >- // manage multiplicity >- if(property.getLower() != 1 || property.getUpper() != 1) { >- result = String.format(MULTIPLICITY_PARAMETER_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(property.getLowerValue()), ValueSpecificationUtil.getSpecificationValue(property.getUpperValue())); >- } >- // manage initial values >- if(property.getDefaultValue() != null) { >- ValueSpecification valueSpecification = property.getDefaultValue(); >- String specificationValue = ValueSpecificationUtil.getSpecificationValue(valueSpecification); >- if(specificationValue != null && specificationValue.length() > 0) { >- result = String.format(DEFAULT_VALUE_PARAMETER_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification)); >- } >- } >- // manage modifier >- StringBuffer sb = new StringBuffer(); >- if(property.isReadOnly()) { >- sb.append(sb.length() == 0 ? "readOnly" : ", readOnly"); >- } >- if(property.isOrdered()) { >- sb.append(sb.length() == 0 ? "ordered" : ", ordered"); >- } >- if(property.isUnique()) { >- sb.append(sb.length() == 0 ? "unique" : ", unique"); >- } >- if(property.isDerivedUnion()) { >- sb.append(sb.length() == 0 ? "union" : ", union"); >- } >- EList<Property> redefinedProperties = property.getRedefinedProperties(); >- if(redefinedProperties != null && !redefinedProperties.isEmpty()) { >- for(Property p : redefinedProperties) { >- sb.append(sb.length() == 0 ? p.getName() : ", redefines " + p.getName()); >- } >- } >- if(sb.length() != 0) { >- result = String.format(MODIFIER_PARAMETER_FORMAT, result, sb.toString()); >- } >- } >- return result; >- } >- >- /** >- * {@inheritDoc} >- */ >- public boolean areSemanticElementsAffected(EObject listener, Object notification) { >- EStructuralFeature feature = getEStructuralFeature(notification); >- return isValidFeature(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- public List<?> getSemanticElementsBeingParsed(EObject element) { >- List<Element> semanticElementsBeingParsed = new ArrayList<Element>(); >- Property property = null; >- if(element instanceof Property) { >- property = (Property)element; >- semanticElementsBeingParsed.add(property); >- if(property.getType() != null) { >- semanticElementsBeingParsed.add(property.getType()); >- } >- if(property.getLowerValue() != null) { >- semanticElementsBeingParsed.add(property.getLowerValue()); >- } >- if(property.getUpperValue() != null) { >- semanticElementsBeingParsed.add(property.getUpperValue()); >- } >- if(property.getDefaultValue() != null) { >- semanticElementsBeingParsed.add(property.getDefaultValue()); >- } >- } >- return semanticElementsBeingParsed; >- } >- >- /** >- * Determines if the given feature has to be taken into account in this parser >- * >- * @param feature >- * the feature to test >- * @return true if is valid, false otherwise >- */ >- private boolean isValidFeature(EStructuralFeature feature) { >- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getConnector_Type().equals(feature) || UMLPackage.eINSTANCE.getInstanceValue_Instance().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_IsOrdered().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_IsUnique().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue().equals(feature) || UMLPackage.eINSTANCE.getStructuralFeature_IsReadOnly().equals(feature) || UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature) || UMLPackage.eINSTANCE.getProperty_IsDerived().equals(feature) || UMLPackage.eINSTANCE.getProperty_IsDerivedUnion().equals(feature) || UMLPackage.eINSTANCE.getProperty_RedefinedProperty().equals(feature); >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public String getEditString(IAdaptable adapter, int flags) { >- EObject element = (EObject)adapter.getAdapter(EObject.class); >- return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new FieldPosition(0)).toString(); >- } >- >- /** >- * Sets the block that is linked to the current property >- * >- * @param element >- */ >- public void setBlock(EObject element) { >- if(element instanceof Classifier) { >- this.classifier = (Classifier)element; >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/CustomEditPolicyProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/CustomEditPolicyProvider.java >deleted file mode 100644 >index 5174117..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/CustomEditPolicyProvider.java >+++ /dev/null >@@ -1,81 +0,0 @@ >-/***************************************************************************** >- * 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: >- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import org.eclipse.gef.EditPart; >-import org.eclipse.gmf.runtime.common.core.service.IOperation; >-import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; >-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.HyperLinkPopupBarEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.NavigationEditPolicy; >- >-/** >- * this is an editpolicy provider in charge to install navigation policies >- * >- * @author Patrick Tessier >- */ >-public class CustomEditPolicyProvider implements IEditPolicyProvider { >- >- /** >- * >- * {@inheritDoc} >- */ >- public void addProviderChangeListener(IProviderChangeListener listener) { >- >- } >- >- /** >- * >- * {@inheritDoc} >- */ >- public void createEditPolicies(EditPart editPart) { >- editPart.installEditPolicy(NavigationEditPolicy.NAVIGATION_POLICY, new NavigationEditPolicy()); >- if( editPart instanceof IPrimaryEditPart){ >- editPart.installEditPolicy(EditPolicyRoles.POPUPBAR_ROLE, new HyperLinkPopupBarEditPolicy()); >- } >- } >- >- /** >- * >- * {@inheritDoc} >- */ >- public boolean provides(IOperation operation) { >- CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation)operation; >- if(!(epOperation.getEditPart() instanceof GraphicalEditPart)) { >- return false; >- } >- GraphicalEditPart gep = (GraphicalEditPart)epOperation.getEditPart(); >- String diagramType = gep.getNotationView().getDiagram().getType(); >- if(ParametricEditPart.MODEL_ID.equals(diagramType)) { >- return true; >- } >- >- >- return false; >- } >- >- /** >- * >- * {@inheritDoc} >- */ >- public void removeProviderChangeListener(IProviderChangeListener listener) { >- >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ParametricDiagramContributionItemProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ParametricDiagramContributionItemProvider.java >deleted file mode 100644 >index 08146a8..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ParametricDiagramContributionItemProvider.java >+++ /dev/null >@@ -1,39 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider; >-import org.eclipse.gmf.runtime.common.ui.util.IWorkbenchPartDescriptor; >-import org.eclipse.jface.action.IAction; >-import org.eclipse.papyrus.sysml.diagram.parametric.actions.RestoreRelatedLinksAction; >- >- >-/** >- * The Class uses to contribute item for specific actions >- */ >-public class ParametricDiagramContributionItemProvider extends AbstractContributionItemProvider { >- >- /** >- * @see org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider#createAction(java.lang.String, >- * org.eclipse.gmf.runtime.common.ui.util.IWorkbenchPartDescriptor) >- */ >- @Override >- protected IAction createAction(String actionId, IWorkbenchPartDescriptor partDescriptor) { >- if(actionId.equals(RestoreRelatedLinksAction.ID)) { >- return new RestoreRelatedLinksAction(); >- } >- return super.createAction(actionId, partDescriptor); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ParametricDiagramContributionPolicyClass.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ParametricDiagramContributionPolicyClass.java >deleted file mode 100644 >index 9cb16bc..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ParametricDiagramContributionPolicyClass.java >+++ /dev/null >@@ -1,46 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2011 Atos Origin. >- * >- * >- * 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: >- * Atos Origin - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import org.eclipse.core.runtime.IConfigurationElement; >-import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.IPopupMenuContributionPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.ui.IEditorPart; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * Reduce the scope of the Menu contribution of the Parametric Diagram. >- * implements {@link IPopupMenuContributionPolicy} >- * >- * @author arthur daussy >- */ >-public class ParametricDiagramContributionPolicyClass implements IPopupMenuContributionPolicy { >- >- public boolean appliesTo(ISelection selection, IConfigurationElement configuration) { >- IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); >- if(editorPart instanceof IMultiDiagramEditor) { >- editorPart = ((IMultiDiagramEditor)editorPart).getActiveEditor(); >- if(editorPart instanceof DiagramEditor) { >- DiagramEditPart host = ((DiagramEditor)editorPart).getDiagramEditPart(); >- return ParametricEditPart.MODEL_ID.equals(host.getDiagramView().getType()); >- } >- } >- return false; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/texteditor/ConstraintPropertyConfiguration.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/texteditor/ConstraintPropertyConfiguration.java >deleted file mode 100644 >index 3489763..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/texteditor/ConstraintPropertyConfiguration.java >+++ /dev/null >@@ -1,133 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.texteditor; >- >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.jface.dialogs.IInputValidator; >-import org.eclipse.jface.text.source.SourceViewerConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.DefaultDirectEditorConfiguration; >-import org.eclipse.papyrus.parsers.modelgenerator.PropertyGenerator; >-import org.eclipse.papyrus.parsers.texteditor.CompletionFilterSourceViewerConfiguration.ICompletionFilter; >-import org.eclipse.papyrus.parsers.texteditor.propertylabel.IContext; >-import org.eclipse.papyrus.parsers.texteditor.propertylabel.PropertyConfigurationForUML; >-import org.eclipse.papyrus.parsers.texteditor.propertylabel.PropertyLabelSourceViewerConfiguration; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.uml.tools.utils.PropertyUtil; >-import org.eclipse.uml2.uml.Element; >-import org.eclipse.uml2.uml.Property; >- >-/** >- * Configuration Class for the direct edition of a SysML constraint property >- */ >-public class ConstraintPropertyConfiguration extends DefaultDirectEditorConfiguration { >- >- /** configuration of the source viewer */ >- final private PropertyLabelSourceViewerConfiguration configuration; >- >- /** >- * Creates a new PropertyConfiguration to filter values. >- */ >- public ConstraintPropertyConfiguration() { >- configuration = new PropertyLabelSourceViewerConfiguration(new ICompletionFilter() { >- >- public boolean filter(int context, EObject e) { >- switch(context) { >- case IContext.AFTER_COLON: >- if(e instanceof Element) { >- if(((Element)e).getAppliedStereotype("SysML::Constraints::ConstraintBlock") != null) { >- return false; >- } >- } >- >- return true; >- default: >- return false; >- } >- } >- }); >- } >- >- /** >- * {@inheritDoc} >- */ >- public SourceViewerConfiguration getSourceViewerConfiguration() { >- return configuration; >- } >- >- /** >- * {@inheritDoc} >- */ >- public String getTextToEdit(Object editedObject) { >- if(editedObject instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)editedObject).getBase_Property(); >- return PropertyUtil.getLabel(property); >- } >- return "not a Constraint Property"; >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public Object preEditAction(Object objectToEdit) { >- if(objectToEdit instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)objectToEdit).getBase_Property(); >- configuration.setProperty(property); >- } >- return super.preEditAction(objectToEdit); >- } >- >- /** >- * {@inheritDoc} >- */ >- public Object postEditAction(Object editedObject, String text) { >- if(editedObject instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)editedObject).getBase_Property(); >- PropertyGenerator generator = new PropertyGenerator(property); >- generator.parseAndModifyProperty(text); >- } >- return null; >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public IInputValidator getInputValidator() { >- return new IInputValidator() { >- >- public String isValid(String newText) { >- if(getObjectToEdit() instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)getObjectToEdit()).getBase_Property(); >- PropertyGenerator generator = new PropertyGenerator(property); >- return generator.parseAndValidateProperty(newText); >- } >- return null; >- } >- }; >- } >- >- /** >- * {@inheritDoc} >- */ >- @Override >- public Selection getTextSelection(String value, Object editedObject) { >- if(editedObject instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)editedObject).getBase_Property(); >- return new PropertyConfigurationForUML().getTextSelection(value, property); >- } >- return super.getTextSelection(value, editedObject); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/PropertyLinkedToClassifier.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/PropertyLinkedToClassifier.java >deleted file mode 100644 >index 828f779..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/PropertyLinkedToClassifier.java >+++ /dev/null >@@ -1,152 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Thibault Landre (Atos Origin) thibault.landre@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.utils; >- >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.emf.common.util.EList; >-import org.eclipse.uml2.uml.Classifier; >-import org.eclipse.uml2.uml.Port; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.Type; >- >-/** >- * PropertyLinkedToClassifier checks if a specified property is linked to a classifier >- */ >-public class PropertyLinkedToClassifier { >- >- /** The classifier. */ >- private final Classifier classifier; >- >- /** The property. */ >- private final Property property; >- >- /** The list routes. */ >- private List<Route> routes; >- >- /** >- * Instantiates a new property linked to classifier. >- * >- * @param classifier >- * @param property >- */ >- public PropertyLinkedToClassifier(Classifier classifier, Property property) { >- this.classifier = classifier; >- this.property = property; >- this.routes = new LinkedList<Route>(); >- refresh(); >- } >- >- /** >- * Checks if the property is linked to classifier. >- * >- * @return true, if is linked to classifier >- */ >- public boolean isLinkedToClassifier() { >- return !routes.isEmpty(); >- } >- >- /** >- * Checks if the property is linked to classifier with a multi-level path of accessible property from the classifier >- * >- * @return true, if is linked to classifier with a multi-level path >- */ >- public boolean isLinkedWithMultiLevelPath() { >- boolean result = false; >- if(!routes.isEmpty()) { >- for(Route r : routes) { >- result |= r.getRouteDepth() > 1; >- } >- } >- return result; >- } >- >- /** >- * Gets the available routes. >- * >- * @return the available routes >- */ >- public List<Route> getAvailableRoutes() { >- return routes; >- } >- >- /** >- * Gets the property. >- * >- * @return the property >- */ >- protected Property getProperty() { >- return property; >- } >- >- /** >- * Gets the number available route. >- * >- * @return the number available route >- */ >- public int getNumberAvailableRoute() { >- return routes.size(); >- } >- >- /** >- * Refresh link to classifier. >- * >- * @param classifierParent >- * @param propertyToFind >- * @param route >- */ >- private void refreshLinkToClassifier(Classifier classifierParent, final Property propertyToFind, final Route route) { >- EList<Property> classifierParentAttributes = classifierParent.getAllAttributes(); >- // If the property is contained by the classifier >- if(classifierParentAttributes.contains(propertyToFind)) { >- route.addSegment(propertyToFind); >- routes.add(route); >- } else { >- for(Property attribute : classifierParentAttributes) { >- if(!(attribute instanceof Port)) { >- Type attributeType = attribute.getType(); >- // stop loop >- if(route.getProperties().contains(attribute)) { >- // Launch a warning ? an error ? >- break; >- } >- if(attributeType instanceof Classifier) { >- Route newRoute = new Route(new LinkedList<Property>(route.getProperties())); >- newRoute.addSegment(attribute); >- refreshLinkToClassifier((Classifier)attributeType, propertyToFind, newRoute); >- } >- } >- } >- } >- } >- >- /** >- * Checks for several routes. >- * >- * @return true, if successful >- */ >- public boolean hasSeveralRoutes() { >- return routes.size() > 1; >- } >- >- /** >- * Refresh. >- */ >- public void refresh() { >- routes.clear(); >- refreshLinkToClassifier(classifier, property, new Route()); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/PropertyLinkedToClassifierNode.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/PropertyLinkedToClassifierNode.java >deleted file mode 100644 >index e918639..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/PropertyLinkedToClassifierNode.java >+++ /dev/null >@@ -1,234 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Thibault Landre (Atos Origin) thibault.landre@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.utils; >- >-import java.util.HashMap; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EcoreFactory; >-import org.eclipse.gmf.runtime.diagram.ui.commands.CreateOrSelectElementCommand.LabelProvider; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.IWorkbench; >-import org.eclipse.ui.dialogs.ElementListSelectionDialog; >-import org.eclipse.uml2.uml.Classifier; >-import org.eclipse.uml2.uml.Property; >- >-public class PropertyLinkedToClassifierNode extends PropertyLinkedToClassifier { >- >- public static final String PROPERTY_ROUTE_URL_SOURCE = "http://www.eclipse.org/papyrus/propertyRoute"; >- >- public static final String SELECTED_ROUTE_KEY = "selectedRoute"; >- >- private Node graphNode; >- >- public PropertyLinkedToClassifierNode(Classifier classifier, Property property, Node graphNode) { >- super(classifier, property); >- this.graphNode = graphNode; >- } >- >- /** >- * >- * @return >- */ >- public String getName() { >- String lName = ""; >- if(getAvailableRoutes().isEmpty()) { >- lName = getProperty().getName(); >- } else if(!hasSeveralRoutes()) { >- lName = getAvailableRoutes().get(0).getName(); >- } else { >- lName = getSelectedRoute(); >- } >- return lName; >- } >- >- private String getSelectedRoute() { >- String result = ""; >- if("".equals(getRootingProperty(graphNode))) { >- LinkedList<Route> filteredAvailableRoute = filterAvailableRoute(getAvailableRoutes()); >- if(filteredAvailableRoute.size() == 1) { >- result = filteredAvailableRoute.getFirst().getName(); >- } else if(!filteredAvailableRoute.isEmpty()) { >- // doesn't display dialog box, only get the first route >- //result = getUserSelectionRoute(filteredAvailableRoute); >- result = filteredAvailableRoute.getFirst().getName(); >- } >- } else { >- String oldRouteSelectedValue = getRootingProperty(graphNode); >- Map<String, Route> routeNameAndRoute = getRouteNameAndRoute(getAvailableRoutes()); >- if(routeNameAndRoute.containsKey(oldRouteSelectedValue)) { >- result = oldRouteSelectedValue; >- } else { >- result = calculateNewRoute(oldRouteSelectedValue); >- } >- } >- return result; >- } >- >- private String getUserSelectionRoute(LinkedList<Route> filteredAvailableRoute) { >- IWorkbench workBench = SysmlDiagramEditorPlugin.getInstance().getWorkbench(); >- Shell shell = workBench.getActiveWorkbenchWindow().getShell(); >- ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider() { >- >- @Override >- public String getText(Object element) { >- if(element instanceof Route) { >- return ((Route)element).getName(); >- } >- return super.getText(element); >- } >- }); >- dialog.setTitle("Routing selection"); >- dialog.setMessage("Select the route of the property (* = any string, ? = any char):"); >- dialog.setElements(filteredAvailableRoute.toArray()); >- dialog.setHelpAvailable(false); >- dialog.setMultipleSelection(false); >- dialog.open(); >- >- String result = ""; >- if(dialog.getResult() != null) { >- result = ((Route)dialog.getFirstResult()).getName(); >- } else { >- result = filteredAvailableRoute.getFirst().getName(); >- } >- return result; >- } >- >- /** >- * Filter the available route for accessing a property. Remove from the list the property that >- * are already displayed in the diagram. >- * >- * @param availableRoutes >- * the availableRoutes for this property >- * @return the availableRoutes for this property that are not already displayed in the diagram >- */ >- private LinkedList<Route> filterAvailableRoute(List<Route> availableRoutes) { >- Map<String, Route> routeNameAndRoute = getRouteNameAndRoute(availableRoutes); >- for(Object view : DiagramEditPartsUtil.getEObjectViews(getProperty())) { >- if(view instanceof Node) { >- String routeNamedSaved = getRootingProperty((Node)view); >- if(routeNameAndRoute.containsKey(routeNamedSaved)) { >- routeNameAndRoute.remove(routeNamedSaved); >- } >- } >- } >- return new LinkedList<Route>(routeNameAndRoute.values()); >- } >- >- /** >- * Return a map containing the routes and their associated names from a list of routes >- * >- * @param routes >- * the list of routes >- * @return the map with key the route, and value the name of the route. >- */ >- private Map<String, Route> getRouteNameAndRoute(List<Route> routes) { >- Map<String, Route> routeAndName = new HashMap<String, Route>(); >- for(Route route : routes) { >- routeAndName.put(route.getName(), route); >- } >- return routeAndName; >- } >- >- private String calculateNewRoute(String oldRouteSelectedValue) { >- List<String> availableSpecificRoute = new LinkedList<String>(); >- // If the length of the availableRoutes is bigger than the length of the old route, it means >- // that the property >- // is dragged/dropped to a parent container of its current container >- if(getAvailableRoutes().get(0).getName().length() > oldRouteSelectedValue.length()) { >- for(Route route : getAvailableRoutes()) { >- >- if(route.getName().indexOf(oldRouteSelectedValue) > 0) { >- availableSpecificRoute.add(route.getName()); >- } >- } >- // If a unique route is present in the list, it means that there is only a route >- // possible >- if(availableSpecificRoute.size() == 1) { >- return availableSpecificRoute.get(0); >- } else { >- // Otherwise it means there is several routes possible. We need to check the name of >- // the >- // container >- } >- } >- // Otherwise the element is dragged/dropped to a child container of its current container >- else { >- for(Route route : getAvailableRoutes()) { >- if(oldRouteSelectedValue.indexOf(route.getName()) > 0) { >- availableSpecificRoute.add(route.getName()); >- } >- } >- if(availableSpecificRoute.size() == 1) { >- return availableSpecificRoute.get(0); >- } >- } >- return ""; >- } >- >- /** >- * Creates the rooting property into an eAnnotation >- * >- * @param node >- * @param name >- */ >- public void createRootingProperty(Node node, String name) { >- if("".equals(getRootingProperty(node))) { >- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation(); >- annotation.setSource(PROPERTY_ROUTE_URL_SOURCE); >- node.getEAnnotations().add(annotation); >- >- annotation.getDetails().put(SELECTED_ROUTE_KEY, name); >- } >- } >- >- /** >- * Checks if the specified name is an existing route. >- * >- * @param name >- * @return true if it is an existing route >- */ >- public boolean isExistingRoute(String name) { >- boolean result = false; >- for(Route r : getAvailableRoutes()) { >- result |= r.getName().equals(name); >- } >- return result; >- } >- >- /** >- * Gets the rooting property. >- * >- * @param node >- * the node >- * @param key >- * the key >- * @return the rooting property >- */ >- private String getRootingProperty(Node node) { >- String value = ""; >- EAnnotation eAnnotation = node.getEAnnotation(PROPERTY_ROUTE_URL_SOURCE); >- if(eAnnotation != null) { >- value = eAnnotation.getDetails().get(SELECTED_ROUTE_KEY); >- } >- return value; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/Route.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/Route.java >deleted file mode 100644 >index 612b435..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/custom-src/org/eclipse/papyrus/sysml/diagram/parametric/utils/Route.java >+++ /dev/null >@@ -1,102 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Thibault Landre (Atos Origin) thibault.landre@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.utils; >- >-import java.util.LinkedList; >- >-import org.eclipse.uml2.uml.Property; >- >-/** >- * A class to described a route to access a property from a classifier. This class contains an >- * ordered list of the property contained in the route and a string representing the name of the >- * route. >- */ >-public class Route { >- >- /** The properties list. */ >- private LinkedList<Property> propertyList; >- >- /** The name of the route */ >- private String name; >- >- /** >- * Instantiates a new route. >- */ >- public Route() { >- this(new LinkedList<Property>()); >- } >- >- /** >- * Instantiates a new route. >- * >- * @param propertyList >- */ >- public Route(LinkedList<Property> propertyList) { >- assert propertyList != null; >- this.propertyList = propertyList; >- this.name = ""; >- } >- >- /** >- * Adds a property to the list >- * >- * @param property >- */ >- protected void addSegment(Property property) { >- propertyList.add(property); >- } >- >- /** >- * Calculate the name of the route. The name is composed of the name of each property which >- * makes up the route separated by coma. >- */ >- private void calculateName() { >- name = ""; >- for(Property property : propertyList) { >- if(name.length() == 0) { >- name = property.getName(); >- } else { >- name = name + "." + property.getName(); >- } >- } >- } >- >- /** >- * Gets the name. >- * >- * @return the name >- */ >- public String getName() { >- calculateName(); >- return name; >- } >- >- /** >- * Gets the properties. >- * >- * @return the properties >- */ >- public LinkedList<Property> getProperties() { >- return propertyList; >- } >- >- /** >- * Gets the route depth. >- * >- * @return the route depth >- */ >- public int getRouteDepth() { >- return propertyList.size(); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/incomingLinksNavigatorGroup.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/incomingLinksNavigatorGroup.gif >deleted file mode 100644 >index fca9c53..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/incomingLinksNavigatorGroup.gif >+++ /dev/null >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linkSourceNavigatorGroup.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linkSourceNavigatorGroup.gif >deleted file mode 100644 >index fca9c53..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linkSourceNavigatorGroup.gif >+++ /dev/null >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linkTargetNavigatorGroup.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linkTargetNavigatorGroup.gif >deleted file mode 100644 >index fca9c53..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linkTargetNavigatorGroup.gif >+++ /dev/null >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linksNavigatorGroup.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linksNavigatorGroup.gif >deleted file mode 100644 >index fca9c53..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/linksNavigatorGroup.gif >+++ /dev/null >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Diagram_Parametric.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Diagram_Parametric.gif >deleted file mode 100644 >index 97e8dd3..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Diagram_Parametric.gif >+++ /dev/null >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Diagram_Parametric.png b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Diagram_Parametric.png >new file mode 100644 >index 0000000..58af58e >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Diagram_Parametric.png >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Link.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Link.gif >new file mode 100644 >index 0000000..13fb22e >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/Link.gif >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/ResourceDiagramFile.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/ResourceDiagramFile.gif >deleted file mode 100644 >index 135bfef..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/obj16/ResourceDiagramFile.gif >+++ /dev/null >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/outgoingLinksNavigatorGroup.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/outgoingLinksNavigatorGroup.gif >deleted file mode 100644 >index fca9c53..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/outgoingLinksNavigatorGroup.gif >+++ /dev/null >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/wizban/NewResourceWizard.gif b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/wizban/NewResourceWizard.gif >deleted file mode 100644 >index 93641ae..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/icons/wizban/NewResourceWizard.gif >+++ /dev/null >Binary files differ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/messages.properties b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/messages.properties >deleted file mode 100644 >index d0e3256..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/messages.properties >+++ /dev/null >@@ -1,133 +0,0 @@ >-#/***************************************************************************** >-# * Copyright (c) 2009 Atos Origin. >-# * >-# * >-# * 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: >-# * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >-# * >-# *****************************************************************************/ >-# TODO: manually put keys and values >-SysMLCreationWizardTitle=New SysML Diagram >-SysMLCreationWizard_DiagramModelFilePageTitle=Create SysML Diagram >-SysMLCreationWizard_DiagramModelFilePageDescription=Select file that will contain diagram model. >-SysMLCreationWizard_DomainModelFilePageTitle=Create SysML Domain Model >-SysMLCreationWizard_DomainModelFilePageDescription=Select file that will contain domain model. >-SysMLCreationWizardOpenEditorError=Error opening diagram editor >-SysMLCreationWizardCreationError=Creation Problems >-SysMLCreationWizardPageExtensionError=File name should have {0} extension. >-SysMLDiagramEditorUtil_OpenModelResourceErrorDialogTitle=Error >-SysMLDiagramEditorUtil_OpenModelResourceErrorDialogMessage=Failed to load model file {0} >-SysMLDiagramEditorUtil_CreateDiagramProgressTask=Creating diagram and model files >-SysMLDiagramEditorUtil_CreateDiagramCommandLabel=Creating diagram and model >-SysMLDocumentProvider_isModifiable=Updating cache failed >-SysMLDocumentProvider_handleElementContentChanged=Failed to refresh hierarchy for changed resource >-SysMLDocumentProvider_IncorrectInputError={1} >-SysMLDocumentProvider_NoDiagramInResourceError=Diagram is not present in resource >-SysMLDocumentProvider_DiagramLoadingError=Error loading diagram >-SysMLDocumentProvider_UnsynchronizedFileSaveError=The file has been changed on the file system >-SysMLDocumentProvider_SaveDiagramTask=Saving diagram >-SysMLDocumentProvider_SaveNextResourceTask=Saving {0} >-SysMLDocumentProvider_SaveAsOperation=Saving {0} diagram as >-InitDiagramFile_ResourceErrorDialogTitle=Error >-InitDiagramFile_ResourceErrorDialogMessage=Model file loading failed >-InitDiagramFile_WizardTitle=Initialize new {0} diagram file >-InitDiagramFile_OpenModelFileDialogTitle=Select domain model >-SysMLNewDiagramFileWizard_CreationPageName=Initialize new diagram file >-SysMLNewDiagramFileWizard_CreationPageTitle=Diagram file >-SysMLNewDiagramFileWizard_CreationPageDescription=Create new diagram based on {0} model content >-SysMLNewDiagramFileWizard_RootSelectionPageName=Select diagram root element >-SysMLNewDiagramFileWizard_RootSelectionPageTitle=Diagram root element >-SysMLNewDiagramFileWizard_RootSelectionPageDescription=Select semantic model element to be depicted on diagram >-SysMLNewDiagramFileWizard_RootSelectionPageSelectionTitle=Select diagram root element: >-SysMLNewDiagramFileWizard_RootSelectionPageNoSelectionMessage=Diagram root element is not selected >-SysMLNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage=Invalid diagram root element is selected >-SysMLNewDiagramFileWizard_InitDiagramCommand=Initializing diagram contents >-SysMLNewDiagramFileWizard_IncorrectRootError=Incorrect model object stored as a root resource object >-SysMLDiagramEditor_SavingDeletedFile=The original file "{0}" has been deleted. >-SysMLDiagramEditor_SaveAsErrorTitle=Problem During Save As... >-SysMLDiagramEditor_SaveAsErrorMessage=Save could not be completed. Target file is already open in another editor. >-SysMLDiagramEditor_SaveErrorTitle=Save Problems >-SysMLDiagramEditor_SaveErrorMessage=Could not save file. >-SysMLElementChooserDialog_SelectModelElementTitle=Select model element >-ModelElementSelectionPageMessage=Select model element: >-ValidateActionMessage=Validate >-Sysml1Group_title=sysml >-ConstraintBlock1CreationTool_title=ConstraintBlock >-ConstraintBlock1CreationTool_desc=Create new ConstraintBlock >-ConstraintProperty2CreationTool_title=ConstraintProperty >-ConstraintProperty2CreationTool_desc=Create new ConstraintProperty >- >-CommandName_OpenDiagram=Open Diagram >-NavigatorActionProvider_OpenDiagramActionName=Open Diagram >-SysMLModelingAssistantProviderTitle=Select domain model element >-SysMLModelingAssistantProviderMessage=Available domain model elements: >-SysmlCreationWizardTitle=New Parametric Diagram >-SysmlCreationWizard_DiagramModelFilePageTitle=Create Parametric Diagram >-SysmlCreationWizard_DiagramModelFilePageDescription=Select file that will contain diagram model. >-SysmlCreationWizard_DomainModelFilePageTitle=Create Parametric Domain Model >-SysmlCreationWizard_DomainModelFilePageDescription=Select file that will contain domain model. >-SysmlCreationWizardOpenEditorError=Error opening diagram editor >-SysmlCreationWizardCreationError=Creation Problems >-SysmlCreationWizardPageExtensionError=File name should have {0} extension. >-SysmlDiagramEditorUtil_OpenModelResourceErrorDialogTitle=Error >-SysmlDiagramEditorUtil_OpenModelResourceErrorDialogMessage=Failed to load model file {0} >-SysmlDiagramEditorUtil_CreateDiagramProgressTask=Creating diagram and model files >-SysmlDiagramEditorUtil_CreateDiagramCommandLabel=Creating diagram and model >-SysmlDocumentProvider_isModifiable=Updating cache failed >-SysmlDocumentProvider_handleElementContentChanged=Failed to refresh hierarchy for changed resource >-SysmlDocumentProvider_IncorrectInputError={1} >-SysmlDocumentProvider_NoDiagramInResourceError=Diagram is not present in resource >-SysmlDocumentProvider_DiagramLoadingError=Error loading diagram >-SysmlDocumentProvider_UnsynchronizedFileSaveError=The file has been changed on the file system >-SysmlDocumentProvider_SaveDiagramTask=Saving diagram >-SysmlDocumentProvider_SaveNextResourceTask=Saving {0} >-SysmlDocumentProvider_SaveAsOperation=Saving {0} diagram as >-SysmlNewDiagramFileWizard_CreationPageName=Initialize new diagram file >-SysmlNewDiagramFileWizard_CreationPageTitle=Diagram file >-SysmlNewDiagramFileWizard_CreationPageDescription=Create new diagram based on {0} model content >-SysmlNewDiagramFileWizard_RootSelectionPageName=Select diagram root element >-SysmlNewDiagramFileWizard_RootSelectionPageTitle=Diagram root element >-SysmlNewDiagramFileWizard_RootSelectionPageDescription=Select semantic model element to be depicted on diagram >-SysmlNewDiagramFileWizard_RootSelectionPageSelectionTitle=Select diagram root element: >-SysmlNewDiagramFileWizard_RootSelectionPageNoSelectionMessage=Diagram root element is not selected >-SysmlNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage=Invalid diagram root element is selected >-SysmlNewDiagramFileWizard_InitDiagramCommand=Initializing diagram contents >-SysmlNewDiagramFileWizard_IncorrectRootError=Incorrect model object stored as a root resource object >-SysmlDiagramEditor_SavingDeletedFile=The original file "{0}" has been deleted. >-SysmlDiagramEditor_SaveAsErrorTitle=Problem During Save As... >-SysmlDiagramEditor_SaveAsErrorMessage=Save could not be completed. Target file is already open in another editor. >-SysmlDiagramEditor_SaveErrorTitle=Save Problems >-SysmlDiagramEditor_SaveErrorMessage=Could not save file. >-SysmlElementChooserDialog_SelectModelElementTitle=Select model element >-SysmlModelingAssistantProviderTitle=Select domain model element >-SysmlModelingAssistantProviderMessage=Available domain model elements: >-ConstraintProperty1CreationTool_title=ConstraintProperty >-ConstraintProperty1CreationTool_desc=Create new ConstraintProperty >-Property2CreationTool_title=Property >-Property2CreationTool_desc=Create new Property >-AbstractParser_UnexpectedValueType=Value of type {0} is expected >-AbstractParser_WrongStringConversion=String value does not convert to {0} value >-AbstractParser_UnknownLiteral=Unknown literal: {0} >-MessageFormatParser_InvalidInputError=Invalid input at {0} >-Parametric1Group_title=Parametric >-Connector3CreationTool_title=Connector >-Connector3CreationTool_desc=Create new Connector >-NavigatorGroupName_Resource_1000_links=links >-NavigatorGroupName_Property_2005_incominglinks=incoming links >-NavigatorGroupName_Property_2005_outgoinglinks=outgoing links >-NavigatorGroupName_Property_3002_incominglinks=incoming links >-NavigatorGroupName_Property_3002_outgoinglinks=outgoing links >-NavigatorGroupName_Connector_4001_target=target >-NavigatorGroupName_Connector_4001_source=source >-createParametric1Group_title=Parametric >-createConstraintProperty1CreationTool_title=ConstraintProperty >-createConstraintProperty1CreationTool_desc=Create new ConstraintProperty >-createProperty2CreationTool_title=Property >-createProperty2CreationTool_desc=Create new Property >-createConnector3CreationTool_title=Connector >-createConnector3CreationTool_desc=Create new Connector >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfgen b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfgen >deleted file mode 100644 >index 274361d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfgen >+++ /dev/null >@@ -1,559 +0,0 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<xmi:XMI xmi:version="2.0" >- xmlns:xmi="http://www.omg.org/XMI" >- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >- xmlns:gmfgen="http://www.eclipse.org/gmf/2009/GenModel" >- xmlns:papyrusgmfgenextension="http://www.eclipse.org/papyrus/2009/papyrusgmfgenextension"> >- <gmfgen:GenEditorGenerator >- packageNamePrefix="org.eclipse.papyrus.sysml.diagram.parametric" >- modelID="Parametric" >- dynamicTemplates="true" >- templateDirectory="/org.eclipse.papyrus.def/dynamic-templates3.5/codegen"> >- <audits> >- <categories >- id="org.eclipse.uml2.uml.util.UMLValidator.validate" >- name="validateSysMLModel" >- description="Validate the SysML model" >- path="/0/@audits/@categories.0"/> >- <categories >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement" >- name="validateConnectorElement" >- description="validate a connector checking that its children are consistent" >- path="/0/@audits/@categories.0 /0/@audits/@categories.1" >- audits="/0/@audits/@rules.0 /0/@audits/@rules.1 /0/@audits/@rules.2 /0/@audits/@rules.3"/> >- <rules >- name="validateConnector" >- description="The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property" >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateConnector" >- rule="/0/@expressionProviders/@providers.0/@expressions.0" >- message="NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector." >- severity="WARNING" >- useInLiveMode="true" >- category="/0/@audits/@categories.1"> >- <target >- xsi:type="gmfgen:GenDomainElementTarget" >- contextSelector="/0/@audits/@clientContexts.0"> >- <element >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Connector"/> >- </target> >- </rules> >- <rules >- name="validateProperty" >- description="When you move a property, check that its incoming or outgoings connector get consistent connectorEnd" >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateProperty" >- rule="/0/@expressionProviders/@providers.0/@expressions.1" >- message="NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector." >- severity="WARNING" >- useInLiveMode="true" >- category="/0/@audits/@categories.1"> >- <target >- xsi:type="gmfgen:GenDomainElementTarget" >- contextSelector="/0/@audits/@clientContexts.0"> >- <element >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Property"/> >- </target> >- </rules> >- <rules >- name="validateConnectorEnd" >- description="The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property" >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateConnectorEnd" >- rule="/0/@expressionProviders/@providers.0/@expressions.2" >- message="NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector." >- severity="WARNING" >- useInLiveMode="true" >- category="/0/@audits/@categories.1"> >- <target >- xsi:type="gmfgen:GenDomainElementTarget" >- contextSelector="/0/@audits/@clientContexts.0"> >- <element >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/ConnectorEnd"/> >- </target> >- </rules> >- <rules >- name="validateNestedConnectorEnd" >- description="The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property" >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateNestedConnectorEnd" >- rule="/0/@expressionProviders/@providers.0/@expressions.3" >- message="NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector." >- severity="WARNING" >- useInLiveMode="true" >- category="/0/@audits/@categories.1"> >- <target >- xsi:type="gmfgen:GenDomainElementTarget" >- contextSelector="/0/@audits/@clientContexts.0"> >- <element >- href="../../org.eclipse.papyrus.sysml/model/sysml.genmodel#//sysml/blocks/NestedConnectorEnd"/> >- </target> >- </rules> >- <clientContexts >- ruleTargets="/0/@audits/@rules.0/@target /0/@audits/@rules.1/@target /0/@audits/@rules.2/@target /0/@audits/@rules.3/@target"/> >- </audits> >- <diagram >- visualID="1000" >- editPartClassName="ParametricEditPart" >- itemSemanticEditPolicyClassName="ParametricItemSemanticEditPolicy" >- canonicalEditPolicyClassName="ParametricCanonicalEditPolicy" >- iconProviderPriority="Low" >- validationProviderPriority="Low"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Diagram"/> >- <elementType >- xsi:type="gmfgen:MetamodelType" >- editHelperClassName="ResourceEditHelper"/> >- <viewmap >- xsi:type="gmfgen:FigureViewmap" >- figureQualifiedClassName="org.eclipse.draw2d.FreeformLayer"/> >- <behaviour >- xsi:type="gmfgen:CustomBehaviour" >- key="EditPolicyRoles.DRAG_DROP_ROLE" >- editPolicyQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.CustomDiagramDragDropEditPolicy"/> >- <domainDiagramElement >- href="../../../plugin/org.eclipse.papyrus.infra.core.resource/model/resource.genmodel#//resource/Resource"/> >- <childNodes >- xsi:type="gmfgen:GenChildSideAffixedNode" >- visualID="3002" >- editPartClassName="Property2EditPart" >- itemSemanticEditPolicyClassName="Property2ItemSemanticEditPolicy" >- notationViewFactoryClassName="PropertyViewFactory" >- canonicalEditPolicyClassName="Property2CanonicalEditPolicy" >- graphicalNodeEditPolicyClassName="Property2GraphicalNodeEditPolicy" >- createCommandClassName="Property2CreateCommand" >- containers="/0/@diagram/@topLevelNodes.0"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> >- <elementType >- xsi:type="gmfgen:MetamodelType" >- editHelperClassName="PropertyEditHelper"/> >- <viewmap >- xsi:type="gmfgen:InnerClassViewmap" >- className="ParameterDescriptor" >- classBody="
/**
 * @generated
 */
public class ParameterDescriptor extends org.eclipse.draw2d.RectangleFigure {




	/**
	 * @generated
	 */
	public ParameterDescriptor() {
				this.setLineWidth(1);
this.setPreferredSize(new org.eclipse.draw2d.geometry.Dimension(getMapMode().DPtoLP(16)
, getMapMode().DPtoLP(16)
));
	}


	/**
	 * @generated
	 */
	private boolean myUseLocalCoordinates = false;

	/**
	 * @generated
	 */
	protected boolean useLocalCoordinates() {
		return myUseLocalCoordinates;
	}

	/**
	 * @generated
	 */
	protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
		myUseLocalCoordinates = useLocalCoordinates;
	}





}

"> >- <attributes >- xsi:type="gmfgen:DefaultSizeAttributes" >- width="16" >- height="16"/> >- </viewmap> >- <behaviour >- xsi:type="gmfgen:OpenDiagramBehaviour"/> >- <behaviour >- xsi:type="gmfgen:CustomBehaviour" >- key="RequestConstants.REQ_DELETE" >- editPolicyQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromDiagramEditPolicy"/> >- <behaviour >- xsi:type="gmfgen:CustomBehaviour" >- key="RequestConstants.REQ_SEMANTIC_WRAPPER" >- editPolicyQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromModelEditPolicy"/> >- <modelFacet> >- <metaClass >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Property"/> >- <containmentMetaFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/StructuredClassifier/ownedAttribute"/> >- <childMetaFeature >- href="../../org.eclipse.papyrus.sysml/model/sysml.genmodel#//sysml/constraints/ConstraintProperty/base_Property"/> >- </modelFacet> >- <labels >- xsi:type="gmfgen:GenExternalNodeLabel" >- visualID="5003" >- editPartClassName="PropertyName2EditPart" >- itemSemanticEditPolicyClassName="PropertyName2ItemSemanticEditPolicy" >- notationViewFactoryClassName="PropertyNameViewFactory"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> >- <viewmap >- xsi:type="gmfgen:FigureViewmap" >- figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"/> >- <behaviour >- xsi:type="gmfgen:CustomBehaviour" >- key="RequestConstants.REQ_DELETE" >- editPolicyQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromDiagramEditPolicy"/> >- <behaviour >- xsi:type="gmfgen:CustomBehaviour" >- key="RequestConstants.REQ_SEMANTIC_WRAPPER" >- editPolicyQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromModelEditPolicy"/> >- <modelFacet >- xsi:type="gmfgen:FeatureLabelModelFacet" >- parser="/0/@labelParsers/@implementations.1"> >- <metaFeatures >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> >- </modelFacet> >- </labels> >- </childNodes> >- <topLevelNodes >- visualID="2003" >- editPartClassName="ConstraintPropertyEditPart" >- itemSemanticEditPolicyClassName="ConstraintPropertyItemSemanticEditPolicy" >- notationViewFactoryClassName="ConstraintPropertyViewFactory" >- canonicalEditPolicyClassName="ConstraintPropertyCanonicalEditPolicy" >- childNodes="/0/@diagram/@childNodes.0" >- graphicalNodeEditPolicyClassName="ConstraintPropertyGraphicalNodeEditPolicy" >- createCommandClassName="ConstraintPropertyCreateCommand"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> >- <elementType >- xsi:type="gmfgen:MetamodelType" >- editHelperClassName="ConstraintPropertyEditHelper"/> >- <viewmap >- xsi:type="gmfgen:InnerClassViewmap" >- className="ConstraintPropertyFigureDescriptor" >- classBody="
/**
 * @generated
 */
public class ConstraintPropertyFigureDescriptor extends org.eclipse.draw2d.RoundedRectangle {


	/**
	 * @generated
	 */
	private org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel fConstraintPropertyFigureLabel; 
	/**
	 * @generated
	 */
	private org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel fConstraintLabel; 


	/**
	 * @generated
	 */
	public ConstraintPropertyFigureDescriptor() {
		
	org.eclipse.draw2d.GridLayout layoutThis = new org.eclipse.draw2d.GridLayout();
	layoutThis.numColumns = 1;
	layoutThis.makeColumnsEqualWidth = true;
	this.setLayoutManager(layoutThis);

		this.setCornerDimensions(new org.eclipse.draw2d.geometry.Dimension(getMapMode().DPtoLP(25)
, getMapMode().DPtoLP(25)
));
this.setLineWidth(1);
this.setMinimumSize(new org.eclipse.draw2d.geometry.Dimension(getMapMode().DPtoLP(200)
, getMapMode().DPtoLP(120)
));
		createContents();
	}
	/**
	 * @generated
	 */
	private void createContents(){


fConstraintPropertyFigureLabel = new org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel();




org.eclipse.draw2d.GridData constraintFConstraintPropertyFigureLabel = new org.eclipse.draw2d.GridData();
constraintFConstraintPropertyFigureLabel.verticalAlignment = org.eclipse.draw2d.GridData.END;
constraintFConstraintPropertyFigureLabel.horizontalAlignment = org.eclipse.draw2d.GridData.CENTER;
constraintFConstraintPropertyFigureLabel.horizontalIndent = 0;
constraintFConstraintPropertyFigureLabel.horizontalSpan = 1;
constraintFConstraintPropertyFigureLabel.verticalSpan = 1;
constraintFConstraintPropertyFigureLabel.grabExcessHorizontalSpace = true;
constraintFConstraintPropertyFigureLabel.grabExcessVerticalSpace = true;
this.add(fConstraintPropertyFigureLabel, constraintFConstraintPropertyFigureLabel);




fConstraintLabel = new org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel();




org.eclipse.draw2d.GridData constraintFConstraintLabel = new org.eclipse.draw2d.GridData();
constraintFConstraintLabel.verticalAlignment = org.eclipse.draw2d.GridData.BEGINNING;
constraintFConstraintLabel.horizontalAlignment = org.eclipse.draw2d.GridData.END;
constraintFConstraintLabel.horizontalIndent = 0;
constraintFConstraintLabel.horizontalSpan = 1;
constraintFConstraintLabel.verticalSpan = 1;
constraintFConstraintLabel.grabExcessHorizontalSpace = true;
constraintFConstraintLabel.grabExcessVerticalSpace = true;
this.add(fConstraintLabel, constraintFConstraintLabel);



	}




	/**
	 * @generated
	 */
	private boolean myUseLocalCoordinates = false;

	/**
	 * @generated
	 */
	protected boolean useLocalCoordinates() {
		return myUseLocalCoordinates;
	}

	/**
	 * @generated
	 */
	protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
		myUseLocalCoordinates = useLocalCoordinates;
	}



	/**
	 * @generated
	 */
	public org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel getConstraintPropertyFigureLabel() {
		return fConstraintPropertyFigureLabel;
	}
	/**
	 * @generated
	 */
	public org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel getConstraintLabel() {
		return fConstraintLabel;
	}


}

"/> >- <behaviour >- xsi:type="gmfgen:CustomBehaviour" >- key="RequestConstants.REQ_CREATE" >- editPolicyQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.CreateParameterEditPolicy"/> >- <modelFacet> >- <metaClass >- href="../../org.eclipse.papyrus.sysml/model/sysml.genmodel#//sysml/constraints/ConstraintProperty"/> >- <containmentMetaFeature >- href="../../../plugin/org.eclipse.papyrus.infra.core.resource/model/resource.genmodel#//resource/Resource/eobjects"/> >- <childMetaFeature >- href="../../../plugin/org.eclipse.papyrus.infra.core.resource/model/resource.genmodel#//resource/Resource/eobjects"/> >- </modelFacet> >- <labels >- visualID="5001" >- editPartClassName="ConstraintPropertyNameEditPart" >- itemSemanticEditPolicyClassName="ConstraintPropertyNameItemSemanticEditPolicy" >- notationViewFactoryClassName="ConstraintPropertyLabelViewFactory" >- elementIcon="true"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> >- <viewmap >- xsi:type="gmfgen:ParentAssignedViewmap" >- getterName="getConstraintPropertyFigureLabel" >- figureQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel"/> >- <modelFacet >- parser="/0/@labelParsers/@implementations.3"/> >- </labels> >- <labels >- visualID="5004" >- editPartClassName="ConstraintLabelEditPart" >- itemSemanticEditPolicyClassName="ConstraintLabelItemSemanticEditPolicy" >- notationViewFactoryClassName="ConstraintPropertyLabelViewFactory" >- elementIcon="true"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> >- <viewmap >- xsi:type="gmfgen:ParentAssignedViewmap" >- getterName="getConstraintLabel" >- figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"/> >- <behaviour >- xsi:type="gmfgen:CustomBehaviour" >- key="RequestConstants.REQ_SEMANTIC_WRAPPER" >- editPolicyQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromModelEditPolicy"/> >- <modelFacet >- parser="/0/@labelParsers/@implementations.4"/> >- </labels> >- </topLevelNodes> >- <topLevelNodes >- visualID="2005" >- editPartClassName="PropertyEditPart" >- itemSemanticEditPolicyClassName="PropertyItemSemanticEditPolicy" >- notationViewFactoryClassName="PropertyViewFactory" >- canonicalEditPolicyClassName="PropertyCanonicalEditPolicy" >- graphicalNodeEditPolicyClassName="PropertyGraphicalNodeEditPolicy" >- createCommandClassName="PropertyCreateCommand"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> >- <elementType >- xsi:type="gmfgen:SpecializationType" >- metamodelType="/0/@diagram/@childNodes.0/@elementType"/> >- <viewmap >- xsi:type="gmfgen:InnerClassViewmap" >- className="PropertyFigure" >- classBody="
/**
 * @generated
 */
public class PropertyFigure extends org.eclipse.draw2d.RectangleFigure {


	/**
	 * @generated
	 */
	private org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel fPropertyFigureLabel; 


	/**
	 * @generated
	 */
	public PropertyFigure() {
		
	org.eclipse.papyrus.uml.diagram.common.draw2d.CenterLayout layoutThis = new org.eclipse.papyrus.uml.diagram.common.draw2d.CenterLayout();


	this.setLayoutManager(layoutThis);

		this.setLineWidth(1);
this.setMinimumSize(new org.eclipse.draw2d.geometry.Dimension(getMapMode().DPtoLP(100)
, getMapMode().DPtoLP(40)
));
		createContents();
	}
	/**
	 * @generated
	 */
	private void createContents(){


fPropertyFigureLabel = new org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel();



this.add(fPropertyFigureLabel);


	}




	/**
	 * @generated
	 */
	private boolean myUseLocalCoordinates = false;

	/**
	 * @generated
	 */
	protected boolean useLocalCoordinates() {
		return myUseLocalCoordinates;
	}

	/**
	 * @generated
	 */
	protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
		myUseLocalCoordinates = useLocalCoordinates;
	}



	/**
	 * @generated
	 */
	public org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel getPropertyFigureLabel() {
		return fPropertyFigureLabel;
	}


}

"/> >- <modelFacet> >- <metaClass >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Property"/> >- <containmentMetaFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/StructuredClassifier/ownedAttribute"/> >- <childMetaFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/StructuredClassifier/ownedAttribute"/> >- </modelFacet> >- <labels >- visualID="5002" >- editPartClassName="PropertyNameEditPart" >- itemSemanticEditPolicyClassName="PropertyNameItemSemanticEditPolicy" >- notationViewFactoryClassName="PropertyNameViewFactory" >- elementIcon="true"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> >- <viewmap >- xsi:type="gmfgen:ParentAssignedViewmap" >- getterName="getPropertyFigureLabel" >- figureQualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel"/> >- <modelFacet >- xsi:type="gmfgen:FeatureLabelModelFacet" >- parser="/0/@labelParsers/@implementations.1"> >- <metaFeatures >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> >- </modelFacet> >- </labels> >- </topLevelNodes> >- <links >- visualID="4001" >- editPartClassName="ConnectorEditPart" >- itemSemanticEditPolicyClassName="ConnectorItemSemanticEditPolicy" >- notationViewFactoryClassName="ConnectorViewFactory" >- createCommandClassName="ConnectorCreateCommand" >- reorientCommandClassName="ConnectorReorientCommand"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Edge"/> >- <elementType >- xsi:type="gmfgen:MetamodelType" >- editHelperClassName="ConnectorEditHelper"/> >- <viewmap >- xsi:type="gmfgen:InnerClassViewmap" >- className="ConnectorFigure" >- classBody="
/**
 * @generated
 */
public class ConnectorFigure extends org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx {


	/**
	 * @generated
	 */
	private org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel fConnectorLabel; 


	/**
	 * @generated
	 */
	public ConnectorFigure() {
		this.setLineWidth(1);

		createContents();
	}


	/**
	 * @generated
	 */
	private void createContents(){


fConnectorLabel = new org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel();
fConnectorLabel.setText("");

this.add(fConnectorLabel);


	}


	/**
	 * @generated
	 */
	public org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel getConnectorLabel() {
		return fConnectorLabel;
	}


}

"/> >- <modelFacet >- xsi:type="gmfgen:TypeLinkModelFacet"> >- <metaClass >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Connector"/> >- <containmentMetaFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/StructuredClassifier/ownedConnector"/> >- <childMetaFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/StructuredClassifier/ownedConnector"/> >- <sourceMetaFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/ConnectorEnd/role"/> >- <targetMetaFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/ConnectorEnd/role"/> >- </modelFacet> >- <labels >- visualID="6001" >- editPartClassName="ConnectorNameEditPart" >- itemSemanticEditPolicyClassName="ConnectorNameItemSemanticEditPolicy" >- notationViewFactoryClassName="ConnectorNameViewFactory" >- elementIcon="true"> >- <diagramRunTimeClass >- href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> >- <viewmap >- xsi:type="gmfgen:ParentAssignedViewmap" >- getterName="getConnectorLabel" >- figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"> >- <attributes >- xsi:type="gmfgen:LabelOffsetAttributes" >- y="40"/> >- </viewmap> >- <modelFacet >- xsi:type="gmfgen:FeatureLabelModelFacet" >- parser="/0/@labelParsers/@implementations.2"> >- <metaFeatures >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> >- </modelFacet> >- </labels> >- </links> >- <palette> >- <groups >- title="Parametric" >- largeIconPath="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif" >- smallIconPath="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif"> >- <entries >- xsi:type="gmfgen:ToolEntry" >- title="ConstraintProperty" >- description="Create new ConstraintProperty" >- largeIconPath="platform:/plugin/org.eclipse.papyrus.sysml.edit/icons/full/obj16/ConstraintProperty.gif" >- smallIconPath="platform:/plugin/org.eclipse.papyrus.sysml.edit/icons/full/obj16/ConstraintProperty.gif" >- genNodes="/0/@diagram/@topLevelNodes.0"/> >- <entries >- xsi:type="gmfgen:ToolEntry" >- title="Property" >- description="Create new Property" >- largeIconPath="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif" >- smallIconPath="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif" >- genNodes="/0/@diagram/@childNodes.0 /0/@diagram/@topLevelNodes.1"/> >- <entries >- xsi:type="gmfgen:ToolEntry" >- title="Connector" >- description="Create new Connector" >- smallIconPath="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Connector.gif" >- genLinks="/0/@diagram/@links.0"/> >- </groups> >- </palette> >- <preferencePages >- xsi:type="gmfgen:GenStandardPreferencePage" >- iD="org.eclipse.papyrus.sysml.diagram.general" >- name="Sysml Diagram"> >- <children >- xsi:type="gmfgen:GenStandardPreferencePage" >- iD="org.eclipse.papyrus.sysml.diagram.appearance" >- name="Appearance" >- kind="Appearance"/> >- <children >- xsi:type="gmfgen:GenStandardPreferencePage" >- iD="org.eclipse.papyrus.sysml.diagram.connections" >- name="Connections" >- kind="Connections"/> >- <children >- xsi:type="gmfgen:GenStandardPreferencePage" >- iD="org.eclipse.papyrus.sysml.diagram.printing" >- name="Printing" >- kind="Printing"/> >- <children >- xsi:type="gmfgen:GenStandardPreferencePage" >- iD="org.eclipse.papyrus.sysml.diagram.rulersAndGrid" >- name="Rulers And Grid" >- kind="RulersAndGrid"/> >- </preferencePages> >- </diagram> >- <plugin >- iD="org.eclipse.papyrus.sysml.diagram.parametric" >- name="Sysml Parametric diagram Plugin" >- provider="Eclipse.org" >- version="0.9.0.qualifier"> >- <requiredPlugins>org.eclipse.draw2d</requiredPlugins> >- <requiredPlugins>org.eclipse.gmf.runtime.draw2d.ui</requiredPlugins> >- </plugin> >- <editor/> >- <navigator> >- <childReferences >- child="/0/@diagram"/> >- <childReferences >- parent="/0/@diagram/@topLevelNodes.0" >- child="/0/@diagram/@childNodes.0"/> >- <childReferences >- parent="/0/@diagram" >- child="/0/@diagram/@topLevelNodes.0"/> >- <childReferences >- parent="/0/@diagram" >- child="/0/@diagram/@topLevelNodes.1"/> >- <childReferences >- parent="/0/@diagram" >- child="/0/@diagram/@links.0" >- groupName="links" >- groupIcon="icons/linksNavigatorGroup.gif"/> >- <childReferences >- parent="/0/@diagram/@links.0" >- child="/0/@diagram/@topLevelNodes.1" >- referenceType="out_target" >- groupName="target" >- groupIcon="icons/linkTargetNavigatorGroup.gif"/> >- <childReferences >- parent="/0/@diagram/@topLevelNodes.1" >- child="/0/@diagram/@links.0" >- referenceType="in_source" >- groupName="incoming links" >- groupIcon="icons/incomingLinksNavigatorGroup.gif"/> >- <childReferences >- parent="/0/@diagram/@links.0" >- child="/0/@diagram/@childNodes.0" >- referenceType="out_target" >- groupName="target" >- groupIcon="icons/linkTargetNavigatorGroup.gif"/> >- <childReferences >- parent="/0/@diagram/@childNodes.0" >- child="/0/@diagram/@links.0" >- referenceType="in_source" >- groupName="incoming links" >- groupIcon="icons/incomingLinksNavigatorGroup.gif"/> >- <childReferences >- parent="/0/@diagram/@links.0" >- child="/0/@diagram/@topLevelNodes.1" >- referenceType="in_source" >- groupName="source" >- groupIcon="icons/linkSourceNavigatorGroup.gif"/> >- <childReferences >- parent="/0/@diagram/@topLevelNodes.1" >- child="/0/@diagram/@links.0" >- referenceType="out_target" >- groupName="outgoing links" >- groupIcon="icons/outgoingLinksNavigatorGroup.gif"/> >- <childReferences >- parent="/0/@diagram/@links.0" >- child="/0/@diagram/@childNodes.0" >- referenceType="in_source" >- groupName="source" >- groupIcon="icons/linkSourceNavigatorGroup.gif"/> >- <childReferences >- parent="/0/@diagram/@childNodes.0" >- child="/0/@diagram/@links.0" >- referenceType="out_target" >- groupName="outgoing links" >- groupIcon="icons/outgoingLinksNavigatorGroup.gif"/> >- </navigator> >- <diagramUpdater/> >- <propertySheet> >- <tabs >- xsi:type="gmfgen:GenStandardPropertyTab" >- iD="appearance"/> >- <tabs >- xsi:type="gmfgen:GenStandardPropertyTab" >- iD="diagram"/> >- <tabs >- xsi:type="gmfgen:GenCustomPropertyTab" >- iD="domain" >- label="Core"> >- <filter >- xsi:type="gmfgen:TypeTabFilter"> >- <types>org.eclipse.gmf.runtime.notation.View</types> >- <types>org.eclipse.gef.EditPart</types> >- <generatedTypes>abstractNavigatorItem</generatedTypes> >- </filter> >- </tabs> >- </propertySheet> >- <domainGenModel >- href="../../org.eclipse.papyrus.sysml/model/sysml.genmodel#/"/> >- <expressionProviders> >- <providers >- xsi:type="gmfgen:GenJavaExpressionProvider" >- injectExpressionBody="true"> >- <expressions >- xsi:type="gmfgen:GenConstraint" >- body="return ModelValidationHelper.validateConnector(context, ctx);"/> >- <expressions >- xsi:type="gmfgen:GenConstraint" >- body="return ModelValidationHelper.validateProperty(context, ctx);"/> >- <expressions >- xsi:type="gmfgen:GenConstraint" >- body="return ModelValidationHelper.validateConnectorEnd(context, ctx);"/> >- <expressions >- xsi:type="gmfgen:GenConstraint" >- body="return ModelValidationHelper.validateNestedConnectorEnd(context, ctx);"/> >- </providers> >- </expressionProviders> >- <labelParsers >- extensibleViaService="true"> >- <implementations >- xsi:type="gmfgen:PredefinedParser"/> >- <implementations >- xsi:type="gmfgen:CustomParser" >- uses="/0/@diagram/@topLevelNodes.1/@labels.0/@modelFacet /0/@diagram/@childNodes.0/@labels.0/@modelFacet" >- qualifiedName="org.eclipse.papyrus.sysml.diagram.parametric.parsers.PropertyLabelParser"/> >- <implementations >- xsi:type="gmfgen:CustomParser" >- uses="/0/@diagram/@links.0/@labels.0/@modelFacet" >- qualifiedName="org.eclipse.papyrus.sysml.diagram.parametric.parsers.ConnectorLabelParser"/> >- <implementations >- xsi:type="gmfgen:CustomParser" >- uses="/0/@diagram/@topLevelNodes.0/@labels.0/@modelFacet" >- qualifiedName="org.eclipse.papyrus.sysml.diagram.parametric.parsers.ConstraintPropertyLabelParser"/> >- <implementations >- xsi:type="gmfgen:CustomParser" >- uses="/0/@diagram/@topLevelNodes.0/@labels.1/@modelFacet" >- qualifiedName="org.eclipse.papyrus.sysml.diagram.parametric.parsers.ConstraintLabelParser"/> >- </labelParsers> >- <contextMenus >- context="/0/@diagram"> >- <items >- xsi:type="gmfgen:LoadResourceAction"/> >- </contextMenus> >- </gmfgen:GenEditorGenerator> >- <papyrusgmfgenextension:PapyrusExtensionRootNode> >- <extensionNodes >- xsi:type="papyrusgmfgenextension:SpecificLocator" >- comment="Affixed Parameter locator" >- classpath="org.eclipse.papyrus.sysml.diagram.parametric.locator.ParameterPositionLocator" >- genChildSideAffixedNode="/0/@diagram/@childNodes.0"/> >- <extensionNodes >- xsi:type="papyrusgmfgenextension:LabelVisibilityPreference" >- comment="HiddenName" >- role="Name" >- iconPathRole="platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/name.png" >- linkLabels="/0/@diagram/@links.0/@labels.0" >- visibleByDefault="false"/> >- <extensionNodes >- xsi:type="papyrusgmfgenextension:ExtendedGenView" >- comment="" >- genView="/0/@diagram/@links.0" >- name="ExtendedUMLLinks" >- superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart"/> >- </papyrusgmfgenextension:PapyrusExtensionRootNode> >-</xmi:XMI> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfgraph b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfgraph >deleted file mode 100644 >index 40f04ca..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfgraph >+++ /dev/null >@@ -1,147 +0,0 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<gmfgraph:Canvas xmi:version="2.0" >- xmlns:xmi="http://www.omg.org/XMI" >- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >- xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition" name="sysml"> >- <figures >- name="Default"> >- <descriptors >- name="ConstraintPropertyFigureDescriptor"> >- <actualFigure >- xsi:type="gmfgraph:RoundedRectangle" >- name="ConstraintPropertyFigure" >- cornerWidth="25" >- cornerHeight="25"> >- <layout >- xsi:type="gmfgraph:GridLayout"/> >- <minimumSize >- dx="200" >- dy="120"/> >- <children >- xsi:type="gmfgraph:CustomFigure" >- name="ConstraintPropertyFigureLabel" >- qualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel"> >- <layoutData >- xsi:type="gmfgraph:GridLayoutData" >- grabExcessHorizontalSpace="true" >- grabExcessVerticalSpace="true" >- verticalAlignment="END"/> >- </children> >- <children >- xsi:type="gmfgraph:CustomFigure" >- name="ConstraintLabel" >- qualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"> >- <layoutData >- xsi:type="gmfgraph:GridLayoutData" >- grabExcessHorizontalSpace="true" >- grabExcessVerticalSpace="true" >- verticalAlignment="BEGINNING" >- horizontalAlignment="END"/> >- </children> >- </actualFigure> >- <accessors >- accessor="getConstraintPropertyFigureLabel" >- figure="//@figures.0/@descriptors.0/@actualFigure/@children.0"/> >- <accessors >- accessor="getConstraintLabel" >- figure="//@figures.0/@descriptors.0/@actualFigure/@children.1"/> >- </descriptors> >- <descriptors >- name="PropertyFigure"> >- <actualFigure >- xsi:type="gmfgraph:Rectangle" >- name="PropertyFigure"> >- <layout >- xsi:type="gmfgraph:CustomLayout" >- qualifiedClassName="org.eclipse.papyrus.uml.diagram.common.draw2d.CenterLayout"/> >- <minimumSize >- dx="100" >- dy="40"/> >- <children >- xsi:type="gmfgraph:CustomFigure" >- name="PropertyFigureLabel" >- qualifiedClassName="org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel"/> >- </actualFigure> >- <accessors >- accessor="getPropertyFigureLabel" >- figure="//@figures.0/@descriptors.1/@actualFigure/@children.0"/> >- </descriptors> >- <descriptors >- name="ParameterDescriptor"> >- <actualFigure >- xsi:type="gmfgraph:Rectangle" >- name="ParameterRectangle"> >- <preferredSize >- dx="16" >- dy="16"/> >- </actualFigure> >- </descriptors> >- <descriptors >- name="ParameterLabelFigure"> >- <actualFigure >- xsi:type="gmfgraph:Label" >- name="ParameterLabel"/> >- </descriptors> >- <descriptors >- name="ConnectorFigure"> >- <actualFigure >- xsi:type="gmfgraph:PolylineConnection" >- name="ConnectorPolylineConnection"> >- <children >- xsi:type="gmfgraph:Label" >- name="ConnectorLabel"/> >- </actualFigure> >- <accessors >- accessor="getConnectorLabel" >- figure="//@figures.0/@descriptors.4/@actualFigure/@children.0"/> >- </descriptors> >- </figures> >- <nodes >- name="NodeConstraintProperty" >- figure="ConstraintPropertyFigureDescriptor"/> >- <nodes >- name="NodeProperty" >- figure="PropertyFigure"/> >- <nodes >- name="ParameterNode" >- figure="ParameterDescriptor" >- affixedParentSide="NSEW"/> >- <connections >- name="ConnectorConnection" >- figure="ConnectorFigure"/> >- <labels >- name="Property" >- figure="PropertyFigure" >- accessor="//@figures.0/@descriptors.1/@accessors.0"> >- <facets >- xsi:type="gmfgraph:AlignmentFacet" >- alignment="CENTER"/> >- </labels> >- <labels >- name="ConstraintProperty" >- figure="ConstraintPropertyFigureDescriptor" >- accessor="//@figures.0/@descriptors.0/@accessors.0"> >- <facets >- xsi:type="gmfgraph:AlignmentFacet" >- alignment="CENTER"/> >- </labels> >- <labels >- name="ParameterLabel" >- figure="ParameterLabelFigure" >- elementIcon="false"> >- <facets >- xsi:type="gmfgraph:AlignmentFacet"/> >- </labels> >- <labels >- name="ConnectorDiagramLabel" >- figure="ConnectorFigure" >- accessor="//@figures.0/@descriptors.4/@accessors.0"/> >- <labels >- name="ConstraintLabel" >- figure="ConstraintPropertyFigureDescriptor" >- accessor="//@figures.0/@descriptors.0/@accessors.1"> >- <facets >- xsi:type="gmfgraph:AlignmentFacet" >- alignment="END"/> >- </labels> >-</gmfgraph:Canvas> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfmap b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfmap >deleted file mode 100644 >index 0e3d161..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmfmap >+++ /dev/null >@@ -1,182 +0,0 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<gmfmap:Mapping xmi:version="2.0" >- xmlns:xmi="http://www.omg.org/XMI" >- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >- xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" >- xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings" >- xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition"> >- <nodes> >- <containmentFeature >- href="../../../plugin/org.eclipse.papyrus.infra.core.resource/model/resource.ecore#//Resource/eobjects"/> >- <ownedChild> >- <domainMetaElement >- href="../../org.eclipse.papyrus.sysml.converted/model/sysml.ecore#//constraints/ConstraintProperty"/> >- <labelMappings> >- <diagramLabel >- href="Parametric.gmfgraph#ConstraintProperty"/> >- </labelMappings> >- <labelMappings> >- <diagramLabel >- href="Parametric.gmfgraph#ConstraintLabel"/> >- </labelMappings> >- <tool >- xsi:type="gmftool:CreationTool" >- href="Parametric.gmftool#//@palette/@tools.0/@tools.0"/> >- <diagramNode >- href="Parametric.gmfgraph#NodeConstraintProperty"/> >- <children >- referencedChild="//@nodes.0/@ownedChild/@children.0/@ownedChild"> >- <containmentFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//StructuredClassifier/ownedAttribute"/> >- <childrenFeature >- href="../../org.eclipse.papyrus.sysml.converted/model/sysml.ecore#//constraints/ConstraintProperty/base_Property"/> >- <ownedChild >- relatedDiagrams="//@diagram"> >- <domainMetaElement >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//Property"/> >- <labelMappings >- xsi:type="gmfmap:FeatureLabelMapping"> >- <diagramLabel >- href="Parametric.gmfgraph#ParameterLabel"/> >- <features >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//NamedElement/name"/> >- </labelMappings> >- <tool >- xsi:type="gmftool:CreationTool" >- href="Parametric.gmftool#//@palette/@tools.0/@tools.1"/> >- <diagramNode >- href="Parametric.gmfgraph#ParameterNode"/> >- </ownedChild> >- </children> >- </ownedChild> >- </nodes> >- <nodes> >- <containmentFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//StructuredClassifier/ownedAttribute"/> >- <ownedChild> >- <domainMetaElement >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//Property"/> >- <labelMappings >- xsi:type="gmfmap:FeatureLabelMapping"> >- <diagramLabel >- href="Parametric.gmfgraph#Property"/> >- <features >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//NamedElement/name"/> >- </labelMappings> >- <tool >- xsi:type="gmftool:CreationTool" >- href="Parametric.gmftool#//@palette/@tools.0/@tools.1"/> >- <diagramNode >- href="Parametric.gmfgraph#NodeProperty"/> >- </ownedChild> >- </nodes> >- <links >- relatedDiagrams="//@diagram"> >- <domainMetaElement >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//Connector"/> >- <labelMappings >- xsi:type="gmfmap:FeatureLabelMapping"> >- <diagramLabel >- href="Parametric.gmfgraph#ConnectorDiagramLabel"/> >- <features >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//NamedElement/name"/> >- </labelMappings> >- <containmentFeature >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//StructuredClassifier/ownedConnector"/> >- <tool >- xsi:type="gmftool:CreationTool" >- href="Parametric.gmftool#//@palette/@tools.0/@tools.2"/> >- <diagramLink >- href="Parametric.gmfgraph#ConnectorConnection"/> >- <sourceMetaFeature >- xsi:type="ecore:EReference" >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//ConnectorEnd/role"/> >- <linkMetaFeature >- xsi:type="ecore:EReference" >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//ConnectorEnd/role"/> >- </links> >- <diagram> >- <diagramCanvas >- href="Parametric.gmfgraph#sysml"/> >- <domainModel >- href="../../org.eclipse.papyrus.sysml.converted/model/sysml.ecore#//blocks"/> >- <domainMetaElement >- href="../../../plugin/org.eclipse.papyrus.infra.core.resource/model/resource.ecore#//Resource"/> >- <palette >- href="Parametric.gmftool#//@palette"/> >- </diagram> >- <audits >- id="org.eclipse.uml2.uml.util.UMLValidator.validate" >- name="validateSysMLModel" >- description="Validate the SysML model"> >- <childContainers >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement" >- name="validateConnectorElement" >- description="validate a connector checking that its children are consistent"> >- <audits >- name="validateConnector" >- description="The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property" >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateConnector" >- severity="WARNING" >- useInLiveMode="true" >- message="NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector."> >- <rule >- body="return ModelValidationHelper.validateConnector(context, ctx);" >- language="java"/> >- <target >- xsi:type="gmfmap:DomainElementTarget"> >- <element >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//Connector"/> >- </target> >- </audits> >- <audits >- name="validateProperty" >- description="When you move a property, check that its incoming or outgoings connector get consistent connectorEnd" >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateProperty" >- severity="WARNING" >- useInLiveMode="true" >- message="NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector."> >- <rule >- body="return ModelValidationHelper.validateProperty(context, ctx);" >- language="java"/> >- <target >- xsi:type="gmfmap:DomainElementTarget"> >- <element >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//Property"/> >- </target> >- </audits> >- <audits >- name="validateConnectorEnd" >- description="The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property" >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateConnectorEnd" >- severity="WARNING" >- useInLiveMode="true" >- message="NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector."> >- <rule >- body="return ModelValidationHelper.validateConnectorEnd(context, ctx);" >- language="java"/> >- <target >- xsi:type="gmfmap:DomainElementTarget"> >- <element >- href="../../../plugin/org.eclipse.uml2.uml/model/UML.ecore#//ConnectorEnd"/> >- </target> >- </audits> >- <audits >- name="validateNestedConnectorEnd" >- description="The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property" >- id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateNestedConnectorEnd" >- severity="WARNING" >- useInLiveMode="true" >- message="NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector."> >- <rule >- body="return ModelValidationHelper.validateNestedConnectorEnd(context, ctx);" >- language="java"/> >- <target >- xsi:type="gmfmap:DomainElementTarget"> >- <element >- href="../../org.eclipse.papyrus.sysml.converted/model/sysml.ecore#//blocks/NestedConnectorEnd"/> >- </target> >- </audits> >- </childContainers> >- </audits> >-</gmfmap:Mapping> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmftool b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmftool >deleted file mode 100644 >index f30d8a8..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.gmftool >+++ /dev/null >@@ -1,56 +0,0 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<gmftool:ToolRegistry xmi:version="2.0" >- xmlns:xmi="http://www.omg.org/XMI" >- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >- xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition"> >- <palette >- title="sysmlPalette"> >- <tools >- xsi:type="gmftool:ToolGroup" >- title="Parametric"> >- <smallIcon >- xsi:type="gmftool:BundleImage" >- path="/icons/group.gif" >- bundle="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui"/> >- <largeIcon >- xsi:type="gmftool:BundleImage" >- path="/icons/group.gif" >- bundle="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui"/> >- <tools >- xsi:type="gmftool:CreationTool" >- title="ConstraintProperty" >- description="Create new ConstraintProperty"> >- <smallIcon >- xsi:type="gmftool:BundleImage" >- path="/icons/full/obj16/ConstraintProperty.gif" >- bundle="platform:/plugin/org.eclipse.papyrus.sysml.edit"/> >- <largeIcon >- xsi:type="gmftool:BundleImage" >- path="/icons/full/obj16/ConstraintProperty.gif" >- bundle="platform:/plugin/org.eclipse.papyrus.sysml.edit"/> >- </tools> >- <tools >- xsi:type="gmftool:CreationTool" >- title="Property" >- description="Create new Property"> >- <smallIcon >- xsi:type="gmftool:BundleImage" >- path="/icons/full/obj16/Property.gif" >- bundle="platform:/plugin/org.eclipse.uml2.uml.edit"/> >- <largeIcon >- xsi:type="gmftool:BundleImage" >- path="/icons/full/obj16/Property.gif" >- bundle="platform:/plugin/org.eclipse.uml2.uml.edit"/> >- </tools> >- <tools >- xsi:type="gmftool:CreationTool" >- title="Connector" >- description="Create new Connector"> >- <smallIcon >- xsi:type="gmftool:BundleImage" >- path="/icons/full/obj16/Connector.gif" >- bundle="platform:/plugin/org.eclipse.uml2.uml.edit"/> >- </tools> >- </tools> >- </palette> >-</gmftool:ToolRegistry> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.trace b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.trace >deleted file mode 100644 >index 89f49f4..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/Parametric.trace >+++ /dev/null >@@ -1,36 +0,0 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<trace:TraceModel xmi:version="2.0" >- xmlns:xmi="http://www.omg.org/XMI" >- xmlns:trace="http://www.eclipse.org/gmf/2006/Trace"> >- <nodeTraces >- visualID="2003" >- queryText="(let _eClass_:ecore::EClass = modelFacet.metaClass.ecoreClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/papyrus/0.7.0/SysML/Constraints' and _eClass_.name = 'ConstraintProperty') and (let _containmentMF_:ecore::EStructuralFeature = modelFacet.containmentMetaFeature.ecoreFeature in (let _eClass_:ecore::EClass = _containmentMF_.eContainingClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/papyurs/0.7.0/Resource' and _eClass_.name = 'Resource') and _containmentMF_.name = 'eobjects')"> >- <nodeLabelTraces >- visualID="5001" >- queryText="true"/> >- <nodeLabelTraces >- visualID="5004" >- queryText="true"/> >- </nodeTraces> >- <nodeTraces >- visualID="2005" >- queryText="(let _eClass_:ecore::EClass = modelFacet.metaClass.ecoreClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/uml2/3.0.0/UML' and _eClass_.name = 'Property') and (let _containmentMF_:ecore::EStructuralFeature = modelFacet.containmentMetaFeature.ecoreFeature in (let _eClass_:ecore::EClass = _containmentMF_.eContainingClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/uml2/3.0.0/UML' and _eClass_.name = 'StructuredClassifier') and _containmentMF_.name = 'ownedAttribute')"> >- <nodeLabelTraces >- visualID="5002" >- queryText="true"/> >- </nodeTraces> >- <childNodeTraces >- visualID="3002" >- queryText="(let _eClass_:ecore::EClass = modelFacet.metaClass.ecoreClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/uml2/3.0.0/UML' and _eClass_.name = 'Property') and (let _containmentMF_:ecore::EStructuralFeature = modelFacet.containmentMetaFeature.ecoreFeature in (let _eClass_:ecore::EClass = _containmentMF_.eContainingClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/uml2/3.0.0/UML' and _eClass_.name = 'StructuredClassifier') and _containmentMF_.name = 'ownedAttribute') and ( let _childMF_:ecore::EStructuralFeature = modelFacet.childMetaFeature.ecoreFeature in (let _eClass_:ecore::EClass = _childMF_.eContainingClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/papyrus/0.7.0/SysML/Constraints' and _eClass_.name = 'ConstraintProperty') and _childMF_.name = 'base_Property')"> >- <nodeLabelTraces >- visualID="5003" >- queryText="true"/> >- </childNodeTraces> >- <linkTraces >- visualID="4001" >- queryText="modelFacet.oclIsKindOf(gmfgen::TypeLinkModelFacet) and (let _eClass_:ecore::EClass = modelFacet.oclAsType(gmfgen::TypeLinkModelFacet).metaClass.ecoreClass in _eClass_.ePackage.nsURI = 'http://www.eclipse.org/uml2/3.0.0/UML' and _eClass_.name = 'Connector')"> >- <linkLabelTraces >- visualID="6001" >- queryText="true"/> >- </linkTraces> >-</trace:TraceModel> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/SysML.Parametric.idgen b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/SysML.Parametric.idgen >new file mode 100644 >index 0000000..1490bbf >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/model/SysML.Parametric.idgen >@@ -0,0 +1,124 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<idgen:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gmfgen="http://www.eclipse.org/gmf/2009/GenModel" xmlns:idgen="http://www.eclipse.org/papyrus/0.7.0/idgen" name="Parametric" type="Parametric" icon="icons/obj16/Diagram_Parametric.gif" label="SysML Parametric Diagram" language="sysml" javaPackagePrefix="org.eclipse.papyrus.sysml.diagram.parametric" javaClassPrefix="ParametricDiagram" createCommandLabel="Create a new Parametric Diagram"> >+ <diagramEditPart name="Diagram edit part"> >+ <behaviors javaClassQualifiedName="org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy" key="DuplicatePasteEditPolicy.PASTE_ROLE"/> >+ <behaviors javaClassQualifiedName="org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomDragDropEditPolicy" key="EditPolicyRoles.DRAG_DROP_ROLE"/> >+ <behaviors javaClassQualifiedName="org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultXYLayoutEditPolicy" key="EditPolicy.LAYOUT_ROLE"/> >+ <behaviors name="" javaClassQualifiedName="org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultCreationEditPolicy" key="EditPolicyRoles.CREATION_ROLE"/> >+ <behaviors javaClassQualifiedName="org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultContainerNodeEditPolicy" key="EditPolicy.GRAPHICAL_NODE_ROLE"/> >+ </diagramEditPart> >+ <inheritedDiagrams name="CompositeDiagram" viewProviderClassQualifiedName="" editPartProviderClassQualifiedName="" dndEditPolicyClassQualifiedName="org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.CustomDiagramDragDropEditPolicy"> >+ <genInheritedEditor href="../../org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen#CompositeStructure"/> >+ <genNodes> >+ <genNode xsi:type="gmfgen:GenTopLevelNode" href="../../org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen#/0/@diagram/@topLevelNodes.48"/> >+ <semanticType href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#org.eclipse.papyrus.uml.Constraint"/> >+ </genNodes> >+ <genNodes generatePreferencePage="false" generateTool="false"> >+ <genNode xsi:type="gmfgen:GenChildNode" href="../../org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen#/0/@diagram/@childNodes.27"/> >+ <semanticType href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#org.eclipse.papyrus.uml.Comment"/> >+ </genNodes> >+ <genNodes> >+ <genNode xsi:type="gmfgen:GenTopLevelNode" href="../../org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen#/0/@diagram/@topLevelNodes.43"/> >+ <semanticType href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#org.eclipse.papyrus.uml.Comment"/> >+ </genNodes> >+ <genNodes generatePreferencePage="false" generateTool="false"> >+ <genNode xsi:type="gmfgen:GenChildNode" href="../../org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen#/0/@diagram/@childNodes.32"/> >+ <semanticType href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#org.eclipse.papyrus.uml.Constraint"/> >+ </genNodes> >+ <genLinks> >+ <genLink href="../../org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen#/0/@diagram/@links.1"/> >+ </genLinks> >+ <genLinks> >+ <genLink href="../../org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen#/0/@diagram/@links.2"/> >+ </genLinks> >+ </inheritedDiagrams> >+ <customJavaClasses name="" customEditPolicyProvider="org.eclipse.papyrus.sysml.diagram.internalblock.CustomEditPolicyProvider" customPreferenceInitializer="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CustomPreferenceInitializer"/> >+ <usedCustomNodes href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_block_as_composite"/> >+ <usedCustomNodes href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_blockproperty_as_composite"/> >+ <usedCustomNodes href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_flowport_as_affixed"/> >+ <usedCustomNodes href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#shape_uml_port_as_affixed"/> >+ <usedCustomEdges href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#link_uml_connector"/> >+ <usedCustomEdges href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#link_uml_dependency"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#label_sysml_block_name"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#affixedlabel_sysml_flowport_label"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#affixedlabel_uml_appliedstereotype"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#affixedlabel_uml_port_label"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#compartment_sysml_structure"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#compartment_sysml_blockproperty_structure"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#label_uml_property_label"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#linklabel_uml_appliedstereotype"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#linklabel_uml_connector_label"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#linklabel_uml_connector_source_multiplicity"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#linklabel_uml_connector_target_multiplicity"/> >+ <usedCustomDecorations href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#linklabel_uml_namedelement_name"/> >+ <diagramConfig> >+ <contains xsi:type="idgen:GraphicalTypeDiagramRef"> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_block_as_composite"/> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_flowport_as_affixed"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#shape_uml_port_as_affixed"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#compartment_sysml_structure"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_blockproperty_as_composite"/> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_flowport_as_affixed"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#shape_uml_port_as_affixed"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#compartment_sysml_blockproperty_structure"/> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_blockproperty_as_composite"/> >+ </contains> >+ </contains> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_constraintblockproperty_as_composite"/> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#shape_uml_property_as_label"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#compartment_sysml_blockproperty_structure"/> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_constraintblockproperty_as_composite"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#label_uml_property_label"/> >+ </contains> >+ </contains> >+ </contains> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#link_uml_dependency"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/UML.ReusableParts.idgen#link_uml_connector"/> >+ </contains> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#compartment_sysml_structure"/> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_blockproperty_as_composite"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_constraintblockproperty_as_composite"/> >+ </contains> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#compartment_sysml_blockproperty_structure"/> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_blockproperty_as_composite"/> >+ </contains> >+ <contains> >+ <ref href="../../org.eclipse.papyrus.sysml.diagram.common/model/SysML.ReusableParts.idgen#shape_sysml_constraintblockproperty_as_composite"/> >+ </contains> >+ </contains> >+ </diagramConfig> >+</idgen:Diagram> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/palettes/parametric.palette.xml b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/palettes/parametric.palette.xml >new file mode 100644 >index 0000000..75247fe >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/palettes/parametric.palette.xml >@@ -0,0 +1,41 @@ >+<?xml version="1.0" encoding="UTF-8" standalone="no"?> >+<paletteDefinition> >+ <content> >+ <drawer id="parametric.drawer.nodes" name="Nodes" iconpath="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif"> >+ <aspectTool description="Create a new ConstraintProperty" id="parametric.tool.constraintblockpropertycomposite" >+ name="ConstraintProperty" refToolId="parametric.tool.constraintblockpropertycomposite"> >+ </aspectTool> >+ <aspectTool description="Create a new ConstraintParameter" id="parametric.tool.parameter" >+ name="ConstraintParameter" refToolId="parametric.tool.parameter"> >+ </aspectTool> >+ <aspectTool description="Create a new Part" id="parametric.tool.blockpropertycomposite" >+ name="Part" refToolId="parametric.tool.blockpropertycomposite"> >+ </aspectTool> >+ <aspectTool description="Create a new Reference" id="parametric.tool.reference" >+ name="Reference" refToolId="parametric.tool.reference"> >+ </aspectTool> >+ <aspectTool description="Create a new Value" id="parametric.tool.value" >+ name="Value" refToolId="parametric.tool.value"> >+ </aspectTool> >+ </drawer> >+ <drawer id="parametric.drawer.edges" name="Edges" iconpath="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif"> >+ <aspectTool description="Create a new BindingConnector" id="parametric.tool.connector" >+ name="BindingConnector" refToolId="parametric.tool.connector"> >+ </aspectTool> >+ </drawer> >+ <drawer id="parametric.drawer.others" name="Others" iconpath="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif"> >+ <aspectTool description="Create a new Dependency" id="parametric.tool.dependency" >+ name="Dependency" refToolId="parametric.tool.dependency"> >+ </aspectTool> >+ <aspectTool description="Create a new Comment" id="parametric.tool.comment" >+ name="Comment" refToolId="parametric.tool.comment"> >+ </aspectTool> >+ <aspectTool description="Create a new Constraint" id="parametric.tool.constraint" >+ name="Constraint" refToolId="parametric.tool.constraint"> >+ </aspectTool> >+ <aspectTool description="Create a new CommentAnnotatedElement" id="parametric.tool.commentannotatedelement" >+ name="CommentAnnotatedElement" refToolId="parametric.tool.comment_constraint_link"> >+ </aspectTool> >+ </drawer> >+ </content> >+</paletteDefinition> >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/plugin.properties b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/plugin.properties >index 7d806bf..1095de7 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/plugin.properties >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/plugin.properties >@@ -1,59 +1,12 @@ >-#/***************************************************************************** >-#* Copyright (c) 2009 Atos Origin. >-# * >-# * >-# * 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: >-# * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >-# * >-# *****************************************************************************/ >-pluginName=Papyrus Paramatric Diagram for SysML (Incubation) >+################################################################################# >+# 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 >+################################################################################## >+pluginName=SysML Parametric Diagram > providerName=Eclipse Modeling Project >- >-editorName=SysML Diagram Editing >-context.description=SysML Diagram Editing >-context.name=In SysML Diagram Editor >-newWizardName=SysML Diagram >-newWizardDesc=Creates SysML diagram. >- >-initDiagramActionLabel=Initialize sysml_diagram diagram file >- >- >-navigatorContentName=*.sysml_diagram diagram contents >-domainNavigatorContentName=*.sysml model contents >-update.diagram.name=Update SysML diagram >-update.diagram.description=Perform SysML diagram update >- >- >-# Property Sheet >-tab.appearance=Appearance >-tab.diagram=Rulers & Grid >-tab.domain=Core >- >-# Preferences >-prefpage.org.eclipse.papyrus.sysml.diagram.general=SysML Diagram >-prefpage.org.eclipse.papyrus.sysml.diagram.appearance=Appearance >-prefpage.org.eclipse.papyrus.sysml.diagram.connections=Connections >-prefpage.org.eclipse.papyrus.sysml.diagram.printing=Printing >-prefpage.org.eclipse.papyrus.sysml.diagram.rulersAndGrid=Rulers And Grid >- >- >-# Providers >-metatype.name.Resource_1000=Undefined >-metatype.name.ConstraintProperty_2001=ConstraintProperty >-metatype.name.ConstraintBlock_2002=ConstraintBlock >- >-# Commands and menu actions >-cmdcategory.name=SysML Editor Commands >-cmdcategory.desc=SysML Editor Commands >- >-metatype.name.ConstraintProperty_2003=ConstraintProperty >-metatype.name.ConstraintBlock_2004=ConstraintBlock >-metatype.name.Property_2004=Property >-metatype.name.Property_2005=Property >-metatype.name.Property_3002=Property >-metatype.name.Connector_4001=Connector >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/plugin.xml b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/plugin.xml >index 451f5e3..9b4009c 100644 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/plugin.xml >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/plugin.xml >@@ -1,838 +1,562 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<?eclipse version="3.0"?> >-<plugin> >- <extension point="org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders"> >- <contributionItemProvider checkPluginLoaded="false" class="org.eclipse.papyrus.sysml.diagram.parametric.providers.ParametricDiagramContributionItemProvider"> >- <Priority name="Low"/> >- <popupContribution class="org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider"> >- <popupStructuredContributionCriteria objectClass="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart" policyClass="org.eclipse.papyrus.sysml.diagram.parametric.providers.ParametricDiagramContributionPolicyClass"/> >- <popupAction id="papyrus.restoreRelatedLinksAction" path="/navigateMenu/additions"/> >- </popupContribution> >- </contributionItemProvider> >- </extension> >- >- >- >- <extension point="org.eclipse.ui.contexts" id="ui-context"> >- <?gmfgen generated="true"?> >- <context >- description="%context.description" >- id="org.eclipse.papyrus.sysml.diagram.parametric.ui.diagramContext" >- name="%context.name" >- parentId="org.eclipse.gmf.runtime.diagram.ui.diagramContext"> >- </context> >- </extension> >+<?xml version="1.0" encoding="UTF-8"?> >+<?eclipse version="3.4"?> >+<plugin> > >- >- <extension point="org.eclipse.ui.popupMenus" id="init-diagram-action"> >- <?gmfgen generated="false"?> >- <!-- FIX Bug 314257--> >- <!--objectContribution >- id="org.eclipse.papyrus.sysml.diagram.parametric.InitDiagram" >- nameFilter="*.sysml" >- objectClass="org.eclipse.core.resources.IFile"> >- <action >- label="%initDiagramActionLabel" >- class="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlInitDiagramFileAction" >- menubarPath="additions" >- enablesFor="1" >- id="org.eclipse.papyrus.sysml.diagram.parametric.InitDiagramAction"> >- </action> >- </objectContribution--> >- </extension> >- >- >- <extension >- id="Sysml Plugin.palettedefinition" >- name="Sysml Plugin Predefined Entries" >- point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders"> >- >- <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider"> >- <Priority name="Lowest"/> >- <contribution >- factoryClass="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlPaletteFactory"> >- <predefinedEntry id="standardGroup/noteStack/noteTool" remove="true"/> >- <predefinedEntry id="standardGroup/noteStack/textTool" remove="true"/> >- <predefinedEntry id="standardGroup/noteStack/noteattachmentTool" remove="true"/> >- <entry >- defineOnly="true" >- description="Create new Property" >- id="createProperty2CreationTool" >- kind="tool" >- label="Property" >- large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif" >- path="" >- small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif"> >- </entry> >- <entry >- defineOnly="true" >- description="Create new ConstraintProperty" >- id="createConstraintProperty1CreationTool" >- kind="tool" >- label="ConstraintProperty" >- large_icon="platform:/plugin/org.eclipse.papyrus.sysml.edit/icons/full/obj16/ConstraintProperty.gif" >- path="" >- small_icon="platform:/plugin/org.eclipse.papyrus.sysml.edit/icons/full/obj16/ConstraintProperty.gif"> >- </entry> >- <entry >- defineOnly="true" >- description="Create new Connector" >- id="createConnector3CreationTool" >- kind="tool" >- label="Connector" >- large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Connector.gif" >- small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Connector.gif"> >- </entry> >- >- </contribution> >- </paletteProvider> >- >- </extension> >- >- <extension >- id="Sysml Plugin.standard" >- name="Sysml Plugin Standard Palette" >- point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders"> >- >- <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider"> >- <Priority name="Low"/> >- <contribution >- factoryClass="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlPaletteFactory"> >- <predefinedEntry id="standardGroup/noteStack/noteTool" remove="true"/> >- <predefinedEntry id="standardGroup/noteStack/textTool" remove="true"/> >- <predefinedEntry id="standardGroup/noteStack/noteattachmentTool" remove="true"/> >- <entry >- description="" >- id="createSysml1Group" >- kind="drawer" >- label="Parametric Diagram" >- large_icon="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif" >- path="/" >- small_icon="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif"> >- </entry> >- >- <predefinedEntry >- id="createProperty2CreationTool" >- path="/createSysml1Group"> >- </predefinedEntry> >- <predefinedEntry >- id="createConstraintProperty1CreationTool" >- path="/createSysml1Group"> >- </predefinedEntry> >- <predefinedEntry >- id="createConnector3CreationTool" >- path="/createSysml1Group"> >- </predefinedEntry> >- >- >- </contribution> >- <editor id="org.eclipse.papyrus.sysml.diagram.parametric"/> >- </paletteProvider> >- >- </extension> >- >- <extension point="org.eclipse.ui.preferencePages" id="prefpages"> >- <?gmfgen generated="true"?> >- <page >- id="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams.Parametric" >- name="Parametric Diagram" >- category="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams" >- class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.DiagramGeneralPreferencePage"> >- </page> >- >- >- >- <page >- id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.DiagramPrintingPreferencePage" >- name="%prefpage.org.eclipse.papyrus.sysml.diagram.printing" >- category="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams.Parametric" >- class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.DiagramPrintingPreferencePage"> >- </page> >- >- <page >- id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.DiagramRulersAndGridPreferencePage" >- name="%prefpage.org.eclipse.papyrus.sysml.diagram.rulersAndGrid" >- category="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams.Parametric" >- class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.DiagramRulersAndGridPreferencePage"> >- </page> >- >- </extension> >- >- <extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor" id="prop-contrib"> >- <?gmfgen generated="true"?> >- <propertyContributor >- contributorId="org.eclipse.papyrus.sysml.diagram.parametric" >- labelProvider="org.eclipse.papyrus.sysml.diagram.parametric.sheet.SysmlSheetLabelProvider"> >- <propertyCategory category="domain"/> >- <propertyCategory category="visual"/> >- <propertyCategory category="extra"/> >- </propertyContributor> >- </extension> >- >- <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" id="proptabs"> >- <?gmfgen generated="true"?> >- <propertyTabs contributorId="org.eclipse.papyrus.sysml.diagram.parametric"> >- <propertyTab >- category="visual" >- id="property.tab.AppearancePropertySection" >- label="%tab.appearance"/> >- <propertyTab >- category="visual" >- id="property.tab.DiagramPropertySection" >- label="%tab.diagram"/> >- <propertyTab >- category="domain" >- id="property.tab.domain" >- label="%tab.domain"/> >- </propertyTabs> >- </extension> >- >- <extension point="org.eclipse.ui.views.properties.tabbed.propertySections" id="propsections"> >- <?gmfgen generated="true"?> >- <propertySections contributorId="org.eclipse.papyrus.sysml.diagram.parametric"> >- <propertySection id="property.section.ConnectorAppearancePropertySection" >- filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.ConnectionEditPartPropertySectionFilter" >- class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ConnectionAppearancePropertySection" >- tab="property.tab.AppearancePropertySection"> >- </propertySection> >- <propertySection id="property.section.ShapeColorAndFontPropertySection" >- filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.ShapeEditPartPropertySectionFilter" >- class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ShapeColorsAndFontsPropertySection" >- tab="property.tab.AppearancePropertySection"> >- </propertySection> >- <propertySection id="property.section.DiagramColorsAndFontsPropertySection" >- filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.DiagramEditPartPropertySectionFilter" >- class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.DiagramColorsAndFontsPropertySection" >- tab="property.tab.AppearancePropertySection"> >- </propertySection> >- <propertySection id="property.section.RulerGridPropertySection" >- filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.DiagramEditPartPropertySectionFilter" >- class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid.RulerGridPropertySection" >- tab="property.tab.DiagramPropertySection"> >- </propertySection> >- <propertySection >- id="property.section.domain" >- tab="property.tab.domain" >- class="org.eclipse.papyrus.sysml.diagram.parametric.sheet.SysmlPropertySection"> >- <input type="org.eclipse.gmf.runtime.notation.View"/> >- <input type="org.eclipse.gef.EditPart"/> >- <input type="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlAbstractNavigatorItem"/> >- </propertySection> >- </propertySections> >- </extension> >- >- >-<?gmfgen generated="true"?> >- >- <extension point="org.eclipse.core.runtime.preferences"> >- <?gmfgen generated="true"?> >- <initializer class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.DiagramPreferenceInitializer"/> >- </extension> >- >- <extension point="org.eclipse.gmf.runtime.diagram.core.viewProviders" id="view-provider"> >- <?gmfgen generated="true"?> >- <viewProvider class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlViewProvider"> >- <Priority name="Lowest"/> >- <context viewClass="org.eclipse.gmf.runtime.notation.Diagram" semanticHints="Parametric"/> >- <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="2003,2005,3002"/> >- <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="4001"/> >- </viewProvider> >- </extension> >- >- <extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders" id="ep-provider"> >- <?gmfgen generated="true"?> >- <editpartProvider class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlEditPartProvider"> >- <Priority name="Lowest"/> >- <object class="org.eclipse.gmf.runtime.notation.Diagram" id="generated-diagram"> >- <method name="getType()" value="Parametric"/> >- </object> >- <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-nodes"> >- <method name="getType()" value="2003,2005,3002"/> >- </object> >- <object class="org.eclipse.gmf.runtime.notation.Edge" id="generated-links"> >- <method name="getType()" value="4001"/> >- </object> >- <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-labels"> >- <method name="getType()" value="5001,5004,5002,5003"/> >- </object> >- <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-compartments"> >- <method name="getType()" value=""/> >- </object> >- <context views="generated-diagram,generated-nodes,generated-links,generated-labels,generated-compartments"/> >- </editpartProvider> >- </extension> >- >- <extension point="org.eclipse.gmf.runtime.emf.ui.modelingAssistantProviders" id="modelassist-provider"> >- <?gmfgen generated="true"?> >- <modelingAssistantProvider class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlModelingAssistantProvider"> >- <Priority name="Lowest"/> >- <object class="org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart" id="Resource_1000"/> >- <object class="org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart" id="ConstraintProperty_2003"/> >- <object class="org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart" id="Property_2005"/> >- <context elements="Resource_1000,ConstraintProperty_2003,Property_2005"/> >- </modelingAssistantProvider> >- </extension> >- >- <extension point="org.eclipse.gmf.runtime.common.ui.services.iconProviders" id="icon-provider"> >- <?gmfgen generated="true"?> >- <IconProvider class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlIconProvider"> >- <Priority name="Low"/> >- </IconProvider> >- </extension> >- >- <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes" id="element-types"> >- <?gmfgen generated="true"?> >- <metamodel nsURI="http://www.eclipse.org/papyurs/0.7.0/Resource"> >- <metamodelType >- id="org.eclipse.papyrus.sysml.diagram.parametric.Resource_1000" >- name="%metatype.name.Resource_1000" >- kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType" >- eclass="Resource" >- edithelper="org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers.ResourceEditHelper"> >- <param name="semanticHint" value="1000"/> >- </metamodelType> >- </metamodel> >- <metamodel nsURI="http://www.eclipse.org/papyrus/0.7.0/SysML/Constraints"> >- <metamodelType >- id="org.eclipse.papyrus.sysml.diagram.parametric.ConstraintProperty_2003" >- name="%metatype.name.ConstraintProperty_2003" >- kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType" >- eclass="ConstraintProperty" >- edithelper="org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers.ConstraintPropertyEditHelper"> >- <param name="semanticHint" value="2003"/> >- </metamodelType> >- </metamodel> >- <metamodel nsURI="http://www.eclipse.org/uml2/3.0.0/UML"> >- <specializationType >- id="org.eclipse.papyrus.sysml.diagram.parametric.Property_2005" >- name="%metatype.name.Property_2005" >- kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"> >- <specializes id="org.eclipse.papyrus.sysml.diagram.parametric.Property_3002"/> >- <param name="semanticHint" value="2005"/> >- </specializationType> >- </metamodel> >- <metamodel nsURI="http://www.eclipse.org/uml2/3.0.0/UML"> >- <metamodelType >- id="org.eclipse.papyrus.sysml.diagram.parametric.Property_3002" >- name="%metatype.name.Property_3002" >- kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType" >- eclass="Property" >- edithelper="org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers.PropertyEditHelper"> >- <param name="semanticHint" value="3002"/> >- </metamodelType> >- </metamodel> >- <metamodel nsURI="http://www.eclipse.org/uml2/3.0.0/UML"> >- <metamodelType >- id="org.eclipse.papyrus.sysml.diagram.parametric.Connector_4001" >- name="%metatype.name.Connector_4001" >- kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType" >- eclass="Connector" >- edithelper="org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers.ConnectorEditHelper"> >- <param name="semanticHint" value="4001"/> >- </metamodelType> >- </metamodel> >- </extension> >- >- <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings" id="element-types-bindings"> >- <?gmfgen generated="true"?> >- <clientContext id="org.eclipse.papyrus.sysml.diagram.parametric.TypeContext"> >- <enablement> >- <test >- property="org.eclipse.gmf.runtime.emf.core.editingDomain" >- value="org.eclipse.papyrus.sysml.diagram.parametric.EditingDomain"/> >- </enablement> >- </clientContext> >- <binding context="org.eclipse.papyrus.sysml.diagram.parametric.TypeContext"> >- <elementType ref="org.eclipse.papyrus.sysml.diagram.parametric.Resource_1000"/> >- <elementType ref="org.eclipse.papyrus.sysml.diagram.parametric.ConstraintProperty_2003"/> >- <elementType ref="org.eclipse.papyrus.sysml.diagram.parametric.Property_2005"/> >- <elementType ref="org.eclipse.papyrus.sysml.diagram.parametric.Property_3002"/> >- <elementType ref="org.eclipse.papyrus.sysml.diagram.parametric.Connector_4001"/> >- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/> >- </binding> >- </extension> >- <extension point="org.eclipse.core.expressions.propertyTesters" id="navigator-proptest.isURIEditorInput"> >- <?gmfgen generated="true"?> >- <propertyTester >- id="org.eclipse.papyrus.sysml.diagram.parametric.URIEditorInputPropertyTester" >- type="org.eclipse.emf.common.ui.URIEditorInput" >- namespace="org.eclipse.papyrus.sysml.diagram.parametric" >- properties="isURIEditorInput" >- class="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlUriEditorInputTester"> >- </propertyTester> >- </extension> >- >- <extension point="org.eclipse.ui.navigator.viewer" id="navigator-viewbinding"> >- <?gmfgen generated="true"?> >- <viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer"> >- <includes> >- <contentExtension pattern="org.eclipse.papyrus.sysml.diagram.parametric.resourceContent"/> >- <contentExtension pattern="org.eclipse.papyrus.sysml.diagram.parametric.domainResourceContent"/> >- <contentExtension pattern="org.eclipse.papyrus.sysml.diagram.parametric.navigatorLinkHelper"/> >- </includes> >- </viewerContentBinding> >- <viewerActionBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer"> >- <includes> >- <actionExtension pattern="org.eclipse.papyrus.sysml.diagram.parametric.navigatorActionProvider"/> >- </includes> >- </viewerActionBinding> >- </extension> >- >- <extension point="org.eclipse.ui.navigator.navigatorContent" id="navigator-content"> >- <?gmfgen generated="true"?> >- <navigatorContent >- id="org.eclipse.papyrus.sysml.diagram.parametric.resourceContent" >- name="%navigatorContentName" >- priority="normal" >- contentProvider="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorContentProvider" >- labelProvider="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorLabelProvider" >- icon="icons/obj16/ResourceDiagramFile.gif" >- activeByDefault="true"> >- <triggerPoints> >- <or> >- <and> >- <instanceof value="org.eclipse.core.resources.IFile"/> >- <test property="org.eclipse.core.resources.extension" value="sysml_diagram"/> >- </and> >- <instanceof value="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlAbstractNavigatorItem"/> >- </or> >- </triggerPoints> >- <possibleChildren> >- <or> >- <instanceof value="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlAbstractNavigatorItem"/> >- </or> >- </possibleChildren> >- <commonSorter >- id="org.eclipse.papyrus.sysml.diagram.parametric.navigatorSorter" >- class="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorSorter"> >- <parentExpression> >- <or> >- <and> >- <instanceof value="org.eclipse.core.resources.IFile"/> >- <test property="org.eclipse.core.resources.extension" value="sysml_diagram"/> >- </and> >- <instanceof value="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlAbstractNavigatorItem"/> >- </or> >- </parentExpression> >- </commonSorter> >- </navigatorContent> >- <navigatorContent >- id="org.eclipse.papyrus.sysml.diagram.parametric.domainResourceContent" >- name="%domainNavigatorContentName" >- priority="normal" >- contentProvider="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorContentProvider" >- labelProvider="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorLabelProvider" >- icon="icons/obj16/ResourceDiagramFile.gif" >- activeByDefault="true"> >- <triggerPoints> >- <or> >- <and> >- <instanceof value="org.eclipse.core.resources.IFile"/> >- <test property="org.eclipse.core.resources.extension" value="sysml"/> >- </and> >- <instanceof value="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorItem"/> >- </or> >- </triggerPoints> >- <possibleChildren> >- <instanceof value="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorItem"/> >- </possibleChildren> >- </navigatorContent> >- <actionProvider >- id="org.eclipse.papyrus.sysml.diagram.parametric.navigatorActionProvider" >- class="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorActionProvider"> >- <enablement> >- <or> >- <instanceof value="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlAbstractNavigatorItem"/> >- </or> >- </enablement> >- </actionProvider> >- </extension> >- >- <extension point="org.eclipse.ui.navigator.linkHelper" id="navigator-linkhelper"> >- <?gmfgen generated="true"?> >- <linkHelper >- id="org.eclipse.papyrus.sysml.diagram.parametric.navigatorLinkHelper" >- class="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorLinkHelper"> >- <editorInputEnablement> >- <and> >- <instanceof value="org.eclipse.emf.common.ui.URIEditorInput"/> >- <test property="org.eclipse.papyrus.sysml.diagram.parametric.isURIEditorInput"/> >- </and> >- </editorInputEnablement> >- <selectionEnablement> >- <instanceof value="org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlAbstractNavigatorItem"/> >- </selectionEnablement> >- </linkHelper> >- </extension> >- <extension point="org.eclipse.ui.commands" id="update-cmd"> >- <?gmfgen generated="true"?> >- <command >- categoryId="org.eclipse.ui.category.edit" >- defaultHandler="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramUpdateCommand" >- description="%update.diagram.description" >- id="org.eclipse.papyrus.sysml.diagram.parametric.updateDiagram" >- name="%update.diagram.name"/> >- </extension> >- >- <extension point="org.eclipse.ui.bindings" id="update-cmd-binding"> >- <?gmfgen generated="true"?> >- <key >- commandId="org.eclipse.papyrus.sysml.diagram.parametric.updateDiagram" >- contextId="org.eclipse.papyrus.sysml.diagram.parametric.ui.diagramContext" >- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" >- sequence="F5"/> >- </extension> >- >- <extension point="org.eclipse.ui.menus" id="context-menus"> >- <?gmfgen generated="true"?> >- <!-- menuContribution locationURI="menu:org.eclipse.ui.main.menu?after="> >- </menuContribution> >- <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after="> >- </menuContribution --> >- <menuContribution locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu"> >- <command commandId="org.eclipse.papyrus.sysml.diagram.parametric.LoadResourceAction"> >- <visibleWhen> >- <and> >- <with variable="activePartId"><equals value="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorID"/></with> >- <with variable="selection"><iterate ifEmpty="false"> >- <instanceof value="org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart"/> >- </iterate></with> >- </and> >- </visibleWhen> >- </command> >- </menuContribution> >- >- >- <menuContribution locationURI="menu:org.eclipse.papyrus.ui.menu"> >- <menu id="org.eclipse.papyrus.uml.diagram.ui.menu.diagrams" >- label="Diagrams"> >- <command commandId="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramCommand" >- icon="icons/obj16/Diagram_Parametric.gif" >- label="Create a new Parametric Diagram" >- style="push" >- tooltip="Create a new Parametric Diagram"> >- <visibleWhen> >- <reference definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML"/> >- </visibleWhen> >- </command> >- </menu> >- </menuContribution> >- >- <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar"> >- <toolbar id="org.eclipse.papyrus.uml.diagram.ui.toolbar"> >- <command commandId="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramCommand" >- icon="icons/obj16/Diagram_Parametric.gif" >- label="Create a new Parametric Diagram" >- style="push" >- tooltip="Create a new Parametric Diagram"> >- <visibleWhen> >- <reference definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML"/> >- </visibleWhen> >- </command> >- </toolbar> >- </menuContribution> >- >- <menuContribution >- locationURI="popup:org.eclipse.papyrus.views.modelexplorer.popupmenu.creatediagram"> >- <command commandId="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramCommand" >- icon="icons/obj16/Diagram_Parametric.gif" >- label="Create a new Parametric Diagram" >- style="push" >- tooltip="Create a new Parametric Diagram"> >- <visibleWhen> >- <reference definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML"/> >- </visibleWhen> >- </command> >- </menuContribution> >- >+<!-- Diagram declaration --> >+<extension point="org.eclipse.papyrus.infra.core.papyrusDiagram"> >+ <creationCommand >+ creationCommandClass="org.eclipse.papyrus.sysml.diagram.parametric.ParametricDiagramCreateCommand" >+ icon="icons/obj16/Diagram_Parametric.png" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.CreateCommand" >+ language="sysml" >+ label="SysML Parametric Diagram"/> >+ <editorDiagram >+ actionBarContributorId="org.eclipse.papyrus.uml.diagram.common.part.UMLDiagramActionBarContributor" >+ factoryClass="org.eclipse.papyrus.sysml.diagram.parametric.ParametricDiagramEditorFactory" >+ icon="icons/obj16/Diagram_Parametric.png" /> > </extension> > >- <extension point="org.eclipse.ui.commands" id="menu-commands"> >- <?gmfgen generated="true"?> >- <category id="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorID" name="%cmdcategory.name" description="%cmdcategory.desc"/> >- <command id="org.eclipse.papyrus.sysml.diagram.parametric.LoadResourceAction" >- name="Load Resource" >- categoryId="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorID" >- defaultHandler="org.eclipse.papyrus.sysml.diagram.parametric.part.LoadResourceAction"/> >- </extension> >- >- <extension point="org.eclipse.ui.commands"> >- <command description="Create a new Parametric Diagram" >- categoryId="org.eclipse.papyrus.editor.category" >- id="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramCommand" >- name="Create Parametric Diagram"> >- </command> >- </extension> >- >- <extension point="org.eclipse.ui.handlers"> >- <handler class="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramWithNavigationHandler" >- commandId="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramCommand"> >- <activeWhen> >- <with variable="activeEditorId"> >- <equals value="org.eclipse.papyrus.infra.core.papyrusEditor"></equals> >- </with> >- </activeWhen> >- </handler> >- </extension> >- >- >- <extension >- point="org.eclipse.papyrus.infra.core.papyrusDiagram"> >- <editorDiagram >- factoryClass="org.eclipse.papyrus.sysml.diagram.parametric.ParametricDiagramEditorFactory" >- icon="icons/obj16/Diagram_Parametric.gif"> >- </editorDiagram> >- <creationCommand >- creationCommandClass="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramCommand" >- creationCondition="org.eclipse.papyrus.sysml.diagram.parametric.ParametricDiagramCondition" >- icon="icons/obj16/Diagram_Parametric.gif" >- id="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramCommand" >- language="sysml" >- label="SysML Parametric Diagram"> >- </creationCommand> >- </extension> >-<extension point="org.eclipse.gmf.runtime.common.ui.services.parserProviders" id="parser-provider"> >- <?gmfgen generated="true"?> >- <ParserProvider class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlParserProvider"> >- <Priority name="Lowest"/> >- </ParserProvider> >- </extension> >+<!-- Diagram creation command and handler --> >+<extension point="org.eclipse.ui.commands"> >+ <command id="org.eclipse.papyrus.sysml.diagram.parametric.CreateCommand" >+ name="Create a new Parametric Diagram" >+ description="Create a new Parametric Diagram" >+ categoryId="org.eclipse.papyrus.editor.category"/> >+</extension> > >-<extension point="org.eclipse.ui.preferencePages"> >- >- >- >- <?gmfgen generated="true"?> >- <page category="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams.Parametric" >- class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConstraintPropertyPreferencePage" >- id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConstraintPropertyPreferencePage" >- name="ConstraintProperty Node" /> >+<extension point="org.eclipse.ui.handlers"> >+ <handler >+ class="org.eclipse.papyrus.sysml.diagram.parametric.CreateParametricDiagramWithNavigationHandler" >+ commandId="org.eclipse.papyrus.sysml.diagram.parametric.CreateCommand"> >+ <activeWhen> >+ <with variable="activeEditorId"> >+ <equals value="org.eclipse.papyrus.infra.core.papyrusEditor" /> >+ </with> >+ </activeWhen> >+ </handler> >+</extension> >+ >+<!-- Diagram creation command registration in menu and toolbar --> >+<extension point="org.eclipse.ui.menus"> >+ >+ <menuContribution locationURI="menu:org.eclipse.papyrus.ui.menu"> >+ <menu id="org.eclipse.papyrus.uml.diagram.ui.menu.diagrams" label="Diagrams"> >+ <command commandId="org.eclipse.papyrus.sysml.diagram.parametric.CreateCommand" >+ icon="icons/obj16/Diagram_Parametric.png" label="Create a new Parametric Diagram" >+ style="push" tooltip="Create a new Parametric Diagram"> >+ <visibleWhen> >+ <reference definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML"/> >+ </visibleWhen> >+ >+ </command> >+ </menu> >+ </menuContribution> > >- >- <?gmfgen generated="true"?> >- <page category="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams.Parametric" >- class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.PropertyPreferencePage" >- id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.PropertyPreferencePage" >- name="Property Node" /> >+ <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar"> >+ <toolbar id="org.eclipse.papyrus.uml.diagram.ui.toolbar"> >+ <command commandId="org.eclipse.papyrus.sysml.diagram.parametric.CreateCommand" >+ icon="icons/obj16/Diagram_Parametric.png" label="Create a new Parametric Diagram" >+ style="push" tooltip="Create a new Parametric Diagram"> >+ <visibleWhen> >+ <reference definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML"/> >+ </visibleWhen> >+ >+ </command> >+ </toolbar> >+ </menuContribution> > >- >- >- >- >- <?gmfgen generated="true"?> >- <page category="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams.Parametric" >- class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConnectorPreferencePage" >- id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConnectorPreferencePage" >- name="Connector Link" /> >- >- >-</extension> >-<extension >- point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor"> >- <DirectEditor >- contributor="Eclipse.org" >- editorConfiguration="org.eclipse.papyrus.sysml.diagram.parametric.texteditor.ConstraintPropertyConfiguration" >- icon="platform:/plugin/org.eclipse.papyrus.sysml/icons/constraints/ConstraintProperty.gif" >- language="Papyrus SysML" >- objectToEdit="org.eclipse.papyrus.sysml.constraints.ConstraintProperty"> >- <simpleeditor >- editorConfiguration="org.eclipse.papyrus.sysml.diagram.parametric.texteditor.ConstraintPropertyConfiguration"> >- </simpleeditor> >- </DirectEditor> >-</extension> >- >-<extension point="org.eclipse.emf.validation.constraintProviders"> >- <?gmfgen generated="true"?> >- <category id="org.eclipse.uml2.uml.util.UMLValidator.validate" mandatory="false" name="validateSysMLModel"> >- <![CDATA[Validate the SysML model]]> >- </category> >- <category id="org.eclipse.uml2.uml.util.UMLValidator.validate/org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement" mandatory="false" name="validateConnectorElement"> >- <![CDATA[validate a connector checking that its children are consistent]]> >- </category> >- <constraintProvider cache="true"> >- <package namespaceUri="http://www.eclipse.org/uml2/3.0.0/UML"/> >- <package namespaceUri="http://www.eclipse.org/papyrus/0.7.0/SysML/Blocks"/> >- <constraints categories="org.eclipse.uml2.uml.util.UMLValidator.validate"> >- </constraints> >- <constraints categories="org.eclipse.uml2.uml.util.UMLValidator.validate/org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement"> >- <constraint id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateConnector" >- lang="Java" class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlValidationProvider$Adapter1" >- name="validateConnector" >- mode="Live" >- severity="WARNING" statusCode="200"> >- >- <description><![CDATA[The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property]]></description> >- <message><![CDATA[NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector.]]></message> >- <target class="uml.Connector"/> >- </constraint> >- <constraint id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateProperty" >- lang="Java" class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlValidationProvider$Adapter2" >- name="validateProperty" >- mode="Live" >- severity="WARNING" statusCode="200"> >- >- <description><![CDATA[When you move a property, check that its incoming or outgoings connector get consistent connectorEnd]]></description> >- <message><![CDATA[NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector.]]></message> >- <target class="uml.Property"/> >- </constraint> >- <constraint id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateConnectorEnd" >- lang="Java" class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlValidationProvider$Adapter3" >- name="validateConnectorEnd" >- mode="Live" >- severity="WARNING" statusCode="200"> >- >- <description><![CDATA[The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property]]></description> >- <message><![CDATA[NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector.]]></message> >- <target class="uml.ConnectorEnd"/> >- </constraint> >- <constraint id="org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateNestedConnectorEnd" >- lang="Java" class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlValidationProvider$Adapter4" >- name="validateNestedConnectorEnd" >- mode="Live" >- severity="WARNING" statusCode="200"> >- >- <description><![CDATA[The NestedConnectorEnd stereotype of UML ConnectorEnd extends a UML ConnectorEnd so that the connected property]]></description> >- <message><![CDATA[NestedConnectorEnd is used for connected property identified by a multi-level path of accessible properties from the block that owns the connector.]]></message> >- <target class="sysml.blocks.NestedConnectorEnd"/> >- </constraint> >- </constraints> >- </constraintProvider> >- </extension> >+ <menuContribution locationURI="popup:org.eclipse.papyrus.views.modelexplorer.popupmenu.creatediagram"> >+ <command commandId="org.eclipse.papyrus.sysml.diagram.parametric.CreateCommand" >+ icon="icons/obj16/Diagram_Parametric.png" >+ label="Create a new Parametric Diagram" >+ style="push" >+ tooltip="Create a new Parametric Diagram"> >+ <visibleWhen> >+ <reference definitionId="org.eclipse.papyrus.sysml.diagram.common.IsPapyrusActiveWithSysML"/> >+ </visibleWhen> >+ >+ </command> >+ </menuContribution> >+ >+</extension> > >-<extension point="org.eclipse.emf.validation.constraintBindings"> >- <?gmfgen generated="true"?> >- <clientContext default="false" id="org.eclipse.papyrus.sysml.diagram.parametricDefaultCtx"> >- <selector class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlValidationProvider$DefaultCtx"/> >- </clientContext> >- <binding context="org.eclipse.papyrus.sysml.diagram.parametricDefaultCtx"> >- <constraint ref="org.eclipse.papyrus.sysml.diagram.parametric.org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateConnector"/> >- <constraint ref="org.eclipse.papyrus.sysml.diagram.parametric.org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateProperty"/> >- <constraint ref="org.eclipse.papyrus.sysml.diagram.parametric.org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateConnectorEnd"/> >- <constraint ref="org.eclipse.papyrus.sysml.diagram.parametric.org.eclipse.uml2.uml.util.UMLValidator.validateConnectorElement_validateNestedConnectorEnd"/> >- </binding> >- >- </extension> >-<extension >- point="org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders"> >- <editpolicyProvider >- class="org.eclipse.papyrus.sysml.diagram.parametric.providers.CustomEditPolicyProvider"> >- <Priority >- name="Lowest"> >- </Priority> >- </editpolicyProvider> >-</extension> >-<extension point="org.eclipse.gmf.runtime.common.ui.services.markerNavigationProviders" id="markers-navigation"> >- <?gmfgen generated="true"?> >- <MarkerNavigationProvider class="org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlMarkerNavigationProvider"> >- <MarkerType name="org.eclipse.papyrus.sysml.diagram.parametric.diagnostic"/> >- <Priority name="Lowest"/> >- </MarkerNavigationProvider> >- </extension> >- >-<extension id="diagnostic" name="Sysml Parametric diagram Plugin problems" point="org.eclipse.core.resources.markers"> >- <?gmfgen generated="true"?> >- <super type="org.eclipse.core.resources.problemmarker"/> >- <super type="org.eclipse.gmf.runtime.common.ui.services.marker"/> >- <persistent value="true"/> >- </extension><extension >- id="Sysml Parametric diagram Plugin.palettedefinition" >- name="Sysml Parametric diagram Plugin Predefined Entries" >- point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders"> >- >- <?gmfgen generated="true"?> >- <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider"> >- <Priority name="Lowest"/> >- <contribution >- factoryClass="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlPaletteFactory"> >- <predefinedEntry id="standardGroup/noteStack/noteTool" remove="true"/> >- <predefinedEntry id="standardGroup/noteStack/textTool" remove="true"/> >- <predefinedEntry id="standardGroup/noteStack/noteattachmentTool" remove="true"/> >- <entry >- defineOnly="true" >- description="Create new ConstraintProperty" >- id="createConstraintProperty1CreationTool" >- kind="tool" >- label="ConstraintProperty" >- large_icon="platform:/plugin/org.eclipse.papyrus.sysml.edit/icons/full/obj16/ConstraintProperty.gif" >- path="" >- small_icon="platform:/plugin/org.eclipse.papyrus.sysml.edit/icons/full/obj16/ConstraintProperty.gif"> >- </entry> >- <entry >- defineOnly="true" >- description="Create new Property" >- id="createProperty2CreationTool" >- kind="tool" >- label="Property" >- large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif" >- path="" >- small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif"> >- </entry> >- <entry >- defineOnly="true" >- description="Create new Connector" >- id="createConnector3CreationTool" >- kind="tool" >- label="Connector" >- large_icon="" >- path="" >- small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Connector.gif"> >- </entry> >- >- </contribution> >- </paletteProvider> >- >- </extension> >- >-<extension >- id="Sysml Parametric diagram Plugin.standard" >- name="Sysml Parametric diagram Plugin Standard Palette" >- point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders"> >- >- <?gmfgen generated="true"?> >- <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider"> >- <Priority name="Low"/> >- <contribution >- factoryClass="org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlPaletteFactory"> >- <predefinedEntry id="standardGroup/noteStack/noteTool" remove="true"/> >- <predefinedEntry id="standardGroup/noteStack/textTool" remove="true"/> >- <predefinedEntry id="standardGroup/noteStack/noteattachmentTool" remove="true"/> >- <entry >- description="" >- id="createParametric1Group" >- kind="drawer" >- label="Parametric" >- large_icon="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif" >- path="/" >- small_icon="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif"> >- <expand >- force="true"> >- </expand> >- </entry> >- >- <predefinedEntry >- id="createConstraintProperty1CreationTool" >- path="/createParametric1Group"> >- </predefinedEntry> >- <predefinedEntry >- id="createProperty2CreationTool" >- path="/createParametric1Group"> >- </predefinedEntry> >- <predefinedEntry >- id="createConnector3CreationTool" >- path="/createParametric1Group"> >- </predefinedEntry> >- >- >- </contribution> >- <editor id="org.eclipse.papyrus.sysml.diagram.parametric"/> >- </paletteProvider> >- >- </extension> >- >-<extension point="org.eclipse.ui.handlers" id="menu-handlers"> >- <?gmfgen generated="true"?> >- </extension> >- >+<!-- Palette tool definition (defines tools possibly used by the palette(s)) --> >+<extension point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders" >+ name="SYSML_Parametric_Predefined_Entries" >+ id="org.eclipse.papyrus.sysml.diagram.blockdefinition.palettedefinition"> >+ >+ <paletteProvider class="org.eclipse.gmf.runtime.diagram.ui.providers.DefaultPaletteProvider"> >+ <Priority name="Lowest"/> <!-- Lower priority than Palette tool declaration --> >+ >+ <!-- SysML Parametric Diagram specific tool definition --> >+ <contribution >+ factoryClass="org.eclipse.papyrus.sysml.diagram.parametric.factory.DiagramPaletteFactory"> >+ >+ <!-- parametric.tool.constraintblockpropertycomposite --> >+ <entry >+ defineOnly="true" >+ description="Create a ConstraintBlockProperty" >+ id="parametric.tool.constraintblockpropertycomposite" >+ kind="tool" >+ label="ConstraintProperty" >+ large_icon="platform:/plugin/org.eclipse.papyrus.sysml/icons/blocks/Block.gif" >+ small_icon="platform:/plugin/org.eclipse.papyrus.sysml/icons/blocks/Block.gif"> >+ </entry> >+ >+ <!-- parametric.tool.parameter --> >+ <entry >+ defineOnly="true" >+ description="Create a Parameter" >+ id="parametric.tool.parameter" >+ kind="tool" >+ label="ConstraintParameter" >+ large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Port.gif" >+ small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Port.gif"> >+ </entry> >+ >+ <!-- parametric.tool.blockpropertycomposite --> >+ <entry >+ defineOnly="true" >+ description="Create a Part" >+ id="parametric.tool.blockpropertycomposite" >+ kind="tool" >+ label="Part" >+ large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif" >+ small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif"> >+ </entry> >+ >+ <!-- parametric.tool.reference --> >+ <entry >+ defineOnly="true" >+ description="Create a Reference" >+ id="parametric.tool.reference" >+ kind="tool" >+ label="Reference" >+ large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif" >+ small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif"> >+ </entry> >+ >+ <!-- parametric.tool.value --> >+ <entry >+ defineOnly="true" >+ description="Create a Value" >+ id="parametric.tool.value" >+ kind="tool" >+ label="Value" >+ large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif" >+ small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Property.gif"> >+ </entry> >+ >+ <!-- Start of user code Custom node button entry >+ --> >+ >+ <!-- End of user code --> >+ >+ >+ <!-- parametric.tool.connector --> >+ <entry >+ defineOnly="true" >+ description="Create a Connector" >+ id="parametric.tool.connector" >+ kind="tool" >+ label="Connector" >+ large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Connector.gif" >+ small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Connector.gif"> >+ </entry> >+ >+ <!-- parametric.tool.dependency --> >+ <entry >+ defineOnly="true" >+ description="Create a Dependency" >+ id="parametric.tool.dependency" >+ kind="tool" >+ label="Dependency" >+ large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Dependency.gif" >+ small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Dependency.gif"> >+ </entry> >+ <!-- Start of user code Custom edge button entry --> >+ <!-- parametric.tool.comment --> >+ <entry >+ defineOnly="true" >+ description="Create a Comment" >+ id="parametric.tool.comment" >+ kind="tool" >+ label="Comment" >+ large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Comment.gif" >+ small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Comment.gif"> >+ </entry> >+ >+ <!-- internalblock.tool.constraint --> >+ <entry defineOnly="true" >+ description="Create a Constraint" >+ id="parametric.tool.constraint" >+ kind="tool" >+ label="Constraint" >+ large_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Constraint.gif" >+ small_icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Constraint.gif"> >+ </entry> > >- <!-- optionally, specify keybindings --> >-</plugin> >+ <entry >+ defineOnly="true" >+ description="Create a Comment / Constraint link" >+ id="parametric.tool.comment_constraint_link" >+ kind="tool" >+ label="Comment / Constraint link" >+ large_icon="icons/obj16/Link.gif" >+ small_icon="icons/obj16/Link.gif"> >+ </entry> >+ >+ <!-- End of user code --> >+ >+ </contribution> >+ >+ <!-- Specify diagram this palette tools relate to --> >+ <editor id="org.eclipse.papyrus.sysml.diagram.parametric"/> >+ >+ </paletteProvider> >+</extension> >+ >+<!-- Palette tool declaration (declares the real palette containment) --> >+<extension point="org.eclipse.papyrus.uml.diagram.common.paletteDefinition" >+ name="SYSML_Parametric"> >+ >+ <paletteDefinition ID="SYSML_Parametric" >+ class="org.eclipse.papyrus.uml.diagram.common.service.PluginPaletteProvider" >+ name="SYSML_Parametric" icon="platform:/plugin/org.eclipse.gmf.runtime.diagram.ui/icons/group.gif" >+ path="palettes/parametric.palette.xml" >+ provider="CEA LIST"> >+ <Priority name="Low"/> >+ >+ <!-- Specify diagram this palette tools relate to --> >+ <editor id="org.eclipse.papyrus.sysml.diagram.parametric"/> >+ </paletteDefinition> >+</extension> >+ >+ >+<!-- Diagram view providers declaration --> >+<extension point="org.eclipse.gmf.runtime.diagram.core.viewProviders"> >+ <!-- Diagram view provider --> >+ <viewProvider class="org.eclipse.papyrus.sysml.diagram.parametric.provider.ParametricDiagramViewProvider"> >+ <Priority name="Low"/> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Diagram" semanticHints="Parametric"/> >+ </viewProvider> >+ >+ <!-- Custom graphical types view provider --> >+ <viewProvider class="org.eclipse.papyrus.sysml.diagram.parametric.provider.CustomViewProvider"> >+ <Priority name="Medium"/> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="UML::Property, UML::Port, SysML::ReferenceProperty, SysML::FlowPort, SysML::FlowPort_Out, SysML::Block, SysML::FlowPort_In, SysML::FlowPort_InOut, SysML::PartProperty, SysML::ConstraintProperty"/> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="shape_sysml_flowport_as_affixed, shape_uml_port_as_affixed, shape_sysml_block_as_composite, shape_sysml_blockproperty_as_composite, shape_sysml_constraintblockproperty_as_composite"/> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="UML::Connector, UML::Dependency"/> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="link_uml_dependency, link_uml_connector"/> >+ >+ <!-- Additional descriptors provided in case the semantic hint is is not provided --> >+ >+ <!-- "uml.Class" --> >+ <object id="uml.Class" class="org.eclipse.gmf.runtime.emf.core.util.IProxyEObject(org.eclipse.gmf.runtime.emf.core)"> >+ <method name="getProxyClassID()" value="uml.Class"/> >+ </object> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="uml.Class"/> >+ >+ <!-- "uml.Port" --> >+ <object id="uml.Port" class="org.eclipse.gmf.runtime.emf.core.util.IProxyEObject(org.eclipse.gmf.runtime.emf.core)"> >+ <method name="getProxyClassID()" value="uml.Port"/> >+ </object> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="uml.Port"/> >+ >+ <!-- "uml.Property" --> >+ <object id="uml.Property" class="org.eclipse.gmf.runtime.emf.core.util.IProxyEObject(org.eclipse.gmf.runtime.emf.core)"> >+ <method name="getProxyClassID()" value="uml.Property"/> >+ </object> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="uml.Property"/> >+ >+ <!-- "uml.Connector" --> >+ <object id="uml.Connector" class="org.eclipse.gmf.runtime.emf.core.util.IProxyEObject(org.eclipse.gmf.runtime.emf.core)"> >+ <method name="getProxyClassID()" value="uml.Connector"/> >+ </object> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="uml.Connector"/> >+ >+ <!-- "uml.Dependency" --> >+ <object id="uml.Dependency" class="org.eclipse.gmf.runtime.emf.core.util.IProxyEObject(org.eclipse.gmf.runtime.emf.core)"> >+ <method name="getProxyClassID()" value="uml.Dependency"/> >+ </object> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="uml.Dependency"/> >+ <object id="elementtype.node" >+ class="org.eclipse.papyrus.gmf.diagram.common.commands.ISemanticHintAdapter(org.eclipse.papyrus.sysml.diagram.common)"> >+ >+ <method >+ name="getSemanticHint()" >+ value="UML::Property, SysML::ActorPartProperty, SysML::ValueProperty, SysML::ReferenceProperty, SysML::FlowPort_In, UML::Port, SysML::FlowPort_Out, SysML::PartProperty, SysML::FlowPort_InOut, SysML::FlowPort, SysML::Block, SysML::FlowPort_NA"> >+ </method> >+ </object> >+ <context >+ elements="elementtype.node" >+ viewClass="org.eclipse.gmf.runtime.notation.Node"> >+ </context> >+ <object id="elementtype.edge" >+ class="org.eclipse.papyrus.gmf.diagram.common.commands.ISemanticHintAdapter(org.eclipse.papyrus.sysml.diagram.common)"> >+ <method >+ name="getSemanticHint()" >+ value="UML::Dependency, UML::Connector"> >+ </method> >+ </object> >+ <context >+ elements="elementtype.edge" >+ viewClass="org.eclipse.gmf.runtime.notation.Edge"> >+ </context> >+ >+ </viewProvider> >+ >+ <!-- ViewProvider for inherited elements (from CompositeDiagram ViewProvider) --> >+ <viewProvider class="org.eclipse.papyrus.sysml.diagram.parametric.provider.InheritedCompositeDiagramViewProvider"> >+ <Priority name="Low"></Priority> >+ >+ <!-- Load the ViewProvider on following SemanticHint related to IElementType(s) used in the palette (also used for legacy elements) --> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="UML::Comment, UML::Constraint"></context> >+ >+ <!-- >+ "2109" = COMMENT >+ "3097" = COMMENT_CN >+ "2114" = CONSTRAINT >+ "3120" = CONSTRAINT_CN >+ --> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="2109, 3097, 2114, 3120"></context> >+ >+ <!-- >+ "4002" = COMMENT_ANNOTATED_ELEMENT >+ "4003" = CONSTRAINT_CONSTRAINED_ELEMENT >+ --> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="4002, 4003"></context> >+ >+ <!-- Additional descriptors provided in case the semantic hint is is not provided --> >+ >+ <!-- "uml.Comment" --> >+ <object id="uml.Comment" class="org.eclipse.gmf.runtime.emf.core.util.IProxyEObject(org.eclipse.gmf.runtime.emf.core)"> >+ <method name="getProxyClassID()" value="uml.Comment"></method> >+ </object> >+ >+ <!-- "uml.Constraint" --> >+ <object id="uml.Constraint" class="org.eclipse.gmf.runtime.emf.core.util.IProxyEObject(org.eclipse.gmf.runtime.emf.core)"> >+ <method name="getProxyClassID()" value="uml.Constraint"></method> >+ </object> >+ >+ <!-- Additional activation contexts for nodes semantic objects --> >+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" elements="uml.Comment, uml.Constraint"></context> >+ >+ </viewProvider> >+</extension> >+ >+<!-- Diagram edit part providers declaration --> >+<extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders"> >+ <!-- Diagram edit part provider --> >+ <editpartProvider class="org.eclipse.papyrus.sysml.diagram.parametric.provider.ParametricDiagramEditPartProvider"> >+ <Priority name="Low"/> >+ <object >+ id="org.eclipse.papyrus.sysml.diagram.parametric.Diagram" >+ class="org.eclipse.gmf.runtime.notation.Diagram"> >+ <method name="getType()" value="Parametric"/> >+ </object> >+ <context views="org.eclipse.papyrus.sysml.diagram.parametric.Diagram"/> >+ </editpartProvider> >+ >+ <!-- Custom graphical types edit part provider --> >+ <editpartProvider class="org.eclipse.papyrus.sysml.diagram.parametric.provider.CustomEditPartProvider"> >+ <Priority name="Medium"/> >+ >+ <object >+ class="org.eclipse.gmf.runtime.notation.Node(org.eclipse.gmf.runtime.notation)" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.CustomNodeGraphicalTypes"> >+ <method name="getType()" value="shape_sysml_flowport_as_affixed, shape_uml_port_as_affixed, shape_sysml_block_as_composite, shape_sysml_blockproperty_as_composite, shape_sysml_constraintblockproperty_as_composite"/> >+ </object> >+ >+ <object >+ class="org.eclipse.gmf.runtime.notation.Node(org.eclipse.gmf.runtime.notation)" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.CustomGraphicalTypes_Decorations"> >+ <method name="getType()" value="linklabel_uml_connector_source_multiplicity, compartment_sysml_blockproperty_structure, linklabel_uml_connector_target_multiplicity, affixedlabel_sysml_flowport_label, compartment_sysml_structure, affixedlabel_uml_port_label, label_sysml_block_name, linklabel_uml_appliedstereotype, linklabel_uml_namedelement_name, linklabel_uml_connector_label, label_uml_property_label, shape_uml_constraint_as_label, affixedlabel_uml_appliedstereotype"/> >+ </object> >+ >+ <context views="org.eclipse.papyrus.sysml.diagram.parametric.CustomNodeGraphicalTypes"/> >+ <context views="org.eclipse.papyrus.sysml.diagram.parametric.CustomGraphicalTypes_Decorations"/> >+ >+ <object >+ class="org.eclipse.gmf.runtime.notation.Edge(org.eclipse.gmf.runtime.notation)" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.CustomEdgeGraphicalTypes"> >+ <method name="getType()" value="link_uml_dependency, link_uml_connector"/> >+ </object> >+ >+ <context views="org.eclipse.papyrus.sysml.diagram.parametric.CustomEdgeGraphicalTypes"/> >+ >+ </editpartProvider> >+ >+ <!-- EditPartProvider for inherited elements (from CompositeDiagram) --> >+ <editpartProvider class="org.eclipse.papyrus.sysml.diagram.parametric.provider.InheritedCompositeDiagramEditPartProvider"> >+ <Priority name="Low"></Priority> >+ >+ <!-- >+ The semantic hints given here are used in case the provider is not already loaded. >+ As soon as the provider is loaded its provides method is used. >+ "2109" = COMMENT >+ "5192" = COMMENT_LABEL_BODY_HINT >+ "3097" = COMMENT_CN >+ "5150" = COMMENT_CN_LABEL_BODY_HINT >+ "2114" = CONSTRAINT >+ "5197" = CONSTRAINT_LABEL_NAME_HINT >+ "6039" = CONSTRAINT_LABEL_SPECIFICATION_HINT >+ "3120" = CONSTRAINT_CN >+ "6048" = CONSTRAINT_CN_LABEL_NAME_HINT >+ "6049" = CONSTRAINT_CN_LABEL_SPECIFICATION_HINT >+ --> >+ <object id="COMMENT" class="org.eclipse.gmf.runtime.notation.Node"> >+ <method name="getType()" value="2109, 5192"></method> >+ </object> >+ <object id="COMMENT_CN" class="org.eclipse.gmf.runtime.notation.Node"> >+ <method name="getType()" value="3097, 5150"></method> >+ </object> >+ <object id="CONSTRAINT" class="org.eclipse.gmf.runtime.notation.Node"> >+ <method name="getType()" value="2114, 5197, 6039"></method> >+ </object> >+ <object id="CONSTRAINT_CN" class="org.eclipse.gmf.runtime.notation.Node"> >+ <method name="getType()" value="3120, 6048, 6049"></method> >+ </object> >+ >+ <!-- >+ "4002" = COMMENT_ANNOTATED_ELEMENT >+ "4003" = CONSTRAINT_CONSTRAINED_ELEMENT >+ --> >+ <object id="COMMENT_ANNOTATED_ELEMENT" class="org.eclipse.gmf.runtime.notation.Edge"> >+ <method name="getType()" value="4002"></method> >+ </object> >+ <object id="CONSTRAINT_CONSTRAINED_ELEMENT" class="org.eclipse.gmf.runtime.notation.Edge"> >+ <method name="getType()" value="4003"></method> >+ </object> >+ >+ <context views="COMMENT, COMMENT_CN, CONSTRAINT, CONSTRAINT_CN"></context> >+ <context views="COMMENT_ANNOTATED_ELEMENT, CONSTRAINT_CONSTRAINED_ELEMENT"></context> >+ >+ </editpartProvider> >+ >+</extension> >+ >+<!-- Diagram edit policy provider --> >+<extension >+ point="org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders"> >+ <editpolicyProvider >+ class="org.eclipse.papyrus.sysml.diagram.parametric.provider.CustomEditPolicyProvider"> >+ <Priority name="Low"/> >+ </editpolicyProvider> >+</extension> >+ >+<!-- Preference pages declaration --> >+<extension point="org.eclipse.ui.preferencePages" id="prefpages"> >+ >+ <!-- Diagram Preference pages declaration --> >+ <page >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ name="Parametric Diagram" >+ category="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ParametricDiagramGeneralPreferencePage"> >+ </page> >+ >+ <!-- Element Preference pages declaration --> >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConstraintPreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConstraintPreferencePage" >+ name="Constraint"> >+ </page> >+ >+ >+ >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CommentPreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CommentPreferencePage" >+ name="Comment"> >+ </page> >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CommentAnnotatedElementPreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CommentAnnotatedElementPreferencePage" >+ name="CommentAnnotatedElement"> >+ </page> >+ >+ >+ >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.BlockCompositePreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.BlockCompositePreferencePage" >+ name="BlockComposite"> >+ </page> >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CustomBlockPropertyCompositePreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CustomBlockPropertyCompositePreferencePage" >+ name="BlockPropertyComposite"> >+ </page> >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CustomConstraintPropertyCompositePreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.CustomConstraintPropertyCompositePreferencePage" >+ name="ConstraintPropertyComposite"> >+ </page> >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.FlowPortPreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.FlowPortPreferencePage" >+ name="FlowPort"> >+ </page> >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.PortPreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.PortPreferencePage" >+ name="Port"> >+ </page> >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConnectorPreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConnectorPreferencePage" >+ name="Connector"> >+ </page> >+ >+ <page category="org.eclipse.papyrus.sysml.diagram.parametric.preferences" >+ class="org.eclipse.papyrus.sysml.diagram.parametric.preferences.DependencyPreferencePage" >+ id="org.eclipse.papyrus.sysml.diagram.parametric.preferences.DependencyPreferencePage" >+ name="Dependency"> >+ </page> >+ >+ >+</extension> >+ >+<!-- // Start of user code custom extensions >+ --> >+<!-- Parser provider declaration --> >+<extension point="org.eclipse.gmf.runtime.common.ui.services.parserProviders"> >+ <ParserProvider class="org.eclipse.papyrus.sysml.diagram.parametric.provider.ParserProvider"> >+ <Priority name="Low"></Priority> >+ </ParserProvider> >+</extension> >+ >+ <!-- Diagram specific advices --> >+<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes"> >+ <metamodel nsURI="http://www.eclipse.org/uml2/4.0.0/UML"> >+ <!-- specific advices (pop up on creation) --> >+ <adviceBinding id="org.eclipse.papyrus.sysml.service.types.helper.ConstraintParameterEditHelperAdvice" >+ class="org.eclipse.papyrus.sysml.service.types.helper.ConstraintParameterEditHelperAdvice" >+ inheritance="none" >+ typeId="org.eclipse.papyrus.uml.Property"/> >+ </metamodel> >+</extension> >+ >+<!-- UML ElementType bindings to Papyrus shared IClientContext --> >+<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings"> >+ >+ <!-- Bindings declaration to shared IClientContext --> >+ <binding context="org.eclipse.papyrus.infra.services.edit.TypeContext"> >+ <elementType ref="org.eclipse.papyrus.sysml.service.types.helper.ConstraintParameterEditHelperAdvice"/> >+ </binding> >+ >+</extension> >+ >+<!-- // End of user code >+ --> >+ >+</plugin> >\ No newline at end of file >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCreateCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCreateCommand.java >new file mode 100644 >index 0000000..7966aa4 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCreateCommand.java >@@ -0,0 +1,168 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric; >+ >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.gmf.runtime.common.core.command.ICommand; >+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >+import org.eclipse.gmf.runtime.diagram.core.services.ViewService; >+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; >+import org.eclipse.gmf.runtime.notation.Bounds; >+import org.eclipse.gmf.runtime.notation.Diagram; >+import org.eclipse.gmf.runtime.notation.Node; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler; >+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; >+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; >+import org.eclipse.papyrus.infra.services.edit.utils.GMFCommandUtils; >+import org.eclipse.papyrus.sysml.blocks.Block; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter; >+import org.eclipse.papyrus.uml.diagram.composite.part.UMLDiagramEditorPlugin; >+import org.eclipse.uml2.uml.Element; >+import org.eclipse.uml2.uml.Package; >+import org.eclipse.uml2.uml.util.UMLUtil; >+ >+// Start of user code custom imports >+// End of user code >+ >+public class ParametricDiagramCreateCommand extends AbstractPapyrusGmfCreateDiagramCommandHandler { >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getDefaultDiagramName() { >+ return "NewParametricDiagram"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getDiagramNotationID() { >+ return ElementTypes.DIAGRAM_ID; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected PreferencesHint getPreferenceHint() { >+ return Activator.DIAGRAM_PREFERENCES_HINT; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Diagram createDiagram(Resource diagramResource, EObject owner, String name) { >+ // Start of user code Custom diagram creation >+ Diagram diagram = null; >+ >+ if(owner instanceof org.eclipse.uml2.uml.Class) { >+ org.eclipse.uml2.uml.Class cOwner = (org.eclipse.uml2.uml.Class)owner; >+ Block block = UMLUtil.getStereotypeApplication(cOwner, Block.class); >+ >+ if(block != null) { >+ canvasDomainElement = (EObject)owner; >+ Package owningPackage = ((Element)owner).getNearestPackage(); >+ diagram = super.createDiagram(diagramResource, owningPackage, name); >+ } >+ >+ } else if(owner instanceof Package) { >+ >+ try { >+ canvasDomainElement = null; >+ >+ IEditCommandRequest request = new CreateElementRequest((Package)owner, SysMLElementTypes.BLOCK); >+ IElementEditService commandService = ElementEditServiceUtils.getCommandProvider(owner); >+ if(commandService == null) { >+ return null; >+ } >+ >+ ICommand createElementCommand = commandService.getEditCommand(request); >+ if((createElementCommand != null) && (createElementCommand.canExecute())) { >+ createElementCommand.execute(new NullProgressMonitor(), null); >+ EObject block = GMFCommandUtils.getCommandEObjectResult(createElementCommand); >+ canvasDomainElement = block; >+ diagram = super.createDiagram(diagramResource, (Package)owner, name); >+ } >+ >+ } catch (ExecutionException e) { >+ e.printStackTrace(); >+ } >+ >+ } >+ >+ return diagram; >+ // End of user code >+ } >+ >+ // Start of user code Custom creation command >+ /** Domain Element referenced by canvas if it differs from {@link Package} */ >+ protected EObject canvasDomainElement = null; >+ >+ /** Default margin for the display of Domain Element referenced by canvas */ >+ protected static int DEFAULT_MARGIN = 20; >+ >+ /** Default height for the display of Domain Element referenced by canvas */ >+ protected static int DEFAULT_HEIGHT = 600; >+ >+ /** Default width for the display of Domain Element referenced by canvas */ >+ protected static int DEFAULT_WIDTH = 1000; >+ >+ /** >+ * Initialize the diagram. The diagram is attached to the element selected on creation. >+ * Possible element types are: Block. >+ */ >+ @Override >+ protected void initializeDiagram(EObject diagram) { >+ if(diagram instanceof Diagram) { >+ Diagram currentDiagram = (Diagram)diagram; >+ if(canvasDomainElement != null) { >+ currentDiagram.setElement(canvasDomainElement); >+ initializeDiagramContent(currentDiagram); >+ } >+ } >+ } >+ >+ /** >+ * Initialize the diagram with the canvas domain element shown. >+ * >+ * @param diagram >+ * the diagram to initialize >+ */ >+ protected void initializeDiagramContent(Diagram diagram) { >+ >+ // Create a view for the canvasDomainElement in the new diagram >+ View view = >+ ViewService.getInstance().createNode(new SemanticAdapter(canvasDomainElement, null), diagram, SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID, ViewUtil.APPEND, true, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); >+ view.setElement(diagram.getElement()); >+ >+ // Update the view position and size (should adapt to canvas current size) >+ Bounds viewBounds = (Bounds)((Node)view).getLayoutConstraint(); >+ viewBounds.setX(DEFAULT_MARGIN); >+ viewBounds.setY(DEFAULT_MARGIN); >+ viewBounds.setHeight(DEFAULT_HEIGHT); >+ viewBounds.setWidth(DEFAULT_WIDTH); >+ } >+ >+ /** >+ * {@inheritDoc} >+ * >+ * @generated NOT >+ */ >+ @Override >+ public boolean isParentReassignable() { >+ // Bug 374626: [Model Explorer] Moving an IBD from a block to another block shall be forbidden >+ return false; >+ } >+ >+ // End of user code >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramEditorFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramEditorFactory.java >new file mode 100644 >index 0000000..2bb7a36 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramEditorFactory.java >@@ -0,0 +1,12 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric; >+ >+import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+ >+public class ParametricDiagramEditorFactory extends GmfEditorFactory { >+ >+ public ParametricDiagramEditorFactory() { >+ super(ParametricDiagramForMultiEditor.class, ElementTypes.DIAGRAM_ID); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramForMultiEditor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramForMultiEditor.java >new file mode 100644 >index 0000000..b622f68 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramForMultiEditor.java >@@ -0,0 +1,103 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.emf.common.ui.URIEditorInput; >+import org.eclipse.emf.ecore.util.EcoreUtil; >+import org.eclipse.gmf.runtime.notation.Diagram; >+import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.papyrus.infra.core.editor.BackboneException; >+import org.eclipse.papyrus.infra.core.services.ServiceException; >+import org.eclipse.papyrus.infra.core.services.ServicesRegistry; >+import org.eclipse.papyrus.sysml.diagram.parametric.part.ParametricDiagramEditor; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IEditorSite; >+import org.eclipse.ui.PartInitException; >+ >+/** >+ * An editor to be used in multitabs editor. This editor extends the original UML Diagram. >+ * >+ */ >+public class ParametricDiagramForMultiEditor extends ParametricDiagramEditor { >+ >+ /** >+ * The location of diagram icon in the plug-in >+ */ >+ private static final String DIAG_IMG_PATH = "icons/obj16/Diagram_Parametric.png"; >+ >+ /** >+ * The image descriptor of the diagram icon >+ */ >+ private static final ImageDescriptor DIAG_IMG_DESC = Activator.getBundledImageDescriptor(ParametricDiagramForMultiEditor.DIAG_IMG_PATH); >+ >+ /** The editor splitter. */ >+ private Composite splitter; >+ >+ /** >+ * Constructor for SashSystem v2. Context and required objects are retrieved from the >+ * ServiceRegistry. >+ * >+ * @throws BackboneException >+ * @throws ServiceException >+ * >+ */ >+ public ParametricDiagramForMultiEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws BackboneException, ServiceException { >+ super(servicesRegistry, diagram); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void init(IEditorSite site, IEditorInput input) throws PartInitException { >+ super.init(site, input); >+ setPartName(getDiagram().getName()); >+ setTitleImage(DIAG_IMG_DESC.createImage()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void setInput(IEditorInput input) { >+ try { >+ // Provide an URI with fragment in order to reuse the same Resource >+ // and set the diagram to the fragment. >+ URIEditorInput uriInput = new URIEditorInput(EcoreUtil.getURI(getDiagram())); >+ doSetInput(uriInput, true); >+ } catch (CoreException x) { >+ String title = "Problem opening"; >+ String msg = "Cannot open input element:"; >+ Shell shell = getSite().getShell(); >+ ErrorDialog.openError(shell, title, msg, x.getStatus()); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createGraphicalViewer(Composite parent) { >+ splitter = parent; >+ super.createGraphicalViewer(parent); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void setFocus() { >+ splitter.setFocus(); >+ super.setFocus(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String getEditingDomainID() { >+ return "org.eclipse.papyrus.sysml.diagram.parametric.EditingDomain"; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/ParametricDiagramEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/ParametricDiagramEditPart.java >new file mode 100644 >index 0000000..8f4125a >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/ParametricDiagramEditPart.java >@@ -0,0 +1,31 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.part; >+ >+import org.eclipse.gef.EditPolicy; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultContainerNodeEditPolicy; >+import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultCreationEditPolicy; >+import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultXYLayoutEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomDragDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.policy.DiagramSemanticEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.CustomParametricSemanticPolicy; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy; >+ >+public class ParametricDiagramEditPart extends DiagramEditPart { >+ >+ public ParametricDiagramEditPart(View view) { >+ super(view); >+ } >+ >+ protected void createDefaultEditPolicies() { >+ super.createDefaultEditPolicies(); >+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DiagramSemanticEditPolicy()); >+ installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy()); >+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDragDropEditPolicy()); >+ installEditPolicy(EditPolicy.LAYOUT_ROLE, new DefaultXYLayoutEditPolicy()); >+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); >+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultContainerNodeEditPolicy()); >+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/policy/DiagramSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/policy/DiagramSemanticEditPolicy.java >new file mode 100644 >index 0000000..f4d1149 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/policy/DiagramSemanticEditPolicy.java >@@ -0,0 +1,43 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.policy; >+ >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.commands.UnexecutableCommand; >+import org.eclipse.gef.requests.ReconnectRequest; >+// Start of user code custom imports >+// End of user code >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.CustomDefaultSemanticEditPolicy; >+ >+public class DiagramSemanticEditPolicy extends CustomDefaultSemanticEditPolicy { >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Command getReorientRelationshipSourceCommand(ReconnectRequest request) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Command getReorientRelationshipTargetCommand(ReconnectRequest request) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Command getReorientRefRelationshipSourceCommand(ReconnectRequest request) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Command getReorientRefRelationshipTargetCommand(ReconnectRequest request) { >+ return UnexecutableCommand.INSTANCE; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/policy/ParametricDiagramDragDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/policy/ParametricDiagramDragDropEditPolicy.java >new file mode 100644 >index 0000000..5aefccb >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/edit/policy/ParametricDiagramDragDropEditPolicy.java >@@ -0,0 +1,38 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.policy; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.provider.IGraphicalTypeRegistry; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.GraphicalTypeRegistry; >+import org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.CustomDiagramDragDropEditPolicy; >+ >+/** Customization of the DND edit policy for the Parametric Diagram */ >+public class ParametricDiagramDragDropEditPolicy extends CustomDiagramDragDropEditPolicy { >+ >+ /** Local graphical type registry */ >+ protected IGraphicalTypeRegistry registry = new GraphicalTypeRegistry(); >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public int getNodeVisualID(View containerView, EObject domainElement) { >+ String domainType = registry.getNodeGraphicalType(domainElement, containerView.getType()); >+ if (IGraphicalTypeRegistry.UNDEFINED_TYPE.equals(domainType)) { >+ return -1; // undefined >+ } >+ return new Integer(domainType); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public int getLinkWithClassVisualID(EObject domainElement) { >+ String domainType = registry.getEdgeGraphicalType(domainElement); >+ if (IGraphicalTypeRegistry.UNDEFINED_TYPE.equals(domainType)) { >+ return -1; // undefined >+ } >+ return new Integer(domainType); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/DiagramPaletteFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/DiagramPaletteFactory.java >new file mode 100644 >index 0000000..2a7b590 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/DiagramPaletteFactory.java >@@ -0,0 +1,62 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.factory; >+ >+import java.util.Arrays; >+import java.util.HashMap; >+ >+import org.eclipse.gef.Tool; >+import org.eclipse.gmf.runtime.diagram.ui.services.palette.PaletteFactory; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+import org.eclipse.papyrus.sysml.diagram.internalblock.provider.ElementTypes; >+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeConnectionTool; >+import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool; >+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; >+ >+@SuppressWarnings("serial") >+public class DiagramPaletteFactory extends PaletteFactory.Adapter { >+ >+ private static HashMap<String, IElementType[]> nodesToolIdTypesMap = new HashMap<String, IElementType[]>() { >+ >+ { >+ put("parametric.tool.blockcomposite", new IElementType[]{ SysMLElementTypes.BLOCK }); >+ put("parametric.tool.blockpropertycomposite", new IElementType[]{ SysMLElementTypes.PART_PROPERTY }); >+ put("parametric.tool.reference", new IElementType[]{ SysMLElementTypes.REFERENCE_PROPERTY }); >+ put("parametric.tool.value", new IElementType[]{ SysMLElementTypes.VALUE_PROPERTY }); >+ put("parametric.tool.constraintblockpropertycomposite", new IElementType[]{ SysMLElementTypes.CONSTRAINT_PROPERTY }); >+ put("parametric.tool.flowport", new IElementType[]{ SysMLElementTypes.FLOW_PORT }); >+ put("parametric.tool.port", new IElementType[]{ UMLElementTypes.PORT }); >+ put("parametric.tool.parameter", new IElementType[]{ UMLElementTypes.PROPERTY }); >+ //Start of user code Custom nodes >+ put("parametric.tool.constraint", new IElementType[]{ UMLElementTypes.CONSTRAINT }); >+ put("parametric.tool.comment", new IElementType[]{ UMLElementTypes.COMMENT }); >+ //End of user code >+ } >+ }; >+ >+ private static HashMap<String, IElementType[]> edgesToolIdTypesMap = new HashMap<String, IElementType[]>() { >+ >+ { >+ put("parametric.tool.connector", new IElementType[]{ UMLElementTypes.CONNECTOR }); >+ put("parametric.tool.dependency", new IElementType[]{ UMLElementTypes.DEPENDENCY }); >+ //Start of user code Custom edges >+ put("parametric.tool.comment_constraint_link", new IElementType[]{ ElementTypes.COMMENT_ANNOTATED_ELEMENT, ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT }); >+ //End of user code >+ } >+ }; >+ >+ public Tool createTool(String toolId) { >+ >+ IElementType[] types; >+ >+ types = nodesToolIdTypesMap.get(toolId); >+ if(types != null) { >+ return new AspectUnspecifiedTypeCreationTool(Arrays.asList(types)); >+ } >+ >+ types = edgesToolIdTypesMap.get(toolId); >+ if(types != null) { >+ return new AspectUnspecifiedTypeConnectionTool(Arrays.asList(types)); >+ } >+ return null; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/DiagramPaletteFactory.java.lost b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/DiagramPaletteFactory.java.lost >new file mode 100644 >index 0000000..78c40fb >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/DiagramPaletteFactory.java.lost >@@ -0,0 +1,18 @@ >+ >+Tue Jun 25 16:58:16 CEST 2013 >+================================================================================ >+Start of user code Custom nodes >+ >+ //End of user code >+Start of user code Custom edges >+ >+ //End of user code >+ >+Tue Jun 25 17:00:48 CEST 2013 >+================================================================================ >+Start of user code Custom nodes >+ >+ //End of user code >+Start of user code Custom edges >+ >+ //End of user code >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/ParametricDiagramViewFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/ParametricDiagramViewFactory.java >new file mode 100644 >index 0000000..95bc342 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/factory/ParametricDiagramViewFactory.java >@@ -0,0 +1,18 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.factory; >+ >+import org.eclipse.gmf.runtime.diagram.ui.view.factories.DiagramViewFactory; >+import org.eclipse.gmf.runtime.notation.MeasurementUnit; >+ >+public class ParametricDiagramViewFactory extends DiagramViewFactory { >+ >+ // Start of user code Custom view Factory field >+ // End of user code >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected MeasurementUnit getMeasurementUnit() { >+ return MeasurementUnit.PIXEL_LITERAL; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/part/ParametricDiagramEditor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/part/ParametricDiagramEditor.java >new file mode 100644 >index 0000000..75d1e14 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/part/ParametricDiagramEditor.java >@@ -0,0 +1,51 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.part; >+ >+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >+import org.eclipse.gmf.runtime.notation.Diagram; >+import org.eclipse.papyrus.infra.core.services.ServiceException; >+import org.eclipse.papyrus.infra.core.services.ServicesRegistry; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+ >+/** >+ * @generated >+ */ >+public class ParametricDiagramEditor extends org.eclipse.papyrus.uml.diagram.composite.part.UMLDiagramEditor { >+ >+ /** context used when trying to find services */ >+ public static final String ID = "org.eclipse.papyrus.sysml.diagram.parametric.part.ParametricDiagramEditorID"; //$NON-NLS-1$ >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String getContextID() { >+ return CONTEXT_ID; >+ } >+ >+ /** >+ * @throws org.eclipse.papyrus.infra.core.services.ServiceException >+ * @generated >+ */ >+ public ParametricDiagramEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws ServiceException, org.eclipse.papyrus.infra.core.services.ServiceException { >+ super(servicesRegistry, diagram); >+ } >+ >+ // Start of user code Custom Editor Methods >+ // End of user code >+ >+ /** >+ * @generated >+ */ >+ @Override >+ public String getContributorId() { >+ return Activator.PLUGIN_ID; >+ } >+ >+ /** >+ * @generated >+ */ >+ @Override >+ protected PreferencesHint getPreferencesHint() { >+ return Activator.DIAGRAM_PREFERENCES_HINT; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/BlockCompositePreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/BlockCompositePreferencePage.java >new file mode 100644 >index 0000000..204f727 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/BlockCompositePreferencePage.java >@@ -0,0 +1,83 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+ >+public class BlockCompositePreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID; //$NON-NLS-1$ >+ >+ /** The compartments default visibility for preferences */ >+ public static final Map<String, Boolean> compartmentDefaultVisibilityMap; >+ >+ /** The compartment titles default visibility for preferences */ >+ public static final Map<String, Boolean> compartmentTitleDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ compartmentDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ compartmentDefaultVisibilityMap.put("structure", Boolean.TRUE); //$NON-NLS-1$ >+ >+ compartmentTitleDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ compartmentTitleDefaultVisibilityMap.put("structure", Boolean.TRUE); //$NON-NLS-1$ >+ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(compartmentDefaultVisibilityMap); >+ Collections.unmodifiableMap(compartmentTitleDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public BlockCompositePreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ // End of user code >+ >+ // Initialize default visibility for compartments in preference page. >+ for(String compartmentName : compartmentDefaultVisibilityMap.keySet()) { >+ String showCompartmentKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_VISIBILITY); >+ store.setDefault(showCompartmentKey, compartmentDefaultVisibilityMap.get(compartmentName)); >+ } >+ >+ // Initialize default title visibility for compartments in preference page. >+ for(String compartmentName : compartmentTitleDefaultVisibilityMap.keySet()) { >+ String showCompartmentTitleKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY); >+ store.setDefault(showCompartmentTitleKey, compartmentTitleDefaultVisibilityMap.get(compartmentName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeCompartmentNamesList() { >+ for(String name : compartmentDefaultVisibilityMap.keySet()) { >+ this.compartmentNamesList.add(name); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeCompartmentTitlesList() { >+ for(String name : compartmentTitleDefaultVisibilityMap.keySet()) { >+ this.compartmentTitlesList.add(name); >+ } >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CommentAnnotatedElementPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CommentAnnotatedElementPreferencePage.java >new file mode 100644 >index 0000000..56fb3a6 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CommentAnnotatedElementPreferencePage.java >@@ -0,0 +1,30 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+ >+public class CommentAnnotatedElementPreferencePage extends ParametricDiagramLinkPreferencePage { >+ >+ /** Constant key to access preferences */ >+ protected static String prefKey = ElementTypes.DIAGRAM_ID + "_CommentAnnotatedElement"; //$NON-NLS-1$ >+ >+ >+ /** Default constructor */ >+ public CommentAnnotatedElementPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_CommentAnnotatedElement"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Initialize defaults using a specified {@link IPreferenceStore} >+ * >+ * @param store >+ * the preference store. >+ */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ // End of user code >+ >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CommentPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CommentPreferencePage.java >new file mode 100644 >index 0000000..d81c51d >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CommentPreferencePage.java >@@ -0,0 +1,31 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+ >+public class CommentPreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ protected static String prefKey = ElementTypes.DIAGRAM_ID + "_Comment"; //$NON-NLS-1$ >+ >+ >+ /** Default constructor */ >+ public CommentPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_Comment"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Initialize defaults using a specified {@link IPreferenceStore} >+ * >+ * @param store >+ * the preference store. >+ */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ // End of user code >+ >+ } >+ >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConnectorPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConnectorPreferencePage.java >new file mode 100644 >index 0000000..21808a0 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConnectorPreferencePage.java >@@ -0,0 +1,61 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+ >+public class ConnectorPreferencePage extends ParametricDiagramLinkPreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_CONNECTOR_ID; //$NON-NLS-1$ >+ >+ /** The labels default visibility for preferences */ >+ public static final Map<String, Boolean> labelDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ labelDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ labelDefaultVisibilityMap.put("Stereotype", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("Name", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("SourceMultiplicity", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("TargetMultiplicity", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(labelDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public ConnectorPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_CONNECTOR_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ // End of user code >+ >+ // Initialize default visibility for labels in preference page. >+ for(String labelName : labelDefaultVisibilityMap.keySet()) { >+ String showLabelKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, labelName, PreferenceConstantHelper.LABEL_VISIBILITY); >+ store.setDefault(showLabelKey, labelDefaultVisibilityMap.get(labelName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeLabelsList() { >+ for(String name : labelDefaultVisibilityMap.keySet()) { >+ this.labelsList.add(name); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintConstrainedElementPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintConstrainedElementPreferencePage.java >new file mode 100644 >index 0000000..42d66df >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintConstrainedElementPreferencePage.java >@@ -0,0 +1,30 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+ >+public class ConstraintConstrainedElementPreferencePage extends ParametricDiagramLinkPreferencePage { >+ >+ /** Constant key to access preferences */ >+ protected static String prefKey = ElementTypes.DIAGRAM_ID + "_ConstraintConstrainedElement"; //$NON-NLS-1$ >+ >+ >+ /** Default constructor */ >+ public ConstraintConstrainedElementPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_ConstraintConstrainedElement"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Initialize defaults using a specified {@link IPreferenceStore} >+ * >+ * @param store >+ * the preference store. >+ */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ // End of user code >+ >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintPreferencePage.java >new file mode 100644 >index 0000000..6a31b45 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintPreferencePage.java >@@ -0,0 +1,31 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+ >+public class ConstraintPreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ protected static String prefKey = ElementTypes.DIAGRAM_ID + "_Constraint"; //$NON-NLS-1$ >+ >+ >+ /** Default constructor */ >+ public ConstraintPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_Constraint"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Initialize defaults using a specified {@link IPreferenceStore} >+ * >+ * @param store >+ * the preference store. >+ */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ // End of user code >+ >+ } >+ >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DependencyPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DependencyPreferencePage.java >new file mode 100644 >index 0000000..c321e7e >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DependencyPreferencePage.java >@@ -0,0 +1,59 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+ >+public class DependencyPreferencePage extends ParametricDiagramLinkPreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID; //$NON-NLS-1$ >+ >+ /** The labels default visibility for preferences */ >+ public static final Map<String, Boolean> labelDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ labelDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ labelDefaultVisibilityMap.put("Stereotype", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("Name", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(labelDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public DependencyPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ // End of user code >+ >+ // Initialize default visibility for labels in preference page. >+ for(String labelName : labelDefaultVisibilityMap.keySet()) { >+ String showLabelKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, labelName, PreferenceConstantHelper.LABEL_VISIBILITY); >+ store.setDefault(showLabelKey, labelDefaultVisibilityMap.get(labelName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeLabelsList() { >+ for(String name : labelDefaultVisibilityMap.keySet()) { >+ this.labelsList.add(name); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/FlowPortPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/FlowPortPreferencePage.java >new file mode 100644 >index 0000000..c5119a7 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/FlowPortPreferencePage.java >@@ -0,0 +1,60 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+ >+public class FlowPortPreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_shape_sysml_flowport_as_affixed"; //$NON-NLS-1$ >+ >+ /** The labels default visibility for preferences */ >+ public static final Map<String, Boolean> labelDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ labelDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ labelDefaultVisibilityMap.put("FlowPortAffixedLabel", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("AppliedStereotypeAffixedLabel", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(labelDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public FlowPortPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_shape_sysml_flowport_as_affixed"); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 20); >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 20); >+ // End of user code >+ >+ // Initialize default visibility for labels in preference page. >+ for(String labelName : labelDefaultVisibilityMap.keySet()) { >+ String showLabelKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, labelName, PreferenceConstantHelper.LABEL_VISIBILITY); >+ store.setDefault(showLabelKey, labelDefaultVisibilityMap.get(labelName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeLabelsList() { >+ for(String name : labelDefaultVisibilityMap.keySet()) { >+ this.labelsList.add(name); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramGeneralPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramGeneralPreferencePage.java >new file mode 100644 >index 0000000..9f0750b >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramGeneralPreferencePage.java >@@ -0,0 +1,11 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.DiagramPreferencePage; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+ >+public class ParametricDiagramGeneralPreferencePage extends DiagramPreferencePage { >+ >+ public ParametricDiagramGeneralPreferencePage() { >+ setPreferenceStore(Activator.getInstance().getPreferenceStore()); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramLinkPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramLinkPreferencePage.java >new file mode 100644 >index 0000000..8f688d2 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramLinkPreferencePage.java >@@ -0,0 +1,60 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+import java.util.TreeMap; >+ >+import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.AbstractPapyrusLinkPreferencePage; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.OrderedLabelGroup; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+import org.eclipse.swt.widgets.Composite; >+ >+public class ParametricDiagramLinkPreferencePage extends AbstractPapyrusLinkPreferencePage { >+ >+ /** The list of label names for this link */ >+ protected List<String> labelsList; >+ >+ /** Constructor */ >+ public ParametricDiagramLinkPreferencePage() { >+ labelsList = new ArrayList<String>(); >+ initializeLabelsList(); >+ Collections.unmodifiableList(labelsList); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createPageContents(Composite parent) { >+ super.createPageContents(parent); >+ >+ // Add label visibility group >+ if(!labelsList.isEmpty()) { >+ OrderedLabelGroup compartmentGroup = new OrderedLabelGroup(parent, getPreferenceKey(), this, labelsList); >+ addAbstractGroup(compartmentGroup); >+ } >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getBundleId() { >+ return Activator.PLUGIN_ID; >+ } >+ >+ /** Initialize the list containing names of labels. */ >+ protected void initializeLabelsList() { >+ // Implemented by subclasses. >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected final TreeMap<String, String> getLabelRole() { >+ return new TreeMap<String, String>(); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramNodePreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramNodePreferencePage.java >new file mode 100644 >index 0000000..4d9e33b >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramNodePreferencePage.java >@@ -0,0 +1,106 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+import java.util.TreeMap; >+ >+import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.AbstractPapyrusNodePreferencePage; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.OrderedCompartmentGroup; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.OrderedLabelGroup; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+import org.eclipse.swt.widgets.Composite; >+ >+public class ParametricDiagramNodePreferencePage extends AbstractPapyrusNodePreferencePage { >+ >+ /** The list owning the names of compartments */ >+ protected List<String> compartmentNamesList; >+ >+ /** The list owning the names of compartment that have a title */ >+ protected List<String> compartmentTitlesList; >+ >+ /** The list of label names for this node */ >+ protected List<String> labelsList; >+ >+ /** Constructor */ >+ public ParametricDiagramNodePreferencePage() { >+ this.labelsList = new ArrayList<String>(); >+ this.compartmentNamesList = new ArrayList<String>(); >+ this.compartmentTitlesList = new ArrayList<String>(); >+ >+ initializeLabelsList(); >+ initializeCompartmentNamesList(); >+ initializeCompartmentTitlesList(); >+ >+ Collections.unmodifiableList(labelsList); >+ Collections.unmodifiableList(compartmentNamesList); >+ Collections.unmodifiableList(compartmentTitlesList); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createPageContents(Composite parent) { >+ super.createPageContents(parent); >+ >+ // Add compartments visibility group >+ if(!compartmentNamesList.isEmpty()) { >+ OrderedCompartmentGroup compartmentGroup = new OrderedCompartmentGroup(parent, getPreferenceKey(), this, compartmentNamesList, compartmentTitlesList, getPreferenceStore()); >+ addAbstractGroup(compartmentGroup); >+ } >+ >+ // Add label visibility group >+ if(!labelsList.isEmpty()) { >+ OrderedLabelGroup compartmentGroup = new OrderedLabelGroup(parent, getPreferenceKey(), this, labelsList); >+ addAbstractGroup(compartmentGroup); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected String getBundleId() { >+ return Activator.PLUGIN_ID; >+ } >+ >+ /** Initialize the list containing names of labels. */ >+ protected void initializeLabelsList() { >+ // Implemented by subclasses. >+ } >+ >+ /** Initialize the list containing the names of compartments. */ >+ protected void initializeCompartmentNamesList() { >+ // Implemented by subclasses. >+ } >+ >+ /** Initialize the list containing the names of compartment that have titles. */ >+ protected void initializeCompartmentTitlesList() { >+ // Implemented by subclasses. >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected final TreeMap<String, String> getLabelRole() { >+ return new TreeMap<String, String>(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected final TreeMap<String, Boolean> getCompartmentTitleVisibilityPreferences() { >+ return new TreeMap<String, Boolean>(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected final void initializeCompartmentsList() { >+ compartmentsList = Collections.emptyList(); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramPreferenceInitializer.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramPreferenceInitializer.java >new file mode 100644 >index 0000000..ae5bebb >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ParametricDiagramPreferenceInitializer.java >@@ -0,0 +1,28 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+ >+public class ParametricDiagramPreferenceInitializer extends AbstractPreferenceInitializer { >+ >+ protected IPreferenceStore getPreferenceStore() { >+ return Activator.getInstance().getPreferenceStore(); >+ } >+ >+ @Override >+ public void initializeDefaultPreferences() { >+ IPreferenceStore store = getPreferenceStore(); >+ >+ org.eclipse.papyrus.sysml.diagram.parametric.preferences.ConstraintPreferencePage.initDefaults(store); >+ org.eclipse.papyrus.sysml.diagram.parametric.preferences.CommentPreferencePage.initDefaults(store); >+ org.eclipse.papyrus.sysml.diagram.parametric.preferences.CommentAnnotatedElementPreferencePage.initDefaults(store); >+ BlockCompositePreferencePage.initDefaults(store); >+ BlockPropertyCompositePreferencePage.initDefaults(store); >+ FlowPortPreferencePage.initDefaults(store); >+ PortPreferencePage.initDefaults(store); >+ ConnectorPreferencePage.initDefaults(store); >+ DependencyPreferencePage.initDefaults(store); >+ >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PortPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PortPreferencePage.java >new file mode 100644 >index 0000000..7c3c730 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PortPreferencePage.java >@@ -0,0 +1,60 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+ >+public class PortPreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_shape_uml_port_as_affixed"; //$NON-NLS-1$ >+ >+ /** The labels default visibility for preferences */ >+ public static final Map<String, Boolean> labelDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ labelDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ labelDefaultVisibilityMap.put("PortAffixedLabel", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("AppliedStereotypeAffixedLabel", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(labelDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public PortPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_shape_uml_port_as_affixed"); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 20); >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 20); >+ // End of user code >+ >+ // Initialize default visibility for labels in preference page. >+ for(String labelName : labelDefaultVisibilityMap.keySet()) { >+ String showLabelKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, labelName, PreferenceConstantHelper.LABEL_VISIBILITY); >+ store.setDefault(showLabelKey, labelDefaultVisibilityMap.get(labelName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeLabelsList() { >+ for(String name : labelDefaultVisibilityMap.keySet()) { >+ this.labelsList.add(name); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomEditPartProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomEditPartProvider.java >new file mode 100644 >index 0000000..9efdac2 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomEditPartProvider.java >@@ -0,0 +1,120 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.gmf.runtime.common.core.service.IOperation; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation; >+import org.eclipse.gmf.runtime.notation.Edge; >+import org.eclipse.gmf.runtime.notation.Node; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.provider.CustomAbstractEditPartProvider; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyStructureCompartmentEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedLabelNameEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.StructureCompartmentEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.CustomBlockCompositeEditPartTN; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.CustomBlockLabelNameEditPart; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.CustomBlockPropertyCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.CustomConstraintBlockPropertyCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.CustomConstraintParameterAffixedNodeEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.AppliedStereotypeAffixedLabelEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.AppliedStereotypeLinkLabelEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorLinkLabelEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorLinkLabelSourceMultiplicityEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorLinkLabelTargetMultiplicityEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConstraintNodeLabelEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.DependencyEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.NamedElementLinkLabelNameEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PortAffixedLabelNameEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PortAffixedNodeEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PropertyNodeLabelEditPart; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+ >+public class CustomEditPartProvider extends CustomAbstractEditPartProvider { >+ >+ /** Map containing node view types supported by this provider */ >+ protected Map<String, Class<?>> nodeMap = new HashMap<String, Class<?>>(); >+ >+ /** Map containing edge view types supported by this provider */ >+ protected Map<String, Class<?>> edgeMap = new HashMap<String, Class<?>>(); >+ >+ /** Default constructor */ >+ public CustomEditPartProvider() { >+ super(); >+ >+ diagramType = ElementTypes.DIAGRAM_ID; >+ >+ // Nodes >+ nodeMap.put(SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID, CustomConstraintBlockPropertyCompositeEditPart.class); >+ nodeMap.put(SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID, CustomBlockPropertyCompositeEditPart.class); >+ nodeMap.put(SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID, CustomBlockCompositeEditPartTN.class); >+ nodeMap.put(SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID, FlowPortAffixedNodeEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID, PortAffixedNodeEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.SHAPE_UML_PROPERTY_AS_AFFIXED_ID, CustomConstraintParameterAffixedNodeEditPart.class); >+ >+ // Decorations >+ nodeMap.put(SysMLGraphicalTypes.AFFIXEDLABEL_SYSML_FLOWPORT_LABEL_ID, FlowPortAffixedLabelNameEditPart.class); >+ nodeMap.put(SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID, BlockPropertyStructureCompartmentEditPart.class); >+ nodeMap.put(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID, StructureCompartmentEditPart.class); >+ nodeMap.put(SysMLGraphicalTypes.LABEL_SYSML_BLOCK_NAME_ID, CustomBlockLabelNameEditPart.class); // TODO : change for multi FlowText >+ nodeMap.put(UMLGraphicalTypes.AFFIXEDLABEL_UML_APPLIEDSTEREOTYPE_ID, AppliedStereotypeAffixedLabelEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.AFFIXEDLABEL_UML_PORT_LABEL_ID, PortAffixedLabelNameEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.LABEL_UML_PROPERTY_LABEL_ID, PropertyNodeLabelEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.SHAPE_UML_CONSTRAINT_AS_LABEL_ID, ConstraintNodeLabelEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_APPLIEDSTEREOTYPE_ID, AppliedStereotypeLinkLabelEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_LABEL_ID, ConnectorLinkLabelEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_SOURCE_MULTIPLICITY_ID, ConnectorLinkLabelSourceMultiplicityEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_TARGET_MULTIPLICITY_ID, ConnectorLinkLabelTargetMultiplicityEditPart.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_NAMEDELEMENT_NAME_ID, NamedElementLinkLabelNameEditPart.class); >+ >+ >+ // Edges >+ edgeMap.put(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID, ConnectorEditPart.class); >+ edgeMap.put(UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID, DependencyEditPart.class); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean provides(IOperation operation) { >+ if(operation instanceof CreateGraphicEditPartOperation) { >+ View newView = ((IEditPartOperation)operation).getView(); >+ if (newView == null) { >+ return false; >+ } >+ >+ String graphicalType = newView.getType(); >+ >+ if((newView instanceof Node) && (!nodeMap.containsKey(graphicalType))) { >+ return false; >+ } >+ >+ if((newView instanceof Edge) && (!edgeMap.containsKey(graphicalType))) { >+ return false; >+ } >+ } >+ >+ return super.provides(operation); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Class<?> getNodeEditPartClass(View view) { >+ return nodeMap.get(view.getType()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Class<?> getEdgeEditPartClass(View view) { >+ return edgeMap.get(view.getType()); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomGraphicalTypeRegistry.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomGraphicalTypeRegistry.java >new file mode 100644 >index 0000000..5b838c3 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomGraphicalTypeRegistry.java >@@ -0,0 +1,224 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; >+ >+public class CustomGraphicalTypeRegistry extends GraphicalTypeRegistry { >+ >+ /** Default constructor */ >+ public CustomGraphicalTypeRegistry() { >+ >+ super(); >+ >+ // Nodes >+ knownNodes.add(SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID); >+ knownNodes.add(SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID); >+ knownNodes.add(SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID); >+ knownNodes.add(SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID); >+ knownNodes.add(UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID); >+ knownNodes.add(UMLGraphicalTypes.SHAPE_UML_PROPERTY_AS_AFFIXED_ID); >+ // Decorations >+ knownNodes.add(SysMLGraphicalTypes.AFFIXEDLABEL_SYSML_FLOWPORT_LABEL_ID); >+ knownNodes.add(SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID); >+ knownNodes.add(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID); >+ knownNodes.add(SysMLGraphicalTypes.LABEL_SYSML_BLOCK_NAME_ID); >+ knownNodes.add(UMLGraphicalTypes.AFFIXEDLABEL_UML_APPLIEDSTEREOTYPE_ID); >+ knownNodes.add(UMLGraphicalTypes.AFFIXEDLABEL_UML_PORT_LABEL_ID); >+ knownNodes.add(UMLGraphicalTypes.LABEL_UML_PROPERTY_LABEL_ID); >+ knownNodes.add(UMLGraphicalTypes.SHAPE_UML_CONSTRAINT_AS_LABEL_ID); >+ knownNodes.add(UMLGraphicalTypes.LINKLABEL_UML_APPLIEDSTEREOTYPE_ID); >+ knownNodes.add(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_LABEL_ID); >+ knownNodes.add(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_SOURCE_MULTIPLICITY_ID); >+ knownNodes.add(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_TARGET_MULTIPLICITY_ID); >+ knownNodes.add(UMLGraphicalTypes.LINKLABEL_UML_NAMEDELEMENT_NAME_ID); >+ >+ // Edges >+ knownEdges.add(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID); >+ knownEdges.add(UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String getNodeGraphicalType(EObject domainElement, String containerType) { >+ // Start of user code getNodeGraphicalType(EObject domainElement, String containerType) >+ // End of user code >+ >+ if(((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(domainElement)) { >+ if (ElementTypes.DIAGRAM_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ if(((ISpecializationType)SysMLElementTypes.CONSTRAINT_PROPERTY).getMatcher().matches(domainElement)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID.equals(domainElement)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ >+ if(((ISpecializationType)SysMLElementTypes.PART_PROPERTY).getMatcher().matches(domainElement)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ if(((ISpecializationType)SysMLElementTypes.REFERENCE_PROPERTY).getMatcher().matches(domainElement)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ if(((ISpecializationType)SysMLElementTypes.VALUE_PROPERTY).getMatcher().matches(domainElement)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ // Order is important for Part/Reference/ConstraintProperty which are also Property >+ if(UMLElementTypes.PROPERTY.getEClass().isInstance(domainElement)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID.equals(containerType)) { >+ return UMLGraphicalTypes.SHAPE_UML_PROPERTY_AS_AFFIXED_ID; >+ } >+ return UNDEFINED_TYPE; >+ >+ } >+ >+ return super.getNodeGraphicalType(domainElement, containerType); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getNodeGraphicalType(String proposedType, String containerType) { >+ // Start of user code getNodeGraphicalType(String proposedType, String containerType) >+ // End of user code >+ >+ if(SysMLElementTypes.BLOCK.getSemanticHint().equals(proposedType)) { >+ if (ElementTypes.DIAGRAM_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ >+ if(UMLElementTypes.PROPERTY.getSemanticHint().equals(proposedType)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID.equals(containerType)) { >+ return UMLGraphicalTypes.SHAPE_UML_PROPERTY_AS_AFFIXED_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ >+ if(SysMLElementTypes.CONSTRAINT_PROPERTY.getSemanticHint().equals(proposedType)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ >+ if(SysMLElementTypes.PART_PROPERTY.getSemanticHint().equals(proposedType)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ if(SysMLElementTypes.REFERENCE_PROPERTY.getSemanticHint().equals(proposedType)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ if(SysMLElementTypes.VALUE_PROPERTY.getSemanticHint().equals(proposedType)) { >+ if (SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ if (SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; >+ } >+ return UNDEFINED_TYPE; >+ } >+ return super.getNodeGraphicalType(proposedType, containerType); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String getEdgeGraphicalType(EObject domainElement) { >+ // Start of user code getEdgeGraphicalType(EObject domainElement) >+ // End of user code >+ >+ if(UMLElementTypes.CONNECTOR.getEClass().isInstance(domainElement)) { >+ return UMLGraphicalTypes.LINK_UML_CONNECTOR_ID; >+ } >+ if(UMLElementTypes.DEPENDENCY.getEClass().isInstance(domainElement)) { >+ return UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID; >+ } >+ return super.getEdgeGraphicalType(domainElement); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getEdgeGraphicalType(String proposedType) { >+ // Start of user code getEdgeGraphicalType(String proposedType) >+ // End of user code >+ >+ if(UMLElementTypes.CONNECTOR.getSemanticHint().equals(proposedType)) { >+ return UMLGraphicalTypes.LINK_UML_CONNECTOR_ID; >+ } >+ if(UMLElementTypes.DEPENDENCY.getSemanticHint().equals(proposedType)) { >+ return UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID; >+ } >+ return super.getEdgeGraphicalType(proposedType); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomGraphicalTypes.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomGraphicalTypes.java >new file mode 100644 >index 0000000..31f18f6 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomGraphicalTypes.java >@@ -0,0 +1,13 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+public class CustomGraphicalTypes { >+ >+ /** ********************************************************* */ >+ /** Diagram custom graphical types id *********************** */ >+ /** ********************************************************* */ >+ >+ >+ >+ >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomViewProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomViewProvider.java >new file mode 100644 >index 0000000..20bfe02 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomViewProvider.java >@@ -0,0 +1,87 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.factory.AffixedLabelViewFactory; >+import org.eclipse.papyrus.gmf.diagram.common.factory.CompartmentShapeViewFactory; >+import org.eclipse.papyrus.gmf.diagram.common.factory.ConnectorLabelViewFactory; >+import org.eclipse.papyrus.gmf.diagram.common.factory.InnerLabelViewFactory; >+import org.eclipse.papyrus.gmf.diagram.common.provider.CustomAbstractViewProvider; >+import org.eclipse.papyrus.sysml.diagram.common.factory.BlockCompositeClassifierViewFactory; >+import org.eclipse.papyrus.sysml.diagram.common.factory.BlockPropertyCompositeClassifierViewFactory; >+import org.eclipse.papyrus.sysml.diagram.common.factory.ConstraintBlockPropertyCompositeClassifierViewFactory; >+import org.eclipse.papyrus.sysml.diagram.common.factory.FlowPortAffixedNodeViewFactory; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.uml.diagram.common.factory.ConnectorLinkViewFactory; >+import org.eclipse.papyrus.uml.diagram.common.factory.ConstraintPropertyAffixedNodeViewFactory; >+import org.eclipse.papyrus.uml.diagram.common.factory.DependencyLinkViewFactory; >+import org.eclipse.papyrus.uml.diagram.common.factory.PortAffixedNodeViewFactory; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+ >+public class CustomViewProvider extends CustomAbstractViewProvider { >+ >+ /** Map containing node view types supported by this provider */ >+ protected Map<String, Class<?>> nodeMap = new HashMap<String, Class<?>>(); >+ >+ /** Map containing edge view types supported by this provider */ >+ protected Map<String, Class<?>> edgeMap = new HashMap<String, Class<?>>(); >+ >+ /** Default constructor */ >+ public CustomViewProvider() { >+ super(); >+ this.registry = new CustomGraphicalTypeRegistry(); >+ >+ diagramType = ElementTypes.DIAGRAM_ID; >+ >+ // Custom classifier nodes >+ nodeMap.put(SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_COMPOSITE_ID, BlockCompositeClassifierViewFactory.class); >+ nodeMap.put(SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID, BlockPropertyCompositeClassifierViewFactory.class); >+ nodeMap.put(SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID, ConstraintBlockPropertyCompositeClassifierViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.SHAPE_UML_PROPERTY_AS_AFFIXED_ID, ConstraintPropertyAffixedNodeViewFactory.class); >+ // Custom affixed nodes >+ nodeMap.put(SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID, FlowPortAffixedNodeViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID, PortAffixedNodeViewFactory.class); >+ // Custom child node labels >+ // Custom inner labels >+ nodeMap.put(SysMLGraphicalTypes.LABEL_SYSML_BLOCK_NAME_ID, InnerLabelViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.LABEL_UML_PROPERTY_LABEL_ID, InnerLabelViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.SHAPE_UML_CONSTRAINT_AS_LABEL_ID, InnerLabelViewFactory.class); >+ // Custom compartments >+ nodeMap.put(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID, CompartmentShapeViewFactory.class); >+ nodeMap.put(SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID, CompartmentShapeViewFactory.class); >+ // Custom affixed labels >+ nodeMap.put(SysMLGraphicalTypes.AFFIXEDLABEL_SYSML_FLOWPORT_LABEL_ID, AffixedLabelViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.AFFIXEDLABEL_UML_APPLIEDSTEREOTYPE_ID, AffixedLabelViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.AFFIXEDLABEL_UML_PORT_LABEL_ID, AffixedLabelViewFactory.class); >+ >+ // Custom edges >+ edgeMap.put(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID, ConnectorLinkViewFactory.class); >+ edgeMap.put(UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID, DependencyLinkViewFactory.class); >+ >+ // Custom edge labels >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_APPLIEDSTEREOTYPE_ID, ConnectorLabelViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_LABEL_ID, ConnectorLabelViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_SOURCE_MULTIPLICITY_ID, ConnectorLabelViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_TARGET_MULTIPLICITY_ID, ConnectorLabelViewFactory.class); >+ nodeMap.put(UMLGraphicalTypes.LINKLABEL_UML_NAMEDELEMENT_NAME_ID, ConnectorLabelViewFactory.class); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Class<?> getNodeViewClass(IAdaptable semanticAdapter, View containerView, String graphicalType) { >+ return nodeMap.get(graphicalType); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Class<?> getEdgeViewClass(IAdaptable semanticAdapter, View containerView, String graphicalType) { >+ return edgeMap.get(graphicalType); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ElementTypes.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ElementTypes.java >new file mode 100644 >index 0000000..21830b1 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ElementTypes.java >@@ -0,0 +1,52 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import org.eclipse.gmf.runtime.emf.type.core.AbstractElementTypeEnumerator; >+import org.eclipse.gmf.runtime.emf.type.core.IHintedType; >+ >+public class ElementTypes extends AbstractElementTypeEnumerator { >+ >+ /** ********************************************************* */ >+ /** SysML Parametric Diagram specific elements **************** */ >+ /** ********************************************************* */ >+ >+ /** SysML Parametric Diagram :: Diagram */ >+ public static final String DIAGRAM_ID = "Parametric"; //$NON-NLS-1$ >+ >+ >+ >+ >+ /** ********************************************************* */ >+ /** SysML Parametric Diagram - CompositeDiagram related elements */ >+ /** ********************************************************* */ >+ >+ /** CompositeDiagram :: CONSTRAINT */ >+ public static final IHintedType CONSTRAINT = (IHintedType)getElementType("org.eclipse.papyrus.uml.diagram.composite.Constraint_2114"); //$NON-NLS-1$ >+ >+ public static final String CONSTRAINT_LABEL_NAME_HINT = "5197"; //$NON-NLS-1$ >+ >+ public static final String CONSTRAINT_LABEL_SPECIFICATION_HINT = "6039"; //$NON-NLS-1$ >+ >+ /** CompositeDiagram :: COMMENT_CN */ >+ public static final IHintedType COMMENT_CN = (IHintedType)getElementType("org.eclipse.papyrus.uml.diagram.composite.Comment_3097"); //$NON-NLS-1$ >+ >+ public static final String COMMENT_CN_LABEL_BODY_HINT = "5150"; //$NON-NLS-1$ >+ >+ /** CompositeDiagram :: COMMENT */ >+ public static final IHintedType COMMENT = (IHintedType)getElementType("org.eclipse.papyrus.uml.diagram.composite.Comment_2109"); //$NON-NLS-1$ >+ >+ public static final String COMMENT_LABEL_BODY_HINT = "5192"; //$NON-NLS-1$ >+ >+ /** CompositeDiagram :: CONSTRAINT_CN */ >+ public static final IHintedType CONSTRAINT_CN = (IHintedType)getElementType("org.eclipse.papyrus.uml.diagram.composite.Constraint_3120"); //$NON-NLS-1$ >+ >+ public static final String CONSTRAINT_CN_LABEL_NAME_HINT = "6048"; //$NON-NLS-1$ >+ >+ public static final String CONSTRAINT_CN_LABEL_SPECIFICATION_HINT = "6049"; //$NON-NLS-1$ >+ >+ /** CompositeDiagram :: COMMENT_ANNOTATED_ELEMENT */ >+ public static final IHintedType COMMENT_ANNOTATED_ELEMENT = (IHintedType)getElementType("org.eclipse.papyrus.uml.diagram.composite.CommentAnnotatedElement_4002"); //$NON-NLS-1$ >+ >+ /** CompositeDiagram :: CONSTRAINT_CONSTRAINED_ELEMENT */ >+ public static final IHintedType CONSTRAINT_CONSTRAINED_ELEMENT = (IHintedType)getElementType("org.eclipse.papyrus.uml.diagram.composite.ConstraintConstrainedElement_4003"); //$NON-NLS-1$ >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/GraphicalTypeRegistry.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/GraphicalTypeRegistry.java >new file mode 100644 >index 0000000..95e3081 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/GraphicalTypeRegistry.java >@@ -0,0 +1,195 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import java.util.HashSet; >+import java.util.Set; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+import org.eclipse.gmf.runtime.emf.type.core.IHintedType; >+import org.eclipse.papyrus.gmf.diagram.common.provider.IGraphicalTypeRegistry; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; >+ >+/** >+ * <pre> >+ * This class provides graphical type id (used as View type) for >+ * domain element according to their actual or expected graphical >+ * container type. >+ * </pre> >+ */ >+public class GraphicalTypeRegistry implements IGraphicalTypeRegistry { >+ >+ /** A Set containing all known node graphical types */ >+ protected Set<String> knownNodes = new HashSet<String>(); >+ >+ /** A Set containing all known edge graphical types */ >+ protected Set<String> knownEdges = new HashSet<String>(); >+ >+ /** Default constructor */ >+ public GraphicalTypeRegistry() { >+ >+ // Fill known edges set >+ knownEdges.add(ElementTypes.COMMENT_ANNOTATED_ELEMENT.getSemanticHint()); >+ knownEdges.add(ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT.getSemanticHint()); >+ >+ // Fill known nodes set (primary nodes) >+ knownNodes.add(UMLElementTypes.CONSTRAINT.getSemanticHint()); >+ knownNodes.add(UMLElementTypes.COMMENT.getSemanticHint()); >+ >+ knownNodes.add(ElementTypes.CONSTRAINT.getSemanticHint()); >+ knownNodes.add(ElementTypes.COMMENT_CN.getSemanticHint()); >+ knownNodes.add(ElementTypes.COMMENT.getSemanticHint()); >+ knownNodes.add(ElementTypes.CONSTRAINT_CN.getSemanticHint()); >+ >+ // Fill known nodes set (child label nodes) >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getEdgeGraphicalType(EObject domainElement) { >+ >+ String graphicalType = UNDEFINED_TYPE; >+ if(domainElement == null) { >+ return UNDEFINED_TYPE; >+ } >+ return graphicalType; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getEdgeGraphicalType(IElementType elementType) { >+ if(elementType instanceof IHintedType) { >+ String semanticHint = ((IHintedType)elementType).getSemanticHint(); >+ return getEdgeGraphicalType(semanticHint); >+ } >+ >+ return UNDEFINED_TYPE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getEdgeGraphicalType(String proposedType) { >+ if(isKnownEdgeType(proposedType)) { >+ return proposedType; >+ } >+ >+ return UNDEFINED_TYPE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getNodeGraphicalType(EObject domainElement, String containerType) { >+ >+ String graphicalType = UNDEFINED_TYPE; >+ if((containerType == null) || (domainElement == null)) { >+ return UNDEFINED_TYPE; >+ } >+ >+ if(domainElement instanceof org.eclipse.uml2.uml.Constraint) { >+ if(ElementTypes.DIAGRAM_ID.equals(containerType)) { // Constraint TopNode >+ graphicalType = ElementTypes.CONSTRAINT.getSemanticHint(); >+ } >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ graphicalType = ElementTypes.CONSTRAINT_CN.getSemanticHint(); >+ } >+ >+ } >+ >+ if(domainElement instanceof org.eclipse.uml2.uml.Comment) { >+ if(ElementTypes.DIAGRAM_ID.equals(containerType)) { // Comment TopNode >+ graphicalType = ElementTypes.COMMENT.getSemanticHint(); >+ } >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ graphicalType = ElementTypes.COMMENT_CN.getSemanticHint(); >+ } >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ graphicalType = ElementTypes.COMMENT_CN.getSemanticHint(); >+ } >+ >+ } >+ >+ return graphicalType; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getNodeGraphicalType(IElementType elementType, String containerType) { >+ if(elementType instanceof IHintedType) { >+ String semanticHint = ((IHintedType)elementType).getSemanticHint(); >+ return getNodeGraphicalType(semanticHint, containerType); >+ } >+ >+ return UNDEFINED_TYPE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getNodeGraphicalType(String proposedType, String containerType) { >+ if((UMLElementTypes.COMMENT.getSemanticHint().equals(proposedType))) { >+ >+ if(ElementTypes.DIAGRAM_ID.equals(containerType)) { // Constraint TopNode >+ return ElementTypes.COMMENT.getSemanticHint(); >+ } >+ >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return ElementTypes.COMMENT_CN.getSemanticHint(); >+ } >+ >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerType)) { >+ return ElementTypes.COMMENT_CN.getSemanticHint(); >+ } >+ >+ return UNDEFINED_TYPE; >+ } >+ >+ if(UMLElementTypes.CONSTRAINT.getSemanticHint().equals(proposedType)) { >+ >+ if(ElementTypes.DIAGRAM_ID.equals(containerType)) { // Constraint TopNode >+ return ElementTypes.CONSTRAINT.getSemanticHint(); >+ } >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerType)) { >+ return ElementTypes.CONSTRAINT_CN.getSemanticHint(); >+ } >+ >+ return UNDEFINED_TYPE; >+ } >+ if(isKnownNodeType(proposedType)) { >+ return proposedType; >+ } >+ >+ return UNDEFINED_TYPE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isKnownEdgeType(String type) { >+ return knownEdges.contains(type); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isKnownNodeType(String type) { >+ return knownNodes.contains(type); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/IGraphicalTypeRegistry.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/IGraphicalTypeRegistry.java >new file mode 100644 >index 0000000..fff577c >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/IGraphicalTypeRegistry.java >@@ -0,0 +1,97 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+ >+/** >+ * This interface provides an API for accessing the local graphical type registry. >+ * This registry provides a graphical type for existing model elements. >+ */ >+public interface IGraphicalTypeRegistry { >+ >+ /** Constant for undefined graphical type */ >+ public static final String UNDEFINED_TYPE = "undefined_type"; >+ >+ /** >+ * Get a valid edge graphical type for the domain element. >+ * >+ * @param domainElement >+ * the domain element. >+ * @return the domain element graphical type. >+ */ >+ public String getEdgeGraphicalType(EObject domainElement); >+ >+ /** >+ * Get a valid edge graphical type for the element type. >+ * >+ * @param elementType >+ * the element type. >+ * @param containerType >+ * the type of the graphical owner of the domain element. >+ * @return the domain element graphical type. >+ */ >+ public String getEdgeGraphicalType(IElementType elementType); >+ >+ /** >+ * Get a valid edge graphical type for the proposed type. >+ * >+ * @param proposedType >+ * the proposed type. >+ * @param containerType >+ * the type of the graphical owner of the domain element. >+ * @return the domain element graphical type. >+ */ >+ public String getEdgeGraphicalType(String proposedType); >+ >+ /** >+ * Get a valid node graphical type for the domain element. >+ * >+ * @param domainElement >+ * the domain element. >+ * @param containerType >+ * the type of the graphical owner of the domain element. >+ * @return the domain element graphical type. >+ */ >+ public String getNodeGraphicalType(EObject domainElement, String containerType); >+ >+ /** >+ * Get a valid node graphical type for the element type. >+ * >+ * @param elementType >+ * the element type. >+ * @param containerType >+ * the type of the graphical owner of the domain element. >+ * @return the domain element graphical type. >+ */ >+ public String getNodeGraphicalType(IElementType elementType, String containerType); >+ >+ /** >+ * Get a valid node graphical type for the proposed type. >+ * >+ * @param proposedType >+ * the proposed type. >+ * @param containerType >+ * the type of the graphical owner of the domain element. >+ * @return the domain element graphical type. >+ */ >+ public String getNodeGraphicalType(String proposedType, String containerType); >+ >+ /** >+ * Test if the type is a known edge graphical type in this diagram >+ * >+ * @param type >+ * the type to test >+ * @return true if the type is known >+ */ >+ public boolean isKnownEdgeType(String type); >+ >+ /** >+ * Test if the type is a known node graphical type in this diagram >+ * >+ * @param type >+ * the type to test >+ * @return true if the type is known >+ */ >+ public boolean isKnownNodeType(String type); >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/InheritedCompositeDiagramEditPartProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/InheritedCompositeDiagramEditPartProvider.java >new file mode 100644 >index 0000000..6ec36d6 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/InheritedCompositeDiagramEditPartProvider.java >@@ -0,0 +1,54 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.common.core.service.IOperation; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.composite.providers.UMLEditPartProvider; >+ >+public class InheritedCompositeDiagramEditPartProvider extends UMLEditPartProvider { >+ >+ >+ @Override >+ public synchronized boolean provides(IOperation operation) { >+ if(operation instanceof CreateGraphicEditPartOperation) { >+ View view = ((IEditPartOperation)operation).getView(); >+ >+ // Ensure current diagram is a Parametric Diagram >+ if(!ElementTypes.DIAGRAM_ID.equals(view.getDiagram().getType())) { >+ return false; >+ } >+ >+ // Test supported inherited types >+ EObject eobject = view.getElement(); >+ >+ /** Nodes (and ChildLabelNodes) *********** */ >+ if(eobject instanceof org.eclipse.uml2.uml.Constraint) { >+ return true; >+ } >+ if(eobject instanceof org.eclipse.uml2.uml.Comment) { >+ return true; >+ } >+ >+ // Additional test needed here to decide whether to support Feature type links. >+ // As feature type link are not related to a MetaClass from the domain model >+ // they are not already handled by previous tests. >+ // Also concerns NotationType. >+ String hint = view.getType(); >+ >+ /** Edges (Feature) : COMMENT_ANNOTATED_ELEMENT *********** */ >+ if(ElementTypes.COMMENT_ANNOTATED_ELEMENT.getSemanticHint().equals(hint)) { >+ return true; >+ } >+ /** Edges (Feature) : CONSTRAINT_CONSTRAINED_ELEMENT *********** */ >+ if(ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT.getSemanticHint().equals(hint)) { >+ return true; >+ } >+ >+ } >+ return false; >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/InheritedCompositeDiagramViewProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/InheritedCompositeDiagramViewProvider.java >new file mode 100644 >index 0000000..37ef4b7 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/InheritedCompositeDiagramViewProvider.java >@@ -0,0 +1,218 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.emf.ecore.EAnnotation; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EcoreFactory; >+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation; >+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation; >+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+import org.eclipse.gmf.runtime.notation.Edge; >+import org.eclipse.gmf.runtime.notation.Node; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.provider.IGraphicalTypeRegistry; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.GraphicalTypeRegistry; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter; >+import org.eclipse.papyrus.uml.diagram.composite.providers.UMLViewProvider; >+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; >+ >+public class InheritedCompositeDiagramViewProvider extends UMLViewProvider { >+ >+ /** Local graphical type registry */ >+ protected IGraphicalTypeRegistry registry = new GraphicalTypeRegistry(); >+ >+ @Override >+ public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { >+ Edge createdEdge = null; >+ >+ IElementType elementType = (IElementType)semanticAdapter.getAdapter(IElementType.class); >+ if(elementType != null) { >+ createdEdge = super.createEdge(semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint); >+ } else { >+ >+ EObject domainElement = (EObject)semanticAdapter.getAdapter(EObject.class); >+ >+ String domainElementGraphicalType = semanticHint; >+ if(domainElementGraphicalType == null) { >+ domainElementGraphicalType = registry.getEdgeGraphicalType(domainElement); >+ } >+ >+ if((!IGraphicalTypeRegistry.UNDEFINED_TYPE.equals(domainElementGraphicalType)) && (registry.isKnownEdgeType(domainElementGraphicalType))) { >+ // Cannot use createEdge from super class as it never take the graphical type (semanticHint) into account. >+ // createdEdge = super.createEdge(semanticAdapter, containerView, domainElementGraphicalType, index, persisted, preferencesHint); >+ >+ if(ElementTypes.COMMENT_ANNOTATED_ELEMENT.getSemanticHint().equals(domainElementGraphicalType)) { >+ createdEdge = createCommentAnnotatedElement_4002(containerView, index, persisted, preferencesHint); >+ } >+ if(ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT.getSemanticHint().equals(domainElementGraphicalType)) { >+ createdEdge = createConstraintConstrainedElement_4003(containerView, index, persisted, preferencesHint); >+ } >+ } >+ } >+ >+ if(createdEdge == null) { >+ Activator.log.error(new Exception("Could not create Edge.")); >+ } >+ >+ return createdEdge; >+ } >+ >+ @Override >+ protected boolean provides(CreateViewForKindOperation op) { >+ // Never use this method (often incorrectly implemented due to GMF Tooling choices). >+ String diagramType = op.getContainerView().getDiagram().getType(); >+ if(!ElementTypes.DIAGRAM_ID.equals(diagramType)) { >+ return false; >+ } >+ >+ throw new UnsupportedOperationException("Should never be called by the " + diagramType + " diagram."); >+ } >+ >+ @Override >+ protected boolean provides(CreateEdgeViewOperation op) { >+ >+ // Must have a container >+ if(op.getContainerView() == null) { >+ return false; >+ } >+ >+ // This provider is registered for InternalBlock Diagram only >+ String diagramType = op.getContainerView().getDiagram().getType(); >+ if(!ElementTypes.DIAGRAM_ID.equals(diagramType)) { >+ return false; >+ } >+ >+ IElementType elementType = getSemanticElementType(op.getSemanticAdapter()); >+ if(elementType == ElementTypes.COMMENT_ANNOTATED_ELEMENT) { >+ return true; >+ } >+ if(elementType == ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT) { >+ return true; >+ } >+ >+ // ///////////////////////////////////////////////////////////////////// >+ // Test possibility to provide a view based on the semantic nature and its expected container. >+ // ///////////////////////////////////////////////////////////////////// >+ >+ // IElementType may be null (especially when drop from ModelExplorer). >+ // In such a case, test the semantic EObject instead. >+ if(elementType == null) { >+ EObject domainElement = (EObject)op.getSemanticAdapter().getAdapter(EObject.class); >+ String domainElementGraphicalType = op.getSemanticHint(); >+ if(domainElementGraphicalType == null) { >+ domainElementGraphicalType = registry.getEdgeGraphicalType(domainElement); >+ } >+ >+ if((!IGraphicalTypeRegistry.UNDEFINED_TYPE.equals(domainElementGraphicalType)) && (registry.isKnownEdgeType(domainElementGraphicalType))) { >+ return true; >+ } >+ } >+ >+ return false; >+ } >+ >+ @Override >+ protected boolean provides(CreateNodeViewOperation op) { >+ // Must have a container >+ if(op.getContainerView() == null) { >+ return false; >+ } >+ // Get the type of the container >+ String containerGraphicalType = op.getContainerView().getType(); >+ >+ // This provider is registered for InternalBlock Diagram only >+ String diagramType = op.getContainerView().getDiagram().getType(); >+ if(!ElementTypes.DIAGRAM_ID.equals(diagramType)) { >+ return false; >+ } >+ >+ // ///////////////////////////////////////////////////////////////////// >+ // Test possibility to provide a view based on the ElementType and its expected container. >+ // ///////////////////////////////////////////////////////////////////// >+ >+ IElementType elementType = (IElementType)op.getSemanticAdapter().getAdapter(IElementType.class); >+ if(elementType == UMLElementTypes.CONSTRAINT) { >+ if(ElementTypes.DIAGRAM_ID.equals(containerGraphicalType)) { >+ return true; >+ } >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerGraphicalType)) { >+ return true; >+ } >+ } >+ if(elementType == UMLElementTypes.COMMENT) { >+ if(ElementTypes.DIAGRAM_ID.equals(containerGraphicalType)) { >+ return true; >+ } >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_STRUCTURE_ID.equals(containerGraphicalType)) { >+ return true; >+ } >+ if(SysMLGraphicalTypes.COMPARTMENT_SYSML_BLOCKPROPERTY_STRUCTURE_ID.equals(containerGraphicalType)) { >+ return true; >+ } >+ } >+ >+ // ///////////////////////////////////////////////////////////////////// >+ // Test possibility to provide a view based on the semantic nature and its expected container. >+ // ///////////////////////////////////////////////////////////////////// >+ >+ // IElementType may be null (especially when drop from ModelExplorer). >+ // In such a case, test the semantic EObject instead. >+ if(elementType == null) { >+ EObject domainElement = (EObject)op.getSemanticAdapter().getAdapter(EObject.class); >+ String domainElementGraphicalType = op.getSemanticHint(); >+ if(domainElementGraphicalType == null) { >+ domainElementGraphicalType = registry.getNodeGraphicalType(domainElement, containerGraphicalType); >+ } else { >+ domainElementGraphicalType = registry.getNodeGraphicalType(domainElementGraphicalType, containerGraphicalType); >+ } >+ >+ if((!IGraphicalTypeRegistry.UNDEFINED_TYPE.equals(domainElementGraphicalType)) && (registry.isKnownNodeType(domainElementGraphicalType))) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ @Override >+ public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { >+ >+ // Use the GraphicalTypeRegistry to find the expected type for a domain element >+ // Get the type of the container >+ String containerGraphicalType = containerView.getType(); >+ >+ // Get the type of the domain element >+ EObject domainElement = (EObject)semanticAdapter.getAdapter(EObject.class); >+ >+ if(semanticHint != null) { >+ // Look for a possible graphicalType replacement >+ String graphicalType = registry.getNodeGraphicalType(semanticHint, containerGraphicalType); >+ return super.createNode(new SemanticAdapter(domainElement, null), containerView, graphicalType, index, persisted, preferencesHint); >+ } >+ >+ String domainElementGraphicalType = registry.getNodeGraphicalType(domainElement, containerGraphicalType); >+ >+ // Create the expected node >+ if(!IGraphicalTypeRegistry.UNDEFINED_TYPE.equals(domainElementGraphicalType)) { >+ return super.createNode(semanticAdapter, containerView, domainElementGraphicalType, index, persisted, preferencesHint); >+ } >+ >+ Activator.log.error(new Exception("Could not create Node.")); >+ return null; >+ } >+ >+ @Override >+ protected void stampShortcut(View containerView, Node target) { >+ if(!ElementTypes.DIAGRAM_ID.equals(containerView.getDiagram().getType())) { >+ EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); >+ shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$ >+ shortcutAnnotation.getDetails().put("modelID", ElementTypes.DIAGRAM_ID); //$NON-NLS-1$ >+ target.getEAnnotations().add(shortcutAnnotation); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramEditPartProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramEditPartProvider.java >new file mode 100644 >index 0000000..4e53242 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramEditPartProvider.java >@@ -0,0 +1,37 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import org.eclipse.gmf.runtime.common.core.service.IOperation; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.ParametricDiagramEditPart; >+ >+public class ParametricDiagramEditPartProvider extends AbstractEditPartProvider { >+ >+ @Override >+ public boolean provides(IOperation operation) { >+ if(operation instanceof CreateGraphicEditPartOperation) { >+ View view = ((IEditPartOperation)operation).getView(); >+ >+ // Ensure current diagram is Parametric Diagram >+ if(ElementTypes.DIAGRAM_ID.equals(view.getType())) { >+ return true; >+ } >+ } >+ >+ return false; >+ } >+ >+ @Override >+ protected Class<?> getDiagramEditPartClass(View view) { >+ if(ElementTypes.DIAGRAM_ID.equals(view.getType())) { >+ return ParametricDiagramEditPart.class; >+ } >+ >+ Activator.log.error(new Exception("Could not create EditPart.")); >+ return null; >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramEditPolicyProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramEditPolicyProvider.java >new file mode 100644 >index 0000000..de9fd40 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramEditPolicyProvider.java >@@ -0,0 +1,50 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import org.eclipse.gef.EditPart; >+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; >+import org.eclipse.gmf.runtime.common.core.service.IOperation; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomDragDropEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PortAffixedNodeEditPart; >+ >+public class ParametricDiagramEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider { >+ >+ public boolean provides(IOperation operation) { >+ >+ CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation)operation; >+ if(!(epOperation.getEditPart() instanceof GraphicalEditPart)) { >+ return false; >+ } >+ GraphicalEditPart gep = (GraphicalEditPart)epOperation.getEditPart(); >+ String diagramType = gep.getNotationView().getDiagram().getType(); >+ if(!ElementTypes.DIAGRAM_ID.equals(diagramType)) { >+ return false; >+ } >+ >+ if(gep instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConstraintEditPart) { >+ return true; >+ } >+ if(gep instanceof PortAffixedNodeEditPart) { >+ return true; >+ } >+ if(gep instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.UseCaseEditPartCN) { >+ return true; >+ } >+ if(gep instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.CommentEditPart) { >+ return true; >+ } >+ if(gep instanceof org.eclipse.papyrus.uml.diagram.composite.edit.parts.InteractionConstraintEditPartCN) { >+ return true; >+ } >+ >+ return false; >+ } >+ >+ public void createEditPolicies(EditPart editPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDragDropEditPolicy()); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramViewProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramViewProvider.java >new file mode 100644 >index 0000000..44dc9c8 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParametricDiagramViewProvider.java >@@ -0,0 +1,31 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.gmf.runtime.diagram.core.providers.AbstractViewProvider; >+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+import org.eclipse.papyrus.sysml.diagram.parametric.factory.ParametricDiagramViewFactory; >+ >+public class ParametricDiagramViewProvider extends AbstractViewProvider { >+ >+ @Override >+ protected boolean provides(CreateDiagramViewOperation operation) { >+ >+ if(ElementTypes.DIAGRAM_ID.equals(operation.getSemanticHint())) { >+ return true; >+ } >+ >+ return false; >+ } >+ >+ @Override >+ protected Class<?> getDiagramViewClass(IAdaptable semanticAdapter, String diagramKind) { >+ if(ElementTypes.DIAGRAM_ID.equals(diagramKind)) { >+ return ParametricDiagramViewFactory.class; >+ } >+ >+ Activator.log.error(new Exception("Could not create View.")); >+ return null; >+ } >+} >+ >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/utils/ParametricDiagramGraphicalTypes.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/utils/ParametricDiagramGraphicalTypes.java >new file mode 100644 >index 0000000..05a8de0 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src-gen/org/eclipse/papyrus/sysml/diagram/parametric/utils/ParametricDiagramGraphicalTypes.java >@@ -0,0 +1,15 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.utils; >+ >+public class ParametricDiagramGraphicalTypes { >+ >+ /** ********************************************************* */ >+ /** Diagram custom graphical types id *********************** */ >+ /** ********************************************************* */ >+ >+ >+ >+ >+ >+ >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/Activator.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/Activator.java >new file mode 100644 >index 0000000..df6e7ce >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/Activator.java >@@ -0,0 +1,105 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric; >+ >+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.papyrus.infra.core.log.LogHelper; >+import org.eclipse.papyrus.sysml.diagram.parametric.preferences.CustomPreferenceInitializer; >+import org.eclipse.ui.plugin.AbstractUIPlugin; >+import org.osgi.framework.BundleContext; >+ >+/** The activator class controls the plug-in life cycle */ >+public class Activator extends AbstractUIPlugin { >+ >+ /** The plug-in ID */ >+ public static final String PLUGIN_ID = "org.eclipse.papyrus.sysml.diagram.parametric"; >+ >+ /** The plug-in shared instance */ >+ private static Activator plugin; >+ >+ /** The logging helper */ >+ public static LogHelper log; >+ >+ /** The plug-in Preference store */ >+ public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(PLUGIN_ID); >+ >+ /** Default constructor */ >+ public Activator() { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) >+ */ >+ public void start(BundleContext context) throws Exception { >+ super.start(context); >+ plugin = this; >+ >+ // register the login helper >+ log = new LogHelper(plugin); >+ >+ // register the preference store >+ PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, getPreferenceStore()); >+ >+ // Preferences initialization >+ CustomPreferenceInitializer diagramPreferenceInitializer = new CustomPreferenceInitializer(); >+ diagramPreferenceInitializer.initializeDefaultPreferences(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) >+ */ >+ public void stop(BundleContext context) throws Exception { >+ plugin = null; >+ super.stop(context); >+ } >+ >+ /** >+ * Returns the shared instance >+ * >+ * @return the shared instance >+ */ >+ public static Activator getInstance() { >+ return plugin; >+ } >+ >+ /** >+ * Returns an image descriptor for the image file at the given plug-in relative path. >+ * >+ * @generated >+ * @param path >+ * the path >+ * @return the image descriptor >+ */ >+ public static ImageDescriptor getBundledImageDescriptor(String path) { >+ return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path); >+ } >+ >+ /** >+ * >+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#getPreferenceStore() >+ * >+ * @return Shared Preference Store. >+ */ >+ @Override >+ public IPreferenceStore getPreferenceStore() { >+ IPreferenceStore store = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore(); >+ return store; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramWithNavigationHandler.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramWithNavigationHandler.java >new file mode 100644 >index 0000000..9281f13 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/CreateParametricDiagramWithNavigationHandler.java >@@ -0,0 +1,25 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric; >+ >+import org.eclipse.papyrus.infra.gmfdiag.navigation.CreateDiagramWithNavigationHandler; >+ >+ >+public class CreateParametricDiagramWithNavigationHandler extends CreateDiagramWithNavigationHandler { >+ >+ public CreateParametricDiagramWithNavigationHandler() { >+ super(new ParametricDiagramCreateCommand(), new ParametricDiagramCondition()); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCondition.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCondition.java >new file mode 100644 >index 0000000..1fb23f3 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/ParametricDiagramCondition.java >@@ -0,0 +1,44 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.papyrus.infra.core.extension.commands.PerspectiveContextDependence; >+import org.eclipse.papyrus.sysml.blocks.Block; >+import org.eclipse.uml2.uml.util.UMLUtil; >+ >+/** >+ * ParametricDiagramCondition to set conditions for the diagram creation >+ */ >+public class ParametricDiagramCondition extends PerspectiveContextDependence { >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean create(EObject selectedElement) { >+ if(super.create(selectedElement)) { >+ if(selectedElement instanceof org.eclipse.uml2.uml.Class) { >+ org.eclipse.uml2.uml.Class clazz = (org.eclipse.uml2.uml.Class)selectedElement; >+ if(UMLUtil.getStereotypeApplication(clazz, Block.class) != null) { >+ return true; >+ } >+ } >+ else if(selectedElement instanceof org.eclipse.uml2.uml.Package) { >+ return true; >+ } >+ } >+ return false; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/commands/CustomBindingConnectorCreateCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/commands/CustomBindingConnectorCreateCommand.java >new file mode 100644 >index 0000000..769dec6 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/commands/CustomBindingConnectorCreateCommand.java >@@ -0,0 +1,113 @@ >+/******************************************************************************* >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ *******************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.commands; >+ >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.common.core.command.CommandResult; >+import org.eclipse.gmf.runtime.common.core.command.ICommand; >+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; >+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; >+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; >+import org.eclipse.papyrus.sysml.blocks.BlocksPackage; >+import org.eclipse.papyrus.sysml.constraints.ConstraintBlock; >+import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >+import org.eclipse.papyrus.uml.service.types.utils.ConnectorUtils; >+import org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils; >+import org.eclipse.uml2.uml.Connector; >+import org.eclipse.uml2.uml.Element; >+import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.StructuredClassifier; >+import org.eclipse.uml2.uml.util.UMLUtil; >+import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper; >+ >+/** >+ * Creates a Message between MessageOccurrenceSpecifications. Converts OccurrenceSpecifications to >+ * MessageOccurrenceSpecifications if needed >+ */ >+public class CustomBindingConnectorCreateCommand extends EditElementCommand { >+ >+ private final EObject source; >+ private final EObject target; >+ >+ public CustomBindingConnectorCreateCommand(final CreateRelationshipRequest request) { >+ super(request.getLabel(), null, request); >+ this.source = request.getSource(); >+ this.target = request.getTarget(); >+ >+ } >+ >+ @Override >+ public boolean canExecute() { >+ if(this.source == null) { >+ return false; >+ } >+ if(this.target == null) { >+ return true; >+ } >+ if(this.source == this.target) { >+ return false; >+ } >+ if (this.source != null && this.target != null) { >+ return isConstraintParameter((Element)source, RequestParameterUtils.getSourceView(getRequest())) >+ || isConstraintParameter((Element)target, RequestParameterUtils.getTargetView(getRequest())); >+ } >+ return false; >+ } >+ >+ private boolean isConstraintParameter(Element element, View view) { >+ if (element instanceof Property) { >+ Property property = (Property) element; >+ Element ownerConstraintBlock = property.getOwner(); >+ if (ownerConstraintBlock instanceof org.eclipse.uml2.uml.Class && UMLUtil.getStereotypeApplication(ownerConstraintBlock, ConstraintBlock.class) != null) { >+ // check for graphics : owned by a constraintProperty >+ View containerView = ViewUtil.getContainerView(view); >+ Element containerElement = (Element)containerView.getElement(); >+ return containerElement instanceof Property >+ && UMLUtil.getStereotypeApplication(containerElement, ConstraintProperty.class) != null >+ && ((Property)containerElement).getType() == ownerConstraintBlock; >+ } >+ } >+ return false; >+ } >+ >+ @Override >+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { >+ >+ if(!canExecute()) { >+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$ >+ } >+ >+ // Create the Connector and its ConnectorEnd. Correct container are set and paths are set in case of <<NestedConnectorEnd>>. >+ StructuredClassifier deducedContainer = new ConnectorUtils().deduceContainer(RequestParameterUtils.getSourceView(getRequest()), RequestParameterUtils.getTargetView(getRequest())); >+ ((CreateRelationshipRequest)getRequest()).setContainer(deducedContainer); >+ IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(deducedContainer); >+ ICommand editCommand = commandProvider.getEditCommand(getRequest()); >+ >+ if (editCommand.canExecute()) { >+ editCommand.execute(monitor, info); >+ Object newObject = editCommand.getCommandResult().getReturnValue(); >+ >+ if (newObject instanceof Connector) { >+ Connector connector = (Connector)newObject; >+ // Apply the <<BindingConnector>> stereotype >+ StereotypeApplicationHelper.INSTANCE.applyStereotype(connector, BlocksPackage.eINSTANCE.getBindingConnector()); >+ } >+ >+ return CommandResult.newOKCommandResult(newObject); >+ } >+ return CommandResult.newErrorCommandResult("Invalid arguments in create link command"); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConnectorCreateCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConnectorCreateCommand.java >deleted file mode 100644 >index 9bbf772..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConnectorCreateCommand.java >+++ /dev/null >@@ -1,174 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.commands; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.SysmlBaseItemSemanticEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; >-import org.eclipse.uml2.uml.ConnectableElement; >-import org.eclipse.uml2.uml.Connector; >-import org.eclipse.uml2.uml.ConnectorEnd; >-import org.eclipse.uml2.uml.StructuredClassifier; >-import org.eclipse.uml2.uml.UMLFactory; >- >-/** >- * @generated >- */ >-public class ConnectorCreateCommand extends EditElementCommand { >- >- /** >- * @generated >- */ >- protected final EObject source; >- >- /** >- * @generated >- */ >- protected final EObject target; >- >- /** >- * @generated >- */ >- protected StructuredClassifier container; >- >- /** >- * @generated >- */ >- public ConnectorCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) { >- super(request.getLabel(), null, request); >- this.source = source; >- this.target = target; >- container = deduceContainer(source, target); >- } >- >- /** >- * @generated >- */ >- public boolean canExecute() { >- if(source == null && target == null) { >- return false; >- } >- if(source != null && false == source instanceof ConnectableElement) { >- return false; >- } >- if(target != null && false == target instanceof ConnectableElement) { >- return false; >- } >- if(getSource() == null) { >- return true; // link creation is in progress; source is not defined yet >- } >- // target may be null here but it's possible to check constraint >- if(getContainer() == null) { >- return false; >- } >- return SysmlBaseItemSemanticEditPolicy.getLinkConstraints().canCreateConnector_4001(getContainer(), getSource(), getTarget()); >- } >- >- /** >- * @generated NOT >- */ >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- if(!canExecute()) { >- throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$ >- } >- Connector newElement = UMLFactory.eINSTANCE.createConnector(); >- if(getContainer() != null) { >- getContainer().getOwnedConnectors().add(newElement); >- } >- // create the connector ends >- ConnectorEnd source = newElement.createEnd(); >- ConnectorEnd target = newElement.createEnd(); >- source.setRole(getSource()); >- target.setRole(getTarget()); >- >- doConfigure(newElement, monitor, info); >- ((CreateElementRequest)getRequest()).setNewElement(newElement); >- return CommandResult.newOKCommandResult(newElement); >- } >- >- /** >- * @generated >- */ >- protected void doConfigure(Connector newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- IElementType elementType = ((CreateElementRequest)getRequest()).getElementType(); >- ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType); >- configureRequest.setClientContext(((CreateElementRequest)getRequest()).getClientContext()); >- configureRequest.addParameters(getRequest().getParameters()); >- configureRequest.setParameter(CreateRelationshipRequest.SOURCE, getSource()); >- configureRequest.setParameter(CreateRelationshipRequest.TARGET, getTarget()); >- ICommand configureCommand = elementType.getEditCommand(configureRequest); >- if(configureCommand != null && configureCommand.canExecute()) { >- configureCommand.execute(monitor, info); >- } >- } >- >- /** >- * @generated >- */ >- protected void setElementToEdit(EObject element) { >- throw new UnsupportedOperationException(); >- } >- >- /** >- * @generated >- */ >- protected ConnectableElement getSource() { >- return (ConnectableElement)source; >- } >- >- /** >- * @generated >- */ >- protected ConnectableElement getTarget() { >- return (ConnectableElement)target; >- } >- >- /** >- * @generated >- */ >- public StructuredClassifier getContainer() { >- return container; >- } >- >- /** >- * Default approach is to traverse ancestors of the source to find instance of container. Modify >- * with appropriate logic. >- * >- * @generated NOT >- */ >- private static StructuredClassifier deduceContainer(EObject source, EObject target) { >- // get the structured classifier, graphical container of the >- for(Object obj : DiagramEditPartsUtil.getEObjectViews(source)) { >- if(obj instanceof Node && ((Node)obj).getDiagram() != null) { >- EObject element = ((Node)obj).getDiagram().getElement(); >- if(element instanceof StructuredClassifier) { >- return (StructuredClassifier)element; >- } >- } >- } >- return null; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConnectorReorientCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConnectorReorientCommand.java >deleted file mode 100644 >index 022b878..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConnectorReorientCommand.java >+++ /dev/null >@@ -1,190 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.commands; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.common.util.EList; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.SysmlBaseItemSemanticEditPolicy; >-import org.eclipse.uml2.uml.ConnectableElement; >-import org.eclipse.uml2.uml.Connector; >-import org.eclipse.uml2.uml.ConnectorEnd; >-import org.eclipse.uml2.uml.StructuredClassifier; >- >-/** >- * @generated >- */ >-public class ConnectorReorientCommand extends EditElementCommand { >- >- /** >- * @generated >- */ >- private final int reorientDirection; >- >- /** >- * @generated >- */ >- private final EObject oldEnd; >- >- /** >- * @generated >- */ >- private final EObject newEnd; >- >- /** >- * @generated >- */ >- public ConnectorReorientCommand(ReorientRelationshipRequest request) { >- super(request.getLabel(), request.getRelationship(), request); >- reorientDirection = request.getDirection(); >- oldEnd = request.getOldRelationshipEnd(); >- newEnd = request.getNewRelationshipEnd(); >- } >- >- /** >- * @generated >- */ >- public boolean canExecute() { >- if(false == getElementToEdit() instanceof Connector) { >- return false; >- } >- if(reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) { >- return canReorientSource(); >- } >- if(reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) { >- return canReorientTarget(); >- } >- return false; >- } >- >- /** >- * @generated NOT >- */ >- protected boolean canReorientSource() { >- if(!(oldEnd instanceof ConnectableElement && newEnd instanceof ConnectableElement)) { >- return false; >- } >- ConnectableElement target = null; >- EList<ConnectorEnd> ends = getLink().getEnds(); >- if(ends != null && !ends.isEmpty()) { >- target = ends.get(1).getRole(); >- } >- if(!(getLink().eContainer() instanceof StructuredClassifier)) { >- return false; >- } >- StructuredClassifier container = (StructuredClassifier)getLink().eContainer(); >- return SysmlBaseItemSemanticEditPolicy.LinkConstraints.canExistConnector_4001(container, getNewSource(), target); >- } >- >- /** >- * @generated NOT >- */ >- protected boolean canReorientTarget() { >- if(!(oldEnd instanceof ConnectableElement && newEnd instanceof ConnectableElement)) { >- return false; >- } >- ConnectableElement source = null; >- EList<ConnectorEnd> ends = getLink().getEnds(); >- if(ends != null && !ends.isEmpty()) { >- source = ends.get(0).getRole(); >- } >- if(!(getLink().eContainer() instanceof StructuredClassifier)) { >- return false; >- } >- StructuredClassifier container = (StructuredClassifier)getLink().eContainer(); >- return SysmlBaseItemSemanticEditPolicy.LinkConstraints.canExistConnector_4001(container, source, getNewTarget()); >- } >- >- /** >- * @generated >- */ >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- if(!canExecute()) { >- throw new ExecutionException("Invalid arguments in reorient link command"); //$NON-NLS-1$ >- } >- if(reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) { >- return reorientSource(); >- } >- if(reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) { >- return reorientTarget(); >- } >- throw new IllegalStateException(); >- } >- >- /** >- * @generated NOT >- */ >- protected CommandResult reorientSource() throws ExecutionException { >- EList<ConnectorEnd> ends = getLink().getEnds(); >- if(ends != null && !ends.isEmpty()) { >- ends.get(0).setRole(getNewSource()); >- return CommandResult.newOKCommandResult(getLink()); >- } else { >- return CommandResult.newCancelledCommandResult(); >- } >- } >- >- /** >- * @generated NOT >- */ >- protected CommandResult reorientTarget() throws ExecutionException { >- EList<ConnectorEnd> ends = getLink().getEnds(); >- if(ends != null && !ends.isEmpty()) { >- ends.get(1).setRole(getNewTarget()); >- return CommandResult.newOKCommandResult(getLink()); >- } else { >- return CommandResult.newCancelledCommandResult(); >- } >- } >- >- /** >- * @generated >- */ >- protected Connector getLink() { >- return (Connector)getElementToEdit(); >- } >- >- /** >- * @generated >- */ >- protected ConnectableElement getOldSource() { >- return (ConnectableElement)oldEnd; >- } >- >- /** >- * @generated >- */ >- protected ConnectableElement getNewSource() { >- return (ConnectableElement)newEnd; >- } >- >- /** >- * @generated >- */ >- protected ConnectableElement getOldTarget() { >- return (ConnectableElement)oldEnd; >- } >- >- /** >- * @generated >- */ >- protected ConnectableElement getNewTarget() { >- return (ConnectableElement)newEnd; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConstraintPropertyCreateCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConstraintPropertyCreateCommand.java >deleted file mode 100644 >index 46dfcfd..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/ConstraintPropertyCreateCommand.java >+++ /dev/null >@@ -1,138 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.commands; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.ecore.EClass; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.resource.Resource; >-import org.eclipse.papyrus.resource.util.ResourceUtil; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.sysml.constraints.ConstraintsFactory; >-import org.eclipse.uml2.uml.Class; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.UMLFactory; >- >-/** >- * @generated >- */ >-public class ConstraintPropertyCreateCommand extends EditElementCommand { >- >- /** >- * @generated >- */ >- private EClass eClass = null; >- >- /** >- * @generated >- */ >- private EObject eObject = null; >- >- /** >- * @generated >- */ >- public ConstraintPropertyCreateCommand(CreateElementRequest req, EObject eObject) { >- super(req.getLabel(), null, req); >- this.eObject = eObject; >- this.eClass = eObject != null ? eObject.eClass() : null; >- } >- >- /** >- * @generated >- */ >- public static ConstraintPropertyCreateCommand create(CreateElementRequest req, EObject eObject) { >- return new ConstraintPropertyCreateCommand(req, eObject); >- } >- >- /** >- * @generated >- */ >- public ConstraintPropertyCreateCommand(CreateElementRequest req) { >- super(req.getLabel(), null, req); >- } >- >- /** >- * FIXME: replace with setElementToEdit() >- * >- * @generated >- */ >- protected EObject getElementToEdit() { >- >- EObject container = ((CreateElementRequest)getRequest()).getContainer(); >- if(container instanceof View) { >- container = ((View)container).getElement(); >- } >- if(container != null) { >- return container; >- } >- return eObject; >- } >- >- /** >- * @generated >- */ >- public boolean canExecute() { >- >- return true; >- >- } >- >- /** >- * @generated NOT >- */ >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- ConstraintProperty newElement = ConstraintsFactory.eINSTANCE.createConstraintProperty(); >- >- EObject elementToEdit = getElementToEdit(); >- >- if(elementToEdit instanceof Class) { >- Class aClass = (Class)elementToEdit; >- Property property = UMLFactory.eINSTANCE.createProperty(); >- aClass.getOwnedAttributes().add(property); >- newElement.setBase_Property(property); >- } >- >- Resource owner = ResourceUtil.getResource(elementToEdit); >- owner.getEobjects().add(newElement); >- >- doConfigure(newElement, monitor, info); >- >- ((CreateElementRequest)getRequest()).setNewElement(newElement); >- return CommandResult.newOKCommandResult(newElement); >- } >- >- /** >- * @generated >- */ >- protected void doConfigure(ConstraintProperty newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- IElementType elementType = ((CreateElementRequest)getRequest()).getElementType(); >- ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType); >- configureRequest.setClientContext(((CreateElementRequest)getRequest()).getClientContext()); >- configureRequest.addParameters(getRequest().getParameters()); >- ICommand configureCommand = elementType.getEditCommand(configureRequest); >- if(configureCommand != null && configureCommand.canExecute()) { >- configureCommand.execute(monitor, info); >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/Property2CreateCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/Property2CreateCommand.java >deleted file mode 100644 >index 1bf23c7..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/Property2CreateCommand.java >+++ /dev/null >@@ -1,141 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.commands; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.ecore.EClass; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.StructuredClassifier; >-import org.eclipse.uml2.uml.Type; >-import org.eclipse.uml2.uml.UMLFactory; >- >-/** >- * @generated >- */ >-public class Property2CreateCommand extends EditElementCommand { >- >- /** >- * @generated >- */ >- private EClass eClass = null; >- >- /** >- * @generated >- */ >- private EObject eObject = null; >- >- /** >- * @generated >- */ >- public Property2CreateCommand(CreateElementRequest req, EObject eObject) { >- super(req.getLabel(), null, req); >- this.eObject = eObject; >- this.eClass = eObject != null ? eObject.eClass() : null; >- } >- >- /** >- * @generated >- */ >- public static Property2CreateCommand create(CreateElementRequest req, EObject eObject) { >- return new Property2CreateCommand(req, eObject); >- } >- >- /** >- * @generated >- */ >- public Property2CreateCommand(CreateElementRequest req) { >- super(req.getLabel(), null, req); >- } >- >- /** >- * FIXME: replace with setElementToEdit() >- * >- * @generated >- */ >- protected EObject getElementToEdit() { >- >- EObject container = ((CreateElementRequest)getRequest()).getContainer(); >- if(container instanceof View) { >- container = ((View)container).getElement(); >- } >- if(container != null) { >- return container; >- } >- return eObject; >- } >- >- /** >- * @generated NOT >- */ >- public boolean canExecute() { >- ConstraintProperty container = (ConstraintProperty)getElementToEdit(); >- Property baseProperty = container.getBase_Property(); >- if(baseProperty != null && baseProperty.getType() != null) { >- // TODO constraint is too restrictive >- // && StereotypeUtils.isStereotypeApplied("SysML::Constraints::ConstraintBlock", >- // baseProperty.getType())) { >- return true; >- } >- return false; >- >- } >- >- /** >- * @generated NOT >- */ >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- >- Property newElement = UMLFactory.eINSTANCE.createProperty(); >- ConstraintProperty owner = (ConstraintProperty)getElementToEdit(); >- Type type = owner.getBase_Property().getType(); >- >- if(type != null && type instanceof StructuredClassifier) { >- StructuredClassifier classifier = (StructuredClassifier)type; >- classifier.getOwnedAttributes().add(newElement); >- >- doConfigure(newElement, monitor, info); >- >- ((CreateElementRequest)getRequest()).setNewElement(newElement); >- return CommandResult.newOKCommandResult(newElement); >- } else { >- return CommandResult.newCancelledCommandResult(); >- } >- } >- >- /** >- * @generated >- */ >- protected void doConfigure(Property newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- IElementType elementType = ((CreateElementRequest)getRequest()).getElementType(); >- ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType); >- configureRequest.setClientContext(((CreateElementRequest)getRequest()).getClientContext()); >- configureRequest.addParameters(getRequest().getParameters()); >- ICommand configureCommand = elementType.getEditCommand(configureRequest); >- if(configureCommand != null && configureCommand.canExecute()) { >- configureCommand.execute(monitor, info); >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/PropertyCreateCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/PropertyCreateCommand.java >deleted file mode 100644 >index f3ab3a7..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/PropertyCreateCommand.java >+++ /dev/null >@@ -1,126 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.commands; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.ecore.EClass; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.StructuredClassifier; >-import org.eclipse.uml2.uml.UMLFactory; >- >-/** >- * @generated >- */ >-public class PropertyCreateCommand extends EditElementCommand { >- >- /** >- * @generated >- */ >- private EClass eClass = null; >- >- /** >- * @generated >- */ >- private EObject eObject = null; >- >- /** >- * @generated >- */ >- public PropertyCreateCommand(CreateElementRequest req, EObject eObject) { >- super(req.getLabel(), null, req); >- this.eObject = eObject; >- this.eClass = eObject != null ? eObject.eClass() : null; >- } >- >- /** >- * @generated >- */ >- public static PropertyCreateCommand create(CreateElementRequest req, EObject eObject) { >- return new PropertyCreateCommand(req, eObject); >- } >- >- /** >- * @generated >- */ >- public PropertyCreateCommand(CreateElementRequest req) { >- super(req.getLabel(), null, req); >- } >- >- /** >- * FIXME: replace with setElementToEdit() >- * >- * @generated >- */ >- protected EObject getElementToEdit() { >- >- EObject container = ((CreateElementRequest)getRequest()).getContainer(); >- if(container instanceof View) { >- container = ((View)container).getElement(); >- } >- if(container != null) { >- return container; >- } >- return eObject; >- } >- >- /** >- * @generated >- */ >- public boolean canExecute() { >- >- return true; >- >- } >- >- /** >- * @generated >- */ >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- >- Property newElement = UMLFactory.eINSTANCE.createProperty(); >- >- StructuredClassifier owner = (StructuredClassifier)getElementToEdit(); >- owner.getOwnedAttributes().add(newElement); >- >- doConfigure(newElement, monitor, info); >- >- ((CreateElementRequest)getRequest()).setNewElement(newElement); >- return CommandResult.newOKCommandResult(newElement); >- } >- >- /** >- * @generated >- */ >- protected void doConfigure(Property newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- IElementType elementType = ((CreateElementRequest)getRequest()).getElementType(); >- ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType); >- configureRequest.setClientContext(((CreateElementRequest)getRequest()).getClientContext()); >- configureRequest.addParameters(getRequest().getParameters()); >- ICommand configureCommand = elementType.getEditCommand(configureRequest); >- if(configureCommand != null && configureCommand.canExecute()) { >- configureCommand.execute(monitor, info); >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/SysmlReorientConnectionViewCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/SysmlReorientConnectionViewCommand.java >deleted file mode 100644 >index d6e9b75..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/commands/SysmlReorientConnectionViewCommand.java >+++ /dev/null >@@ -1,80 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.commands; >- >-import java.util.List; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >-import org.eclipse.gmf.runtime.notation.Edge; >-import org.eclipse.gmf.runtime.notation.View; >- >-/** >- * @generated >- */ >-public class SysmlReorientConnectionViewCommand extends AbstractTransactionalCommand { >- >- /** >- * @generated >- */ >- private IAdaptable edgeAdaptor; >- >- /** >- * @generated >- */ >- public SysmlReorientConnectionViewCommand(TransactionalEditingDomain editingDomain, String label) { >- super(editingDomain, label, null); >- } >- >- /** >- * @generated >- */ >- public List getAffectedFiles() { >- View view = (View)edgeAdaptor.getAdapter(View.class); >- if(view != null) { >- return getWorkspaceFiles(view); >- } >- return super.getAffectedFiles(); >- } >- >- /** >- * @generated >- */ >- public IAdaptable getEdgeAdaptor() { >- return edgeAdaptor; >- } >- >- /** >- * @generated >- */ >- public void setEdgeAdaptor(IAdaptable edgeAdaptor) { >- this.edgeAdaptor = edgeAdaptor; >- } >- >- /** >- * @generated >- */ >- protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) { >- assert null != edgeAdaptor : "Null child in SysmlReorientConnectionViewCommand"; //$NON-NLS-1$ >- Edge edge = (Edge)getEdgeAdaptor().getAdapter(Edge.class); >- assert null != edge : "Null edge in SysmlReorientConnectionViewCommand"; //$NON-NLS-1$ >- View tempView = edge.getSource(); >- edge.setSource(edge.getTarget()); >- edge.setTarget(tempView); >- return CommandResult.newOKCommandResult(); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ConnectorEditHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ConnectorEditHelper.java >deleted file mode 100644 >index e55d99d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ConnectorEditHelper.java >+++ /dev/null >@@ -1,20 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers; >- >-/** >- * @generated >- */ >-public class ConnectorEditHelper extends SysmlBaseEditHelper { >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ConstraintPropertyEditHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ConstraintPropertyEditHelper.java >deleted file mode 100644 >index cb092f6..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ConstraintPropertyEditHelper.java >+++ /dev/null >@@ -1,20 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers; >- >-/** >- * @generated >- */ >-public class ConstraintPropertyEditHelper extends SysmlBaseEditHelper { >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/PropertyEditHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/PropertyEditHelper.java >deleted file mode 100644 >index 1cbb908..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/PropertyEditHelper.java >+++ /dev/null >@@ -1,20 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers; >- >-/** >- * @generated >- */ >-public class PropertyEditHelper extends SysmlBaseEditHelper { >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ResourceEditHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ResourceEditHelper.java >deleted file mode 100644 >index b249148..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/ResourceEditHelper.java >+++ /dev/null >@@ -1,20 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers; >- >-/** >- * @generated >- */ >-public class ResourceEditHelper extends SysmlBaseEditHelper { >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/SysmlBaseEditHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/SysmlBaseEditHelper.java >deleted file mode 100644 >index 5f679ef..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/helpers/SysmlBaseEditHelper.java >+++ /dev/null >@@ -1,99 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers; >- >-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper; >-import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; >-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.IEditCommandRequest; >- >-/** >- * @generated >- */ >-public class SysmlBaseEditHelper extends AbstractEditHelper { >- >- /** >- * @generated >- */ >- public static final String EDIT_POLICY_COMMAND = "edit policy command"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static final String CONTEXT_ELEMENT_TYPE = "context element type"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- protected IEditHelperAdvice[] getEditHelperAdvice(IEditCommandRequest req) { >- if(req.getParameter(CONTEXT_ELEMENT_TYPE) instanceof IElementType) { >- return ElementTypeRegistry.getInstance().getEditHelperAdvice((IElementType)req.getParameter(CONTEXT_ELEMENT_TYPE)); >- } >- return super.getEditHelperAdvice(req); >- } >- >- /** >- * @generated >- */ >- protected ICommand getInsteadCommand(IEditCommandRequest req) { >- ICommand epCommand = (ICommand)req.getParameter(EDIT_POLICY_COMMAND); >- req.setParameter(EDIT_POLICY_COMMAND, null); >- ICommand ehCommand = super.getInsteadCommand(req); >- if(epCommand == null) { >- return ehCommand; >- } >- if(ehCommand == null) { >- return epCommand; >- } >- CompositeCommand command = new CompositeCommand(null); >- command.add(epCommand); >- command.add(ehCommand); >- return command; >- } >- >- /** >- * @generated >- */ >- protected ICommand getCreateCommand(CreateElementRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected ICommand getCreateRelationshipCommand(CreateRelationshipRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected ICommand getDestroyElementCommand(DestroyElementRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected ICommand getDestroyReferenceCommand(DestroyReferenceRequest req) { >- return null; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockCompositeEditPartTN.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockCompositeEditPartTN.java >new file mode 100644 >index 0000000..a273b3f >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockCompositeEditPartTN.java >@@ -0,0 +1,69 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.part; >+ >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.gef.EditPart; >+import org.eclipse.gef.editpolicies.LayoutEditPolicy; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockLabelNameEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.StructureCompartmentEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.figure.SysMLDiagramFrameFigure; >+import org.eclipse.papyrus.sysml.diagram.parametric.figures.ParametricDiagramFrameFigure; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementEditPart; >+import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure; >+ >+ >+public class CustomBlockCompositeEditPartTN extends AbstractElementEditPart { >+ >+ public CustomBlockCompositeEditPartTN(View view) { >+ super(view); >+ } >+ >+ @Override >+ protected IFigure createNodeShape() { >+ return this.primaryShape = new ParametricDiagramFrameFigure(); >+ } >+ >+ @Override >+ public NodeNamedElementFigure getPrimaryShape() { >+ return (NodeNamedElementFigure)primaryShape; >+ } >+ >+ @Override >+ protected boolean addFixedChild(EditPart childEditPart) { >+ if(childEditPart instanceof BlockLabelNameEditPart) { >+ ((BlockLabelNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); >+ return true; >+ } >+ if(childEditPart instanceof StructureCompartmentEditPart) { >+ IFigure pane = ((SysMLDiagramFrameFigure)getPrimaryShape()).getStructureCompartmentFigure(); >+ setupContentPane(pane); >+ pane.add(((StructureCompartmentEditPart)childEditPart).getFigure()); >+ return true; >+ } >+ return false; >+ } >+ >+ @Override >+ protected boolean removeFixedChild(EditPart childEditPart) { >+ return false; >+ } >+ >+ @Override >+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { >+ if(editPart instanceof StructureCompartmentEditPart) { >+ return ((SysMLDiagramFrameFigure)getPrimaryShape()).getStructureCompartmentFigure(); >+ } >+ return getContentPane(); >+ } >+ >+ @Override >+ public EditPart getPrimaryChildEditPart() { >+ return null; >+ } >+ >+ @Override >+ protected LayoutEditPolicy createLayoutEditPolicy() { >+ return null; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockLabelNameEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockLabelNameEditPart.java >new file mode 100644 >index 0000000..aebb7b8 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockLabelNameEditPart.java >@@ -0,0 +1,17 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.part; >+ >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockLabelNameEditPart; >+ >+public class CustomBlockLabelNameEditPart extends BlockLabelNameEditPart { >+ >+ public CustomBlockLabelNameEditPart(View view) { >+ super(view); >+ } >+ >+ @Override >+ protected String getLabelText() { >+ String diagramName = getDiagramView().getName(); >+ return super.getLabelText() + " [" + diagramName + "]"; >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockPropertyCompositeEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockPropertyCompositeEditPart.java >new file mode 100644 >index 0000000..8922e83 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomBlockPropertyCompositeEditPart.java >@@ -0,0 +1,20 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.part; >+ >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.CustomParametricSemanticPolicy; >+ >+public class CustomBlockPropertyCompositeEditPart extends >+ BlockPropertyCompositeEditPart { >+ >+ public CustomBlockPropertyCompositeEditPart(View view) { >+ super(view); >+ } >+ >+ @Override >+ protected void createDefaultEditPolicies() { >+ super.createDefaultEditPolicies(); >+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomConstraintBlockPropertyCompositeEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomConstraintBlockPropertyCompositeEditPart.java >new file mode 100644 >index 0000000..edcf407 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomConstraintBlockPropertyCompositeEditPart.java >@@ -0,0 +1,21 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.part; >+ >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockPropertyCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.CustomParametricSemanticPolicy; >+ >+public class CustomConstraintBlockPropertyCompositeEditPart extends >+ ConstraintBlockPropertyCompositeEditPart { >+ >+ public CustomConstraintBlockPropertyCompositeEditPart(View view) { >+ super(view); >+ } >+ >+ @Override >+ protected void createDefaultEditPolicies() { >+ super.createDefaultEditPolicies(); >+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomConstraintParameterAffixedNodeEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomConstraintParameterAffixedNodeEditPart.java >new file mode 100644 >index 0000000..1d36872 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomConstraintParameterAffixedNodeEditPart.java >@@ -0,0 +1,19 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.part; >+ >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.CustomParametricSemanticPolicy; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConstraintParameterAffixedNodeEditPart; >+ >+public class CustomConstraintParameterAffixedNodeEditPart extends ConstraintParameterAffixedNodeEditPart { >+ >+ public CustomConstraintParameterAffixedNodeEditPart(View view) { >+ super(view); >+ } >+ >+ @Override >+ protected void createDefaultEditPolicies() { >+ super.createDefaultEditPolicies(); >+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomPortAffixedNodeEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomPortAffixedNodeEditPart.java >new file mode 100644 >index 0000000..f2e10ca >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/part/CustomPortAffixedNodeEditPart.java >@@ -0,0 +1,20 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.edit.part; >+ >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.CustomParametricSemanticPolicy; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PortAffixedNodeEditPart; >+ >+public class CustomPortAffixedNodeEditPart extends PortAffixedNodeEditPart { >+ >+ public CustomPortAffixedNodeEditPart(View view) { >+ super(view); >+ } >+ >+ @Override >+ protected void createDefaultEditPolicies() { >+ super.createDefaultEditPolicies(); >+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConnectorEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConnectorEditPart.java >deleted file mode 100644 >index 58ecd9c..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConnectorEditPart.java >+++ /dev/null >@@ -1,154 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import org.eclipse.draw2d.Connection; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.ConnectorItemSemanticEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart; >-import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure; >- >-/** >- * @generated >- */ >-public class ConnectorEditPart extends UMLConnectionNodeEditPart >- >-implements ITreeBranchEditPart { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 4001; >- >- /** >- * @generated >- */ >- public ConnectorEditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ConnectorItemSemanticEditPolicy()); >- } >- >- /** >- * @generated >- */ >- protected boolean addFixedChild(EditPart childEditPart) { >- if(childEditPart instanceof ConnectorNameEditPart) { >- ((ConnectorNameEditPart)childEditPart).setLabel(getPrimaryShape().getConnectorLabel()); >- return true; >- } >- return false; >- } >- >- /** >- * @generated >- */ >- protected void addChildVisual(EditPart childEditPart, int index) { >- if(addFixedChild(childEditPart)) { >- return; >- } >- super.addChildVisual(childEditPart, -1); >- } >- >- /** >- * @generated >- */ >- protected boolean removeFixedChild(EditPart childEditPart) { >- if(childEditPart instanceof ConnectorNameEditPart) { >- return true; >- } >- return false; >- } >- >- /** >- * @generated >- */ >- protected void removeChildVisual(EditPart childEditPart) { >- if(removeFixedChild(childEditPart)) { >- return; >- } >- super.removeChildVisual(childEditPart); >- } >- >- /** >- * Creates figure for this edit part. >- * >- * Body of this method does not depend on settings in generation model so you may safely remove >- * <i>generated</i> tag and modify it. >- * >- * @generated >- */ >- >- protected Connection createConnectionFigure() { >- return new ConnectorFigure(); >- } >- >- /** >- * @generated >- */ >- public ConnectorFigure getPrimaryShape() { >- return (ConnectorFigure)getFigure(); >- } >- >- /** >- * @generated NOT extends UMLEdgeFigure >- */ >- public class ConnectorFigure extends UMLEdgeFigure { >- >- /** >- * @generated >- */ >- private WrappingLabel fConnectorLabel; >- >- /** >- * @generated >- */ >- public ConnectorFigure() { >- this.setLineWidth(1); >- >- createContents(); >- } >- >- /** >- * @generated NOT protected >- */ >- protected void createContents() { >- >- fConnectorLabel = new WrappingLabel(); >- fConnectorLabel.setText(""); >- >- this.add(fConnectorLabel); >- >- } >- >- /** >- * @generated >- */ >- public WrappingLabel getConnectorLabel() { >- return fConnectorLabel; >- } >- >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConnectorNameEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConnectorNameEditPart.java >deleted file mode 100644 >index 105a4f9..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConnectorNameEditPart.java >+++ /dev/null >@@ -1,756 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import java.util.Collections; >-import java.util.List; >- >-import org.eclipse.draw2d.ConnectionLocator; >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.Label; >-import org.eclipse.draw2d.geometry.Point; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.transaction.RecordingCommand; >-import org.eclipse.emf.transaction.RunnableWithResult; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gef.AccessibleEditPart; >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.requests.DirectEditRequest; >-import org.eclipse.gef.tools.DirectEditManager; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.gmf.runtime.notation.FontStyle; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.text.contentassist.IContentAssistProcessor; >-import org.eclipse.jface.viewers.ICellEditorValidator; >-import org.eclipse.jface.window.Window; >-import org.eclipse.papyrus.extensionpoints.editors.Activator; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; >-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; >-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.SysmlTextSelectionEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlParserProvider; >-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; >-import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; >-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; >-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; >-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; >-import org.eclipse.papyrus.infra.emf.appearance.helper.NameLabelIconHelper; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.accessibility.AccessibleEvent; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * @generated >- */ >-public class ConnectorNameEditPart extends LabelEditPart implements ITextAwareEditPart, ILabelRoleProvider { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 6001; >- >- /** >- * @generated >- */ >- private DirectEditManager manager; >- >- /** >- * @generated >- */ >- private IParser parser; >- >- /** >- * @generated >- */ >- private List<?> parserElements; >- >- /** >- * @generated >- */ >- private String defaultText; >- >- /** direct edition mode (default, undefined, registered editor, etc.) */ >- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; >- >- /** configuration from a registered edit dialog */ >- protected IDirectEditorConfiguration configuration; >- >- /** >- * @generated >- */ >- static { >- registerSnapBackPosition(SysmlVisualIDRegistry.getType(org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorNameEditPart.VISUAL_ID), new Point(0, 40)); >- } >- >- /** >- * @generated >- */ >- public ConnectorNameEditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); >- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new SysmlTextSelectionEditPolicy()); >- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ParametricEditPart.LinkLabelDragPolicy()); >- } >- >- /** >- * @generated >- */ >- public int getKeyPoint() { >- return ConnectionLocator.MIDDLE; >- } >- >- /** >- * @generated >- */ >- protected String getLabelTextHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getText(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getText(); >- } else { >- return ((Label)figure).getText(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelTextHelper(IFigure figure, String text) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setText(text); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setText(text); >- } else { >- ((Label)figure).setText(text); >- } >- } >- >- /** >- * @generated >- */ >- protected Image getLabelIconHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getIcon(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getIcon(); >- } else { >- return ((Label)figure).getIcon(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelIconHelper(IFigure figure, Image icon) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setIcon(icon); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setIcon(icon); >- } else { >- ((Label)figure).setIcon(icon); >- } >- } >- >- /** >- * @generated >- */ >- public void setLabel(WrappingLabel figure) { >- unregisterVisuals(); >- setFigure(figure); >- defaultText = getLabelTextHelper(figure); >- registerVisuals(); >- refreshVisuals(); >- } >- >- /** >- * @generated >- */ >- protected List getModelChildren() { >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected EObject getParserElement() { >- return resolveSemanticElement(); >- } >- >- /** >- * @generated NOT >- */ >- protected Image getLabelIcon() { >- EObject parserElement = getParserElement(); >- if(parserElement == null) { >- return null; >- } >- >- List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); >- for(View view : views) { >- if(NameLabelIconHelper.showLabelIcon(view)) { >- return SysmlElementTypes.getImage(parserElement.eClass()); >- } >- } >- return null; >- >- } >- >- /** >- * @generated >- */ >- protected String getLabelText() { >- String text = null; >- EObject parserElement = getParserElement(); >- if(parserElement != null && getParser() != null) { >- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); >- } >- if(text == null || text.length() == 0) { >- text = defaultText; >- } >- return text; >- } >- >- /** >- * @generated >- */ >- public void setLabelText(String text) { >- setLabelTextHelper(getFigure(), text); >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- public String getEditText() { >- if(getParserElement() == null || getParser() == null) { >- return ""; //$NON-NLS-1$ >- } >- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); >- } >- >- /** >- * @generated >- */ >- protected boolean isEditable() { >- return getParser() != null; >- } >- >- /** >- * @generated >- */ >- public ICellEditorValidator getEditTextValidator() { >- return new ICellEditorValidator() { >- >- public String isValid(final Object value) { >- if(value instanceof String) { >- final EObject element = getParserElement(); >- final IParser parser = getParser(); >- try { >- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() { >- >- public void run() { >- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); >- } >- }); >- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); >- } catch (InterruptedException ie) { >- ie.printStackTrace(); >- } >- } >- >- // shouldn't get here >- return null; >- } >- }; >- } >- >- /** >- * @generated >- */ >- public IContentAssistProcessor getCompletionProcessor() { >- if(getParserElement() == null || getParser() == null) { >- return null; >- } >- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); >- } >- >- /** >- * @generated >- */ >- public ParserOptions getParserOptions() { >- return ParserOptions.NONE; >- } >- >- /** >- * @generated >- */ >- public IParser getParser() { >- if(parser == null) { >- parser = SysmlParserProvider.getParser(SysmlElementTypes.Connector_4001, getParserElement(), SysmlVisualIDRegistry.getType(org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorNameEditPart.VISUAL_ID)); >- } >- return parser; >- } >- >- /** >- * @generated >- */ >- protected DirectEditManager getManager() { >- if(manager == null) { >- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), SysmlEditPartFactory.getTextCellEditorLocator(this))); >- } >- return manager; >- } >- >- /** >- * @generated >- */ >- protected void setManager(DirectEditManager manager) { >- this.manager = manager; >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit() { >- getManager().show(); >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit(Point eventLocation) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); >- } >- } >- >- /** >- * @generated >- */ >- private void performDirectEdit(char initialCharacter) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(initialCharacter); >- } else { >- performDirectEdit(); >- } >- } >- >- /** >- * @generated >- */ >- protected void performDirectEditRequest(Request request) { >- >- final Request theRequest = request; >- >- if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { >- directEditionMode = getDirectEditionType(); >- } >- switch(directEditionMode) { >- case IDirectEdition.NO_DIRECT_EDITION: >- // no direct edition mode => does nothing >- return; >- case IDirectEdition.EXTENDED_DIRECT_EDITOR: >- updateExtendedEditorConfiguration(); >- if(configuration == null || configuration.getLanguage() == null) { >- performDefaultDirectEditorEdit(theRequest); >- } else { >- configuration.preEditAction(resolveSemanticElement()); >- Dialog dialog = null; >- if(configuration instanceof IPopupEditorConfiguration) { >- IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); >- helper.showEditor(); >- return; >- } else if(configuration instanceof IAdvancedEditorConfiguration) { >- dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); >- } else if(configuration instanceof IDirectEditorConfiguration) { >- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration)configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration)configuration); >- } else { >- return; >- } >- final Dialog finalDialog = dialog; >- >- if(Window.OK == dialog.open()) { >- TransactionalEditingDomain domain = getEditingDomain(); >- RecordingCommand command = new RecordingCommand(domain, "Edit Label") { >- >- @Override >- protected void doExecute() { >- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); >- >- } >- }; >- domain.getCommandStack().execute(command); >- } >- } >- break; >- case IDirectEdition.DEFAULT_DIRECT_EDITOR: >- >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- break; >- default: >- break; >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshVisuals() { >- super.refreshVisuals(); >- refreshLabel(); >- refreshFont(); >- refreshFontColor(); >- refreshUnderline(); >- refreshStrikeThrough(); >- } >- >- /** >- * @generated >- */ >- protected void refreshLabel() { >- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); >- if(maskLabelPolicy == null) { >- setLabelTextHelper(getFigure(), getLabelText()); >- setLabelIconHelper(getFigure(), getLabelIcon()); >- } >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshUnderline() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshStrikeThrough() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshFont() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null) { >- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); >- setFont(fontData); >- } >- } >- >- /** >- * @generated >- */ >- protected void setFontColor(Color color) { >- getFigure().setForegroundColor(color); >- } >- >- /** >- * @generated >- */ >- protected void addSemanticListeners() { >- if(getParser() instanceof ISemanticParser) { >- EObject element = resolveSemanticElement(); >- parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); >- for(int i = 0; i < parserElements.size(); i++) { >- addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ >- } >- } else { >- super.addSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected void removeSemanticListeners() { >- if(parserElements != null) { >- for(int i = 0; i < parserElements.size(); i++) { >- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ >- } >- } else { >- super.removeSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected AccessibleEditPart getAccessibleEditPart() { >- if(accessibleEP == null) { >- accessibleEP = new AccessibleGraphicalEditPart() { >- >- public void getName(AccessibleEvent e) { >- e.result = getLabelTextHelper(getFigure()); >- } >- }; >- } >- return accessibleEP; >- } >- >- /** >- * @generated >- */ >- private View getFontStyleOwnerView() { >- return getPrimaryView(); >- } >- >- /** >- * Returns the kind of associated editor for direct edition. >- * >- * @return an <code>int</code> corresponding to the kind of direct editor, @see >- * org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition >- * @generated >- */ >- public int getDirectEditionType() { >- if(checkExtendedEditor()) { >- initExtendedEditorConfiguration(); >- return IDirectEdition.EXTENDED_DIRECT_EDITOR; >- } >- if(checkDefaultEdition()) { >- return IDirectEdition.DEFAULT_DIRECT_EDITOR; >- } >- >- // not a named element. no specific editor => do nothing >- return IDirectEdition.NO_DIRECT_EDITION; >- } >- >- /** >- * Checks if an extended editor is present. >- * >- * @return <code>true</code> if an extended editor is present. >- * @generated >- */ >- protected boolean checkExtendedEditor() { >- if(resolveSemanticElement() != null) { >- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName()); >- } >- return false; >- } >- >- /** >- * Checks if a default direct edition is available >- * >- * @return <code>true</code> if a default direct edition is available >- * @generated >- */ >- protected boolean checkDefaultEdition() { >- return (getParser() != null); >- } >- >- /** >- * Initializes the extended editor configuration >- * >- * @generated >- */ >- protected void initExtendedEditorConfiguration() { >- if(configuration == null) { >- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("")) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else { >- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); >- } >- } >- } >- >- /** >- * Updates the preference configuration >- */ >- protected void updateExtendedEditorConfiguration() { >- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { >- configuration = null; >- } >- } >- >- /** >- * Performs the direct edit usually used by GMF editors. >- * >- * @param theRequest >- * the direct edit request that starts the direct edit system >- */ >- protected void performDefaultDirectEditorEdit(final Request theRequest) { >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- } >- >- /** >- * @generated >- */ >- protected void handleNotificationEvent(Notification event) { >- Object feature = event.getFeature(); >- if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { >- Integer c = (Integer)event.getNewValue(); >- setFontColor(DiagramColorRegistry.getInstance().getColor(c)); >- } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { >- refreshUnderline(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { >- refreshStrikeThrough(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { >- refreshFont(); >- } else { >- if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { >- refreshLabel(); >- } >- if(getParser() instanceof ISemanticParser) { >- ISemanticParser modelParser = (ISemanticParser)getParser(); >- if(modelParser.areSemanticElementsAffected(null, event)) { >- removeSemanticListeners(); >- if(resolveSemanticElement() != null) { >- addSemanticListeners(); >- } >- refreshLabel(); >- } >- } >- } >- >- if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { >- refreshLabel(); >- } >- >- super.handleNotificationEvent(event); >- } >- >- /** >- * @generated >- */ >- protected IFigure createFigure() { >- // Parent should assign one using setLabel() method >- return null; >- } >- >- /** >- * @generated >- */ >- public String getLabelRole() { >- return "Name";//$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- public String getIconPathRole() { >- return "platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/name.png";//$NON-NLS-1$ >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintLabelEditPart.java >deleted file mode 100644 >index 1440997..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintLabelEditPart.java >+++ /dev/null >@@ -1,767 +0,0 @@ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import java.util.Collections; >-import java.util.List; >- >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.Label; >-import org.eclipse.draw2d.geometry.Point; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.transaction.RecordingCommand; >-import org.eclipse.emf.transaction.RunnableWithResult; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gef.AccessibleEditPart; >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.requests.DirectEditRequest; >-import org.eclipse.gef.tools.DirectEditManager; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.gmf.runtime.notation.FontStyle; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.text.contentassist.IContentAssistProcessor; >-import org.eclipse.jface.viewers.ICellEditorValidator; >-import org.eclipse.jface.window.Window; >-import org.eclipse.papyrus.extensionpoints.editors.Activator; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; >-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; >-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromModelEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.SysmlTextSelectionEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlParserProvider; >-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; >-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; >-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; >-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; >-import org.eclipse.papyrus.infra.emf.appearance.helper.NameLabelIconHelper; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.accessibility.AccessibleEvent; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * @generated >- */ >-public class ConstraintLabelEditPart extends CompartmentEditPart implements ITextAwareEditPart { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 5004; >- >- /** >- * @generated >- */ >- private DirectEditManager manager; >- >- /** >- * @generated >- */ >- private IParser parser; >- >- /** >- * @generated >- */ >- private List<?> parserElements; >- >- /** >- * @generated >- */ >- private String defaultText; >- >- /** direct edition mode (default, undefined, registered editor, etc.) */ >- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; >- >- /** configuration from a registered edit dialog */ >- protected IDirectEditorConfiguration configuration; >- >- /** >- * @generated >- */ >- public ConstraintLabelEditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new SysmlTextSelectionEditPolicy()); >- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); >- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ParametricEditPart.NodeLabelDragPolicy()); >- installEditPolicy(RequestConstants.REQ_SEMANTIC_WRAPPER, new NoDeleteFromModelEditPolicy()); >- } >- >- /** >- * @generated >- */ >- protected String getLabelTextHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getText(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getText(); >- } else { >- return ((Label)figure).getText(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelTextHelper(IFigure figure, String text) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setText(text); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setText(text); >- } else { >- ((Label)figure).setText(text); >- } >- } >- >- /** >- * @generated >- */ >- protected Image getLabelIconHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getIcon(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getIcon(); >- } else { >- return ((Label)figure).getIcon(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelIconHelper(IFigure figure, Image icon) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setIcon(icon); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setIcon(icon); >- } else { >- ((Label)figure).setIcon(icon); >- } >- } >- >- /** >- * @generated >- */ >- public void setLabel(WrappingLabel figure) { >- unregisterVisuals(); >- setFigure(figure); >- defaultText = getLabelTextHelper(figure); >- registerVisuals(); >- refreshVisuals(); >- } >- >- /** >- * @generated >- */ >- protected List getModelChildren() { >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected EObject getParserElement() { >- return resolveSemanticElement(); >- } >- >- /** >- * @generated NOT >- */ >- protected Image getLabelIcon() { >- EObject parserElement = getParserElement(); >- if(parserElement == null) { >- return null; >- } >- >- List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); >- for(View view : views) { >- if(NameLabelIconHelper.showLabelIcon(view)) { >- return SysmlElementTypes.getImage(parserElement.eClass()); >- } >- } >- return null; >- >- } >- >- /** >- * @generated >- */ >- protected String getLabelText() { >- String text = null; >- EObject parserElement = getParserElement(); >- if(parserElement != null && getParser() != null) { >- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); >- } >- if(text == null || text.length() == 0) { >- text = defaultText; >- } >- return text; >- } >- >- /** >- * @generated >- */ >- public void setLabelText(String text) { >- setLabelTextHelper(getFigure(), text); >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- public String getEditText() { >- if(getParserElement() == null || getParser() == null) { >- return ""; //$NON-NLS-1$ >- } >- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); >- } >- >- /** >- * @generated >- */ >- protected boolean isEditable() { >- return getParser() != null; >- } >- >- /** >- * @generated >- */ >- public ICellEditorValidator getEditTextValidator() { >- return new ICellEditorValidator() { >- >- public String isValid(final Object value) { >- if(value instanceof String) { >- final EObject element = getParserElement(); >- final IParser parser = getParser(); >- try { >- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() { >- >- public void run() { >- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); >- } >- }); >- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); >- } catch (InterruptedException ie) { >- ie.printStackTrace(); >- } >- } >- >- // shouldn't get here >- return null; >- } >- }; >- } >- >- /** >- * @generated >- */ >- public IContentAssistProcessor getCompletionProcessor() { >- if(getParserElement() == null || getParser() == null) { >- return null; >- } >- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); >- } >- >- /** >- * @generated >- */ >- public ParserOptions getParserOptions() { >- return ParserOptions.NONE; >- } >- >- /** >- * @generated >- */ >- public IParser getParser() { >- if(parser == null) { >- parser = SysmlParserProvider.getParser(SysmlElementTypes.ConstraintProperty_2003, getParserElement(), SysmlVisualIDRegistry.getType(org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintLabelEditPart.VISUAL_ID)); >- } >- return parser; >- } >- >- /** >- * @generated >- */ >- protected DirectEditManager getManager() { >- if(manager == null) { >- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), SysmlEditPartFactory.getTextCellEditorLocator(this))); >- } >- return manager; >- } >- >- /** >- * @generated >- */ >- protected void setManager(DirectEditManager manager) { >- this.manager = manager; >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit() { >- getManager().show(); >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit(Point eventLocation) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); >- } >- } >- >- /** >- * @generated >- */ >- private void performDirectEdit(char initialCharacter) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(initialCharacter); >- } else { >- performDirectEdit(); >- } >- } >- >- /** >- * @generated >- */ >- protected void performDirectEditRequest(Request request) { >- >- final Request theRequest = request; >- >- if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { >- directEditionMode = getDirectEditionType(); >- } >- switch(directEditionMode) { >- case IDirectEdition.NO_DIRECT_EDITION: >- // no direct edition mode => does nothing >- return; >- case IDirectEdition.EXTENDED_DIRECT_EDITOR: >- updateExtendedEditorConfiguration(); >- if(configuration == null || configuration.getLanguage() == null) { >- performDefaultDirectEditorEdit(theRequest); >- } else { >- configuration.preEditAction(resolveSemanticElement()); >- Dialog dialog = null; >- if(configuration instanceof IPopupEditorConfiguration) { >- IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); >- helper.showEditor(); >- return; >- } else if(configuration instanceof IAdvancedEditorConfiguration) { >- dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); >- } else if(configuration instanceof IDirectEditorConfiguration) { >- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration)configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration)configuration); >- } else { >- return; >- } >- final Dialog finalDialog = dialog; >- >- if(Window.OK == dialog.open()) { >- TransactionalEditingDomain domain = getEditingDomain(); >- RecordingCommand command = new RecordingCommand(domain, "Edit Label") { >- >- @Override >- protected void doExecute() { >- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); >- >- } >- }; >- domain.getCommandStack().execute(command); >- } >- } >- break; >- case IDirectEdition.DEFAULT_DIRECT_EDITOR: >- >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- break; >- default: >- break; >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshVisuals() { >- super.refreshVisuals(); >- refreshLabel(); >- refreshFont(); >- refreshFontColor(); >- refreshUnderline(); >- refreshStrikeThrough(); >- } >- >- /** >- * @generated >- */ >- protected void refreshLabel() { >- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); >- if(maskLabelPolicy == null) { >- setLabelTextHelper(getFigure(), getLabelText()); >- setLabelIconHelper(getFigure(), getLabelIcon()); >- } >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshUnderline() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshStrikeThrough() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshFont() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null) { >- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); >- setFont(fontData); >- } >- } >- >- /** >- * @generated >- */ >- protected void setFontColor(Color color) { >- getFigure().setForegroundColor(color); >- } >- >- /** >- * @generated >- */ >- protected void addSemanticListeners() { >- if(getParser() instanceof ISemanticParser) { >- EObject element = resolveSemanticElement(); >- parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); >- for(int i = 0; i < parserElements.size(); i++) { >- addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ >- } >- } else { >- super.addSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected void removeSemanticListeners() { >- if(parserElements != null) { >- for(int i = 0; i < parserElements.size(); i++) { >- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ >- } >- } else { >- super.removeSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected AccessibleEditPart getAccessibleEditPart() { >- if(accessibleEP == null) { >- accessibleEP = new AccessibleGraphicalEditPart() { >- >- public void getName(AccessibleEvent e) { >- e.result = getLabelTextHelper(getFigure()); >- } >- }; >- } >- return accessibleEP; >- } >- >- /** >- * @generated >- */ >- private View getFontStyleOwnerView() { >- return getPrimaryView(); >- } >- >- /** >- * Returns the kind of associated editor for direct edition. >- * >- * @return an <code>int</code> corresponding to the kind of direct editor, @see >- * org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition >- * @generated >- */ >- public int getDirectEditionType() { >- if(checkExtendedEditor()) { >- initExtendedEditorConfiguration(); >- return IDirectEdition.EXTENDED_DIRECT_EDITOR; >- } >- if(checkDefaultEdition()) { >- return IDirectEdition.DEFAULT_DIRECT_EDITOR; >- } >- >- // not a named element. no specific editor => do nothing >- return IDirectEdition.NO_DIRECT_EDITION; >- } >- >- /** >- * Checks if an extended editor is present. >- * >- * @return <code>true</code> if an extended editor is present. >- * @generated >- */ >- protected boolean checkExtendedEditor() { >- if(resolveSemanticElement() != null) { >- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName()); >- } >- return false; >- } >- >- /** >- * Checks if a default direct edition is available >- * >- * @return <code>true</code> if a default direct edition is available >- * @generated >- */ >- protected boolean checkDefaultEdition() { >- return (getParser() != null); >- } >- >- /** >- * Initializes the extended editor configuration >- * >- * @generated >- */ >- protected void initExtendedEditorConfiguration() { >- if(configuration == null) { >- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("")) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else { >- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); >- } >- } >- } >- >- /** >- * Updates the preference configuration >- */ >- protected void updateExtendedEditorConfiguration() { >- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { >- configuration = null; >- } >- } >- >- /** >- * Performs the direct edit usually used by GMF editors. >- * >- * @param theRequest >- * the direct edit request that starts the direct edit system >- */ >- protected void performDefaultDirectEditorEdit(final Request theRequest) { >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- } >- >- /** >- * @generated >- */ >- protected void addNotationalListeners() { >- super.addNotationalListeners(); >- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- protected void removeNotationalListeners() { >- super.removeNotationalListeners(); >- removeListenerFilter("PrimaryView"); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- protected void handleNotificationEvent(Notification event) { >- refreshLabel(); >- Object feature = event.getFeature(); >- if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { >- Integer c = (Integer)event.getNewValue(); >- setFontColor(DiagramColorRegistry.getInstance().getColor(c)); >- } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { >- refreshUnderline(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { >- refreshStrikeThrough(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { >- refreshFont(); >- } else { >- if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { >- refreshLabel(); >- } >- if(getParser() instanceof ISemanticParser) { >- ISemanticParser modelParser = (ISemanticParser)getParser(); >- if(modelParser.areSemanticElementsAffected(null, event)) { >- removeSemanticListeners(); >- if(resolveSemanticElement() != null) { >- addSemanticListeners(); >- } >- refreshLabel(); >- } >- } >- } >- >- if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { >- refreshLabel(); >- } >- >- super.handleNotificationEvent(event); >- } >- >- /** >- * @generated >- */ >- protected IFigure createFigure() { >- // Parent should assign one using setLabel() method >- return null; >- } >- >- private static final String ADD_PARENT_MODEL = "AddParentModel"; >- >- /** >- * @generated >- */ >- public void activate() { >- super.activate(); >- addOwnerElementListeners(); >- } >- >- /** >- * @generated >- */ >- protected void addOwnerElementListeners() { >- addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); //$NON-NLS-1$ >- >- } >- >- /** >- * @generated >- */ >- public void deactivate() { >- removeOwnerElementListeners(); >- super.deactivate(); >- >- } >- >- /** >- * @generated >- */ >- protected void removeOwnerElementListeners() { >- removeListenerFilter(ADD_PARENT_MODEL); >- >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintPropertyEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintPropertyEditPart.java >deleted file mode 100644 >index 44b7e14..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintPropertyEditPart.java >+++ /dev/null >@@ -1,496 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import org.eclipse.draw2d.GridData; >-import org.eclipse.draw2d.GridLayout; >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.PositionConstants; >-import org.eclipse.draw2d.RoundedRectangle; >-import org.eclipse.draw2d.Shape; >-import org.eclipse.draw2d.StackLayout; >-import org.eclipse.draw2d.geometry.Dimension; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.RequestConstants; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.editpolicies.LayoutEditPolicy; >-import org.eclipse.gef.editpolicies.NonResizableEditPolicy; >-import org.eclipse.gef.requests.CreateRequest; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >-import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >-import org.eclipse.gmf.runtime.emf.type.core.IHintedType; >-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; >-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.preference.PreferenceConverter; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.ConstraintPropertyItemSemanticEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.CreateParameterEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel; >-import org.eclipse.papyrus.sysml.diagram.parametric.helper.SelfCompartmentNotificationHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.locator.ParameterPositionLocator; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * @generated >- */ >-public class ConstraintPropertyEditPart extends >- >-AbstractBorderedShapeEditPart { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 2003; >- >- /** >- * @generated >- */ >- protected IFigure contentPane; >- >- /** >- * @generated >- */ >- protected IFigure primaryShape; >- >- /** >- * Notifier for listening and stop listening model element. >- */ >- private SelfCompartmentNotificationHelper notifier = new SelfCompartmentNotificationHelper(this, UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute(), (IHintedType)SysmlElementTypes.Property_3002); >- >- /** >- * @generated >- */ >- public ConstraintPropertyEditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy()); >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ConstraintPropertyItemSemanticEditPolicy()); >- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); >- >- //in Papyrus diagrams are not strongly synchronised >- //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.ConstraintPropertyCanonicalEditPolicy()); >- >- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); >- installEditPolicy(RequestConstants.REQ_CREATE, new CreateParameterEditPolicy()); >- // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies >- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); >- } >- >- /** >- * @generated >- */ >- protected LayoutEditPolicy createLayoutEditPolicy() { >- org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { >- >- protected EditPolicy createChildEditPolicy(EditPart child) { >- View childView = (View)child.getModel(); >- switch(SysmlVisualIDRegistry.getVisualID(childView)) { >- case Property2EditPart.VISUAL_ID: >- >- return new BorderItemResizableEditPolicy(); >- >- } >- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(result == null) { >- result = new NonResizableEditPolicy(); >- } >- return result; >- } >- >- protected Command getMoveChildrenCommand(Request request) { >- return null; >- } >- >- protected Command getCreateCommand(CreateRequest request) { >- return null; >- } >- }; >- return lep; >- } >- >- /** >- * @generated >- */ >- protected IFigure createNodeShape() { >- return primaryShape = new ConstraintPropertyFigureDescriptor(); >- } >- >- /** >- * @generated >- */ >- public ConstraintPropertyFigureDescriptor getPrimaryShape() { >- return (ConstraintPropertyFigureDescriptor)primaryShape; >- } >- >- /** >- * @generated >- */ >- protected boolean addFixedChild(EditPart childEditPart) { >- if(childEditPart instanceof ConstraintPropertyNameEditPart) { >- ((ConstraintPropertyNameEditPart)childEditPart).setLabel(getPrimaryShape().getConstraintPropertyFigureLabel()); >- return true; >- } >- if(childEditPart instanceof ConstraintLabelEditPart) { >- ((ConstraintLabelEditPart)childEditPart).setLabel(getPrimaryShape().getConstraintLabel()); >- return true; >- } >- >- //Papyrus Gencode :Affixed Parameter locator >- if(childEditPart instanceof Property2EditPart) { >- IBorderItemLocator locator = new ParameterPositionLocator(getMainFigure(), PositionConstants.NONE); >- getBorderedFigure().getBorderItemContainer().add(((Property2EditPart)childEditPart).getFigure(), locator); >- return true; >- } >- >- return false; >- } >- >- /** >- * @generated >- */ >- protected boolean removeFixedChild(EditPart childEditPart) { >- if(childEditPart instanceof ConstraintPropertyNameEditPart) { >- return true; >- } >- if(childEditPart instanceof ConstraintLabelEditPart) { >- return true; >- } >- if(childEditPart instanceof Property2EditPart) { >- getBorderedFigure().getBorderItemContainer().remove(((Property2EditPart)childEditPart).getFigure()); >- return true; >- } >- return false; >- } >- >- /** >- * @generated >- */ >- protected void addChildVisual(EditPart childEditPart, int index) { >- if(addFixedChild(childEditPart)) { >- return; >- } >- super.addChildVisual(childEditPart, -1); >- } >- >- /** >- * @generated >- */ >- protected void removeChildVisual(EditPart childEditPart) { >- if(removeFixedChild(childEditPart)) { >- return; >- } >- super.removeChildVisual(childEditPart); >- } >- >- /** >- * @generated >- */ >- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { >- if(editPart instanceof IBorderItemEditPart) { >- return getBorderedFigure().getBorderItemContainer(); >- } >- return getContentPane(); >- } >- >- /** >- * @generated >- */ >- protected NodeFigure createNodePlate() { >- String prefElementId = "ConstraintProperty"; >- IPreferenceStore store = SysmlDiagramEditorPlugin.getInstance().getPreferenceStore(); >- String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.WIDTH); >- String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.HEIGHT); >- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)); >- >- return result; >- } >- >- /** >- * Creates figure for this edit part. >- * >- * Body of this method does not depend on settings in generation model so you may safely remove >- * <i>generated</i> tag and modify it. >- * >- * @generated >- */ >- protected NodeFigure createMainFigure() { >- NodeFigure figure = createNodePlate(); >- figure.setLayoutManager(new StackLayout()); >- IFigure shape = createNodeShape(); >- figure.add(shape); >- contentPane = setupContentPane(shape); >- return figure; >- } >- >- /** >- * Default implementation treats passed figure as content pane. Respects layout one may have set >- * for generated figure. >- * >- * @param nodeShape >- * instance of generated figure class >- * @generated >- */ >- protected IFigure setupContentPane(IFigure nodeShape) { >- if(nodeShape.getLayoutManager() == null) { >- ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); >- layout.setSpacing(5); >- nodeShape.setLayoutManager(layout); >- } >- return nodeShape; // use nodeShape itself as contentPane >- } >- >- /** >- * @generated >- */ >- public IFigure getContentPane() { >- if(contentPane != null) { >- return contentPane; >- } >- return super.getContentPane(); >- } >- >- /** >- * @generated >- */ >- protected void setForegroundColor(Color color) { >- if(primaryShape != null) { >- primaryShape.setForegroundColor(color); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLineWidth(int width) { >- if(primaryShape instanceof Shape) { >- ((Shape)primaryShape).setLineWidth(width); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLineType(int style) { >- if(primaryShape instanceof Shape) { >- ((Shape)primaryShape).setLineStyle(style); >- } >- } >- >- /** >- * @generated >- */ >- public EditPart getPrimaryChildEditPart() { >- return getChildBySemanticHint(SysmlVisualIDRegistry.getType(ConstraintPropertyNameEditPart.VISUAL_ID)); >- } >- >- /** >- * @generated >- */ >- public class ConstraintPropertyFigureDescriptor extends RoundedRectangle { >- >- /** >- * @generated >- */ >- private CenteredWrappedLabel fConstraintPropertyFigureLabel; >- >- /** >- * @generated >- */ >- private WrappingLabel fConstraintLabel; >- >- /** >- * @generated >- */ >- public ConstraintPropertyFigureDescriptor() { >- >- GridLayout layoutThis = new GridLayout(); >- layoutThis.numColumns = 1; >- layoutThis.makeColumnsEqualWidth = true; >- this.setLayoutManager(layoutThis); >- >- this.setCornerDimensions(new Dimension(getMapMode().DPtoLP(25), getMapMode().DPtoLP(25))); >- this.setLineWidth(1); >- this.setMinimumSize(new Dimension(getMapMode().DPtoLP(200), getMapMode().DPtoLP(120))); >- createContents(); >- } >- >- /** >- * @generated >- */ >- private void createContents() { >- >- fConstraintPropertyFigureLabel = new CenteredWrappedLabel(); >- >- GridData constraintFConstraintPropertyFigureLabel = new GridData(); >- constraintFConstraintPropertyFigureLabel.verticalAlignment = GridData.END; >- constraintFConstraintPropertyFigureLabel.horizontalAlignment = GridData.CENTER; >- constraintFConstraintPropertyFigureLabel.horizontalIndent = 0; >- constraintFConstraintPropertyFigureLabel.horizontalSpan = 1; >- constraintFConstraintPropertyFigureLabel.verticalSpan = 1; >- constraintFConstraintPropertyFigureLabel.grabExcessHorizontalSpace = true; >- constraintFConstraintPropertyFigureLabel.grabExcessVerticalSpace = true; >- this.add(fConstraintPropertyFigureLabel, constraintFConstraintPropertyFigureLabel); >- >- fConstraintLabel = new WrappingLabel(); >- >- GridData constraintFConstraintLabel = new GridData(); >- constraintFConstraintLabel.verticalAlignment = GridData.BEGINNING; >- constraintFConstraintLabel.horizontalAlignment = GridData.END; >- constraintFConstraintLabel.horizontalIndent = 0; >- constraintFConstraintLabel.horizontalSpan = 1; >- constraintFConstraintLabel.verticalSpan = 1; >- constraintFConstraintLabel.grabExcessHorizontalSpace = true; >- constraintFConstraintLabel.grabExcessVerticalSpace = true; >- this.add(fConstraintLabel, constraintFConstraintLabel); >- >- } >- >- /** >- * @generated >- */ >- private boolean myUseLocalCoordinates = false; >- >- /** >- * @generated >- */ >- protected boolean useLocalCoordinates() { >- return myUseLocalCoordinates; >- } >- >- /** >- * @generated >- */ >- protected void setUseLocalCoordinates(boolean useLocalCoordinates) { >- myUseLocalCoordinates = useLocalCoordinates; >- } >- >- /** >- * @generated >- */ >- public CenteredWrappedLabel getConstraintPropertyFigureLabel() { >- return fConstraintPropertyFigureLabel; >- } >- >- /** >- * @generated >- */ >- public WrappingLabel getConstraintLabel() { >- return fConstraintLabel; >- } >- >- } >- >- /** >- * @generated >- */ >- @Override >- public Object getPreferredValue(EStructuralFeature feature) { >- IPreferenceStore preferenceStore = (IPreferenceStore)getDiagramPreferencesHint().getPreferenceStore(); >- Object result = null; >- >- if(feature == NotationPackage.eINSTANCE.getLineStyle_LineColor() || feature == NotationPackage.eINSTANCE.getFontStyle_FontColor() || feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { >- String prefColor = null; >- if(feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("ConstraintProperty", PreferenceConstantHelper.COLOR_LINE); >- } else if(feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("ConstraintProperty", PreferenceConstantHelper.COLOR_FONT); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("ConstraintProperty", PreferenceConstantHelper.COLOR_FILL); >- } >- result = FigureUtilities.RGBToInteger(PreferenceConverter.getColor((IPreferenceStore)preferenceStore, prefColor)); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_Transparency() || feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { >- String prefGradient = PreferenceConstantHelper.getElementConstant("ConstraintProperty", PreferenceConstantHelper.COLOR_GRADIENT); >- GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(preferenceStore.getString(prefGradient)); >- if(feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()) { >- result = new Integer(gradientPreferenceConverter.getTransparency()); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { >- result = gradientPreferenceConverter.getGradientData(); >- } >- } >- >- if(result == null) { >- result = getStructuralFeatureValue(feature); >- } >- return result; >- } >- >- /** >- * Activate a listener for to Handle notification for new owned property >- */ >- @Override >- public void activate() { >- super.activate(); >- EObject parent = resolveSemanticElement(); >- // listen constraint property and self base property >- notifier.listenObject(parent); >- if(parent instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)parent).getBase_Property(); >- notifier.listenObject(property); >- if(property.getType() != null) { >- notifier.listenObject(property.getType()); >- } >- } >- // ensure children parts are correctly initialized. >- SelfCompartmentNotificationHelper.updatePropertiesParts(this, UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute(), (IHintedType)SysmlElementTypes.Property_3002); >- } >- >- /** >- * Deactivate listeners to handle notification in the message occurence specification >- */ >- @Override >- public void deactivate() { >- notifier.unlistenAll(); >- super.deactivate(); >- } >- >- /** >- * Remove listeners to handle notification in the message occurence specification >- */ >- @Override >- public void removeNotify() { >- notifier.unlistenAll(); >- super.removeNotify(); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintPropertyNameEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintPropertyNameEditPart.java >deleted file mode 100644 >index 7b44fc3..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ConstraintPropertyNameEditPart.java >+++ /dev/null >@@ -1,792 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import java.util.Collections; >-import java.util.List; >- >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.Label; >-import org.eclipse.draw2d.geometry.Point; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.transaction.RecordingCommand; >-import org.eclipse.emf.transaction.RunnableWithResult; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gef.AccessibleEditPart; >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.requests.DirectEditRequest; >-import org.eclipse.gef.tools.DirectEditManager; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.gmf.runtime.notation.FontStyle; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.text.contentassist.IContentAssistProcessor; >-import org.eclipse.jface.viewers.ICellEditorValidator; >-import org.eclipse.jface.window.Window; >-import org.eclipse.papyrus.extensionpoints.editors.Activator; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; >-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; >-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.SysmlTextSelectionEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlParserProvider; >-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; >-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; >-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; >-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; >-import org.eclipse.papyrus.infra.emf.appearance.helper.NameLabelIconHelper; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.accessibility.AccessibleEvent; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * @generated >- */ >-public class ConstraintPropertyNameEditPart extends CompartmentEditPart implements ITextAwareEditPart { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 5001; >- >- /** >- * @generated >- */ >- private DirectEditManager manager; >- >- /** >- * @generated >- */ >- private IParser parser; >- >- /** >- * @generated >- */ >- private List<?> parserElements; >- >- /** >- * @generated >- */ >- private String defaultText; >- >- /** direct edition mode (default, undefined, registered editor, etc.) */ >- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; >- >- /** configuration from a registered edit dialog */ >- protected IDirectEditorConfiguration configuration; >- >- /** >- * @generated >- */ >- public ConstraintPropertyNameEditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new SysmlTextSelectionEditPolicy()); >- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); >- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ParametricEditPart.NodeLabelDragPolicy()); >- } >- >- /** >- * @generated >- */ >- protected String getLabelTextHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getText(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getText(); >- } else { >- return ((Label)figure).getText(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelTextHelper(IFigure figure, String text) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setText(text); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setText(text); >- } else { >- ((Label)figure).setText(text); >- } >- } >- >- /** >- * @generated >- */ >- protected Image getLabelIconHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getIcon(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getIcon(); >- } else { >- return ((Label)figure).getIcon(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelIconHelper(IFigure figure, Image icon) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setIcon(icon); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setIcon(icon); >- } else { >- ((Label)figure).setIcon(icon); >- } >- } >- >- /** >- * @generated >- */ >- public void setLabel(CenteredWrappedLabel figure) { >- unregisterVisuals(); >- setFigure(figure); >- defaultText = getLabelTextHelper(figure); >- registerVisuals(); >- refreshVisuals(); >- } >- >- /** >- * @generated >- */ >- protected List getModelChildren() { >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected EObject getParserElement() { >- return resolveSemanticElement(); >- } >- >- /** >- * @generated NOT >- */ >- protected Image getLabelIcon() { >- EObject parserElement = getParserElement(); >- if(parserElement == null) { >- return null; >- } >- >- List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); >- for(View view : views) { >- if(NameLabelIconHelper.showLabelIcon(view)) { >- return SysmlElementTypes.getImage(parserElement.eClass()); >- } >- } >- return null; >- >- } >- >- /** >- * @generated >- */ >- protected String getLabelText() { >- String text = null; >- EObject parserElement = getParserElement(); >- if(parserElement != null && getParser() != null) { >- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); >- } >- if(text == null || text.length() == 0) { >- text = defaultText; >- } >- return text; >- } >- >- /** >- * @generated >- */ >- public void setLabelText(String text) { >- setLabelTextHelper(getFigure(), text); >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- public String getEditText() { >- if(getParserElement() == null || getParser() == null) { >- return ""; //$NON-NLS-1$ >- } >- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); >- } >- >- /** >- * @generated >- */ >- protected boolean isEditable() { >- return getParser() != null; >- } >- >- /** >- * @generated >- */ >- public ICellEditorValidator getEditTextValidator() { >- return new ICellEditorValidator() { >- >- public String isValid(final Object value) { >- if(value instanceof String) { >- final EObject element = getParserElement(); >- final IParser parser = getParser(); >- try { >- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() { >- >- public void run() { >- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); >- } >- }); >- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); >- } catch (InterruptedException ie) { >- ie.printStackTrace(); >- } >- } >- >- // shouldn't get here >- return null; >- } >- }; >- } >- >- /** >- * @generated >- */ >- public IContentAssistProcessor getCompletionProcessor() { >- if(getParserElement() == null || getParser() == null) { >- return null; >- } >- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); >- } >- >- /** >- * @generated >- */ >- public ParserOptions getParserOptions() { >- return ParserOptions.NONE; >- } >- >- /** >- * @generated >- */ >- public IParser getParser() { >- if(parser == null) { >- parser = SysmlParserProvider.getParser(SysmlElementTypes.ConstraintProperty_2003, getParserElement(), SysmlVisualIDRegistry.getType(org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyNameEditPart.VISUAL_ID)); >- } >- return parser; >- } >- >- /** >- * @generated >- */ >- protected DirectEditManager getManager() { >- if(manager == null) { >- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), SysmlEditPartFactory.getTextCellEditorLocator(this))); >- } >- return manager; >- } >- >- /** >- * @generated >- */ >- protected void setManager(DirectEditManager manager) { >- this.manager = manager; >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit() { >- getManager().show(); >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit(Point eventLocation) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); >- } >- } >- >- /** >- * @generated >- */ >- private void performDirectEdit(char initialCharacter) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(initialCharacter); >- } else { >- performDirectEdit(); >- } >- } >- >- /** >- * @generated >- */ >- protected void performDirectEditRequest(Request request) { >- >- final Request theRequest = request; >- >- if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { >- directEditionMode = getDirectEditionType(); >- } >- switch(directEditionMode) { >- case IDirectEdition.NO_DIRECT_EDITION: >- // no direct edition mode => does nothing >- return; >- case IDirectEdition.EXTENDED_DIRECT_EDITOR: >- updateExtendedEditorConfiguration(); >- if(configuration == null || configuration.getLanguage() == null) { >- performDefaultDirectEditorEdit(theRequest); >- } else { >- configuration.preEditAction(resolveSemanticElement()); >- Dialog dialog = null; >- if(configuration instanceof IPopupEditorConfiguration) { >- IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); >- helper.showEditor(); >- return; >- } else if(configuration instanceof IAdvancedEditorConfiguration) { >- dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); >- } else if(configuration instanceof IDirectEditorConfiguration) { >- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration)configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration)configuration); >- } else { >- return; >- } >- final Dialog finalDialog = dialog; >- >- if(Window.OK == dialog.open()) { >- TransactionalEditingDomain domain = getEditingDomain(); >- RecordingCommand command = new RecordingCommand(domain, "Edit Label") { >- >- @Override >- protected void doExecute() { >- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); >- >- } >- }; >- domain.getCommandStack().execute(command); >- } >- } >- break; >- case IDirectEdition.DEFAULT_DIRECT_EDITOR: >- >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- break; >- default: >- break; >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshVisuals() { >- super.refreshVisuals(); >- refreshLabel(); >- refreshFont(); >- refreshFontColor(); >- refreshUnderline(); >- refreshStrikeThrough(); >- } >- >- /** >- * @generated >- */ >- protected void refreshLabel() { >- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); >- if(maskLabelPolicy == null) { >- setLabelTextHelper(getFigure(), getLabelText()); >- setLabelIconHelper(getFigure(), getLabelIcon()); >- } >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshUnderline() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshStrikeThrough() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshFont() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null) { >- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); >- setFont(fontData); >- } >- } >- >- /** >- * @generated >- */ >- protected void setFontColor(Color color) { >- getFigure().setForegroundColor(color); >- } >- >- /** >- * @generated >- */ >- protected void addSemanticListeners() { >- if(getParser() instanceof ISemanticParser) { >- EObject element = resolveSemanticElement(); >- parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); >- for(int i = 0; i < parserElements.size(); i++) { >- addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ >- } >- } else { >- super.addSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected void removeSemanticListeners() { >- if(parserElements != null) { >- for(int i = 0; i < parserElements.size(); i++) { >- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ >- } >- } else { >- super.removeSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected AccessibleEditPart getAccessibleEditPart() { >- if(accessibleEP == null) { >- accessibleEP = new AccessibleGraphicalEditPart() { >- >- public void getName(AccessibleEvent e) { >- e.result = getLabelTextHelper(getFigure()); >- } >- }; >- } >- return accessibleEP; >- } >- >- /** >- * @generated >- */ >- private View getFontStyleOwnerView() { >- return getPrimaryView(); >- } >- >- /** >- * Returns the kind of associated editor for direct edition. >- * >- * @return an <code>int</code> corresponding to the kind of direct editor, @see >- * org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition >- * @generated >- */ >- public int getDirectEditionType() { >- if(checkExtendedEditor()) { >- initExtendedEditorConfiguration(); >- return IDirectEdition.EXTENDED_DIRECT_EDITOR; >- } >- if(checkDefaultEdition()) { >- return IDirectEdition.DEFAULT_DIRECT_EDITOR; >- } >- >- // not a named element. no specific editor => do nothing >- return IDirectEdition.NO_DIRECT_EDITION; >- } >- >- /** >- * Checks if an extended editor is present. >- * >- * @return <code>true</code> if an extended editor is present. >- * @generated NOT >- */ >- protected boolean checkExtendedEditor() { >- EObject semanticElement = resolveSemanticElement(); >- if(semanticElement != null && semanticElement instanceof ConstraintProperty) { >- boolean hasSpecificEditorConfiguration = DirectEditorsUtil.hasSpecificEditorConfiguration(((ConstraintProperty)semanticElement).getBase_Property().eClass().getInstanceClassName()); >- >- return hasSpecificEditorConfiguration; >- } >- return false; >- } >- >- /** >- * Checks if a default direct edition is available >- * >- * @return <code>true</code> if a default direct edition is available >- * @generated >- */ >- protected boolean checkDefaultEdition() { >- return (getParser() != null); >- } >- >- /** >- * Initializes the extended editor configuration >- * >- * @generated NOT >- */ >- protected void initExtendedEditorConfiguration() { >- if(configuration == null) { >- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("")) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else { >- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.SYSML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); >- } >- } >- } >- >- /** >- * Updates the preference configuration >- */ >- protected void updateExtendedEditorConfiguration() { >- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { >- configuration = null; >- } >- } >- >- /** >- * Performs the direct edit usually used by GMF editors. >- * >- * @param theRequest >- * the direct edit request that starts the direct edit system >- */ >- protected void performDefaultDirectEditorEdit(final Request theRequest) { >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- } >- >- /** >- * @generated >- */ >- protected void addNotationalListeners() { >- super.addNotationalListeners(); >- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- protected void removeNotationalListeners() { >- super.removeNotationalListeners(); >- removeListenerFilter("PrimaryView"); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- protected void handleNotificationEvent(Notification event) { >- refreshLabel(); >- Object feature = event.getFeature(); >- if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { >- Integer c = (Integer)event.getNewValue(); >- setFontColor(DiagramColorRegistry.getInstance().getColor(c)); >- } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { >- refreshUnderline(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { >- refreshStrikeThrough(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { >- refreshFont(); >- } else { >- if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { >- refreshLabel(); >- } >- if(getParser() instanceof ISemanticParser) { >- ISemanticParser modelParser = (ISemanticParser)getParser(); >- if(modelParser.areSemanticElementsAffected(null, event)) { >- removeSemanticListeners(); >- if(resolveSemanticElement() != null) { >- addSemanticListeners(); >- } >- refreshLabel(); >- } >- } >- } >- >- if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { >- refreshLabel(); >- } >- >- super.handleNotificationEvent(event); >- } >- >- /** >- * @generated >- */ >- protected IFigure createFigure() { >- // Parent should assign one using setLabel() method >- return null; >- } >- >- private static final String ADD_PARENT_MODEL = "AddParentModel"; >- >- /** >- * @generated >- */ >- public void activate() { >- super.activate(); >- addOwnerElementListeners(); >- } >- >- /** >- * @generated >- */ >- protected void addOwnerElementListeners() { >- addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); //$NON-NLS-1$ >- >- } >- >- /** >- * @generated >- */ >- public void deactivate() { >- removeOwnerElementListeners(); >- super.deactivate(); >- >- } >- >- /** >- * @generated >- */ >- protected void removeOwnerElementListeners() { >- removeListenerFilter(ADD_PARENT_MODEL); >- >- } >- >- // @Override >- // public EObject resolveSemanticElement() { >- // EObject semanticElement = super.resolveSemanticElement(); >- // if (semanticElement instanceof ConstraintProperty) { >- // semanticElement = ((ConstraintProperty) semanticElement).getBase_Property(); >- // } >- // return semanticElement; >- // } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ParametricEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ParametricEditPart.java >deleted file mode 100644 >index cceaf0d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/ParametricEditPart.java >+++ /dev/null >@@ -1,147 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import java.util.Collections; >-import java.util.List; >- >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.gef.GraphicalEditPart; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.editpolicies.NonResizableEditPolicy; >-import org.eclipse.gef.handles.MoveHandle; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.CustomDiagramDragDropEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.ParametricItemSemanticEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.providers.ViewInfo; >-import org.eclipse.papyrus.uml.diagram.common.util.MDTUtil; >- >-/** >- * @generated >- */ >-public class ParametricEditPart extends DiagramEditPart { >- >- /** >- * @generated >- */ >- public final static String MODEL_ID = "Parametric"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 1000; >- >- /** >- * @generated >- */ >- public ParametricEditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new DuplicatePasteEditPolicy()); >- >- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ParametricItemSemanticEditPolicy()); >- >- //in Papyrus diagrams are not strongly synchronised >- //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.ParametricCanonicalEditPolicy()); >- >- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); >- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE); >- } >- >- /** >- * @generated >- */ >- /* package-local */static class NodeLabelDragPolicy extends NonResizableEditPolicy { >- >- /** >- * @generated >- */ >- @SuppressWarnings("rawtypes") >- protected List createSelectionHandles() { >- MoveHandle h = new MoveHandle((GraphicalEditPart)getHost()); >- h.setBorder(null); >- return Collections.singletonList(h); >- } >- >- /** >- * @generated >- */ >- public Command getCommand(Request request) { >- return null; >- } >- >- /** >- * @generated >- */ >- public boolean understandsRequest(Request request) { >- return false; >- } >- } >- >- /** >- * @generated >- */ >- /* package-local */static class LinkLabelDragPolicy extends NonResizableLabelEditPolicy { >- >- /** >- * @generated >- */ >- @SuppressWarnings("rawtypes") >- protected List createSelectionHandles() { >- MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); >- mh.setBorder(null); >- return Collections.singletonList(mh); >- } >- } >- >- /** >- * @generated >- */ >- protected void handleNotificationEvent(Notification event) { >- >- super.handleNotificationEvent(event); >- if(event.getNotifier() instanceof EAnnotation) { >- EAnnotation eAnnotation = (EAnnotation)event.getNotifier(); >- if(eAnnotation.getSource() != null && eAnnotation.getSource().equals(MDTUtil.FilterViewAndLabelsSource)) { >- //modification form MOSKitt approach, canonical policies are not called >- MDTUtil.filterDiagramViews(this.getDiagramView()); >- } >- } >- } >- >- /** >- * @generated >- */ >- public Object getAdapter(Class adapter) { >- >- if(adapter != null && adapter.equals(ViewInfo.class)) { >- return SysmlVisualIDRegistry.getDiagramViewInfo(); >- } >- return super.getAdapter(adapter); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/Property2EditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/Property2EditPart.java >deleted file mode 100644 >index cdd49de..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/Property2EditPart.java >+++ /dev/null >@@ -1,383 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import java.util.ArrayList; >-import java.util.Collections; >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.PositionConstants; >-import org.eclipse.draw2d.RectangleFigure; >-import org.eclipse.draw2d.Shape; >-import org.eclipse.draw2d.StackLayout; >-import org.eclipse.draw2d.geometry.Dimension; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.GraphicalEditPart; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.editpolicies.LayoutEditPolicy; >-import org.eclipse.gef.editpolicies.NonResizableEditPolicy; >-import org.eclipse.gef.handles.MoveHandle; >-import org.eclipse.gef.requests.CreateRequest; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >-import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; >-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.preference.PreferenceConverter; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromDiagramEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromModelEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.OpenDiagramEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.Property2ItemSemanticEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; >-import org.eclipse.swt.graphics.Color; >- >-/** >- * @generated >- */ >-public class Property2EditPart extends >- >-BorderedBorderItemEditPart { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 3002; >- >- /** >- * @generated >- */ >- protected IFigure contentPane; >- >- /** >- * @generated >- */ >- protected IFigure primaryShape; >- >- /** >- * @generated >- */ >- public Property2EditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy()); >- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new Property2ItemSemanticEditPolicy()); >- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); >- installEditPolicy(EditPolicyRoles.OPEN_ROLE, new OpenDiagramEditPolicy()); >- installEditPolicy(RequestConstants.REQ_DELETE, new NoDeleteFromDiagramEditPolicy()); >- installEditPolicy(RequestConstants.REQ_SEMANTIC_WRAPPER, new NoDeleteFromModelEditPolicy()); >- // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies >- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); >- } >- >- /** >- * @generated >- */ >- protected LayoutEditPolicy createLayoutEditPolicy() { >- org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { >- >- protected EditPolicy createChildEditPolicy(EditPart child) { >- View childView = (View)child.getModel(); >- switch(SysmlVisualIDRegistry.getVisualID(childView)) { >- case PropertyName2EditPart.VISUAL_ID: >- return new BorderItemSelectionEditPolicy() { >- >- protected List createSelectionHandles() { >- MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); >- mh.setBorder(null); >- return Collections.singletonList(mh); >- } >- }; >- } >- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(result == null) { >- result = new NonResizableEditPolicy(); >- } >- return result; >- } >- >- protected Command getMoveChildrenCommand(Request request) { >- return null; >- } >- >- protected Command getCreateCommand(CreateRequest request) { >- return null; >- } >- }; >- return lep; >- } >- >- /** >- * @generated >- */ >- protected IFigure createNodeShape() { >- return primaryShape = new ParameterDescriptor(); >- } >- >- /** >- * @generated >- */ >- public ParameterDescriptor getPrimaryShape() { >- return (ParameterDescriptor)primaryShape; >- } >- >- /** >- * @generated >- */ >- protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { >- if(borderItemEditPart instanceof PropertyName2EditPart) { >- BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); >- locator.setBorderItemOffset(new Dimension(-20, -20)); >- borderItemContainer.add(borderItemEditPart.getFigure(), locator); >- } else { >- super.addBorderItem(borderItemContainer, borderItemEditPart); >- } >- } >- >- /** >- * @generated >- */ >- protected NodeFigure createNodePlate() { >- String prefElementId = "Property"; >- IPreferenceStore store = SysmlDiagramEditorPlugin.getInstance().getPreferenceStore(); >- String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.WIDTH); >- String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.HEIGHT); >- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)); >- >- //FIXME: workaround for #154536 >- result.getBounds().setSize(result.getPreferredSize()); >- return result; >- } >- >- /** >- * Creates figure for this edit part. >- * >- * Body of this method does not depend on settings in generation model so you may safely remove >- * <i>generated</i> tag and modify it. >- * >- * @generated >- */ >- protected NodeFigure createMainFigure() { >- NodeFigure figure = createNodePlate(); >- figure.setLayoutManager(new StackLayout()); >- IFigure shape = createNodeShape(); >- figure.add(shape); >- contentPane = setupContentPane(shape); >- return figure; >- } >- >- /** >- * Default implementation treats passed figure as content pane. Respects layout one may have set >- * for generated figure. >- * >- * @param nodeShape >- * instance of generated figure class >- * @generated >- */ >- protected IFigure setupContentPane(IFigure nodeShape) { >- return nodeShape; // use nodeShape itself as contentPane >- } >- >- /** >- * @generated >- */ >- public IFigure getContentPane() { >- if(contentPane != null) { >- return contentPane; >- } >- return super.getContentPane(); >- } >- >- /** >- * @generated >- */ >- protected void setForegroundColor(Color color) { >- if(primaryShape != null) { >- primaryShape.setForegroundColor(color); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLineWidth(int width) { >- if(primaryShape instanceof Shape) { >- ((Shape)primaryShape).setLineWidth(width); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLineType(int style) { >- if(primaryShape instanceof Shape) { >- ((Shape)primaryShape).setLineStyle(style); >- } >- } >- >- /** >- * @generated >- */ >- public EditPart getPrimaryChildEditPart() { >- return getChildBySemanticHint(SysmlVisualIDRegistry.getType(PropertyName2EditPart.VISUAL_ID)); >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMARelTypesOnSource() { >- ArrayList<IElementType> types = new ArrayList<IElementType>(1); >- types.add(SysmlElementTypes.Connector_4001); >- return types; >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMARelTypesOnSourceAndTarget(IGraphicalEditPart targetEditPart) { >- LinkedList<IElementType> types = new LinkedList<IElementType>(); >- if(targetEditPart instanceof PropertyEditPart) { >- types.add(SysmlElementTypes.Connector_4001); >- } >- if(targetEditPart instanceof org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart) { >- types.add(SysmlElementTypes.Connector_4001); >- } >- return types; >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMATypesForTarget(IElementType relationshipType) { >- LinkedList<IElementType> types = new LinkedList<IElementType>(); >- if(relationshipType == SysmlElementTypes.Connector_4001) { >- types.add(SysmlElementTypes.Property_2005); >- types.add(SysmlElementTypes.Property_3002); >- } >- return types; >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMARelTypesOnTarget() { >- ArrayList<IElementType> types = new ArrayList<IElementType>(1); >- types.add(SysmlElementTypes.Connector_4001); >- return types; >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMATypesForSource(IElementType relationshipType) { >- LinkedList<IElementType> types = new LinkedList<IElementType>(); >- if(relationshipType == SysmlElementTypes.Connector_4001) { >- types.add(SysmlElementTypes.Property_2005); >- types.add(SysmlElementTypes.Property_3002); >- } >- return types; >- } >- >- /** >- * @generated >- */ >- public class ParameterDescriptor extends RectangleFigure { >- >- /** >- * @generated >- */ >- public ParameterDescriptor() { >- this.setLineWidth(1); >- this.setPreferredSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(16))); >- } >- >- /** >- * @generated >- */ >- private boolean myUseLocalCoordinates = false; >- >- /** >- * @generated >- */ >- protected boolean useLocalCoordinates() { >- return myUseLocalCoordinates; >- } >- >- /** >- * @generated >- */ >- protected void setUseLocalCoordinates(boolean useLocalCoordinates) { >- myUseLocalCoordinates = useLocalCoordinates; >- } >- >- } >- >- /** >- * @generated >- */ >- @Override >- public Object getPreferredValue(EStructuralFeature feature) { >- IPreferenceStore preferenceStore = (IPreferenceStore)getDiagramPreferencesHint().getPreferenceStore(); >- Object result = null; >- >- if(feature == NotationPackage.eINSTANCE.getLineStyle_LineColor() || feature == NotationPackage.eINSTANCE.getFontStyle_FontColor() || feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { >- String prefColor = null; >- if(feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("Property", PreferenceConstantHelper.COLOR_LINE); >- } else if(feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("Property", PreferenceConstantHelper.COLOR_FONT); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("Property", PreferenceConstantHelper.COLOR_FILL); >- } >- result = FigureUtilities.RGBToInteger(PreferenceConverter.getColor((IPreferenceStore)preferenceStore, prefColor)); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_Transparency() || feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { >- String prefGradient = PreferenceConstantHelper.getElementConstant("Property", PreferenceConstantHelper.COLOR_GRADIENT); >- GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(preferenceStore.getString(prefGradient)); >- if(feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()) { >- result = new Integer(gradientPreferenceConverter.getTransparency()); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { >- result = gradientPreferenceConverter.getGradientData(); >- } >- } >- >- if(result == null) { >- result = getStructuralFeatureValue(feature); >- } >- return result; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyEditPart.java >deleted file mode 100644 >index 4d954cc..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyEditPart.java >+++ /dev/null >@@ -1,427 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import java.util.ArrayList; >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.RectangleFigure; >-import org.eclipse.draw2d.Shape; >-import org.eclipse.draw2d.StackLayout; >-import org.eclipse.draw2d.geometry.Dimension; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.editpolicies.LayoutEditPolicy; >-import org.eclipse.gef.editpolicies.NonResizableEditPolicy; >-import org.eclipse.gef.requests.CreateRequest; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; >-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.preference.PreferenceConverter; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.PropertyItemSemanticEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.uml.diagram.common.draw2d.CenterLayout; >-import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; >-import org.eclipse.swt.graphics.Color; >- >-/** >- * @generated >- */ >-public class PropertyEditPart extends >- >-ShapeNodeEditPart { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 2005; >- >- /** >- * @generated >- */ >- protected IFigure contentPane; >- >- /** >- * @generated >- */ >- protected IFigure primaryShape; >- >- /** >- * @generated >- */ >- public PropertyEditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new PropertyItemSemanticEditPolicy()); >- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); >- // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies >- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); >- } >- >- /** >- * @generated >- */ >- protected LayoutEditPolicy createLayoutEditPolicy() { >- org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { >- >- protected EditPolicy createChildEditPolicy(EditPart child) { >- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(result == null) { >- result = new NonResizableEditPolicy(); >- } >- return result; >- } >- >- protected Command getMoveChildrenCommand(Request request) { >- return null; >- } >- >- protected Command getCreateCommand(CreateRequest request) { >- return null; >- } >- }; >- return lep; >- } >- >- /** >- * @generated >- */ >- protected IFigure createNodeShape() { >- return primaryShape = new PropertyFigure(); >- } >- >- /** >- * @generated >- */ >- public PropertyFigure getPrimaryShape() { >- return (PropertyFigure)primaryShape; >- } >- >- /** >- * @generated >- */ >- protected boolean addFixedChild(EditPart childEditPart) { >- if(childEditPart instanceof PropertyNameEditPart) { >- ((PropertyNameEditPart)childEditPart).setLabel(getPrimaryShape().getPropertyFigureLabel()); >- return true; >- } >- >- return false; >- } >- >- /** >- * @generated >- */ >- protected boolean removeFixedChild(EditPart childEditPart) { >- if(childEditPart instanceof PropertyNameEditPart) { >- return true; >- } >- return false; >- } >- >- /** >- * @generated >- */ >- protected void addChildVisual(EditPart childEditPart, int index) { >- if(addFixedChild(childEditPart)) { >- return; >- } >- super.addChildVisual(childEditPart, -1); >- } >- >- /** >- * @generated >- */ >- protected void removeChildVisual(EditPart childEditPart) { >- if(removeFixedChild(childEditPart)) { >- return; >- } >- super.removeChildVisual(childEditPart); >- } >- >- /** >- * @generated >- */ >- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { >- return getContentPane(); >- } >- >- /** >- * @generated >- */ >- protected NodeFigure createNodePlate() { >- String prefElementId = "Property"; >- IPreferenceStore store = SysmlDiagramEditorPlugin.getInstance().getPreferenceStore(); >- String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.WIDTH); >- String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.HEIGHT); >- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)); >- >- return result; >- } >- >- /** >- * Creates figure for this edit part. >- * >- * Body of this method does not depend on settings in generation model so you may safely remove >- * <i>generated</i> tag and modify it. >- * >- * @generated >- */ >- protected NodeFigure createNodeFigure() { >- NodeFigure figure = createNodePlate(); >- figure.setLayoutManager(new StackLayout()); >- IFigure shape = createNodeShape(); >- figure.add(shape); >- contentPane = setupContentPane(shape); >- return figure; >- } >- >- /** >- * Default implementation treats passed figure as content pane. Respects layout one may have set >- * for generated figure. >- * >- * @param nodeShape >- * instance of generated figure class >- * @generated >- */ >- protected IFigure setupContentPane(IFigure nodeShape) { >- if(nodeShape.getLayoutManager() == null) { >- ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); >- layout.setSpacing(5); >- nodeShape.setLayoutManager(layout); >- } >- return nodeShape; // use nodeShape itself as contentPane >- } >- >- /** >- * @generated >- */ >- public IFigure getContentPane() { >- if(contentPane != null) { >- return contentPane; >- } >- return super.getContentPane(); >- } >- >- /** >- * @generated >- */ >- protected void setForegroundColor(Color color) { >- if(primaryShape != null) { >- primaryShape.setForegroundColor(color); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLineWidth(int width) { >- if(primaryShape instanceof Shape) { >- ((Shape)primaryShape).setLineWidth(width); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLineType(int style) { >- if(primaryShape instanceof Shape) { >- ((Shape)primaryShape).setLineStyle(style); >- } >- } >- >- /** >- * @generated >- */ >- public EditPart getPrimaryChildEditPart() { >- return getChildBySemanticHint(SysmlVisualIDRegistry.getType(PropertyNameEditPart.VISUAL_ID)); >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMARelTypesOnSource() { >- ArrayList<IElementType> types = new ArrayList<IElementType>(1); >- types.add(SysmlElementTypes.Connector_4001); >- return types; >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMARelTypesOnSourceAndTarget(IGraphicalEditPart targetEditPart) { >- LinkedList<IElementType> types = new LinkedList<IElementType>(); >- if(targetEditPart instanceof org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart) { >- types.add(SysmlElementTypes.Connector_4001); >- } >- if(targetEditPart instanceof Property2EditPart) { >- types.add(SysmlElementTypes.Connector_4001); >- } >- return types; >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMATypesForTarget(IElementType relationshipType) { >- LinkedList<IElementType> types = new LinkedList<IElementType>(); >- if(relationshipType == SysmlElementTypes.Connector_4001) { >- types.add(SysmlElementTypes.Property_2005); >- types.add(SysmlElementTypes.Property_3002); >- } >- return types; >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMARelTypesOnTarget() { >- ArrayList<IElementType> types = new ArrayList<IElementType>(1); >- types.add(SysmlElementTypes.Connector_4001); >- return types; >- } >- >- /** >- * @generated >- */ >- public List<IElementType> getMATypesForSource(IElementType relationshipType) { >- LinkedList<IElementType> types = new LinkedList<IElementType>(); >- if(relationshipType == SysmlElementTypes.Connector_4001) { >- types.add(SysmlElementTypes.Property_2005); >- types.add(SysmlElementTypes.Property_3002); >- } >- return types; >- } >- >- /** >- * @generated >- */ >- public class PropertyFigure extends RectangleFigure { >- >- /** >- * @generated >- */ >- private CenteredWrappedLabel fPropertyFigureLabel; >- >- /** >- * @generated >- */ >- public PropertyFigure() { >- >- CenterLayout layoutThis = new CenterLayout(); >- >- this.setLayoutManager(layoutThis); >- >- this.setLineWidth(1); >- this.setMinimumSize(new Dimension(getMapMode().DPtoLP(100), getMapMode().DPtoLP(40))); >- createContents(); >- } >- >- /** >- * @generated >- */ >- private void createContents() { >- >- fPropertyFigureLabel = new CenteredWrappedLabel(); >- >- this.add(fPropertyFigureLabel); >- >- } >- >- /** >- * @generated >- */ >- private boolean myUseLocalCoordinates = false; >- >- /** >- * @generated >- */ >- protected boolean useLocalCoordinates() { >- return myUseLocalCoordinates; >- } >- >- /** >- * @generated >- */ >- protected void setUseLocalCoordinates(boolean useLocalCoordinates) { >- myUseLocalCoordinates = useLocalCoordinates; >- } >- >- /** >- * @generated >- */ >- public CenteredWrappedLabel getPropertyFigureLabel() { >- return fPropertyFigureLabel; >- } >- >- } >- >- /** >- * @generated >- */ >- @Override >- public Object getPreferredValue(EStructuralFeature feature) { >- IPreferenceStore preferenceStore = (IPreferenceStore)getDiagramPreferencesHint().getPreferenceStore(); >- Object result = null; >- >- if(feature == NotationPackage.eINSTANCE.getLineStyle_LineColor() || feature == NotationPackage.eINSTANCE.getFontStyle_FontColor() || feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { >- String prefColor = null; >- if(feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("Property", PreferenceConstantHelper.COLOR_LINE); >- } else if(feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("Property", PreferenceConstantHelper.COLOR_FONT); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { >- prefColor = PreferenceConstantHelper.getElementConstant("Property", PreferenceConstantHelper.COLOR_FILL); >- } >- result = FigureUtilities.RGBToInteger(PreferenceConverter.getColor((IPreferenceStore)preferenceStore, prefColor)); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_Transparency() || feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { >- String prefGradient = PreferenceConstantHelper.getElementConstant("Property", PreferenceConstantHelper.COLOR_GRADIENT); >- GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(preferenceStore.getString(prefGradient)); >- if(feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()) { >- result = new Integer(gradientPreferenceConverter.getTransparency()); >- } else if(feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { >- result = gradientPreferenceConverter.getGradientData(); >- } >- } >- >- if(result == null) { >- result = getStructuralFeatureValue(feature); >- } >- return result; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyName2EditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyName2EditPart.java >deleted file mode 100644 >index 6e7f3e2..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyName2EditPart.java >+++ /dev/null >@@ -1,754 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import java.util.Collections; >-import java.util.List; >- >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.Label; >-import org.eclipse.draw2d.geometry.Point; >-import org.eclipse.draw2d.geometry.Rectangle; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.transaction.RecordingCommand; >-import org.eclipse.emf.transaction.RunnableWithResult; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gef.AccessibleEditPart; >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.requests.DirectEditRequest; >-import org.eclipse.gef.tools.DirectEditManager; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; >-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.gmf.runtime.notation.FontStyle; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.text.contentassist.IContentAssistProcessor; >-import org.eclipse.jface.viewers.ICellEditorValidator; >-import org.eclipse.jface.window.Window; >-import org.eclipse.papyrus.extensionpoints.editors.Activator; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; >-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; >-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromDiagramEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.NoDeleteFromModelEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.SysmlTextSelectionEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlParserProvider; >-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; >-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.accessibility.AccessibleEvent; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * @generated >- */ >-public class PropertyName2EditPart >- >-extends LabelEditPart >- >-implements ITextAwareEditPart, IBorderItemEditPart { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 5003; >- >- /** >- * @generated >- */ >- private DirectEditManager manager; >- >- /** >- * @generated >- */ >- private IParser parser; >- >- /** >- * @generated >- */ >- private List<?> parserElements; >- >- /** >- * @generated >- */ >- private String defaultText; >- >- /** direct edition mode (default, undefined, registered editor, etc.) */ >- // disable direct edition for property of a constraint property >- protected int directEditionMode = IDirectEdition.NO_DIRECT_EDITION; >- >- /** configuration from a registered edit dialog */ >- protected IDirectEditorConfiguration configuration; >- >- /** >- * @generated >- */ >- static { >- registerSnapBackPosition(SysmlVisualIDRegistry.getType(org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyName2EditPart.VISUAL_ID), new Point(0, 0)); >- } >- >- /** >- * @generated >- */ >- public PropertyName2EditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); >- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new SysmlTextSelectionEditPolicy()); >- installEditPolicy(RequestConstants.REQ_DELETE, new NoDeleteFromDiagramEditPolicy()); >- installEditPolicy(RequestConstants.REQ_SEMANTIC_WRAPPER, new NoDeleteFromModelEditPolicy()); >- } >- >- /** >- * @generated >- */ >- public IBorderItemLocator getBorderItemLocator() { >- IFigure parentFigure = getFigure().getParent(); >- if(parentFigure != null && parentFigure.getLayoutManager() != null) { >- Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); >- return (IBorderItemLocator)constraint; >- } >- return null; >- } >- >- /** >- * @generated >- */ >- public void refreshBounds() { >- int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); >- int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); >- int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); >- int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); >- getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); >- } >- >- /** >- * @generated >- */ >- protected String getLabelTextHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getText(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getText(); >- } else { >- return ((Label)figure).getText(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelTextHelper(IFigure figure, String text) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setText(text); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setText(text); >- } else { >- ((Label)figure).setText(text); >- } >- } >- >- /** >- * @generated >- */ >- protected Image getLabelIconHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getIcon(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getIcon(); >- } else { >- return ((Label)figure).getIcon(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelIconHelper(IFigure figure, Image icon) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setIcon(icon); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setIcon(icon); >- } else { >- ((Label)figure).setIcon(icon); >- } >- } >- >- /** >- * @generated >- */ >- public void setLabel(IFigure figure) { >- unregisterVisuals(); >- setFigure(figure); >- defaultText = getLabelTextHelper(figure); >- registerVisuals(); >- refreshVisuals(); >- } >- >- /** >- * @generated >- */ >- protected List getModelChildren() { >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected EObject getParserElement() { >- return resolveSemanticElement(); >- } >- >- /** >- * @generated >- */ >- protected Image getLabelIcon() { >- return null; >- } >- >- /** >- * @generated >- */ >- protected String getLabelText() { >- String text = null; >- EObject parserElement = getParserElement(); >- if(parserElement != null && getParser() != null) { >- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); >- } >- if(text == null || text.length() == 0) { >- text = defaultText; >- } >- return text; >- } >- >- /** >- * @generated >- */ >- public void setLabelText(String text) { >- setLabelTextHelper(getFigure(), text); >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- public String getEditText() { >- if(getParserElement() == null || getParser() == null) { >- return ""; //$NON-NLS-1$ >- } >- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); >- } >- >- /** >- * @generated >- */ >- protected boolean isEditable() { >- return getParser() != null; >- } >- >- /** >- * @generated >- */ >- public ICellEditorValidator getEditTextValidator() { >- return new ICellEditorValidator() { >- >- public String isValid(final Object value) { >- if(value instanceof String) { >- final EObject element = getParserElement(); >- final IParser parser = getParser(); >- try { >- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() { >- >- public void run() { >- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); >- } >- }); >- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); >- } catch (InterruptedException ie) { >- ie.printStackTrace(); >- } >- } >- >- // shouldn't get here >- return null; >- } >- }; >- } >- >- /** >- * @generated >- */ >- public IContentAssistProcessor getCompletionProcessor() { >- if(getParserElement() == null || getParser() == null) { >- return null; >- } >- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); >- } >- >- /** >- * @generated >- */ >- public ParserOptions getParserOptions() { >- return ParserOptions.NONE; >- } >- >- /** >- * @generated >- */ >- public IParser getParser() { >- if(parser == null) { >- parser = SysmlParserProvider.getParser(SysmlElementTypes.Property_3002, getParserElement(), SysmlVisualIDRegistry.getType(org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyName2EditPart.VISUAL_ID)); >- } >- return parser; >- } >- >- /** >- * @generated >- */ >- protected DirectEditManager getManager() { >- if(manager == null) { >- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), SysmlEditPartFactory.getTextCellEditorLocator(this))); >- } >- return manager; >- } >- >- /** >- * @generated >- */ >- protected void setManager(DirectEditManager manager) { >- this.manager = manager; >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit() { >- getManager().show(); >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit(Point eventLocation) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); >- } >- } >- >- /** >- * @generated >- */ >- private void performDirectEdit(char initialCharacter) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(initialCharacter); >- } else { >- performDirectEdit(); >- } >- } >- >- /** >- * @generated >- */ >- protected void performDirectEditRequest(Request request) { >- >- final Request theRequest = request; >- >- if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { >- directEditionMode = getDirectEditionType(); >- } >- switch(directEditionMode) { >- case IDirectEdition.NO_DIRECT_EDITION: >- // no direct edition mode => does nothing >- return; >- case IDirectEdition.EXTENDED_DIRECT_EDITOR: >- updateExtendedEditorConfiguration(); >- if(configuration == null || configuration.getLanguage() == null) { >- performDefaultDirectEditorEdit(theRequest); >- } else { >- configuration.preEditAction(resolveSemanticElement()); >- Dialog dialog = null; >- if(configuration instanceof IPopupEditorConfiguration) { >- IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); >- helper.showEditor(); >- return; >- } else if(configuration instanceof IAdvancedEditorConfiguration) { >- dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); >- } else if(configuration instanceof IDirectEditorConfiguration) { >- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration)configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration)configuration); >- } else { >- return; >- } >- final Dialog finalDialog = dialog; >- >- if(Window.OK == dialog.open()) { >- TransactionalEditingDomain domain = getEditingDomain(); >- RecordingCommand command = new RecordingCommand(domain, "Edit Label") { >- >- @Override >- protected void doExecute() { >- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); >- >- } >- }; >- domain.getCommandStack().execute(command); >- } >- } >- break; >- case IDirectEdition.DEFAULT_DIRECT_EDITOR: >- >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- break; >- default: >- break; >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshVisuals() { >- super.refreshVisuals(); >- refreshLabel(); >- refreshFont(); >- refreshFontColor(); >- refreshUnderline(); >- refreshStrikeThrough(); >- } >- >- /** >- * @generated >- */ >- protected void refreshLabel() { >- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); >- if(maskLabelPolicy == null) { >- setLabelTextHelper(getFigure(), getLabelText()); >- setLabelIconHelper(getFigure(), getLabelIcon()); >- } >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshUnderline() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshStrikeThrough() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshFont() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null) { >- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); >- setFont(fontData); >- } >- } >- >- /** >- * @generated >- */ >- protected void setFontColor(Color color) { >- getFigure().setForegroundColor(color); >- } >- >- /** >- * @generated >- */ >- protected void addSemanticListeners() { >- if(getParser() instanceof ISemanticParser) { >- EObject element = resolveSemanticElement(); >- parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); >- for(int i = 0; i < parserElements.size(); i++) { >- addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ >- } >- } else { >- super.addSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected void removeSemanticListeners() { >- if(parserElements != null) { >- for(int i = 0; i < parserElements.size(); i++) { >- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ >- } >- } else { >- super.removeSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected AccessibleEditPart getAccessibleEditPart() { >- if(accessibleEP == null) { >- accessibleEP = new AccessibleGraphicalEditPart() { >- >- public void getName(AccessibleEvent e) { >- e.result = getLabelTextHelper(getFigure()); >- } >- }; >- } >- return accessibleEP; >- } >- >- /** >- * @generated >- */ >- private View getFontStyleOwnerView() { >- return getPrimaryView(); >- } >- >- /** >- * Returns the kind of associated editor for direct edition. >- * >- * @return an <code>int</code> corresponding to the kind of direct editor, @see >- * org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition >- * @generated >- */ >- public int getDirectEditionType() { >- if(checkExtendedEditor()) { >- initExtendedEditorConfiguration(); >- return IDirectEdition.EXTENDED_DIRECT_EDITOR; >- } >- if(checkDefaultEdition()) { >- return IDirectEdition.DEFAULT_DIRECT_EDITOR; >- } >- >- // not a named element. no specific editor => do nothing >- return IDirectEdition.NO_DIRECT_EDITION; >- } >- >- /** >- * Checks if an extended editor is present. >- * >- * @return <code>true</code> if an extended editor is present. >- * @generated >- */ >- protected boolean checkExtendedEditor() { >- if(resolveSemanticElement() != null) { >- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName()); >- } >- return false; >- } >- >- /** >- * Checks if a default direct edition is available >- * >- * @return <code>true</code> if a default direct edition is available >- * @generated >- */ >- protected boolean checkDefaultEdition() { >- return (getParser() != null); >- } >- >- /** >- * Initializes the extended editor configuration >- * >- * @generated >- */ >- protected void initExtendedEditorConfiguration() { >- if(configuration == null) { >- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("")) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else { >- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); >- } >- } >- } >- >- /** >- * Updates the preference configuration >- */ >- protected void updateExtendedEditorConfiguration() { >- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { >- configuration = null; >- } >- } >- >- /** >- * Performs the direct edit usually used by GMF editors. >- * >- * @param theRequest >- * the direct edit request that starts the direct edit system >- */ >- protected void performDefaultDirectEditorEdit(final Request theRequest) { >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- } >- >- /** >- * @generated >- */ >- protected void handleNotificationEvent(Notification event) { >- Object feature = event.getFeature(); >- if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { >- Integer c = (Integer)event.getNewValue(); >- setFontColor(DiagramColorRegistry.getInstance().getColor(c)); >- } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { >- refreshUnderline(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { >- refreshStrikeThrough(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { >- refreshFont(); >- } else { >- if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { >- refreshLabel(); >- } >- if(getParser() instanceof ISemanticParser) { >- ISemanticParser modelParser = (ISemanticParser)getParser(); >- if(modelParser.areSemanticElementsAffected(null, event)) { >- removeSemanticListeners(); >- if(resolveSemanticElement() != null) { >- addSemanticListeners(); >- } >- refreshLabel(); >- } >- } >- } >- super.handleNotificationEvent(event); >- } >- >- /** >- * @generated >- */ >- protected IFigure createFigure() { >- IFigure label = createFigurePrim(); >- defaultText = getLabelTextHelper(label); >- return label; >- } >- >- /** >- * @generated >- */ >- protected IFigure createFigurePrim() { >- return new WrappingLabel(); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyNameEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyNameEditPart.java >deleted file mode 100644 >index f8ed798..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/PropertyNameEditPart.java >+++ /dev/null >@@ -1,800 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import java.util.Collections; >-import java.util.List; >- >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.Label; >-import org.eclipse.draw2d.geometry.Point; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.transaction.RecordingCommand; >-import org.eclipse.emf.transaction.RunnableWithResult; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gef.AccessibleEditPart; >-import org.eclipse.gef.EditPolicy; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.requests.DirectEditRequest; >-import org.eclipse.gef.tools.DirectEditManager; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >-import org.eclipse.gmf.runtime.notation.FontStyle; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.text.contentassist.IContentAssistProcessor; >-import org.eclipse.jface.viewers.ICellEditorValidator; >-import org.eclipse.jface.window.Window; >-import org.eclipse.papyrus.extensionpoints.editors.Activator; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; >-import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; >-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; >-import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.SysmlTextSelectionEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.figures.CenteredWrappedLabel; >-import org.eclipse.papyrus.sysml.diagram.parametric.parsers.PropertyLabelParser; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlParserProvider; >-import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; >-import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; >-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; >-import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; >-import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; >-import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; >-import org.eclipse.papyrus.infra.emf.appearance.helper.NameLabelIconHelper; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.accessibility.AccessibleEvent; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * @generated >- */ >-public class PropertyNameEditPart extends CompartmentEditPart implements ITextAwareEditPart { >- >- /** >- * @generated >- */ >- public static final int VISUAL_ID = 5002; >- >- /** >- * @generated >- */ >- private DirectEditManager manager; >- >- /** >- * @generated >- */ >- private IParser parser; >- >- /** >- * @generated >- */ >- private List<?> parserElements; >- >- /** >- * @generated >- */ >- private String defaultText; >- >- /** direct edition mode (default, undefined, registered editor, etc.) */ >- protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; >- >- /** configuration from a registered edit dialog */ >- protected IDirectEditorConfiguration configuration; >- >- /** >- * @generated >- */ >- public PropertyNameEditPart(View view) { >- super(view); >- } >- >- /** >- * @generated >- */ >- protected void createDefaultEditPolicies() { >- super.createDefaultEditPolicies(); >- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new SysmlTextSelectionEditPolicy()); >- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); >- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ParametricEditPart.NodeLabelDragPolicy()); >- } >- >- /** >- * @generated >- */ >- protected String getLabelTextHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getText(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getText(); >- } else { >- return ((Label)figure).getText(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelTextHelper(IFigure figure, String text) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setText(text); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setText(text); >- } else { >- ((Label)figure).setText(text); >- } >- } >- >- /** >- * @generated >- */ >- protected Image getLabelIconHelper(IFigure figure) { >- if(figure instanceof WrappingLabel) { >- return ((WrappingLabel)figure).getIcon(); >- } else if(figure instanceof ILabelFigure) { >- return ((ILabelFigure)figure).getIcon(); >- } else { >- return ((Label)figure).getIcon(); >- } >- } >- >- /** >- * @generated >- */ >- protected void setLabelIconHelper(IFigure figure, Image icon) { >- if(figure instanceof WrappingLabel) { >- ((WrappingLabel)figure).setIcon(icon); >- } else if(figure instanceof ILabelFigure) { >- ((ILabelFigure)figure).setIcon(icon); >- } else { >- ((Label)figure).setIcon(icon); >- } >- } >- >- /** >- * @generated >- */ >- public void setLabel(CenteredWrappedLabel figure) { >- unregisterVisuals(); >- setFigure(figure); >- defaultText = getLabelTextHelper(figure); >- registerVisuals(); >- refreshVisuals(); >- } >- >- /** >- * @generated >- */ >- protected List getModelChildren() { >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected EObject getParserElement() { >- return resolveSemanticElement(); >- } >- >- /** >- * @generated NOT >- */ >- protected Image getLabelIcon() { >- EObject parserElement = getParserElement(); >- if(parserElement == null) { >- return null; >- } >- >- List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); >- for(View view : views) { >- if(NameLabelIconHelper.showLabelIcon(view)) { >- return SysmlElementTypes.getImage(parserElement.eClass()); >- } >- } >- return null; >- >- } >- >- // /** >- // * @generated >- // */ >- // protected String getLabelText() { >- // String text = null; >- // EObject parserElement = getParserElement(); >- // if (parserElement != null && getParser() != null) { >- // text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); >- // } >- // if (text == null || text.length() == 0) { >- // text = defaultText; >- // } >- // return text; >- // } >- >- /** >- * @generated NOT >- */ >- protected String getLabelText() { >- String text = null; >- EObject parserElement = getParserElement(); >- if(parserElement != null && getParser() != null && getDiagramView() != null) { >- EObject element = getDiagramView().getElement(); >- if(getParser() instanceof PropertyLabelParser) { >- // set the container to compute the property name depth >- ((PropertyLabelParser)getParser()).setBlock(element); >- } >- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); >- } >- if(text == null || text.length() == 0) { >- text = defaultText; >- } >- return text; >- } >- >- /** >- * @generated >- */ >- public void setLabelText(String text) { >- setLabelTextHelper(getFigure(), text); >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- public String getEditText() { >- if(getParserElement() == null || getParser() == null) { >- return ""; //$NON-NLS-1$ >- } >- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); >- } >- >- /** >- * @generated >- */ >- protected boolean isEditable() { >- return getParser() != null; >- } >- >- /** >- * @generated >- */ >- public ICellEditorValidator getEditTextValidator() { >- return new ICellEditorValidator() { >- >- public String isValid(final Object value) { >- if(value instanceof String) { >- final EObject element = getParserElement(); >- final IParser parser = getParser(); >- try { >- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() { >- >- public void run() { >- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); >- } >- }); >- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); >- } catch (InterruptedException ie) { >- ie.printStackTrace(); >- } >- } >- >- // shouldn't get here >- return null; >- } >- }; >- } >- >- /** >- * @generated >- */ >- public IContentAssistProcessor getCompletionProcessor() { >- if(getParserElement() == null || getParser() == null) { >- return null; >- } >- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); >- } >- >- /** >- * @generated >- */ >- public ParserOptions getParserOptions() { >- return ParserOptions.NONE; >- } >- >- /** >- * @generated >- */ >- public IParser getParser() { >- if(parser == null) { >- parser = SysmlParserProvider.getParser(SysmlElementTypes.Property_2005, getParserElement(), SysmlVisualIDRegistry.getType(org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyNameEditPart.VISUAL_ID)); >- } >- return parser; >- } >- >- /** >- * @generated >- */ >- protected DirectEditManager getManager() { >- if(manager == null) { >- setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), SysmlEditPartFactory.getTextCellEditorLocator(this))); >- } >- return manager; >- } >- >- /** >- * @generated >- */ >- protected void setManager(DirectEditManager manager) { >- this.manager = manager; >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit() { >- getManager().show(); >- } >- >- /** >- * @generated >- */ >- protected void performDirectEdit(Point eventLocation) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); >- } >- } >- >- /** >- * @generated >- */ >- private void performDirectEdit(char initialCharacter) { >- if(getManager() instanceof TextDirectEditManager) { >- ((TextDirectEditManager)getManager()).show(initialCharacter); >- } else { >- performDirectEdit(); >- } >- } >- >- /** >- * @generated >- */ >- protected void performDirectEditRequest(Request request) { >- >- final Request theRequest = request; >- >- if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { >- directEditionMode = getDirectEditionType(); >- } >- switch(directEditionMode) { >- case IDirectEdition.NO_DIRECT_EDITION: >- // no direct edition mode => does nothing >- return; >- case IDirectEdition.EXTENDED_DIRECT_EDITOR: >- updateExtendedEditorConfiguration(); >- if(configuration == null || configuration.getLanguage() == null) { >- performDefaultDirectEditorEdit(theRequest); >- } else { >- configuration.preEditAction(resolveSemanticElement()); >- Dialog dialog = null; >- if(configuration instanceof IPopupEditorConfiguration) { >- IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); >- helper.showEditor(); >- return; >- } else if(configuration instanceof IAdvancedEditorConfiguration) { >- dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); >- } else if(configuration instanceof IDirectEditorConfiguration) { >- dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration)configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration)configuration); >- } else { >- return; >- } >- final Dialog finalDialog = dialog; >- >- if(Window.OK == dialog.open()) { >- TransactionalEditingDomain domain = getEditingDomain(); >- RecordingCommand command = new RecordingCommand(domain, "Edit Label") { >- >- @Override >- protected void doExecute() { >- configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); >- >- } >- }; >- domain.getCommandStack().execute(command); >- } >- } >- break; >- case IDirectEdition.DEFAULT_DIRECT_EDITOR: >- >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- break; >- default: >- break; >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshVisuals() { >- super.refreshVisuals(); >- refreshLabel(); >- refreshFont(); >- refreshFontColor(); >- refreshUnderline(); >- refreshStrikeThrough(); >- } >- >- /** >- * @generated >- */ >- protected void refreshLabel() { >- EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); >- if(maskLabelPolicy == null) { >- setLabelTextHelper(getFigure(), getLabelText()); >- setLabelIconHelper(getFigure(), getLabelIcon()); >- } >- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); >- if(pdEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); >- } >- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); >- if(sfEditPolicy instanceof SysmlTextSelectionEditPolicy) { >- ((SysmlTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshUnderline() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshStrikeThrough() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null && getFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshFont() { >- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); >- if(style != null) { >- FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); >- setFont(fontData); >- } >- } >- >- /** >- * @generated >- */ >- protected void setFontColor(Color color) { >- getFigure().setForegroundColor(color); >- } >- >- /** >- * @generated >- */ >- protected void addSemanticListeners() { >- if(getParser() instanceof ISemanticParser) { >- EObject element = resolveSemanticElement(); >- parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); >- for(int i = 0; i < parserElements.size(); i++) { >- addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ >- } >- } else { >- super.addSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected void removeSemanticListeners() { >- if(parserElements != null) { >- for(int i = 0; i < parserElements.size(); i++) { >- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ >- } >- } else { >- super.removeSemanticListeners(); >- } >- } >- >- /** >- * @generated >- */ >- protected AccessibleEditPart getAccessibleEditPart() { >- if(accessibleEP == null) { >- accessibleEP = new AccessibleGraphicalEditPart() { >- >- public void getName(AccessibleEvent e) { >- e.result = getLabelTextHelper(getFigure()); >- } >- }; >- } >- return accessibleEP; >- } >- >- /** >- * @generated >- */ >- private View getFontStyleOwnerView() { >- return getPrimaryView(); >- } >- >- /** >- * Returns the kind of associated editor for direct edition. >- * >- * @return an <code>int</code> corresponding to the kind of direct editor, @see >- * org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition >- * @generated >- */ >- public int getDirectEditionType() { >- if(checkExtendedEditor()) { >- initExtendedEditorConfiguration(); >- return IDirectEdition.EXTENDED_DIRECT_EDITOR; >- } >- if(checkDefaultEdition()) { >- return IDirectEdition.DEFAULT_DIRECT_EDITOR; >- } >- >- // not a named element. no specific editor => do nothing >- return IDirectEdition.NO_DIRECT_EDITION; >- } >- >- /** >- * Checks if an extended editor is present. >- * >- * @return <code>true</code> if an extended editor is present. >- * @generated >- */ >- protected boolean checkExtendedEditor() { >- if(resolveSemanticElement() != null) { >- return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName()); >- } >- return false; >- } >- >- /** >- * Checks if a default direct edition is available >- * >- * @return <code>true</code> if a default direct edition is available >- * @generated >- */ >- protected boolean checkDefaultEdition() { >- return (getParser() != null); >- } >- >- /** >- * Initializes the extended editor configuration >- * >- * @generated >- */ >- protected void initExtendedEditorConfiguration() { >- if(configuration == null) { >- final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("")) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else { >- configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); >- } >- } >- } >- >- /** >- * Updates the preference configuration >- */ >- protected void updateExtendedEditorConfiguration() { >- String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); >- if(languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { >- configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); >- } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { >- configuration = null; >- } >- } >- >- /** >- * Performs the direct edit usually used by GMF editors. >- * >- * @param theRequest >- * the direct edit request that starts the direct edit system >- */ >- protected void performDefaultDirectEditorEdit(final Request theRequest) { >- // initialize the direct edit manager >- try { >- getEditingDomain().runExclusive(new Runnable() { >- >- public void run() { >- if(isActive() && isEditable()) { >- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { >- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); >- performDirectEdit(initialChar.charValue()); >- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { >- DirectEditRequest editRequest = (DirectEditRequest)theRequest; >- performDirectEdit(editRequest.getLocation()); >- } else { >- performDirectEdit(); >- } >- } >- } >- }); >- } catch (InterruptedException e) { >- e.printStackTrace(); >- } >- } >- >- /** >- * @generated >- */ >- protected void addNotationalListeners() { >- super.addNotationalListeners(); >- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- protected void removeNotationalListeners() { >- super.removeNotationalListeners(); >- removeListenerFilter("PrimaryView"); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- protected void handleNotificationEvent(Notification event) { >- refreshLabel(); >- Object feature = event.getFeature(); >- if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { >- Integer c = (Integer)event.getNewValue(); >- setFontColor(DiagramColorRegistry.getInstance().getColor(c)); >- } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { >- refreshUnderline(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { >- refreshStrikeThrough(); >- } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { >- refreshFont(); >- } else { >- if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { >- refreshLabel(); >- } >- if(getParser() instanceof ISemanticParser) { >- ISemanticParser modelParser = (ISemanticParser)getParser(); >- if(modelParser.areSemanticElementsAffected(null, event)) { >- removeSemanticListeners(); >- if(resolveSemanticElement() != null) { >- addSemanticListeners(); >- } >- refreshLabel(); >- } >- } >- } >- >- if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { >- refreshLabel(); >- } >- >- super.handleNotificationEvent(event); >- } >- >- /** >- * @generated >- */ >- protected IFigure createFigure() { >- // Parent should assign one using setLabel() method >- return null; >- } >- >- private static final String ADD_PARENT_MODEL = "AddParentModel"; >- >- /** >- * @generated >- */ >- public void activate() { >- super.activate(); >- addOwnerElementListeners(); >- } >- >- /** >- * @generated >- */ >- protected void addOwnerElementListeners() { >- addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); //$NON-NLS-1$ >- >- } >- >- /** >- * @generated >- */ >- public void deactivate() { >- removeOwnerElementListeners(); >- super.deactivate(); >- >- } >- >- /** >- * @generated >- */ >- protected void removeOwnerElementListeners() { >- removeListenerFilter(ADD_PARENT_MODEL); >- >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/SysmlEditPartFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/SysmlEditPartFactory.java >deleted file mode 100644 >index 8159736..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/parts/SysmlEditPartFactory.java >+++ /dev/null >@@ -1,228 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.parts; >- >-import org.eclipse.draw2d.FigureUtilities; >-import org.eclipse.draw2d.Label; >-import org.eclipse.draw2d.geometry.Dimension; >-import org.eclipse.draw2d.geometry.Rectangle; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.EditPartFactory; >-import org.eclipse.gef.tools.CellEditorLocator; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.viewers.CellEditor; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.widgets.Text; >- >-/** >- * @generated >- */ >-public class SysmlEditPartFactory implements EditPartFactory { >- >- /** >- * @generated >- */ >- public EditPart createEditPart(EditPart context, Object model) { >- if(model instanceof View) { >- View view = (View)model; >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- >- case ParametricEditPart.VISUAL_ID: >- return new ParametricEditPart(view); >- >- case ConstraintPropertyEditPart.VISUAL_ID: >- return new ConstraintPropertyEditPart(view); >- >- case ConstraintPropertyNameEditPart.VISUAL_ID: >- return new ConstraintPropertyNameEditPart(view); >- >- case ConstraintLabelEditPart.VISUAL_ID: >- return new ConstraintLabelEditPart(view); >- >- case PropertyEditPart.VISUAL_ID: >- return new PropertyEditPart(view); >- >- case PropertyNameEditPart.VISUAL_ID: >- return new PropertyNameEditPart(view); >- >- case Property2EditPart.VISUAL_ID: >- return new Property2EditPart(view); >- >- case PropertyName2EditPart.VISUAL_ID: >- return new PropertyName2EditPart(view); >- >- case ConnectorEditPart.VISUAL_ID: >- return new ConnectorEditPart(view); >- >- case ConnectorNameEditPart.VISUAL_ID: >- return new ConnectorNameEditPart(view); >- >- } >- } >- return createUnrecognizedEditPart(context, model); >- } >- >- /** >- * @generated >- */ >- private EditPart createUnrecognizedEditPart(EditPart context, Object model) { >- // Handle creation of unrecognized child node EditParts here >- return null; >- } >- >- /** >- * @generated >- */ >- public static CellEditorLocator getTextCellEditorLocator(ITextAwareEditPart source) { >- if(source.getFigure() instanceof IMultilineEditableFigure) >- return new MultilineCellEditorLocator((IMultilineEditableFigure)source.getFigure()); >- else if(source.getFigure() instanceof WrappingLabel) >- return new TextCellEditorLocator((WrappingLabel)source.getFigure()); >- else { >- return new LabelCellEditorLocator((Label)source.getFigure()); >- } >- } >- >- /** >- * @generated >- */ >- static private class MultilineCellEditorLocator implements CellEditorLocator { >- >- /** >- * @generated >- */ >- private IMultilineEditableFigure multilineEditableFigure; >- >- /** >- * @generated >- */ >- public MultilineCellEditorLocator(IMultilineEditableFigure figure) { >- this.multilineEditableFigure = figure; >- } >- >- /** >- * @generated >- */ >- public IMultilineEditableFigure getMultilineEditableFigure() { >- return multilineEditableFigure; >- } >- >- /** >- * @generated >- */ >- public void relocate(CellEditor celleditor) { >- Text text = (Text)celleditor.getControl(); >- Rectangle rect = getMultilineEditableFigure().getBounds().getCopy(); >- rect.x = getMultilineEditableFigure().getEditionLocation().x; >- rect.y = getMultilineEditableFigure().getEditionLocation().y; >- getMultilineEditableFigure().translateToAbsolute(rect); >- if(getMultilineEditableFigure().getText().length() > 0) { >- rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT))); >- } >- if(!rect.equals(new Rectangle(text.getBounds()))) { >- text.setBounds(rect.x, rect.y, rect.width, rect.height); >- } >- } >- } >- >- /** >- * @generated >- */ >- static private class TextCellEditorLocator implements CellEditorLocator { >- >- /** >- * @generated >- */ >- private WrappingLabel wrapLabel; >- >- /** >- * @generated >- */ >- public TextCellEditorLocator(WrappingLabel wrapLabel) { >- this.wrapLabel = wrapLabel; >- } >- >- /** >- * @generated >- */ >- public WrappingLabel getWrapLabel() { >- return wrapLabel; >- } >- >- /** >- * @generated >- */ >- public void relocate(CellEditor celleditor) { >- Text text = (Text)celleditor.getControl(); >- Rectangle rect = getWrapLabel().getTextBounds().getCopy(); >- getWrapLabel().translateToAbsolute(rect); >- if(!text.getFont().isDisposed()) { >- if(getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) { >- rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT))); >- } else { >- int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth(); >- rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0)); >- } >- } >- if(!rect.equals(new Rectangle(text.getBounds()))) { >- text.setBounds(rect.x, rect.y, rect.width, rect.height); >- } >- } >- } >- >- /** >- * @generated >- */ >- private static class LabelCellEditorLocator implements CellEditorLocator { >- >- /** >- * @generated >- */ >- private Label label; >- >- /** >- * @generated >- */ >- public LabelCellEditorLocator(Label label) { >- this.label = label; >- } >- >- /** >- * @generated >- */ >- public Label getLabel() { >- return label; >- } >- >- /** >- * @generated >- */ >- public void relocate(CellEditor celleditor) { >- Text text = (Text)celleditor.getControl(); >- Rectangle rect = getLabel().getTextBounds().getCopy(); >- getLabel().translateToAbsolute(rect); >- if(!text.getFont().isDisposed()) { >- int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth(); >- rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0)); >- } >- if(!rect.equals(new Rectangle(text.getBounds()))) { >- text.setBounds(rect.x, rect.y, rect.width, rect.height); >- } >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConnectorItemSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConnectorItemSemanticEditPolicy.java >deleted file mode 100644 >index cc64477..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConnectorItemSemanticEditPolicy.java >+++ /dev/null >@@ -1,52 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.edit.command.DeleteCommand; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; >-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >- >-/** >- * @generated >- */ >-public class ConnectorItemSemanticEditPolicy extends SysmlBaseItemSemanticEditPolicy { >- >- /** >- * @generated >- */ >- public ConnectorItemSemanticEditPolicy() { >- super(SysmlElementTypes.Connector_4001); >- } >- >- /** >- * @generated >- */ >- protected Command getDestroyElementCommand(DestroyElementRequest req) { >- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null); >- cmd.setTransactionNestingEnabled(true); >- List<EObject> todestroy = new ArrayList<EObject>(); >- todestroy.add(req.getElementToDestroy()); >- //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)); >- cmd.add(new EMFtoGMFCommandWrapper(new DeleteCommand(getEditingDomain(), todestroy))); >- return getGEFWrapper(cmd.reduce()); >- //return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConstraintPropertyCanonicalEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConstraintPropertyCanonicalEditPolicy.java >deleted file mode 100644 >index 9970060..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConstraintPropertyCanonicalEditPolicy.java >+++ /dev/null >@@ -1,172 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >-import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand; >-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >-import org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilityCommand; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramUpdater; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlNodeDescriptor; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * @generated >- */ >-public class ConstraintPropertyCanonicalEditPolicy extends CanonicalEditPolicy { >- >- /** >- * @generated >- */ >- protected void refreshOnActivate() { >- // Need to activate editpart children before invoking the canonical refresh for EditParts to add event listeners >- List<?> c = getHost().getChildren(); >- for(int i = 0; i < c.size(); i++) { >- ((EditPart)c.get(i)).activate(); >- } >- super.refreshOnActivate(); >- } >- >- /** >- * @generated >- */ >- protected EStructuralFeature getFeatureToSynchronize() { >- return UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute(); >- } >- >- /** >- * @generated >- */ >- @SuppressWarnings("rawtypes") >- protected List getSemanticChildrenList() { >- View viewObject = (View)getHost().getModel(); >- LinkedList<EObject> result = new LinkedList<EObject>(); >- List<SysmlNodeDescriptor> childDescriptors = SysmlDiagramUpdater.getConstraintProperty_2003SemanticChildren(viewObject); >- for(SysmlNodeDescriptor d : childDescriptors) { >- result.add(d.getModelElement()); >- } >- return result; >- } >- >- /** >- * @generated >- */ >- protected boolean isOrphaned(Collection<EObject> semanticChildren, final View view) { >- return isMyDiagramElement(view) && !semanticChildren.contains(view.getElement()); >- } >- >- /** >- * @generated >- */ >- private boolean isMyDiagramElement(View view) { >- return Property2EditPart.VISUAL_ID == SysmlVisualIDRegistry.getVisualID(view); >- } >- >- /** >- * @generated >- */ >- protected void refreshSemantic() { >- if(resolveSemanticElement() == null) { >- return; >- } >- LinkedList<IAdaptable> createdViews = new LinkedList<IAdaptable>(); >- List<SysmlNodeDescriptor> childDescriptors = SysmlDiagramUpdater.getConstraintProperty_2003SemanticChildren((View)getHost().getModel()); >- LinkedList<View> orphaned = new LinkedList<View>(); >- // we care to check only views we recognize as ours >- LinkedList<View> knownViewChildren = new LinkedList<View>(); >- for(View v : getViewChildren()) { >- if(isMyDiagramElement(v)) { >- knownViewChildren.add(v); >- } >- } >- // alternative to #cleanCanonicalSemanticChildren(getViewChildren(), semanticChildren) >- // >- // iteration happens over list of desired semantic elements, trying to find best matching View, while original CEP >- // iterates views, potentially losing view (size/bounds) information - i.e. if there are few views to reference same EObject, only last one >- // to answer isOrphaned == true will be used for the domain element representation, see #cleanCanonicalSemanticChildren() >- for(Iterator<SysmlNodeDescriptor> descriptorsIterator = childDescriptors.iterator(); descriptorsIterator.hasNext();) { >- SysmlNodeDescriptor next = descriptorsIterator.next(); >- String hint = SysmlVisualIDRegistry.getType(next.getVisualID()); >- LinkedList<View> perfectMatch = new LinkedList<View>(); // both semanticElement and hint match that of NodeDescriptor >- for(View childView : getViewChildren()) { >- EObject semanticElement = childView.getElement(); >- if(next.getModelElement().equals(semanticElement)) { >- if(hint.equals(childView.getType())) { >- perfectMatch.add(childView); >- // actually, can stop iteration over view children here, but >- // may want to use not the first view but last one as a 'real' match (the way original CEP does >- // with its trick with viewToSemanticMap inside #cleanCanonicalSemanticChildren >- } >- } >- } >- if(perfectMatch.size() > 0) { >- descriptorsIterator.remove(); // precise match found no need to create anything for the NodeDescriptor >- // use only one view (first or last?), keep rest as orphaned for further consideration >- knownViewChildren.remove(perfectMatch.getFirst()); >- } >- } >- // those left in knownViewChildren are subject to removal - they are our diagram elements we didn't find match to, >- // or those we have potential matches to, and thus need to be recreated, preserving size/location information. >- orphaned.addAll(knownViewChildren); >- // >- ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>(childDescriptors.size()); >- for(SysmlNodeDescriptor next : childDescriptors) { >- String hint = SysmlVisualIDRegistry.getType(next.getVisualID()); >- IAdaptable elementAdapter = new CanonicalElementAdapter(next.getModelElement(), hint); >- CreateViewRequest.ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor(elementAdapter, Node.class, hint, ViewUtil.APPEND, false, host().getDiagramPreferencesHint()); >- viewDescriptors.add(descriptor); >- } >- >- boolean changed = deleteViews(orphaned.iterator()); >- // >- CreateViewRequest request = getCreateViewRequest(viewDescriptors); >- Command cmd = getCreateViewCommand(request); >- if(cmd != null && cmd.canExecute()) { >- SetViewMutabilityCommand.makeMutable(new EObjectAdapter(host().getNotationView())).execute(); >- executeCommand(cmd); >- @SuppressWarnings("unchecked") >- List<IAdaptable> nl = (List<IAdaptable>)request.getNewObject(); >- createdViews.addAll(nl); >- } >- if(changed || createdViews.size() > 0) { >- postProcessRefreshSemantic(createdViews); >- } >- if(createdViews.size() > 1) { >- // perform a layout of the container >- DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host()); >- executeCommand(new ICommandProxy(layoutCmd)); >- } >- >- makeViewsImmutable(createdViews); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConstraintPropertyItemSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConstraintPropertyItemSemanticEditPolicy.java >deleted file mode 100644 >index f78e4a0..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ConstraintPropertyItemSemanticEditPolicy.java >+++ /dev/null >@@ -1,115 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.Iterator; >- >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand; >-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.commands.Property2CreateCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.uml2.uml.Property; >- >-/** >- * @generated >- */ >-public class ConstraintPropertyItemSemanticEditPolicy extends SysmlBaseItemSemanticEditPolicy { >- >- /** >- * @generated >- */ >- public ConstraintPropertyItemSemanticEditPolicy() { >- super(SysmlElementTypes.ConstraintProperty_2003); >- } >- >- /** >- * @generated >- */ >- protected Command getCreateCommand(CreateElementRequest req) { >- if(SysmlElementTypes.Property_3002 == req.getElementType()) { >- return getGEFWrapper(new Property2CreateCommand(req)); >- } >- return super.getCreateCommand(req); >- } >- >- /** >- * @generated NOT delete property views if any >- */ >- protected Command getDestroyElementCommand(DestroyElementRequest req) { >- View view = (View)getHost().getModel(); >- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null); >- cmd.setTransactionNestingEnabled(false); >- EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ >- if(annotation == null) { >- // there are indirectly referenced children, need extra commands: true >- addDestroyChildNodesCommand(cmd); >- addDestroyShortcutsCommand(cmd, view); >- // delete host element >- cmd.add(new DestroyElementCommand(req)); >- // destroy base property >- addDestroyBasePropertyCommand(cmd); >- } else { >- cmd.add(new DeleteCommand(getEditingDomain(), view)); >- } >- return getGEFWrapper(cmd.reduce()); >- } >- >- /** >- * Delete property views of the constraint property >- * >- * @generated NOT >- */ >- private void addDestroyChildNodesCommand(ICompositeCommand cmd) { >- View view = (View)getHost().getModel(); >- for(Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) { >- Node node = (Node)nit.next(); >- switch(SysmlVisualIDRegistry.getVisualID(node)) { >- case Property2EditPart.VISUAL_ID: >- // only delete from diagram >- cmd.add(new DeleteCommand(getEditingDomain(), node)); >- break; >- } >- } >- } >- >- /** >- * Delete the base property from the constraint property >- * >- * @generated NOT >- */ >- private void addDestroyBasePropertyCommand(ICompositeCommand cmd) { >- View view = (View)getHost().getModel(); >- EObject element = view.getElement(); >- if(element instanceof ConstraintProperty) { >- Property property = ((ConstraintProperty)element).getBase_Property(); >- if(property != null) { >- DestroyElementRequest request = new DestroyElementRequest(property, false); >- cmd.add(new DestroyElementCommand(request)); >- } >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/OpenDiagramEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/OpenDiagramEditPolicy.java >deleted file mode 100644 >index 4547027..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/OpenDiagramEditPolicy.java >+++ /dev/null >@@ -1,183 +0,0 @@ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.io.IOException; >-import java.lang.reflect.InvocationTargetException; >-import java.util.Iterator; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.common.ui.URIEditorInput; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.emf.transaction.util.TransactionUtil; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >-import org.eclipse.gmf.runtime.diagram.core.services.ViewService; >-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy; >-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.Style; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.Messages; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditor; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorUtil; >-import org.eclipse.ui.IEditorInput; >-import org.eclipse.ui.IWorkbenchPage; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.actions.WorkspaceModifyOperation; >- >-/** >- * @generated >- */ >-public class OpenDiagramEditPolicy extends OpenEditPolicy { >- >- /** >- * @generated >- */ >- protected Command getOpenCommand(Request request) { >- EditPart targetEditPart = getTargetEditPart(request); >- if(false == targetEditPart.getModel() instanceof View) { >- return null; >- } >- View view = (View)targetEditPart.getModel(); >- Style link = view.getStyle(NotationPackage.eINSTANCE.getHintedDiagramLinkStyle()); >- if(false == link instanceof HintedDiagramLinkStyle) { >- return null; >- } >- return new ICommandProxy(new OpenDiagramCommand((HintedDiagramLinkStyle)link)); >- } >- >- /** >- * @generated >- */ >- private static class OpenDiagramCommand extends AbstractTransactionalCommand { >- >- /** >- * @generated >- */ >- private final HintedDiagramLinkStyle diagramFacet; >- >- /** >- * @generated >- */ >- OpenDiagramCommand(HintedDiagramLinkStyle linkStyle) { >- // editing domain is taken for original diagram, >- // if we open diagram from another file, we should use another editing domain >- super(TransactionUtil.getEditingDomain(linkStyle), Messages.CommandName_OpenDiagram, null); >- diagramFacet = linkStyle; >- } >- >- // FIXME canExecute if !(readOnly && getDiagramToOpen == null), i.e. open works on ro >- // diagrams only when there's associated diagram already >- >- /** >- * @generated >- */ >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- try { >- Diagram diagram = getDiagramToOpen(); >- if(diagram == null) { >- diagram = intializeNewDiagram(); >- } >- URI uri = EcoreUtil.getURI(diagram); >- String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram); >- IEditorInput editorInput = new URIEditorInput(uri, editorName); >- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >- page.openEditor(editorInput, getEditorID()); >- return CommandResult.newOKCommandResult(); >- } catch (Exception ex) { >- throw new ExecutionException("Can't open diagram", ex); >- } >- } >- >- /** >- * @generated >- */ >- protected Diagram getDiagramToOpen() { >- return diagramFacet.getDiagramLink(); >- } >- >- /** >- * @generated >- */ >- protected Diagram intializeNewDiagram() throws ExecutionException { >- Diagram d = ViewService.createDiagram(getDiagramDomainElement(), getDiagramKind(), getPreferencesHint()); >- if(d == null) { >- throw new ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind"); >- } >- diagramFacet.setDiagramLink(d); >- assert diagramFacet.eResource() != null; >- diagramFacet.eResource().getContents().add(d); >- EObject container = diagramFacet.eContainer(); >- while(container instanceof View) { >- ((View)container).persist(); >- container = container.eContainer(); >- } >- try { >- new WorkspaceModifyOperation() { >- >- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { >- try { >- for(Iterator it = diagramFacet.eResource().getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource nextResource = (Resource)it.next(); >- if(nextResource.isLoaded() && !getEditingDomain().isReadOnly(nextResource)) { >- nextResource.save(SysmlDiagramEditorUtil.getSaveOptions()); >- } >- } >- } catch (IOException ex) { >- throw new InvocationTargetException(ex, "Save operation failed"); >- } >- } >- }.run(null); >- } catch (InvocationTargetException e) { >- throw new ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", e); >- } catch (InterruptedException e) { >- throw new ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", e); >- } >- return d; >- } >- >- /** >- * @generated >- */ >- protected EObject getDiagramDomainElement() { >- // use same element as associated with EP >- return ((View)diagramFacet.eContainer()).getElement(); >- } >- >- /** >- * @generated >- */ >- protected PreferencesHint getPreferencesHint() { >- // XXX prefhint from target diagram's editor? >- return SysmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT; >- } >- >- /** >- * @generated >- */ >- protected String getDiagramKind() { >- return ParametricEditPart.MODEL_ID; >- } >- >- /** >- * @generated >- */ >- protected String getEditorID() { >- return SysmlDiagramEditor.ID; >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ParametricCanonicalEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ParametricCanonicalEditPolicy.java >deleted file mode 100644 >index 2bd26ca..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ParametricCanonicalEditPolicy.java >+++ /dev/null >@@ -1,352 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.Collections; >-import java.util.HashMap; >-import java.util.HashSet; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >-import java.util.Set; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >-import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand; >-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >-import org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilityCommand; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; >-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.Edge; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.resource.ResourcePackage; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramUpdater; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlLinkDescriptor; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlNodeDescriptor; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * @generated >- */ >-public class ParametricCanonicalEditPolicy extends CanonicalEditPolicy { >- >- /** >- * @generated >- */ >- private Set<EStructuralFeature> myFeaturesToSynchronize; >- >- /** >- * @generated >- */ >- protected void refreshOnActivate() { >- // Need to activate editpart children before invoking the canonical refresh for EditParts to add event listeners >- List<?> c = getHost().getChildren(); >- for(int i = 0; i < c.size(); i++) { >- ((EditPart)c.get(i)).activate(); >- } >- super.refreshOnActivate(); >- } >- >- /** >- * @generated >- */ >- @SuppressWarnings("rawtypes") >- protected List getSemanticChildrenList() { >- View viewObject = (View)getHost().getModel(); >- LinkedList<EObject> result = new LinkedList<EObject>(); >- List<SysmlNodeDescriptor> childDescriptors = SysmlDiagramUpdater.getResource_1000SemanticChildren(viewObject); >- for(SysmlNodeDescriptor d : childDescriptors) { >- result.add(d.getModelElement()); >- } >- return result; >- } >- >- /** >- * @generated >- */ >- protected boolean isOrphaned(Collection<EObject> semanticChildren, final View view) { >- return isMyDiagramElement(view) && !semanticChildren.contains(view.getElement()); >- } >- >- /** >- * @generated >- */ >- private boolean isMyDiagramElement(View view) { >- int visualID = SysmlVisualIDRegistry.getVisualID(view); >- return visualID == ConstraintPropertyEditPart.VISUAL_ID || visualID == PropertyEditPart.VISUAL_ID; >- } >- >- /** >- * @generated >- */ >- protected Set getFeaturesToSynchronize() { >- if(myFeaturesToSynchronize == null) { >- myFeaturesToSynchronize = new HashSet<EStructuralFeature>(); >- myFeaturesToSynchronize.add(ResourcePackage.eINSTANCE.getResource_Eobjects()); >- myFeaturesToSynchronize.add(UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute()); >- } >- return myFeaturesToSynchronize; >- } >- >- /** >- * @generated >- */ >- protected void refreshSemantic() { >- if(resolveSemanticElement() == null) { >- return; >- } >- LinkedList<IAdaptable> createdViews = new LinkedList<IAdaptable>(); >- List<SysmlNodeDescriptor> childDescriptors = SysmlDiagramUpdater.getResource_1000SemanticChildren((View)getHost().getModel()); >- LinkedList<View> orphaned = new LinkedList<View>(); >- // we care to check only views we recognize as ours >- LinkedList<View> knownViewChildren = new LinkedList<View>(); >- for(View v : getViewChildren()) { >- if(isMyDiagramElement(v)) { >- knownViewChildren.add(v); >- } >- } >- // alternative to #cleanCanonicalSemanticChildren(getViewChildren(), semanticChildren) >- // >- // iteration happens over list of desired semantic elements, trying to find best matching View, while original CEP >- // iterates views, potentially losing view (size/bounds) information - i.e. if there are few views to reference same EObject, only last one >- // to answer isOrphaned == true will be used for the domain element representation, see #cleanCanonicalSemanticChildren() >- for(Iterator<SysmlNodeDescriptor> descriptorsIterator = childDescriptors.iterator(); descriptorsIterator.hasNext();) { >- SysmlNodeDescriptor next = descriptorsIterator.next(); >- String hint = SysmlVisualIDRegistry.getType(next.getVisualID()); >- LinkedList<View> perfectMatch = new LinkedList<View>(); // both semanticElement and hint match that of NodeDescriptor >- for(View childView : getViewChildren()) { >- EObject semanticElement = childView.getElement(); >- if(next.getModelElement().equals(semanticElement)) { >- if(hint.equals(childView.getType())) { >- perfectMatch.add(childView); >- // actually, can stop iteration over view children here, but >- // may want to use not the first view but last one as a 'real' match (the way original CEP does >- // with its trick with viewToSemanticMap inside #cleanCanonicalSemanticChildren >- } >- } >- } >- if(perfectMatch.size() > 0) { >- descriptorsIterator.remove(); // precise match found no need to create anything for the NodeDescriptor >- // use only one view (first or last?), keep rest as orphaned for further consideration >- knownViewChildren.remove(perfectMatch.getFirst()); >- } >- } >- // those left in knownViewChildren are subject to removal - they are our diagram elements we didn't find match to, >- // or those we have potential matches to, and thus need to be recreated, preserving size/location information. >- orphaned.addAll(knownViewChildren); >- // >- ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>(childDescriptors.size()); >- for(SysmlNodeDescriptor next : childDescriptors) { >- String hint = SysmlVisualIDRegistry.getType(next.getVisualID()); >- IAdaptable elementAdapter = new CanonicalElementAdapter(next.getModelElement(), hint); >- CreateViewRequest.ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor(elementAdapter, Node.class, hint, ViewUtil.APPEND, false, host().getDiagramPreferencesHint()); >- viewDescriptors.add(descriptor); >- } >- >- boolean changed = deleteViews(orphaned.iterator()); >- // >- CreateViewRequest request = getCreateViewRequest(viewDescriptors); >- Command cmd = getCreateViewCommand(request); >- if(cmd != null && cmd.canExecute()) { >- SetViewMutabilityCommand.makeMutable(new EObjectAdapter(host().getNotationView())).execute(); >- executeCommand(cmd); >- @SuppressWarnings("unchecked") >- List<IAdaptable> nl = (List<IAdaptable>)request.getNewObject(); >- createdViews.addAll(nl); >- } >- if(changed || createdViews.size() > 0) { >- postProcessRefreshSemantic(createdViews); >- } >- >- Collection<IAdaptable> createdConnectionViews = refreshConnections(); >- >- if(createdViews.size() > 1) { >- // perform a layout of the container >- DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host()); >- executeCommand(new ICommandProxy(layoutCmd)); >- } >- >- createdViews.addAll(createdConnectionViews); >- >- makeViewsImmutable(createdViews); >- } >- >- /** >- * @generated >- */ >- private Diagram getDiagram() { >- return ((View)getHost().getModel()).getDiagram(); >- } >- >- /** >- * @generated >- */ >- private Collection<IAdaptable> refreshConnections() { >- Map<EObject, View> domain2NotationMap = new HashMap<EObject, View>(); >- Collection<SysmlLinkDescriptor> linkDescriptors = collectAllLinks(getDiagram(), domain2NotationMap); >- Collection existingLinks = new LinkedList(getDiagram().getEdges()); >- for(Iterator linksIterator = existingLinks.iterator(); linksIterator.hasNext();) { >- Edge nextDiagramLink = (Edge)linksIterator.next(); >- int diagramLinkVisualID = SysmlVisualIDRegistry.getVisualID(nextDiagramLink); >- if(diagramLinkVisualID == -1) { >- if(nextDiagramLink.getSource() != null && nextDiagramLink.getTarget() != null) { >- linksIterator.remove(); >- } >- continue; >- } >- EObject diagramLinkObject = nextDiagramLink.getElement(); >- EObject diagramLinkSrc = nextDiagramLink.getSource().getElement(); >- EObject diagramLinkDst = nextDiagramLink.getTarget().getElement(); >- for(Iterator<SysmlLinkDescriptor> linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) { >- SysmlLinkDescriptor nextLinkDescriptor = linkDescriptorsIterator.next(); >- if(diagramLinkObject == nextLinkDescriptor.getModelElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) { >- linksIterator.remove(); >- linkDescriptorsIterator.remove(); >- break; >- } >- } >- } >- deleteViews(existingLinks.iterator()); >- return createConnections(linkDescriptors, domain2NotationMap); >- } >- >- /** >- * @generated >- */ >- private Collection<SysmlLinkDescriptor> collectAllLinks(View view, Map<EObject, View> domain2NotationMap) { >- if(!ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID(view))) { >- return Collections.emptyList(); >- } >- LinkedList<SysmlLinkDescriptor> result = new LinkedList<SysmlLinkDescriptor>(); >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- case ParametricEditPart.VISUAL_ID: >- { >- if(!domain2NotationMap.containsKey(view.getElement())) { >- result.addAll(SysmlDiagramUpdater.getResource_1000ContainedLinks(view)); >- } >- if(!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$ >- domain2NotationMap.put(view.getElement(), view); >- } >- break; >- } >- case ConstraintPropertyEditPart.VISUAL_ID: >- { >- if(!domain2NotationMap.containsKey(view.getElement())) { >- result.addAll(SysmlDiagramUpdater.getConstraintProperty_2003ContainedLinks(view)); >- } >- if(!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$ >- domain2NotationMap.put(view.getElement(), view); >- } >- break; >- } >- case PropertyEditPart.VISUAL_ID: >- { >- if(!domain2NotationMap.containsKey(view.getElement())) { >- result.addAll(SysmlDiagramUpdater.getProperty_2005ContainedLinks(view)); >- } >- if(!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$ >- domain2NotationMap.put(view.getElement(), view); >- } >- break; >- } >- case Property2EditPart.VISUAL_ID: >- { >- if(!domain2NotationMap.containsKey(view.getElement())) { >- result.addAll(SysmlDiagramUpdater.getProperty_3002ContainedLinks(view)); >- } >- if(!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$ >- domain2NotationMap.put(view.getElement(), view); >- } >- break; >- } >- case ConnectorEditPart.VISUAL_ID: >- { >- if(!domain2NotationMap.containsKey(view.getElement())) { >- result.addAll(SysmlDiagramUpdater.getConnector_4001ContainedLinks(view)); >- } >- if(!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$ >- domain2NotationMap.put(view.getElement(), view); >- } >- break; >- } >- } >- for(Iterator children = view.getChildren().iterator(); children.hasNext();) { >- result.addAll(collectAllLinks((View)children.next(), domain2NotationMap)); >- } >- for(Iterator edges = view.getSourceEdges().iterator(); edges.hasNext();) { >- result.addAll(collectAllLinks((View)edges.next(), domain2NotationMap)); >- } >- return result; >- } >- >- /** >- * @generated >- */ >- private Collection<IAdaptable> createConnections(Collection<SysmlLinkDescriptor> linkDescriptors, Map<EObject, View> domain2NotationMap) { >- LinkedList<IAdaptable> adapters = new LinkedList<IAdaptable>(); >- for(SysmlLinkDescriptor nextLinkDescriptor : linkDescriptors) { >- EditPart sourceEditPart = getEditPart(nextLinkDescriptor.getSource(), domain2NotationMap); >- EditPart targetEditPart = getEditPart(nextLinkDescriptor.getDestination(), domain2NotationMap); >- if(sourceEditPart == null || targetEditPart == null) { >- continue; >- } >- CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(nextLinkDescriptor.getSemanticAdapter(), SysmlVisualIDRegistry.getType(nextLinkDescriptor.getVisualID()), ViewUtil.APPEND, false, ((IGraphicalEditPart)getHost()).getDiagramPreferencesHint()); >- CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(descriptor); >- ccr.setType(RequestConstants.REQ_CONNECTION_START); >- ccr.setSourceEditPart(sourceEditPart); >- sourceEditPart.getCommand(ccr); >- ccr.setTargetEditPart(targetEditPart); >- ccr.setType(RequestConstants.REQ_CONNECTION_END); >- Command cmd = targetEditPart.getCommand(ccr); >- if(cmd != null && cmd.canExecute()) { >- executeCommand(cmd); >- IAdaptable viewAdapter = (IAdaptable)ccr.getNewObject(); >- if(viewAdapter != null) { >- adapters.add(viewAdapter); >- } >- } >- } >- return adapters; >- } >- >- /** >- * @generated >- */ >- private EditPart getEditPart(EObject domainModelElement, Map<EObject, View> domain2NotationMap) { >- View view = (View)domain2NotationMap.get(domainModelElement); >- if(view != null) { >- return (EditPart)getHost().getViewer().getEditPartRegistry().get(view); >- } >- return null; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ParametricItemSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ParametricItemSemanticEditPolicy.java >deleted file mode 100644 >index 6527fe2..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/ParametricItemSemanticEditPolicy.java >+++ /dev/null >@@ -1,80 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.commands.ConstraintPropertyCreateCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.commands.PropertyCreateCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.uml.diagram.common.commands.DuplicateNamedElementCommand; >- >-/** >- * @generated >- */ >-public class ParametricItemSemanticEditPolicy extends SysmlBaseItemSemanticEditPolicy { >- >- /** >- * @generated >- */ >- public ParametricItemSemanticEditPolicy() { >- super(SysmlElementTypes.Resource_1000); >- } >- >- /** >- * @generated >- */ >- protected Command getCreateCommand(CreateElementRequest req) { >- if(SysmlElementTypes.ConstraintProperty_2003 == req.getElementType()) { >- return getGEFWrapper(new ConstraintPropertyCreateCommand(req)); >- } >- if(SysmlElementTypes.Property_2005 == req.getElementType()) { >- return getGEFWrapper(new PropertyCreateCommand(req)); >- } >- return super.getCreateCommand(req); >- } >- >- /** >- * @generated >- */ >- protected Command getDuplicateCommand(DuplicateElementsRequest req) { >- TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain(); >- Diagram currentDiagram = null; >- if(getHost() instanceof IGraphicalEditPart) { >- currentDiagram = ((IGraphicalEditPart)getHost()).getNotationView().getDiagram(); >- } >- return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req, currentDiagram)); >- } >- >- /** >- * @generated >- */ >- private static class DuplicateAnythingCommand extends DuplicateNamedElementCommand { >- >- private Diagram diagram; >- >- /** >- * @generated >- */ >- public DuplicateAnythingCommand(TransactionalEditingDomain editingDomain, DuplicateElementsRequest req, Diagram currentDiagram) { >- super(editingDomain, req.getLabel(), req.getElementsToBeDuplicated(), req.getAllDuplicatedElementsMap(), currentDiagram); >- this.diagram = currentDiagram; >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/Property2ItemSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/Property2ItemSemanticEditPolicy.java >deleted file mode 100644 >index d20e4f3..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/Property2ItemSemanticEditPolicy.java >+++ /dev/null >@@ -1,111 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; >-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.notation.View; >-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.commands.ConnectorCreateCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.commands.ConnectorReorientCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >- >-/** >- * @generated >- */ >-public class Property2ItemSemanticEditPolicy extends SysmlBaseItemSemanticEditPolicy { >- >- /** >- * @generated >- */ >- public Property2ItemSemanticEditPolicy() { >- super(SysmlElementTypes.Property_3002); >- } >- >- /** >- * @generated >- */ >- protected Command getDestroyElementCommand(DestroyElementRequest req) { >- View view = (View)getHost().getModel(); >- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null); >- cmd.setTransactionNestingEnabled(true); >- >- EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ >- if(annotation == null) { >- // there are indirectly referenced children, need extra commands: false >- addDestroyShortcutsCommand(cmd, view); >- // delete host element >- List<EObject> todestroy = new ArrayList<EObject>(); >- todestroy.add(req.getElementToDestroy()); >- //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)); >- cmd.add(new EMFtoGMFCommandWrapper(new org.eclipse.emf.edit.command.DeleteCommand(getEditingDomain(), todestroy))); >- } else { >- cmd.add(new DeleteCommand(getEditingDomain(), view)); >- } >- return getGEFWrapper(cmd.reduce()); >- } >- >- /** >- * @generated >- */ >- protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) { >- Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req); >- return command != null ? command : super.getCreateRelationshipCommand(req); >- } >- >- /** >- * @generated >- */ >- protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { >- if(SysmlElementTypes.Connector_4001 == req.getElementType()) { >- return getGEFWrapper(new ConnectorCreateCommand(req, req.getSource(), req.getTarget())); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) { >- if(SysmlElementTypes.Connector_4001 == req.getElementType()) { >- return getGEFWrapper(new ConnectorCreateCommand(req, req.getSource(), req.getTarget())); >- } >- return null; >- } >- >- /** >- * Returns command to reorient EClass based link. New link target or source should be the domain >- * model element associated with this node. >- * >- * @generated >- */ >- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) { >- switch(getVisualID(req)) { >- case ConnectorEditPart.VISUAL_ID: >- return getGEFWrapper(new ConnectorReorientCommand(req)); >- } >- return super.getReorientRelationshipCommand(req); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/PropertyItemSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/PropertyItemSemanticEditPolicy.java >deleted file mode 100644 >index 454d419..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/PropertyItemSemanticEditPolicy.java >+++ /dev/null >@@ -1,111 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; >-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.notation.View; >-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.commands.ConnectorCreateCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.commands.ConnectorReorientCommand; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >- >-/** >- * @generated >- */ >-public class PropertyItemSemanticEditPolicy extends SysmlBaseItemSemanticEditPolicy { >- >- /** >- * @generated >- */ >- public PropertyItemSemanticEditPolicy() { >- super(SysmlElementTypes.Property_2005); >- } >- >- /** >- * @generated >- */ >- protected Command getDestroyElementCommand(DestroyElementRequest req) { >- View view = (View)getHost().getModel(); >- CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null); >- cmd.setTransactionNestingEnabled(true); >- >- EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ >- if(annotation == null) { >- // there are indirectly referenced children, need extra commands: false >- addDestroyShortcutsCommand(cmd, view); >- // delete host element >- List<EObject> todestroy = new ArrayList<EObject>(); >- todestroy.add(req.getElementToDestroy()); >- //cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)); >- cmd.add(new EMFtoGMFCommandWrapper(new org.eclipse.emf.edit.command.DeleteCommand(getEditingDomain(), todestroy))); >- } else { >- cmd.add(new DeleteCommand(getEditingDomain(), view)); >- } >- return getGEFWrapper(cmd.reduce()); >- } >- >- /** >- * @generated >- */ >- protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) { >- Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req); >- return command != null ? command : super.getCreateRelationshipCommand(req); >- } >- >- /** >- * @generated >- */ >- protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { >- if(SysmlElementTypes.Connector_4001 == req.getElementType()) { >- return getGEFWrapper(new ConnectorCreateCommand(req, req.getSource(), req.getTarget())); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) { >- if(SysmlElementTypes.Connector_4001 == req.getElementType()) { >- return getGEFWrapper(new ConnectorCreateCommand(req, req.getSource(), req.getTarget())); >- } >- return null; >- } >- >- /** >- * Returns command to reorient EClass based link. New link target or source should be the domain >- * model element associated with this node. >- * >- * @generated >- */ >- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) { >- switch(getVisualID(req)) { >- case ConnectorEditPart.VISUAL_ID: >- return getGEFWrapper(new ConnectorReorientCommand(req)); >- } >- return super.getReorientRelationshipCommand(req); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlBaseItemSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlBaseItemSemanticEditPolicy.java >deleted file mode 100644 >index 0aa8697..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlBaseItemSemanticEditPolicy.java >+++ /dev/null >@@ -1,379 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.Iterator; >- >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gef.Request; >-import org.eclipse.gef.commands.Command; >-import org.eclipse.gef.commands.UnexecutableCommand; >-import org.eclipse.gef.requests.ReconnectRequest; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand; >-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand; >-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; >-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; >-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.DestroyRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; >-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType; >-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; >-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.helpers.SysmlBaseEditHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.uml2.uml.ConnectableElement; >-import org.eclipse.uml2.uml.Connector; >-import org.eclipse.uml2.uml.StructuredClassifier; >-import org.eclipse.uml2.uml.Type; >- >-/** >- * @generated >- */ >-public class SysmlBaseItemSemanticEditPolicy extends SemanticEditPolicy { >- >- /** >- * Extended request data key to hold editpart visual id. >- * >- * @generated >- */ >- public static final String VISUAL_ID_KEY = "visual_id"; //$NON-NLS-1$ >- >- /** >- * Extended request data key to hold the edge view during a reconnect request. >- * >- * @generated >- */ >- public static final String GRAPHICAL_RECONNECTED_EDGE = "graphical_edge"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- private final IElementType myElementType; >- >- /** >- * @generated >- */ >- protected SysmlBaseItemSemanticEditPolicy(IElementType elementType) { >- myElementType = elementType; >- } >- >- /** >- * Extended request data key to hold editpart visual id. Add visual id of edited editpart to >- * extended data of the request so command switch can decide what kind of diagram element is >- * being edited. It is done in those cases when it's not possible to deduce diagram element kind >- * from domain element. >- * >- * @generated >- */ >- @SuppressWarnings("unchecked") >- public Command getCommand(Request request) { >- if(request instanceof ReconnectRequest) { >- Object view = ((ReconnectRequest)request).getConnectionEditPart().getModel(); >- if(view instanceof View) { >- Integer id = new Integer(SysmlVisualIDRegistry.getVisualID((View)view)); >- request.getExtendedData().put(VISUAL_ID_KEY, id); >- request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE, (View)view); >- } >- } >- return super.getCommand(request); >- } >- >- /** >- * Returns visual id from request parameters. >- * >- * @generated >- */ >- protected int getVisualID(IEditCommandRequest request) { >- Object id = request.getParameter(VISUAL_ID_KEY); >- return id instanceof Integer ? ((Integer)id).intValue() : -1; >- } >- >- /** >- * @generated >- */ >- protected Command getSemanticCommand(IEditCommandRequest request) { >- IEditCommandRequest completedRequest = completeRequest(request); >- Command semanticCommand = getSemanticCommandSwitch(completedRequest); >- semanticCommand = getEditHelperCommand(completedRequest, semanticCommand); >- if(completedRequest instanceof DestroyRequest) { >- DestroyRequest destroyRequest = (DestroyRequest)completedRequest; >- return shouldProceed(destroyRequest) ? addDeleteViewCommand(semanticCommand, destroyRequest) : null; >- } >- return semanticCommand; >- } >- >- /** >- * @generated >- */ >- protected Command addDeleteViewCommand(Command mainCommand, DestroyRequest completedRequest) { >- Command deleteViewCommand = getGEFWrapper(new DeleteCommand(getEditingDomain(), (View)getHost().getModel())); >- return mainCommand == null ? deleteViewCommand : mainCommand.chain(deleteViewCommand); >- } >- >- /** >- * @generated >- */ >- private Command getEditHelperCommand(IEditCommandRequest request, Command editPolicyCommand) { >- if(editPolicyCommand != null) { >- ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy)editPolicyCommand).getICommand() : new CommandProxy(editPolicyCommand); >- request.setParameter(SysmlBaseEditHelper.EDIT_POLICY_COMMAND, command); >- } >- IElementType requestContextElementType = getContextElementType(request); >- request.setParameter(SysmlBaseEditHelper.CONTEXT_ELEMENT_TYPE, requestContextElementType); >- ICommand command = requestContextElementType.getEditCommand(request); >- request.setParameter(SysmlBaseEditHelper.EDIT_POLICY_COMMAND, null); >- request.setParameter(SysmlBaseEditHelper.CONTEXT_ELEMENT_TYPE, null); >- if(command != null) { >- if(!(command instanceof CompositeTransactionalCommand)) { >- command = new CompositeTransactionalCommand(getEditingDomain(), command.getLabel()).compose(command); >- } >- return new ICommandProxy(command); >- } >- return editPolicyCommand; >- } >- >- /** >- * @generated >- */ >- protected IElementType getContextElementType(IEditCommandRequest request) { >- IElementType requestContextElementType = SysmlElementTypes.getElementType(getVisualID(request)); >- return requestContextElementType != null ? requestContextElementType : myElementType; >- } >- >- /** >- * @generated >- */ >- protected Command getSemanticCommandSwitch(IEditCommandRequest req) { >- if(req instanceof CreateRelationshipRequest) { >- return getCreateRelationshipCommand((CreateRelationshipRequest)req); >- } else if(req instanceof CreateElementRequest) { >- return getCreateCommand((CreateElementRequest)req); >- } else if(req instanceof ConfigureRequest) { >- return getConfigureCommand((ConfigureRequest)req); >- } else if(req instanceof DestroyElementRequest) { >- return getDestroyElementCommand((DestroyElementRequest)req); >- } else if(req instanceof DestroyReferenceRequest) { >- return getDestroyReferenceCommand((DestroyReferenceRequest)req); >- } else if(req instanceof DuplicateElementsRequest) { >- return getDuplicateCommand((DuplicateElementsRequest)req); >- } else if(req instanceof GetEditContextRequest) { >- return getEditContextCommand((GetEditContextRequest)req); >- } else if(req instanceof MoveRequest) { >- return getMoveCommand((MoveRequest)req); >- } else if(req instanceof ReorientReferenceRelationshipRequest) { >- return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest)req); >- } else if(req instanceof ReorientRelationshipRequest) { >- return getReorientRelationshipCommand((ReorientRelationshipRequest)req); >- } else if(req instanceof SetRequest) { >- return getSetCommand((SetRequest)req); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getConfigureCommand(ConfigureRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getCreateCommand(CreateElementRequest req) { >- // check if the type is an extended type, and then create directly the element... >- IElementType type = req.getElementType(); >- if(type instanceof IExtendedHintedElementType) { >- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(req.getContainer()); >- if(provider == null) { >- return UnexecutableCommand.INSTANCE; >- } >- >- // Retrieve create command from the Element Edit service >- ICommand createGMFCommand = provider.getEditCommand(req); >- >- return getGEFWrapper(createGMFCommand); >- } >- >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getSetCommand(SetRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getEditContextCommand(GetEditContextRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getDestroyElementCommand(DestroyElementRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getDuplicateCommand(DuplicateElementsRequest req) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected Command getMoveCommand(MoveRequest req) { >- >- return getGEFWrapper(new MoveElementsCommand(req)); >- >- } >- >- /** >- * @generated >- */ >- protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) { >- return UnexecutableCommand.INSTANCE; >- } >- >- /** >- * @generated >- */ >- protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) { >- return UnexecutableCommand.INSTANCE; >- } >- >- /** >- * @generated >- */ >- protected final Command getGEFWrapper(ICommand cmd) { >- return new ICommandProxy(cmd); >- } >- >- /** >- * Returns editing domain from the host edit part. >- * >- * @generated >- */ >- protected TransactionalEditingDomain getEditingDomain() { >- return ((IGraphicalEditPart)getHost()).getEditingDomain(); >- } >- >- /** >- * Clean all shortcuts to the host element from the same diagram >- * >- * @generated >- */ >- protected void addDestroyShortcutsCommand(ICompositeCommand cmd, View view) { >- assert view.getEAnnotation("Shortcut") == null; //$NON-NLS-1$ >- for(Iterator it = view.getDiagram().getChildren().iterator(); it.hasNext();) { >- View nextView = (View)it.next(); >- if(nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { //$NON-NLS-1$ >- continue; >- } >- cmd.add(new DeleteCommand(getEditingDomain(), nextView)); >- } >- } >- >- /** >- * @generated >- */ >- public static LinkConstraints getLinkConstraints() { >- LinkConstraints cached = SysmlDiagramEditorPlugin.getInstance().getLinkConstraints(); >- if(cached == null) { >- SysmlDiagramEditorPlugin.getInstance().setLinkConstraints(cached = new LinkConstraints()); >- } >- return cached; >- } >- >- /** >- * @generated >- */ >- public static class LinkConstraints { >- >- /** >- * @generated >- */ >- public LinkConstraints() { >- // use static method #getLinkConstraints() to access instance >- } >- >- /** >- * @generated >- */ >- public boolean canCreateConnector_4001(StructuredClassifier container, ConnectableElement source, ConnectableElement target) { >- return canExistConnector_4001(container, null, source, target); >- } >- >- /** >- * @generated >- */ >- public boolean canExistConnector_4001(StructuredClassifier container, Connector linkInstance, ConnectableElement source, ConnectableElement target) { >- return true; >- } >- >- /** >- * Connector source and target must have the salme type >- * >- * @generated NOT >- */ >- public static boolean canExistConnector_4001(StructuredClassifier container, ConnectableElement source, ConnectableElement target) { >- Type sourceType = (source == null) ? null : source.getType(); >- Type targetType = (target == null) ? null : target.getType(); >- if(sourceType != null && target == null) { >- return true; >- } >- return (sourceType != null && targetType != null && sourceType.equals(targetType)); >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlTextNonResizableEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlTextNonResizableEditPolicy.java >deleted file mode 100644 >index 8265437..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlTextNonResizableEditPolicy.java >+++ /dev/null >@@ -1,236 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import java.util.Collections; >-import java.util.List; >- >-import org.eclipse.draw2d.ColorConstants; >-import org.eclipse.draw2d.Figure; >-import org.eclipse.draw2d.FigureListener; >-import org.eclipse.draw2d.Graphics; >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.Label; >-import org.eclipse.draw2d.RectangleFigure; >-import org.eclipse.draw2d.geometry.Rectangle; >-import org.eclipse.gef.GraphicalEditPart; >-import org.eclipse.gef.handles.MoveHandle; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableEditPolicyEx; >-import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >- >-/** >- * @generated >- */ >-public class SysmlTextNonResizableEditPolicy extends NonResizableEditPolicyEx { >- >- /** >- * @generated >- */ >- private IFigure selectionFeedbackFigure; >- >- /** >- * @generated >- */ >- private IFigure focusFeedbackFigure; >- >- /** >- * @generated >- */ >- private FigureListener hostPositionListener; >- >- /** >- * @generated >- */ >- protected void showPrimarySelection() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setSelected(true); >- ((WrappingLabel)getHostFigure()).setFocus(true); >- } else { >- showSelection(); >- showFocus(); >- } >- } >- >- /** >- * @generated >- */ >- protected void showSelection() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setSelected(true); >- ((WrappingLabel)getHostFigure()).setFocus(false); >- } else { >- hideSelection(); >- addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure()); >- getHostFigure().addFigureListener(getHostPositionListener()); >- refreshSelectionFeedback(); >- hideFocus(); >- } >- } >- >- /** >- * @generated >- */ >- protected void hideSelection() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setSelected(false); >- ((WrappingLabel)getHostFigure()).setFocus(false); >- } else { >- if(selectionFeedbackFigure != null) { >- removeFeedback(selectionFeedbackFigure); >- getHostFigure().removeFigureListener(getHostPositionListener()); >- selectionFeedbackFigure = null; >- } >- hideFocus(); >- } >- } >- >- /** >- * @generated >- */ >- protected void showFocus() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setFocus(true); >- } else { >- hideFocus(); >- addFeedback(focusFeedbackFigure = createFocusFeedbackFigure()); >- refreshFocusFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- protected void hideFocus() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setFocus(false); >- } else { >- if(focusFeedbackFigure != null) { >- removeFeedback(focusFeedbackFigure); >- focusFeedbackFigure = null; >- } >- } >- } >- >- /** >- * @generated >- */ >- protected Rectangle getFeedbackBounds() { >- Rectangle bounds; >- if(getHostFigure() instanceof Label) { >- bounds = ((Label)getHostFigure()).getTextBounds(); >- bounds.intersect(getHostFigure().getBounds()); >- } else { >- bounds = getHostFigure().getBounds().getCopy(); >- } >- getHostFigure().getParent().translateToAbsolute(bounds); >- getFeedbackLayer().translateToRelative(bounds); >- return bounds; >- } >- >- /** >- * @generated >- */ >- protected IFigure createSelectionFeedbackFigure() { >- if(getHostFigure() instanceof Label) { >- Label feedbackFigure = new Label(); >- feedbackFigure.setOpaque(true); >- feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected); >- feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected); >- return feedbackFigure; >- } else { >- RectangleFigure feedbackFigure = new RectangleFigure(); >- feedbackFigure.setFill(false); >- return feedbackFigure; >- } >- } >- >- /** >- * @generated >- */ >- protected IFigure createFocusFeedbackFigure() { >- return new Figure() { >- >- protected void paintFigure(Graphics graphics) { >- graphics.drawFocus(getBounds().getResized(-1, -1)); >- } >- }; >- } >- >- /** >- * @generated >- */ >- protected void updateLabel(Label target) { >- Label source = (Label)getHostFigure(); >- target.setText(source.getText()); >- target.setTextAlignment(source.getTextAlignment()); >- target.setFont(source.getFont()); >- } >- >- /** >- * @generated >- */ >- protected void refreshSelectionFeedback() { >- if(selectionFeedbackFigure != null) { >- if(selectionFeedbackFigure instanceof Label) { >- updateLabel((Label)selectionFeedbackFigure); >- selectionFeedbackFigure.setBounds(getFeedbackBounds()); >- } else { >- selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5)); >- } >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshFocusFeedback() { >- if(focusFeedbackFigure != null) { >- focusFeedbackFigure.setBounds(getFeedbackBounds()); >- } >- } >- >- /** >- * @generated >- */ >- public void refreshFeedback() { >- refreshSelectionFeedback(); >- refreshFocusFeedback(); >- } >- >- /** >- * @generated >- */ >- private FigureListener getHostPositionListener() { >- if(hostPositionListener == null) { >- hostPositionListener = new FigureListener() { >- >- public void figureMoved(IFigure source) { >- refreshFeedback(); >- } >- }; >- } >- return hostPositionListener; >- } >- >- /** >- * @generated >- */ >- protected List createSelectionHandles() { >- MoveHandle moveHandle = new MoveHandle((GraphicalEditPart)getHost()); >- moveHandle.setBorder(null); >- moveHandle.setDragTracker(new DragEditPartsTrackerEx(getHost())); >- return Collections.singletonList(moveHandle); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlTextSelectionEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlTextSelectionEditPolicy.java >deleted file mode 100644 >index 3e5d81b..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/edit/policies/SysmlTextSelectionEditPolicy.java >+++ /dev/null >@@ -1,220 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.edit.policies; >- >-import org.eclipse.draw2d.ColorConstants; >-import org.eclipse.draw2d.Figure; >-import org.eclipse.draw2d.FigureListener; >-import org.eclipse.draw2d.Graphics; >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.Label; >-import org.eclipse.draw2d.RectangleFigure; >-import org.eclipse.draw2d.geometry.Rectangle; >-import org.eclipse.gef.editpolicies.SelectionEditPolicy; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; >- >-/** >- * @generated >- */ >-public class SysmlTextSelectionEditPolicy extends SelectionEditPolicy { >- >- /** >- * @generated >- */ >- private IFigure selectionFeedbackFigure; >- >- /** >- * @generated >- */ >- private IFigure focusFeedbackFigure; >- >- /** >- * @generated >- */ >- private FigureListener hostPositionListener; >- >- /** >- * @generated >- */ >- protected void showPrimarySelection() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setSelected(true); >- ((WrappingLabel)getHostFigure()).setFocus(true); >- } else { >- showSelection(); >- showFocus(); >- } >- } >- >- /** >- * @generated >- */ >- protected void showSelection() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setSelected(true); >- ((WrappingLabel)getHostFigure()).setFocus(false); >- } else { >- hideSelection(); >- addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure()); >- getHostFigure().addFigureListener(getHostPositionListener()); >- refreshSelectionFeedback(); >- hideFocus(); >- } >- } >- >- /** >- * @generated >- */ >- protected void hideSelection() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setSelected(false); >- ((WrappingLabel)getHostFigure()).setFocus(false); >- } else { >- if(selectionFeedbackFigure != null) { >- removeFeedback(selectionFeedbackFigure); >- getHostFigure().removeFigureListener(getHostPositionListener()); >- selectionFeedbackFigure = null; >- } >- hideFocus(); >- } >- } >- >- /** >- * @generated >- */ >- protected void showFocus() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setFocus(true); >- } else { >- hideFocus(); >- addFeedback(focusFeedbackFigure = createFocusFeedbackFigure()); >- refreshFocusFeedback(); >- } >- } >- >- /** >- * @generated >- */ >- protected void hideFocus() { >- if(getHostFigure() instanceof WrappingLabel) { >- ((WrappingLabel)getHostFigure()).setFocus(false); >- } else { >- if(focusFeedbackFigure != null) { >- removeFeedback(focusFeedbackFigure); >- focusFeedbackFigure = null; >- } >- } >- } >- >- /** >- * @generated >- */ >- protected Rectangle getFeedbackBounds() { >- Rectangle bounds; >- if(getHostFigure() instanceof Label) { >- bounds = ((Label)getHostFigure()).getTextBounds(); >- bounds.intersect(getHostFigure().getBounds()); >- } else { >- bounds = getHostFigure().getBounds().getCopy(); >- } >- getHostFigure().getParent().translateToAbsolute(bounds); >- getFeedbackLayer().translateToRelative(bounds); >- return bounds; >- } >- >- /** >- * @generated >- */ >- protected IFigure createSelectionFeedbackFigure() { >- if(getHostFigure() instanceof Label) { >- Label feedbackFigure = new Label(); >- feedbackFigure.setOpaque(true); >- feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected); >- feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected); >- return feedbackFigure; >- } else { >- RectangleFigure feedbackFigure = new RectangleFigure(); >- feedbackFigure.setFill(false); >- return feedbackFigure; >- } >- } >- >- /** >- * @generated >- */ >- protected IFigure createFocusFeedbackFigure() { >- return new Figure() { >- >- protected void paintFigure(Graphics graphics) { >- graphics.drawFocus(getBounds().getResized(-1, -1)); >- } >- }; >- } >- >- /** >- * @generated >- */ >- protected void updateLabel(Label target) { >- Label source = (Label)getHostFigure(); >- target.setText(source.getText()); >- target.setTextAlignment(source.getTextAlignment()); >- target.setFont(source.getFont()); >- } >- >- /** >- * @generated >- */ >- protected void refreshSelectionFeedback() { >- if(selectionFeedbackFigure != null) { >- if(selectionFeedbackFigure instanceof Label) { >- updateLabel((Label)selectionFeedbackFigure); >- selectionFeedbackFigure.setBounds(getFeedbackBounds()); >- } else { >- selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5)); >- } >- } >- } >- >- /** >- * @generated >- */ >- protected void refreshFocusFeedback() { >- if(focusFeedbackFigure != null) { >- focusFeedbackFigure.setBounds(getFeedbackBounds()); >- } >- } >- >- /** >- * @generated >- */ >- public void refreshFeedback() { >- refreshSelectionFeedback(); >- refreshFocusFeedback(); >- } >- >- /** >- * @generated >- */ >- private FigureListener getHostPositionListener() { >- if(hostPositionListener == null) { >- hostPositionListener = new FigureListener() { >- >- public void figureMoved(IFigure source) { >- refreshFeedback(); >- } >- }; >- } >- return hostPositionListener; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/figures/CustomBlockPropertyCompositeFigure.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/figures/CustomBlockPropertyCompositeFigure.java >new file mode 100644 >index 0000000..29ec489 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/figures/CustomBlockPropertyCompositeFigure.java >@@ -0,0 +1,24 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.figures; >+ >+import org.eclipse.draw2d.Label; >+import org.eclipse.papyrus.sysml.diagram.common.figure.BlockPropertyCompositeFigure; >+ >+public class CustomBlockPropertyCompositeFigure extends >+ BlockPropertyCompositeFigure { >+ >+ @Override >+ protected void initTagLabel(String value) { >+ // do nothing: we don't want a two lines element (tag + name) >+ } >+ >+ @Override >+ public Label getTaggedLabel() { >+ // return a mock Label >+ return new Label(); >+ } >+ >+ @Override >+ public void setNameLabelIcon(boolean displayNameLabelIcon) { >+ getNameLabel().setIcon(null); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/figures/ParametricDiagramFrameFigure.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/figures/ParametricDiagramFrameFigure.java >new file mode 100644 >index 0000000..0f392df >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/figures/ParametricDiagramFrameFigure.java >@@ -0,0 +1,17 @@ >+/***************************************************************************** >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.figures; >+ >+import org.eclipse.papyrus.sysml.diagram.common.figure.SysMLDiagramFrameFigure; >+ >+public class ParametricDiagramFrameFigure extends SysMLDiagramFrameFigure { >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlAbstractNavigatorItem.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlAbstractNavigatorItem.java >deleted file mode 100644 >index c8dacc0..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlAbstractNavigatorItem.java >+++ /dev/null >@@ -1,71 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import org.eclipse.core.runtime.IAdapterFactory; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.core.runtime.PlatformObject; >-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; >- >-/** >- * @generated >- */ >-public abstract class SysmlAbstractNavigatorItem extends PlatformObject { >- >- /** >- * @generated >- */ >- static { >- final Class[] supportedTypes = new Class[]{ ITabbedPropertySheetPageContributor.class }; >- final ITabbedPropertySheetPageContributor propertySheetPageContributor = new ITabbedPropertySheetPageContributor() { >- >- public String getContributorId() { >- return "org.eclipse.papyrus.sysml.diagram.parametric"; //$NON-NLS-1$ >- } >- }; >- Platform.getAdapterManager().registerAdapters(new IAdapterFactory() { >- >- public Object getAdapter(Object adaptableObject, Class adapterType) { >- if(adaptableObject instanceof org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlAbstractNavigatorItem && adapterType == ITabbedPropertySheetPageContributor.class) { >- return propertySheetPageContributor; >- } >- return null; >- } >- >- public Class[] getAdapterList() { >- return supportedTypes; >- } >- }, org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlAbstractNavigatorItem.class); >- } >- >- /** >- * @generated >- */ >- private Object myParent; >- >- /** >- * @generated >- */ >- protected SysmlAbstractNavigatorItem(Object parent) { >- myParent = parent; >- } >- >- /** >- * @generated >- */ >- public Object getParent() { >- return myParent; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorContentProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorContentProvider.java >deleted file mode 100644 >index 2125893..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorContentProvider.java >+++ /dev/null >@@ -1,230 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.HashMap; >-import java.util.Iterator; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; >-import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; >-import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory; >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.ui.IMemento; >-import org.eclipse.ui.navigator.ICommonContentExtensionSite; >-import org.eclipse.ui.navigator.ICommonContentProvider; >- >-/** >- * @generated >- */ >-public class SysmlDomainNavigatorContentProvider implements ICommonContentProvider { >- >- /** >- * @generated >- */ >- private AdapterFactoryContentProvider myAdapterFctoryContentProvier; >- >- /** >- * @generated >- */ >- private static final Object[] EMPTY_ARRAY = new Object[0]; >- >- /** >- * @generated >- */ >- private Viewer myViewer; >- >- /** >- * @generated >- */ >- private AdapterFactoryEditingDomain myEditingDomain; >- >- /** >- * @generated >- */ >- private WorkspaceSynchronizer myWorkspaceSynchronizer; >- >- /** >- * @generated >- */ >- private Runnable myViewerRefreshRunnable; >- >- /** >- * @generated >- */ >- public SysmlDomainNavigatorContentProvider() { >- myAdapterFctoryContentProvier = new AdapterFactoryContentProvider(SysmlDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory()); >- TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain(); >- myEditingDomain = (AdapterFactoryEditingDomain)editingDomain; >- myEditingDomain.setResourceToReadOnlyMap(new HashMap() { >- >- public Object get(Object key) { >- if(!containsKey(key)) { >- put(key, Boolean.TRUE); >- } >- return super.get(key); >- } >- }); >- myViewerRefreshRunnable = new Runnable() { >- >- public void run() { >- if(myViewer != null) { >- myViewer.refresh(); >- } >- } >- }; >- myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain, new WorkspaceSynchronizer.Delegate() { >- >- public void dispose() { >- } >- >- public boolean handleResourceChanged(final Resource resource) { >- for(Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource nextResource = (Resource)it.next(); >- nextResource.unload(); >- } >- if(myViewer != null) { >- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable); >- } >- return true; >- } >- >- public boolean handleResourceDeleted(Resource resource) { >- for(Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource nextResource = (Resource)it.next(); >- nextResource.unload(); >- } >- if(myViewer != null) { >- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable); >- } >- return true; >- } >- >- public boolean handleResourceMoved(Resource resource, final URI newURI) { >- for(Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource nextResource = (Resource)it.next(); >- nextResource.unload(); >- } >- if(myViewer != null) { >- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable); >- } >- return true; >- } >- }); >- } >- >- /** >- * @generated >- */ >- public void dispose() { >- myWorkspaceSynchronizer.dispose(); >- myWorkspaceSynchronizer = null; >- myViewerRefreshRunnable = null; >- for(Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource resource = (Resource)it.next(); >- resource.unload(); >- } >- ((TransactionalEditingDomain)myEditingDomain).dispose(); >- myEditingDomain = null; >- } >- >- /** >- * @generated >- */ >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- myViewer = viewer; >- } >- >- /** >- * @generated >- */ >- public Object[] getElements(Object inputElement) { >- return getChildren(inputElement); >- } >- >- /** >- * @generated >- */ >- public void restoreState(IMemento aMemento) { >- } >- >- /** >- * @generated >- */ >- public void saveState(IMemento aMemento) { >- } >- >- /** >- * @generated >- */ >- public void init(ICommonContentExtensionSite aConfig) { >- } >- >- /** >- * @generated >- */ >- public Object[] getChildren(Object parentElement) { >- if(parentElement instanceof IFile) { >- IFile file = (IFile)parentElement; >- URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); >- Resource resource = myEditingDomain.getResourceSet().getResource(fileURI, true); >- return wrapEObjects(myAdapterFctoryContentProvier.getChildren(resource), parentElement); >- } >- >- if(parentElement instanceof SysmlDomainNavigatorItem) { >- return wrapEObjects(myAdapterFctoryContentProvier.getChildren(((SysmlDomainNavigatorItem)parentElement).getEObject()), parentElement); >- } >- return EMPTY_ARRAY; >- } >- >- /** >- * @generated >- */ >- public Object[] wrapEObjects(Object[] objects, Object parentElement) { >- Collection result = new ArrayList(); >- for(int i = 0; i < objects.length; i++) { >- if(objects[i] instanceof EObject) { >- result.add(new SysmlDomainNavigatorItem((EObject)objects[i], parentElement, myAdapterFctoryContentProvier)); >- } >- } >- return result.toArray(); >- } >- >- /** >- * @generated >- */ >- public Object getParent(Object element) { >- if(element instanceof SysmlAbstractNavigatorItem) { >- SysmlAbstractNavigatorItem abstractNavigatorItem = (SysmlAbstractNavigatorItem)element; >- return abstractNavigatorItem.getParent(); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- public boolean hasChildren(Object element) { >- return element instanceof IFile || getChildren(element).length > 0; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorItem.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorItem.java >deleted file mode 100644 >index 446065f..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorItem.java >+++ /dev/null >@@ -1,119 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import org.eclipse.core.runtime.IAdapterFactory; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.core.runtime.PlatformObject; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.ui.views.properties.IPropertySource; >-import org.eclipse.ui.views.properties.IPropertySourceProvider; >- >-/** >- * @generated >- */ >-public class SysmlDomainNavigatorItem extends PlatformObject { >- >- /** >- * @generated >- */ >- static { >- final Class[] supportedTypes = new Class[]{ EObject.class, IPropertySource.class }; >- Platform.getAdapterManager().registerAdapters(new IAdapterFactory() { >- >- public Object getAdapter(Object adaptableObject, Class adapterType) { >- if(adaptableObject instanceof org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorItem) { >- org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorItem domainNavigatorItem = (org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorItem)adaptableObject; >- EObject eObject = domainNavigatorItem.getEObject(); >- if(adapterType == EObject.class) { >- return eObject; >- } >- if(adapterType == IPropertySource.class) { >- return domainNavigatorItem.getPropertySourceProvider().getPropertySource(eObject); >- } >- } >- >- return null; >- } >- >- public Class[] getAdapterList() { >- return supportedTypes; >- } >- }, org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorItem.class); >- } >- >- /** >- * @generated >- */ >- private Object myParent; >- >- /** >- * @generated >- */ >- private EObject myEObject; >- >- /** >- * @generated >- */ >- private IPropertySourceProvider myPropertySourceProvider; >- >- /** >- * @generated >- */ >- public SysmlDomainNavigatorItem(EObject eObject, Object parent, IPropertySourceProvider propertySourceProvider) { >- myParent = parent; >- myEObject = eObject; >- myPropertySourceProvider = propertySourceProvider; >- } >- >- /** >- * @generated >- */ >- public Object getParent() { >- return myParent; >- } >- >- /** >- * @generated >- */ >- public EObject getEObject() { >- return myEObject; >- } >- >- /** >- * @generated >- */ >- public IPropertySourceProvider getPropertySourceProvider() { >- return myPropertySourceProvider; >- } >- >- /** >- * @generated >- */ >- public boolean equals(Object obj) { >- if(obj instanceof org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorItem) { >- return EcoreUtil.getURI(getEObject()).equals(EcoreUtil.getURI(((org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlDomainNavigatorItem)obj).getEObject())); >- } >- return super.equals(obj); >- } >- >- /** >- * @generated >- */ >- public int hashCode() { >- return EcoreUtil.getURI(getEObject()).hashCode(); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorLabelProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorLabelProvider.java >deleted file mode 100644 >index 935c470..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlDomainNavigatorLabelProvider.java >+++ /dev/null >@@ -1,107 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; >-import org.eclipse.jface.viewers.ILabelProviderListener; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.IMemento; >-import org.eclipse.ui.navigator.ICommonContentExtensionSite; >-import org.eclipse.ui.navigator.ICommonLabelProvider; >- >-/** >- * @generated >- */ >-public class SysmlDomainNavigatorLabelProvider implements ICommonLabelProvider { >- >- /** >- * @generated >- */ >- private AdapterFactoryLabelProvider myAdapterFactoryLabelProvider = new AdapterFactoryLabelProvider(SysmlDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory()); >- >- /** >- * @generated >- */ >- public void init(ICommonContentExtensionSite aConfig) { >- } >- >- /** >- * @generated >- */ >- public Image getImage(Object element) { >- if(element instanceof SysmlDomainNavigatorItem) { >- return myAdapterFactoryLabelProvider.getImage(((SysmlDomainNavigatorItem)element).getEObject()); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- public String getText(Object element) { >- if(element instanceof SysmlDomainNavigatorItem) { >- return myAdapterFactoryLabelProvider.getText(((SysmlDomainNavigatorItem)element).getEObject()); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- public void addListener(ILabelProviderListener listener) { >- myAdapterFactoryLabelProvider.addListener(listener); >- } >- >- /** >- * @generated >- */ >- public void dispose() { >- myAdapterFactoryLabelProvider.dispose(); >- } >- >- /** >- * @generated >- */ >- public boolean isLabelProperty(Object element, String property) { >- return myAdapterFactoryLabelProvider.isLabelProperty(element, property); >- } >- >- /** >- * @generated >- */ >- public void removeListener(ILabelProviderListener listener) { >- myAdapterFactoryLabelProvider.removeListener(listener); >- } >- >- /** >- * @generated >- */ >- public void restoreState(IMemento aMemento) { >- } >- >- /** >- * @generated >- */ >- public void saveState(IMemento aMemento) { >- } >- >- /** >- * @generated >- */ >- public String getDescription(Object anElement) { >- return null; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorActionProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorActionProvider.java >deleted file mode 100644 >index 5f39e88..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorActionProvider.java >+++ /dev/null >@@ -1,181 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.ui.URIEditorInput; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.action.Action; >-import org.eclipse.jface.action.IMenuManager; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.Messages; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditor; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.ui.IActionBars; >-import org.eclipse.ui.IEditorInput; >-import org.eclipse.ui.IWorkbenchPage; >-import org.eclipse.ui.PartInitException; >-import org.eclipse.ui.navigator.CommonActionProvider; >-import org.eclipse.ui.navigator.ICommonActionConstants; >-import org.eclipse.ui.navigator.ICommonActionExtensionSite; >-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; >-import org.eclipse.ui.part.FileEditorInput; >- >-/** >- * @generated >- */ >-public class SysmlNavigatorActionProvider extends CommonActionProvider { >- >- /** >- * @generated >- */ >- private boolean myContribute; >- >- /** >- * @generated >- */ >- private OpenDiagramAction myOpenDiagramAction; >- >- /** >- * @generated >- */ >- public void init(ICommonActionExtensionSite aSite) { >- super.init(aSite); >- if(aSite.getViewSite() instanceof ICommonViewerWorkbenchSite) { >- myContribute = true; >- makeActions((ICommonViewerWorkbenchSite)aSite.getViewSite()); >- } else { >- myContribute = false; >- } >- } >- >- /** >- * @generated >- */ >- private void makeActions(ICommonViewerWorkbenchSite viewerSite) { >- myOpenDiagramAction = new OpenDiagramAction(viewerSite); >- } >- >- /** >- * @generated >- */ >- public void fillActionBars(IActionBars actionBars) { >- if(!myContribute) { >- return; >- } >- IStructuredSelection selection = (IStructuredSelection)getContext().getSelection(); >- myOpenDiagramAction.selectionChanged(selection); >- if(myOpenDiagramAction.isEnabled()) { >- actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, myOpenDiagramAction); >- } >- } >- >- /** >- * @generated >- */ >- public void fillContextMenu(IMenuManager menu) { >- } >- >- /** >- * @generated >- */ >- private static class OpenDiagramAction extends Action { >- >- /** >- * @generated >- */ >- private Diagram myDiagram; >- >- /** >- * @generated >- */ >- private ICommonViewerWorkbenchSite myViewerSite; >- >- /** >- * @generated >- */ >- public OpenDiagramAction(ICommonViewerWorkbenchSite viewerSite) { >- super(Messages.NavigatorActionProvider_OpenDiagramActionName); >- myViewerSite = viewerSite; >- } >- >- /** >- * @generated >- */ >- public final void selectionChanged(IStructuredSelection selection) { >- myDiagram = null; >- if(selection.size() == 1) { >- Object selectedElement = selection.getFirstElement(); >- if(selectedElement instanceof SysmlNavigatorItem) { >- selectedElement = ((SysmlNavigatorItem)selectedElement).getView(); >- } else if(selectedElement instanceof IAdaptable) { >- selectedElement = ((IAdaptable)selectedElement).getAdapter(View.class); >- } >- if(selectedElement instanceof Diagram) { >- Diagram diagram = (Diagram)selectedElement; >- if(ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID(diagram))) { >- myDiagram = diagram; >- } >- } >- } >- setEnabled(myDiagram != null); >- } >- >- /** >- * @generated >- */ >- public void run() { >- if(myDiagram == null || myDiagram.eResource() == null) { >- return; >- } >- >- IEditorInput editorInput = getEditorInput(myDiagram); >- IWorkbenchPage page = myViewerSite.getPage(); >- try { >- page.openEditor(editorInput, SysmlDiagramEditor.ID); >- } catch (PartInitException e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Exception while openning diagram", e); //$NON-NLS-1$ >- } >- } >- >- /** >- * @generated >- */ >- private static IEditorInput getEditorInput(Diagram diagram) { >- Resource diagramResource = diagram.eResource(); >- for(EObject nextEObject : diagramResource.getContents()) { >- if(nextEObject == diagram) { >- return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource)); >- } >- if(nextEObject instanceof Diagram) { >- break; >- } >- } >- URI uri = EcoreUtil.getURI(diagram); >- String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram); >- IEditorInput editorInput = new URIEditorInput(uri, editorName); >- return editorInput; >- } >- >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorContentProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorContentProvider.java >deleted file mode 100644 >index aca9e58..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorContentProvider.java >+++ /dev/null >@@ -1,503 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.Collections; >-import java.util.HashMap; >-import java.util.Iterator; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; >-import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.Edge; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.Messages; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.ui.IMemento; >-import org.eclipse.ui.navigator.ICommonContentExtensionSite; >-import org.eclipse.ui.navigator.ICommonContentProvider; >- >-/** >- * @generated >- */ >-public class SysmlNavigatorContentProvider implements ICommonContentProvider { >- >- /** >- * @generated >- */ >- private static final Object[] EMPTY_ARRAY = new Object[0]; >- >- /** >- * @generated >- */ >- private Viewer myViewer; >- >- /** >- * @generated >- */ >- private AdapterFactoryEditingDomain myEditingDomain; >- >- /** >- * @generated >- */ >- private WorkspaceSynchronizer myWorkspaceSynchronizer; >- >- /** >- * @generated >- */ >- private Runnable myViewerRefreshRunnable; >- >- /** >- * @generated >- */ >- @SuppressWarnings({ "unchecked", "serial", "rawtypes" }) >- public SysmlNavigatorContentProvider() { >- TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain(); >- myEditingDomain = (AdapterFactoryEditingDomain)editingDomain; >- myEditingDomain.setResourceToReadOnlyMap(new HashMap() { >- >- public Object get(Object key) { >- if(!containsKey(key)) { >- put(key, Boolean.TRUE); >- } >- return super.get(key); >- } >- }); >- myViewerRefreshRunnable = new Runnable() { >- >- public void run() { >- if(myViewer != null) { >- myViewer.refresh(); >- } >- } >- }; >- myWorkspaceSynchronizer = new WorkspaceSynchronizer(editingDomain, new WorkspaceSynchronizer.Delegate() { >- >- public void dispose() { >- } >- >- public boolean handleResourceChanged(final Resource resource) { >- for(Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource nextResource = (Resource)it.next(); >- nextResource.unload(); >- } >- if(myViewer != null) { >- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable); >- } >- return true; >- } >- >- public boolean handleResourceDeleted(Resource resource) { >- for(Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource nextResource = (Resource)it.next(); >- nextResource.unload(); >- } >- if(myViewer != null) { >- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable); >- } >- return true; >- } >- >- public boolean handleResourceMoved(Resource resource, final URI newURI) { >- for(Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource nextResource = (Resource)it.next(); >- nextResource.unload(); >- } >- if(myViewer != null) { >- myViewer.getControl().getDisplay().asyncExec(myViewerRefreshRunnable); >- } >- return true; >- } >- }); >- } >- >- /** >- * >- * Papyrus Template this method is a modification of gmf code in order to avoid >- * getViewChidreen() method becoming greater than 64kb. >- * >- * @generated >- **/ >- private Object[] getViewChildrenForParametricEditPart(View view, Object parentElement) { >- Collection result = new ArrayList(); >- SysmlNavigatorGroup links = new SysmlNavigatorGroup(Messages.NavigatorGroupName_Resource_1000_links, "icons/linksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ >- Collection connectedViews = getChildrenByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(ConstraintPropertyEditPart.VISUAL_ID)); >- result.addAll(createNavigatorItems(connectedViews, parentElement, false)); >- connectedViews = getChildrenByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(PropertyEditPart.VISUAL_ID)); >- result.addAll(createNavigatorItems(connectedViews, parentElement, false)); >- connectedViews = getDiagramLinksByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(ConnectorEditPart.VISUAL_ID)); >- links.addChildren(createNavigatorItems(connectedViews, links, false)); >- if(!links.isEmpty()) { >- result.add(links); >- } >- return result.toArray(); >- } >- >- /** >- * >- * Papyrus Template this method is a modification of gmf code in order to avoid >- * getViewChidreen() method becoming greater than 64kb. >- * >- * @generated >- **/ >- private Object[] getViewChildrenForConstraintPropertyEditPart(View view, Object parentElement) { >- Collection result = new ArrayList(); >- Collection connectedViews = getChildrenByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(Property2EditPart.VISUAL_ID)); >- result.addAll(createNavigatorItems(connectedViews, parentElement, false)); >- return result.toArray(); >- } >- >- /** >- * >- * Papyrus Template this method is a modification of gmf code in order to avoid >- * getViewChidreen() method becoming greater than 64kb. >- * >- * @generated >- **/ >- private Object[] getViewChildrenForPropertyEditPart(View view, Object parentElement) { >- Collection result = new ArrayList(); >- SysmlNavigatorGroup incominglinks = new SysmlNavigatorGroup(Messages.NavigatorGroupName_Property_2005_incominglinks, "icons/incomingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ >- SysmlNavigatorGroup outgoinglinks = new SysmlNavigatorGroup(Messages.NavigatorGroupName_Property_2005_outgoinglinks, "icons/outgoingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ >- Collection connectedViews = getIncomingLinksByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(ConnectorEditPart.VISUAL_ID)); >- incominglinks.addChildren(createNavigatorItems(connectedViews, incominglinks, true)); >- connectedViews = getOutgoingLinksByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(ConnectorEditPart.VISUAL_ID)); >- outgoinglinks.addChildren(createNavigatorItems(connectedViews, outgoinglinks, true)); >- if(!incominglinks.isEmpty()) { >- result.add(incominglinks); >- } >- if(!outgoinglinks.isEmpty()) { >- result.add(outgoinglinks); >- } >- return result.toArray(); >- } >- >- /** >- * >- * Papyrus Template this method is a modification of gmf code in order to avoid >- * getViewChidreen() method becoming greater than 64kb. >- * >- * @generated >- **/ >- private Object[] getViewChildrenForProperty2EditPart(View view, Object parentElement) { >- Collection result = new ArrayList(); >- SysmlNavigatorGroup incominglinks = new SysmlNavigatorGroup(Messages.NavigatorGroupName_Property_3002_incominglinks, "icons/incomingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ >- SysmlNavigatorGroup outgoinglinks = new SysmlNavigatorGroup(Messages.NavigatorGroupName_Property_3002_outgoinglinks, "icons/outgoingLinksNavigatorGroup.gif", parentElement); //$NON-NLS-1$ >- Collection connectedViews = getIncomingLinksByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(ConnectorEditPart.VISUAL_ID)); >- incominglinks.addChildren(createNavigatorItems(connectedViews, incominglinks, true)); >- connectedViews = getOutgoingLinksByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(ConnectorEditPart.VISUAL_ID)); >- outgoinglinks.addChildren(createNavigatorItems(connectedViews, outgoinglinks, true)); >- if(!incominglinks.isEmpty()) { >- result.add(incominglinks); >- } >- if(!outgoinglinks.isEmpty()) { >- result.add(outgoinglinks); >- } >- return result.toArray(); >- } >- >- /** >- * >- * Papyrus Template this method is a modification of gmf code in order to avoid >- * getViewChidreen() method becoming greater than 64kb. >- * >- * @generated >- **/ >- private Object[] getViewChildrenForConnectorEditPart(View view, Object parentElement) { >- Collection result = new ArrayList(); >- SysmlNavigatorGroup target = new SysmlNavigatorGroup(Messages.NavigatorGroupName_Connector_4001_target, "icons/linkTargetNavigatorGroup.gif", parentElement); //$NON-NLS-1$ >- SysmlNavigatorGroup source = new SysmlNavigatorGroup(Messages.NavigatorGroupName_Connector_4001_source, "icons/linkSourceNavigatorGroup.gif", parentElement); //$NON-NLS-1$ >- Collection connectedViews = getLinksTargetByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(PropertyEditPart.VISUAL_ID)); >- target.addChildren(createNavigatorItems(connectedViews, target, true)); >- connectedViews = getLinksTargetByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(Property2EditPart.VISUAL_ID)); >- target.addChildren(createNavigatorItems(connectedViews, target, true)); >- connectedViews = getLinksSourceByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(PropertyEditPart.VISUAL_ID)); >- source.addChildren(createNavigatorItems(connectedViews, source, true)); >- connectedViews = getLinksSourceByType(Collections.singleton(view), SysmlVisualIDRegistry.getType(Property2EditPart.VISUAL_ID)); >- source.addChildren(createNavigatorItems(connectedViews, source, true)); >- if(!target.isEmpty()) { >- result.add(target); >- } >- if(!source.isEmpty()) { >- result.add(source); >- } >- return result.toArray(); >- } >- >- /** >- * @generated >- */ >- public void dispose() { >- myWorkspaceSynchronizer.dispose(); >- myWorkspaceSynchronizer = null; >- myViewerRefreshRunnable = null; >- for(Iterator it = myEditingDomain.getResourceSet().getResources().iterator(); it.hasNext();) { >- Resource resource = (Resource)it.next(); >- resource.unload(); >- } >- ((TransactionalEditingDomain)myEditingDomain).dispose(); >- myEditingDomain = null; >- } >- >- /** >- * @generated >- */ >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- myViewer = viewer; >- } >- >- /** >- * @generated >- */ >- public Object[] getElements(Object inputElement) { >- return getChildren(inputElement); >- } >- >- /** >- * @generated >- */ >- public void restoreState(IMemento aMemento) { >- } >- >- /** >- * @generated >- */ >- public void saveState(IMemento aMemento) { >- } >- >- /** >- * @generated >- */ >- public void init(ICommonContentExtensionSite aConfig) { >- } >- >- /** >- * @generated >- */ >- public Object[] getChildren(Object parentElement) { >- if(parentElement instanceof IFile) { >- IFile file = (IFile)parentElement; >- URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); >- Resource resource = myEditingDomain.getResourceSet().getResource(fileURI, true); >- Collection result = new ArrayList(); >- return result.toArray(); >- } >- >- if(parentElement instanceof SysmlNavigatorGroup) { >- SysmlNavigatorGroup group = (SysmlNavigatorGroup)parentElement; >- return group.getChildren(); >- } >- >- if(parentElement instanceof SysmlNavigatorItem) { >- SysmlNavigatorItem navigatorItem = (SysmlNavigatorItem)parentElement; >- if(navigatorItem.isLeaf() || !isOwnView(navigatorItem.getView())) { >- return EMPTY_ARRAY; >- } >- return getViewChildren(navigatorItem.getView(), parentElement); >- } >- >- return EMPTY_ARRAY; >- } >- >- /** >- * @generated >- */ >- private Object[] getViewChildren(View view, Object parentElement) { >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- >- case ParametricEditPart.VISUAL_ID: >- { >- >- //modification of the template to avoid mistake of 65kb. >- return getViewChildrenForParametricEditPart(view, parentElement); >- >- } >- >- case Property2EditPart.VISUAL_ID: >- { >- >- //modification of the template to avoid mistake of 65kb. >- return getViewChildrenForProperty2EditPart(view, parentElement); >- >- } >- >- case ConnectorEditPart.VISUAL_ID: >- { >- >- //modification of the template to avoid mistake of 65kb. >- return getViewChildrenForConnectorEditPart(view, parentElement); >- >- } >- >- case PropertyEditPart.VISUAL_ID: >- { >- >- //modification of the template to avoid mistake of 65kb. >- return getViewChildrenForPropertyEditPart(view, parentElement); >- >- } >- >- case ConstraintPropertyEditPart.VISUAL_ID: >- { >- >- //modification of the template to avoid mistake of 65kb. >- return getViewChildrenForConstraintPropertyEditPart(view, parentElement); >- >- } >- >- } >- return EMPTY_ARRAY; >- } >- >- /** >- * @generated >- */ >- private Collection getLinksSourceByType(Collection edges, String type) { >- Collection result = new ArrayList(); >- for(Iterator it = edges.iterator(); it.hasNext();) { >- Edge nextEdge = (Edge)it.next(); >- View nextEdgeSource = nextEdge.getSource(); >- if(type.equals(nextEdgeSource.getType()) && isOwnView(nextEdgeSource)) { >- result.add(nextEdgeSource); >- } >- } >- return result; >- } >- >- /** >- * @generated >- */ >- private Collection getLinksTargetByType(Collection edges, String type) { >- Collection result = new ArrayList(); >- for(Iterator it = edges.iterator(); it.hasNext();) { >- Edge nextEdge = (Edge)it.next(); >- View nextEdgeTarget = nextEdge.getTarget(); >- if(type.equals(nextEdgeTarget.getType()) && isOwnView(nextEdgeTarget)) { >- result.add(nextEdgeTarget); >- } >- } >- return result; >- } >- >- /** >- * @generated >- */ >- private Collection getOutgoingLinksByType(Collection nodes, String type) { >- Collection result = new ArrayList(); >- for(Iterator it = nodes.iterator(); it.hasNext();) { >- View nextNode = (View)it.next(); >- result.addAll(selectViewsByType(nextNode.getSourceEdges(), type)); >- } >- return result; >- } >- >- /** >- * @generated >- */ >- private Collection getIncomingLinksByType(Collection nodes, String type) { >- Collection result = new ArrayList(); >- for(Iterator it = nodes.iterator(); it.hasNext();) { >- View nextNode = (View)it.next(); >- result.addAll(selectViewsByType(nextNode.getTargetEdges(), type)); >- } >- return result; >- } >- >- /** >- * @generated >- */ >- private Collection getChildrenByType(Collection nodes, String type) { >- Collection result = new ArrayList(); >- for(Iterator it = nodes.iterator(); it.hasNext();) { >- View nextNode = (View)it.next(); >- result.addAll(selectViewsByType(nextNode.getChildren(), type)); >- } >- return result; >- } >- >- /** >- * @generated >- */ >- private Collection getDiagramLinksByType(Collection diagrams, String type) { >- Collection result = new ArrayList(); >- for(Iterator it = diagrams.iterator(); it.hasNext();) { >- Diagram nextDiagram = (Diagram)it.next(); >- result.addAll(selectViewsByType(nextDiagram.getEdges(), type)); >- } >- return result; >- } >- >- /** >- * @generated >- */ >- private Collection selectViewsByType(Collection views, String type) { >- Collection result = new ArrayList(); >- for(Iterator it = views.iterator(); it.hasNext();) { >- View nextView = (View)it.next(); >- if(type.equals(nextView.getType()) && isOwnView(nextView)) { >- result.add(nextView); >- } >- } >- return result; >- } >- >- /** >- * @generated >- */ >- private boolean isOwnView(View view) { >- return ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID(view)); >- } >- >- /** >- * @generated >- */ >- private Collection createNavigatorItems(Collection views, Object parent, boolean isLeafs) { >- Collection result = new ArrayList(); >- for(Iterator it = views.iterator(); it.hasNext();) { >- result.add(new SysmlNavigatorItem((View)it.next(), parent, isLeafs)); >- } >- return result; >- } >- >- /** >- * @generated >- */ >- public Object getParent(Object element) { >- if(element instanceof SysmlAbstractNavigatorItem) { >- SysmlAbstractNavigatorItem abstractNavigatorItem = (SysmlAbstractNavigatorItem)element; >- return abstractNavigatorItem.getParent(); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- public boolean hasChildren(Object element) { >- return element instanceof IFile || getChildren(element).length > 0; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorGroup.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorGroup.java >deleted file mode 100644 >index aff7bf8..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorGroup.java >+++ /dev/null >@@ -1,110 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import java.util.Collection; >-import java.util.LinkedList; >- >-/** >- * @generated >- */ >-public class SysmlNavigatorGroup extends SysmlAbstractNavigatorItem { >- >- /** >- * @generated >- */ >- private String myGroupName; >- >- /** >- * @generated >- */ >- private String myIcon; >- >- /** >- * @generated >- */ >- private Collection myChildren = new LinkedList(); >- >- /** >- * @generated >- */ >- SysmlNavigatorGroup(String groupName, String icon, Object parent) { >- super(parent); >- myGroupName = groupName; >- myIcon = icon; >- } >- >- /** >- * @generated >- */ >- public String getGroupName() { >- return myGroupName; >- } >- >- /** >- * @generated >- */ >- public String getIcon() { >- return myIcon; >- } >- >- /** >- * @generated >- */ >- public Object[] getChildren() { >- return myChildren.toArray(); >- } >- >- /** >- * @generated >- */ >- public void addChildren(Collection children) { >- myChildren.addAll(children); >- } >- >- /** >- * @generated >- */ >- public void addChild(Object child) { >- myChildren.add(child); >- } >- >- /** >- * @generated >- */ >- public boolean isEmpty() { >- return myChildren.size() == 0; >- } >- >- /** >- * @generated >- */ >- public boolean equals(Object obj) { >- if(obj instanceof org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorGroup) { >- org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorGroup anotherGroup = (org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorGroup)obj; >- if(getGroupName().equals(anotherGroup.getGroupName())) { >- return getParent().equals(anotherGroup.getParent()); >- } >- } >- return super.equals(obj); >- } >- >- /** >- * @generated >- */ >- public int hashCode() { >- return getGroupName().hashCode(); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorItem.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorItem.java >deleted file mode 100644 >index 11e87b6..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorItem.java >+++ /dev/null >@@ -1,97 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import org.eclipse.core.runtime.IAdapterFactory; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.gmf.runtime.notation.View; >- >-/** >- * @generated >- */ >-public class SysmlNavigatorItem extends SysmlAbstractNavigatorItem { >- >- /** >- * @generated >- */ >- static { >- final Class[] supportedTypes = new Class[]{ View.class, EObject.class }; >- Platform.getAdapterManager().registerAdapters(new IAdapterFactory() { >- >- public Object getAdapter(Object adaptableObject, Class adapterType) { >- if(adaptableObject instanceof org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorItem && (adapterType == View.class || adapterType == EObject.class)) { >- return ((org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorItem)adaptableObject).getView(); >- } >- return null; >- } >- >- public Class[] getAdapterList() { >- return supportedTypes; >- } >- }, org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorItem.class); >- } >- >- /** >- * @generated >- */ >- private View myView; >- >- /** >- * @generated >- */ >- private boolean myLeaf = false; >- >- /** >- * @generated >- */ >- public SysmlNavigatorItem(View view, Object parent, boolean isLeaf) { >- super(parent); >- myView = view; >- myLeaf = isLeaf; >- } >- >- /** >- * @generated >- */ >- public View getView() { >- return myView; >- } >- >- /** >- * @generated >- */ >- public boolean isLeaf() { >- return myLeaf; >- } >- >- /** >- * @generated >- */ >- public boolean equals(Object obj) { >- if(obj instanceof org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorItem) { >- return EcoreUtil.getURI(getView()).equals(EcoreUtil.getURI(((org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorItem)obj).getView())); >- } >- return super.equals(obj); >- } >- >- /** >- * @generated >- */ >- public int hashCode() { >- return EcoreUtil.getURI(getView()).hashCode(); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorLabelProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorLabelProvider.java >deleted file mode 100644 >index dc5dc54..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorLabelProvider.java >+++ /dev/null >@@ -1,274 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.jface.resource.ImageRegistry; >-import org.eclipse.jface.viewers.ITreePathLabelProvider; >-import org.eclipse.jface.viewers.LabelProvider; >-import org.eclipse.jface.viewers.TreePath; >-import org.eclipse.jface.viewers.ViewerLabel; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyName2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlParserProvider; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.IMemento; >-import org.eclipse.ui.navigator.ICommonContentExtensionSite; >-import org.eclipse.ui.navigator.ICommonLabelProvider; >- >-/** >- * @generated >- */ >-public class SysmlNavigatorLabelProvider extends LabelProvider implements ICommonLabelProvider, ITreePathLabelProvider { >- >- /** >- * @generated >- */ >- static { >- SysmlDiagramEditorPlugin.getInstance().getImageRegistry().put("Navigator?UnknownElement", ImageDescriptor.getMissingImageDescriptor()); //$NON-NLS-1$ >- SysmlDiagramEditorPlugin.getInstance().getImageRegistry().put("Navigator?ImageNotFound", ImageDescriptor.getMissingImageDescriptor()); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- public void updateLabel(ViewerLabel label, TreePath elementPath) { >- Object element = elementPath.getLastSegment(); >- if(element instanceof SysmlNavigatorItem && !isOwnView(((SysmlNavigatorItem)element).getView())) { >- return; >- } >- label.setText(getText(element)); >- label.setImage(getImage(element)); >- } >- >- /** >- * @generated >- */ >- public Image getImage(Object element) { >- if(element instanceof SysmlNavigatorGroup) { >- SysmlNavigatorGroup group = (SysmlNavigatorGroup)element; >- return SysmlDiagramEditorPlugin.getInstance().getBundledImage(group.getIcon()); >- } >- >- if(element instanceof SysmlNavigatorItem) { >- SysmlNavigatorItem navigatorItem = (SysmlNavigatorItem)element; >- if(!isOwnView(navigatorItem.getView())) { >- return super.getImage(element); >- } >- return getImage(navigatorItem.getView()); >- } >- >- return super.getImage(element); >- } >- >- /** >- * @generated >- */ >- public Image getImage(View view) { >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- case ParametricEditPart.VISUAL_ID: >- return getImage("Navigator?Diagram?http://www.eclipse.org/papyurs/0.7.0/Resource?Resource", SysmlElementTypes.Resource_1000); //$NON-NLS-1$ >- case Property2EditPart.VISUAL_ID: >- return getImage("Navigator?Node?http://www.eclipse.org/uml2/3.0.0/UML?Property", SysmlElementTypes.Property_3002); //$NON-NLS-1$ >- case ConnectorEditPart.VISUAL_ID: >- return getImage("Navigator?Link?http://www.eclipse.org/uml2/3.0.0/UML?Connector", SysmlElementTypes.Connector_4001); //$NON-NLS-1$ >- case PropertyEditPart.VISUAL_ID: >- return getImage("Navigator?TopLevelNode?http://www.eclipse.org/uml2/3.0.0/UML?Property", SysmlElementTypes.Property_2005); //$NON-NLS-1$ >- case ConstraintPropertyEditPart.VISUAL_ID: >- return getImage("Navigator?TopLevelNode?http://www.eclipse.org/papyrus/0.7.0/SysML/Constraints?ConstraintProperty", SysmlElementTypes.ConstraintProperty_2003); //$NON-NLS-1$ >- } >- return getImage("Navigator?UnknownElement", null); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- private Image getImage(String key, IElementType elementType) { >- ImageRegistry imageRegistry = SysmlDiagramEditorPlugin.getInstance().getImageRegistry(); >- Image image = imageRegistry.get(key); >- if(image == null && elementType != null && SysmlElementTypes.isKnownElementType(elementType)) { >- image = SysmlElementTypes.getImage(elementType); >- imageRegistry.put(key, image); >- } >- >- if(image == null) { >- image = imageRegistry.get("Navigator?ImageNotFound"); //$NON-NLS-1$ >- imageRegistry.put(key, image); >- } >- return image; >- } >- >- /** >- * @generated >- */ >- public String getText(Object element) { >- if(element instanceof SysmlNavigatorGroup) { >- SysmlNavigatorGroup group = (SysmlNavigatorGroup)element; >- return group.getGroupName(); >- } >- >- if(element instanceof SysmlNavigatorItem) { >- SysmlNavigatorItem navigatorItem = (SysmlNavigatorItem)element; >- if(!isOwnView(navigatorItem.getView())) { >- return null; >- } >- return getText(navigatorItem.getView()); >- } >- >- return super.getText(element); >- } >- >- /** >- * @generated >- */ >- public String getText(View view) { >- if(view.getElement() != null && view.getElement().eIsProxy()) { >- return getUnresolvedDomainElementProxyText(view); >- } >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- case ParametricEditPart.VISUAL_ID: >- return getResource_1000Text(view); >- case Property2EditPart.VISUAL_ID: >- return getProperty_3002Text(view); >- case ConnectorEditPart.VISUAL_ID: >- return getConnector_4001Text(view); >- case PropertyEditPart.VISUAL_ID: >- return getProperty_2005Text(view); >- case ConstraintPropertyEditPart.VISUAL_ID: >- return getConstraintProperty_2003Text(view); >- } >- return getUnknownElementText(view); >- } >- >- /** >- * @generated >- */ >- private String getResource_1000Text(View view) { >- return ""; //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- private String getConstraintProperty_2003Text(View view) { >- IParser parser = SysmlParserProvider.getParser(SysmlElementTypes.ConstraintProperty_2003, view.getElement() != null ? view.getElement() : view, SysmlVisualIDRegistry.getType(ConstraintPropertyNameEditPart.VISUAL_ID)); >- if(parser != null) { >- return parser.getPrintString(new EObjectAdapter(view.getElement() != null ? view.getElement() : view), ParserOptions.NONE.intValue()); >- } else { >- SysmlDiagramEditorPlugin.getInstance().logError("Parser was not found for label " + 5001); //$NON-NLS-1$ >- return ""; //$NON-NLS-1$ >- } >- } >- >- /** >- * @generated >- */ >- private String getProperty_2005Text(View view) { >- IParser parser = SysmlParserProvider.getParser(SysmlElementTypes.Property_2005, view.getElement() != null ? view.getElement() : view, SysmlVisualIDRegistry.getType(PropertyNameEditPart.VISUAL_ID)); >- if(parser != null) { >- return parser.getPrintString(new EObjectAdapter(view.getElement() != null ? view.getElement() : view), ParserOptions.NONE.intValue()); >- } else { >- SysmlDiagramEditorPlugin.getInstance().logError("Parser was not found for label " + 5002); //$NON-NLS-1$ >- return ""; //$NON-NLS-1$ >- } >- } >- >- /** >- * @generated >- */ >- private String getProperty_3002Text(View view) { >- IParser parser = SysmlParserProvider.getParser(SysmlElementTypes.Property_3002, view.getElement() != null ? view.getElement() : view, SysmlVisualIDRegistry.getType(PropertyName2EditPart.VISUAL_ID)); >- if(parser != null) { >- return parser.getPrintString(new EObjectAdapter(view.getElement() != null ? view.getElement() : view), ParserOptions.NONE.intValue()); >- } else { >- SysmlDiagramEditorPlugin.getInstance().logError("Parser was not found for label " + 5003); //$NON-NLS-1$ >- return ""; //$NON-NLS-1$ >- } >- } >- >- /** >- * @generated >- */ >- private String getConnector_4001Text(View view) { >- IParser parser = SysmlParserProvider.getParser(SysmlElementTypes.Connector_4001, view.getElement() != null ? view.getElement() : view, SysmlVisualIDRegistry.getType(ConnectorNameEditPart.VISUAL_ID)); >- if(parser != null) { >- return parser.getPrintString(new EObjectAdapter(view.getElement() != null ? view.getElement() : view), ParserOptions.NONE.intValue()); >- } else { >- SysmlDiagramEditorPlugin.getInstance().logError("Parser was not found for label " + 6001); //$NON-NLS-1$ >- return ""; //$NON-NLS-1$ >- } >- } >- >- /** >- * @generated >- */ >- private String getUnknownElementText(View view) { >- return "<UnknownElement Visual_ID = " + view.getType() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ >- } >- >- /** >- * @generated >- */ >- private String getUnresolvedDomainElementProxyText(View view) { >- return "<Unresolved domain element Visual_ID = " + view.getType() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ >- } >- >- /** >- * @generated >- */ >- public void init(ICommonContentExtensionSite aConfig) { >- } >- >- /** >- * @generated >- */ >- public void restoreState(IMemento aMemento) { >- } >- >- /** >- * @generated >- */ >- public void saveState(IMemento aMemento) { >- } >- >- /** >- * @generated >- */ >- public String getDescription(Object anElement) { >- return null; >- } >- >- /** >- * @generated >- */ >- private boolean isOwnView(View view) { >- return ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID(view)); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorLinkHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorLinkHelper.java >deleted file mode 100644 >index 66c239f..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorLinkHelper.java >+++ /dev/null >@@ -1,128 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.emf.common.ui.URIEditorInput; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.GraphicalViewer; >-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.ui.IEditorInput; >-import org.eclipse.ui.IEditorPart; >-import org.eclipse.ui.IWorkbenchPage; >-import org.eclipse.ui.navigator.ILinkHelper; >-import org.eclipse.ui.part.FileEditorInput; >- >-/** >- * @generated >- */ >-public class SysmlNavigatorLinkHelper implements ILinkHelper { >- >- /** >- * @generated >- */ >- private static IEditorInput getEditorInput(Diagram diagram) { >- Resource diagramResource = diagram.eResource(); >- for(EObject nextEObject : diagramResource.getContents()) { >- if(nextEObject == diagram) { >- return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource)); >- } >- if(nextEObject instanceof Diagram) { >- break; >- } >- } >- URI uri = EcoreUtil.getURI(diagram); >- String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram); >- IEditorInput editorInput = new URIEditorInput(uri, editorName); >- return editorInput; >- } >- >- /** >- * @generated >- */ >- public IStructuredSelection findSelection(IEditorInput anInput) { >- IDiagramDocument document = SysmlDiagramEditorPlugin.getInstance().getDocumentProvider().getDiagramDocument(anInput); >- if(document == null) { >- return StructuredSelection.EMPTY; >- } >- Diagram diagram = document.getDiagram(); >- if(diagram == null || diagram.eResource() == null) { >- return StructuredSelection.EMPTY; >- } >- IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); >- if(file != null) { >- SysmlNavigatorItem item = new SysmlNavigatorItem(diagram, file, false); >- return new StructuredSelection(item); >- } >- return StructuredSelection.EMPTY; >- } >- >- /** >- * @generated >- */ >- public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) { >- if(aSelection == null || aSelection.isEmpty()) { >- return; >- } >- if(false == aSelection.getFirstElement() instanceof SysmlAbstractNavigatorItem) { >- return; >- } >- >- SysmlAbstractNavigatorItem abstractNavigatorItem = (SysmlAbstractNavigatorItem)aSelection.getFirstElement(); >- View navigatorView = null; >- if(abstractNavigatorItem instanceof SysmlNavigatorItem) { >- navigatorView = ((SysmlNavigatorItem)abstractNavigatorItem).getView(); >- } else if(abstractNavigatorItem instanceof SysmlNavigatorGroup) { >- SysmlNavigatorGroup navigatorGroup = (SysmlNavigatorGroup)abstractNavigatorItem; >- if(navigatorGroup.getParent() instanceof SysmlNavigatorItem) { >- navigatorView = ((SysmlNavigatorItem)navigatorGroup.getParent()).getView(); >- } >- } >- if(navigatorView == null) { >- return; >- } >- IEditorInput editorInput = getEditorInput(navigatorView.getDiagram()); >- IEditorPart editor = aPage.findEditor(editorInput); >- if(editor == null) { >- return; >- } >- aPage.bringToTop(editor); >- if(editor instanceof DiagramEditor) { >- DiagramEditor diagramEditor = (DiagramEditor)editor; >- ResourceSet diagramEditorResourceSet = diagramEditor.getEditingDomain().getResourceSet(); >- EObject selectedView = diagramEditorResourceSet.getEObject(EcoreUtil.getURI(navigatorView), true); >- if(selectedView == null) { >- return; >- } >- GraphicalViewer graphicalViewer = (GraphicalViewer)diagramEditor.getAdapter(GraphicalViewer.class); >- EditPart selectedEditPart = (EditPart)graphicalViewer.getEditPartRegistry().get(selectedView); >- if(selectedEditPart != null) { >- graphicalViewer.select(selectedEditPart); >- } >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorSorter.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorSorter.java >deleted file mode 100644 >index 99cb6db..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/navigator/SysmlNavigatorSorter.java >+++ /dev/null >@@ -1,40 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.navigator; >- >-import org.eclipse.jface.viewers.ViewerSorter; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >- >-/** >- * @generated >- */ >-public class SysmlNavigatorSorter extends ViewerSorter { >- >- /** >- * @generated >- */ >- private static final int GROUP_CATEGORY = 4003; >- >- /** >- * @generated >- */ >- public int category(Object element) { >- if(element instanceof SysmlNavigatorItem) { >- SysmlNavigatorItem item = (SysmlNavigatorItem)element; >- return SysmlVisualIDRegistry.getVisualID(item.getView()); >- } >- return GROUP_CATEGORY; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parser/ParametricFrameParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parser/ParametricFrameParser.java >new file mode 100644 >index 0000000..c545230 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parser/ParametricFrameParser.java >@@ -0,0 +1,22 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.parser; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >+import org.eclipse.papyrus.sysml.constraints.ConstraintBlock; >+import org.eclipse.papyrus.uml.diagram.common.parser.NamedElementLabelParser; >+import org.eclipse.uml2.uml.util.UMLUtil; >+ >+public class ParametricFrameParser extends NamedElementLabelParser { >+ >+ @Override >+ public String getPrintString(IAdaptable element, int flags) { >+ String elementType = null; >+ if (element instanceof EObjectAdapter) { >+ Object realObject = ((EObjectAdapter)element).getRealObject(); >+ if (realObject instanceof org.eclipse.uml2.uml.Class) { >+ elementType = UMLUtil.getStereotypeApplication(((org.eclipse.uml2.uml.Class)realObject), ConstraintBlock.class) != null ? "ConstraintBlock" : "Block"; >+ } >+ } >+ return "par [" + elementType + "] " + super.getPrintString(element, flags); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/AbstractParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/AbstractParser.java >deleted file mode 100644 >index b7c8cb3..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/AbstractParser.java >+++ /dev/null >@@ -1,431 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.parsers; >- >-import java.util.Arrays; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EAttribute; >-import org.eclipse.emf.ecore.EClassifier; >-import org.eclipse.emf.ecore.EDataType; >-import org.eclipse.emf.ecore.EEnum; >-import org.eclipse.emf.ecore.EEnumLiteral; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.transaction.util.TransactionUtil; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; >-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; >-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; >-import org.eclipse.jface.text.contentassist.IContentAssistProcessor; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.Messages; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public abstract class AbstractParser implements IParser { >- >- /** >- * @generated >- */ >- protected final EAttribute[] features; >- >- /** >- * @generated >- */ >- protected final EAttribute[] editableFeatures; >- >- /** >- * @generated >- */ >- private String viewPattern; >- >- /** >- * @generated >- */ >- private String editorPattern; >- >- /** >- * @generated >- */ >- private String editPattern; >- >- /** >- * @generated >- */ >- public AbstractParser(EAttribute[] features) { >- if(features == null || Arrays.asList(features).contains(null)) { >- throw new IllegalArgumentException(); >- } >- this.editableFeatures = this.features = features; >- } >- >- /** >- * @generated >- */ >- public AbstractParser(EAttribute[] features, EAttribute[] editableFeatures) { >- if(features == null || Arrays.asList(features).contains(null)) { >- throw new IllegalArgumentException(); >- } >- this.features = features; >- if(editableFeatures == null || Arrays.asList(editableFeatures).contains(null)) { >- throw new IllegalArgumentException(); >- } >- this.editableFeatures = editableFeatures; >- } >- >- /** >- * @generated >- */ >- public String getViewPattern() { >- return viewPattern; >- } >- >- /** >- * @generated >- */ >- public void setViewPattern(String viewPattern) { >- this.viewPattern = viewPattern; >- } >- >- /** >- * @generated >- */ >- public String getEditorPattern() { >- return editorPattern; >- } >- >- /** >- * @generated >- */ >- public void setEditorPattern(String editorPattern) { >- this.editorPattern = editorPattern; >- } >- >- /** >- * @generated >- */ >- public String getEditPattern() { >- return editPattern; >- } >- >- /** >- * @generated >- */ >- public void setEditPattern(String editPattern) { >- this.editPattern = editPattern; >- } >- >- /** >- * @generated >- */ >- public boolean isAffectingEvent(Object event, int flags) { >- if(event instanceof Notification) { >- return isAffectingFeature(((Notification)event).getFeature()); >- } >- return false; >- } >- >- /** >- * @generated >- */ >- protected boolean isAffectingFeature(Object feature) { >- for(int i = 0; i < features.length; i++) { >- if(features[i] == feature) { >- return true; >- } >- } >- return false; >- } >- >- /** >- * @generated >- */ >- public IContentAssistProcessor getCompletionProcessor(IAdaptable element) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected Object[] getValues(EObject element) { >- Object[] values = new Object[features.length]; >- for(int i = 0; i < features.length; i++) { >- values[i] = getValue(element, features[i]); >- } >- return values; >- } >- >- /** >- * @generated >- */ >- protected Object[] getEditableValues(EObject element) { >- Object[] values = new Object[editableFeatures.length]; >- for(int i = 0; i < editableFeatures.length; i++) { >- values[i] = getValue(element, editableFeatures[i]); >- } >- return values; >- } >- >- /** >- * @generated >- */ >- protected Object getValue(EObject element, EAttribute feature) { >- Object value = element.eGet(feature); >- Class iClass = feature.getEAttributeType().getInstanceClass(); >- if(String.class.equals(iClass)) { >- if(value == null) { >- value = ""; //$NON-NLS-1$ >- } >- } >- return value; >- } >- >- /** >- * @generated >- */ >- protected ICommand getParseCommand(IAdaptable adapter, Object[] values, int flags) { >- if(values == null || validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) { >- return UnexecutableCommand.INSTANCE; >- } >- EObject element = (EObject)adapter.getAdapter(EObject.class); >- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element); >- if(editingDomain == null) { >- return UnexecutableCommand.INSTANCE; >- } >- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$ >- for(int i = 0; i < values.length; i++) { >- command.compose(getModificationCommand(element, editableFeatures[i], values[i])); >- } >- return command; >- } >- >- /** >- * @generated >- */ >- protected ICommand getModificationCommand(EObject element, EAttribute feature, Object value) { >- value = getValidNewValue(feature, value); >- if(value instanceof InvalidValue) { >- return UnexecutableCommand.INSTANCE; >- } >- SetRequest request = new SetRequest(element, feature, value); >- return new SetValueCommand(request); >- } >- >- /** >- * @generated >- */ >- protected IParserEditStatus validateNewValues(Object[] values) { >- if(values.length != editableFeatures.length) { >- return ParserEditStatus.UNEDITABLE_STATUS; >- } >- for(int i = 0; i < values.length; i++) { >- Object value = getValidNewValue(editableFeatures[i], values[i]); >- if(value instanceof InvalidValue) { >- return new ParserEditStatus(SysmlDiagramEditorPlugin.ID, IParserEditStatus.UNEDITABLE, value.toString()); >- } >- } >- return ParserEditStatus.EDITABLE_STATUS; >- } >- >- /** >- * @generated >- */ >- protected Object getValidNewValue(EAttribute feature, Object value) { >- EClassifier type = feature.getEType(); >- if(type instanceof EDataType) { >- Class iClass = type.getInstanceClass(); >- if(Boolean.TYPE.equals(iClass)) { >- if(value instanceof Boolean) { >- // ok >- } else if(value instanceof String) { >- value = Boolean.valueOf((String)value); >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName())); >- } >- } else if(Character.TYPE.equals(iClass)) { >- if(value instanceof Character) { >- // ok >- } else if(value instanceof String) { >- String s = (String)value; >- if(s.length() == 0) { >- value = null; >- } else { >- value = new Character(s.charAt(0)); >- } >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName())); >- } >- } else if(Byte.TYPE.equals(iClass)) { >- if(value instanceof Byte) { >- // ok >- } else if(value instanceof Number) { >- value = new Byte(((Number)value).byteValue()); >- } else if(value instanceof String) { >- String s = (String)value; >- if(s.length() == 0) { >- value = null; >- } else { >- try { >- value = Byte.valueOf(s); >- } catch (NumberFormatException nfe) { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName())); >- } >- } >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName())); >- } >- } else if(Short.TYPE.equals(iClass)) { >- if(value instanceof Short) { >- // ok >- } else if(value instanceof Number) { >- value = new Short(((Number)value).shortValue()); >- } else if(value instanceof String) { >- String s = (String)value; >- if(s.length() == 0) { >- value = null; >- } else { >- try { >- value = Short.valueOf(s); >- } catch (NumberFormatException nfe) { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName())); >- } >- } >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName())); >- } >- } else if(Integer.TYPE.equals(iClass)) { >- if(value instanceof Integer) { >- // ok >- } else if(value instanceof Number) { >- value = new Integer(((Number)value).intValue()); >- } else if(value instanceof String) { >- String s = (String)value; >- if(s.length() == 0) { >- value = null; >- } else { >- try { >- value = Integer.valueOf(s); >- } catch (NumberFormatException nfe) { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName())); >- } >- } >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName())); >- } >- } else if(Long.TYPE.equals(iClass)) { >- if(value instanceof Long) { >- // ok >- } else if(value instanceof Number) { >- value = new Long(((Number)value).longValue()); >- } else if(value instanceof String) { >- String s = (String)value; >- if(s.length() == 0) { >- value = null; >- } else { >- try { >- value = Long.valueOf(s); >- } catch (NumberFormatException nfe) { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName())); >- } >- } >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName())); >- } >- } else if(Float.TYPE.equals(iClass)) { >- if(value instanceof Float) { >- // ok >- } else if(value instanceof Number) { >- value = new Float(((Number)value).floatValue()); >- } else if(value instanceof String) { >- String s = (String)value; >- if(s.length() == 0) { >- value = null; >- } else { >- try { >- value = Float.valueOf(s); >- } catch (NumberFormatException nfe) { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName())); >- } >- } >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName())); >- } >- } else if(Double.TYPE.equals(iClass)) { >- if(value instanceof Double) { >- // ok >- } else if(value instanceof Number) { >- value = new Double(((Number)value).doubleValue()); >- } else if(value instanceof String) { >- String s = (String)value; >- if(s.length() == 0) { >- value = null; >- } else { >- try { >- value = Double.valueOf(s); >- } catch (NumberFormatException nfe) { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName())); >- } >- } >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName())); >- } >- } else if(type instanceof EEnum) { >- if(value instanceof String) { >- EEnumLiteral literal = ((EEnum)type).getEEnumLiteralByLiteral((String)value); >- if(literal == null) { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnknownLiteral, value)); >- } else { >- value = literal.getInstance(); >- } >- } else { >- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, String.class.getName())); >- } >- } >- } >- return value; >- } >- >- /** >- * @generated >- */ >- protected class InvalidValue { >- >- /** >- * @generated >- */ >- private String description; >- >- /** >- * @generated >- */ >- public InvalidValue(String description) { >- this.description = description; >- } >- >- /** >- * @generated >- */ >- public String toString() { >- return description; >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/MessageFormatParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/MessageFormatParser.java >deleted file mode 100644 >index d3dc06d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/parsers/MessageFormatParser.java >+++ /dev/null >@@ -1,202 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.parsers; >- >-import java.text.FieldPosition; >-import java.text.MessageFormat; >-import java.text.ParsePosition; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.ecore.EAttribute; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.common.core.command.ICommand; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.Messages; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class MessageFormatParser extends AbstractParser { >- >- /** >- * @generated >- */ >- private String defaultPattern; >- >- /** >- * @generated >- */ >- private String defaultEditablePattern; >- >- /** >- * @generated >- */ >- private MessageFormat viewProcessor; >- >- /** >- * @generated >- */ >- private MessageFormat editorProcessor; >- >- /** >- * @generated >- */ >- private MessageFormat editProcessor; >- >- /** >- * @generated >- */ >- public MessageFormatParser(EAttribute[] features) { >- super(features); >- } >- >- /** >- * @generated >- */ >- public MessageFormatParser(EAttribute[] features, EAttribute[] editableFeatures) { >- super(features, editableFeatures); >- } >- >- /** >- * @generated >- */ >- protected String getDefaultPattern() { >- if(defaultPattern == null) { >- StringBuffer sb = new StringBuffer(); >- for(int i = 0; i < features.length; i++) { >- if(i > 0) { >- sb.append(' '); >- } >- sb.append('{'); >- sb.append(i); >- sb.append('}'); >- } >- defaultPattern = sb.toString(); >- } >- return defaultPattern; >- } >- >- /** >- * @generated >- */ >- public void setViewPattern(String viewPattern) { >- super.setViewPattern(viewPattern); >- viewProcessor = null; >- } >- >- /** >- * @generated >- */ >- public void setEditorPattern(String editorPattern) { >- super.setEditorPattern(editorPattern); >- editorProcessor = null; >- } >- >- /** >- * @generated >- */ >- protected MessageFormat getViewProcessor() { >- if(viewProcessor == null) { >- viewProcessor = new MessageFormat(getViewPattern() == null ? getDefaultPattern() : getViewPattern()); >- } >- return viewProcessor; >- } >- >- /** >- * @generated >- */ >- protected MessageFormat getEditorProcessor() { >- if(editorProcessor == null) { >- editorProcessor = new MessageFormat(getEditorPattern() == null ? getDefaultEditablePattern() : getEditorPattern()); >- } >- return editorProcessor; >- } >- >- /** >- * @generated >- */ >- protected String getDefaultEditablePattern() { >- if(defaultEditablePattern == null) { >- StringBuffer sb = new StringBuffer(); >- for(int i = 0; i < editableFeatures.length; i++) { >- if(i > 0) { >- sb.append(' '); >- } >- sb.append('{'); >- sb.append(i); >- sb.append('}'); >- } >- defaultEditablePattern = sb.toString(); >- } >- return defaultEditablePattern; >- } >- >- /** >- * @generated >- */ >- public void setEditPattern(String editPattern) { >- super.setEditPattern(editPattern); >- editProcessor = null; >- } >- >- /** >- * @generated >- */ >- protected MessageFormat getEditProcessor() { >- if(editProcessor == null) { >- editProcessor = new MessageFormat(getEditPattern() == null ? getDefaultEditablePattern() : getEditPattern()); >- } >- return editProcessor; >- } >- >- /** >- * @generated >- */ >- public String getEditString(IAdaptable adapter, int flags) { >- EObject element = (EObject)adapter.getAdapter(EObject.class); >- return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new FieldPosition(0)).toString(); >- } >- >- /** >- * @generated >- */ >- public IParserEditStatus isValidEditString(IAdaptable adapter, String editString) { >- ParsePosition pos = new ParsePosition(0); >- Object[] values = getEditProcessor().parse(editString, pos); >- if(values == null) { >- return new ParserEditStatus(SysmlDiagramEditorPlugin.ID, IParserEditStatus.UNEDITABLE, NLS.bind(Messages.MessageFormatParser_InvalidInputError, new Integer(pos.getErrorIndex()))); >- } >- return validateNewValues(values); >- } >- >- /** >- * @generated >- */ >- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) { >- Object[] values = getEditProcessor().parse(newString, new ParsePosition(0)); >- return getParseCommand(adapter, values, flags); >- } >- >- /** >- * @generated >- */ >- public String getPrintString(IAdaptable adapter, int flags) { >- EObject element = (EObject)adapter.getAdapter(EObject.class); >- return getViewProcessor().format(getValues(element), new StringBuffer(), new FieldPosition(0)).toString(); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/DeleteElementAction.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/DeleteElementAction.java >deleted file mode 100644 >index 58f3349..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/DeleteElementAction.java >+++ /dev/null >@@ -1,16 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >- >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/DiagramEditorContextMenuProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/DiagramEditorContextMenuProvider.java >deleted file mode 100644 >index d6dcf4d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/DiagramEditorContextMenuProvider.java >+++ /dev/null >@@ -1,62 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.transaction.util.TransactionUtil; >-import org.eclipse.gef.EditPartViewer; >-import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService; >-import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds; >-import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider; >-import org.eclipse.jface.action.IMenuManager; >-import org.eclipse.ui.IWorkbenchPart; >- >-/** >- * @generated >- */ >-public class DiagramEditorContextMenuProvider extends DiagramContextMenuProvider { >- >- /** >- * @generated >- */ >- private IWorkbenchPart part; >- >- /** >- * @generated >- */ >- public DiagramEditorContextMenuProvider(IWorkbenchPart part, EditPartViewer viewer) { >- super(part, viewer); >- this.part = part; >- >- } >- >- /** >- * @generated >- */ >- public void buildContextMenu(final IMenuManager menu) { >- getViewer().flush(); >- try { >- TransactionUtil.getEditingDomain((EObject)getViewer().getContents().getModel()).runExclusive(new Runnable() { >- >- public void run() { >- ContributionItemService.getInstance().contributeToPopupMenu(DiagramEditorContextMenuProvider.this, part); >- menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL); >- >- } >- }); >- } catch (Exception e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Error building context menu", e); >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/LoadResourceAction.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/LoadResourceAction.java >deleted file mode 100644 >index b213a7b..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/LoadResourceAction.java >+++ /dev/null >@@ -1,43 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.core.commands.AbstractHandler; >-import org.eclipse.core.commands.ExecutionEvent; >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.IEditorPart; >-import org.eclipse.ui.handlers.HandlerUtil; >- >-/** >- * @generated >- */ >-public class LoadResourceAction extends AbstractHandler { >- >- /** >- * @generated >- */ >- public Object execute(ExecutionEvent event) throws ExecutionException { >- IEditorPart diagramEditor = HandlerUtil.getActiveEditorChecked(event); >- Shell shell = diagramEditor.getEditorSite().getShell(); >- assert diagramEditor instanceof DiagramEditor; >- TransactionalEditingDomain editingDomain = ((DiagramEditor)diagramEditor).getEditingDomain(); >- org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog = new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(shell, editingDomain); >- loadResourceDialog.open(); >- return null; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/Messages.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/Messages.java >deleted file mode 100644 >index 4ba5d7e..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/Messages.java >+++ /dev/null >@@ -1,367 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.osgi.util.NLS; >- >-/** >- * @generated >- */ >-public class Messages extends NLS { >- >- /** >- * @generated >- */ >- static { >- NLS.initializeMessages("messages", Messages.class); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- private Messages() { >- } >- >- /** >- * @generated >- */ >- public static String SysmlCreationWizardTitle; >- >- /** >- * @generated >- */ >- public static String SysmlCreationWizard_DiagramModelFilePageTitle; >- >- /** >- * @generated >- */ >- public static String SysmlCreationWizard_DiagramModelFilePageDescription; >- >- /** >- * @generated >- */ >- public static String SysmlCreationWizard_DomainModelFilePageTitle; >- >- /** >- * @generated >- */ >- public static String SysmlCreationWizard_DomainModelFilePageDescription; >- >- /** >- * @generated >- */ >- public static String SysmlCreationWizardOpenEditorError; >- >- /** >- * @generated >- */ >- public static String SysmlCreationWizardCreationError; >- >- /** >- * @generated >- */ >- public static String SysmlCreationWizardPageExtensionError; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditorUtil_OpenModelResourceErrorDialogTitle; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditorUtil_OpenModelResourceErrorDialogMessage; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditorUtil_CreateDiagramProgressTask; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditorUtil_CreateDiagramCommandLabel; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_isModifiable; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_handleElementContentChanged; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_IncorrectInputError; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_NoDiagramInResourceError; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_DiagramLoadingError; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_UnsynchronizedFileSaveError; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_SaveDiagramTask; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_SaveNextResourceTask; >- >- /** >- * @generated >- */ >- public static String SysmlDocumentProvider_SaveAsOperation; >- >- /** >- * @generated >- */ >- public static String InitDiagramFile_ResourceErrorDialogTitle; >- >- /** >- * @generated >- */ >- public static String InitDiagramFile_ResourceErrorDialogMessage; >- >- /** >- * @generated >- */ >- public static String InitDiagramFile_WizardTitle; >- >- /** >- * @generated >- */ >- public static String InitDiagramFile_OpenModelFileDialogTitle; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_CreationPageName; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_CreationPageTitle; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_CreationPageDescription; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_RootSelectionPageName; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_RootSelectionPageTitle; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_RootSelectionPageDescription; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_RootSelectionPageSelectionTitle; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_RootSelectionPageNoSelectionMessage; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_InitDiagramCommand; >- >- /** >- * @generated >- */ >- public static String SysmlNewDiagramFileWizard_IncorrectRootError; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditor_SavingDeletedFile; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditor_SaveAsErrorTitle; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditor_SaveAsErrorMessage; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditor_SaveErrorTitle; >- >- /** >- * @generated >- */ >- public static String SysmlDiagramEditor_SaveErrorMessage; >- >- /** >- * @generated >- */ >- public static String SysmlElementChooserDialog_SelectModelElementTitle; >- >- /** >- * @generated >- */ >- public static String ModelElementSelectionPageMessage; >- >- /** >- * @generated >- */ >- public static String ValidateActionMessage; >- >- /** >- * @generated >- */ >- public static String createParametric1Group_title; >- >- /** >- * @generated >- */ >- public static String createConstraintProperty1CreationTool_title; >- >- /** >- * @generated >- */ >- public static String createConstraintProperty1CreationTool_desc; >- >- /** >- * @generated >- */ >- public static String createProperty2CreationTool_title; >- >- /** >- * @generated >- */ >- public static String createProperty2CreationTool_desc; >- >- /** >- * @generated >- */ >- public static String createConnector3CreationTool_title; >- >- /** >- * @generated >- */ >- public static String createConnector3CreationTool_desc; >- >- /** >- * @generated >- */ >- public static String CommandName_OpenDiagram; >- >- /** >- * @generated >- */ >- public static String NavigatorGroupName_Resource_1000_links; >- >- /** >- * @generated >- */ >- public static String NavigatorGroupName_Property_2005_incominglinks; >- >- /** >- * @generated >- */ >- public static String NavigatorGroupName_Property_2005_outgoinglinks; >- >- /** >- * @generated >- */ >- public static String NavigatorGroupName_Property_3002_incominglinks; >- >- /** >- * @generated >- */ >- public static String NavigatorGroupName_Property_3002_outgoinglinks; >- >- /** >- * @generated >- */ >- public static String NavigatorGroupName_Connector_4001_target; >- >- /** >- * @generated >- */ >- public static String NavigatorGroupName_Connector_4001_source; >- >- /** >- * @generated >- */ >- public static String NavigatorActionProvider_OpenDiagramActionName; >- >- /** >- * @generated >- */ >- public static String AbstractParser_UnexpectedValueType; >- >- /** >- * @generated >- */ >- public static String AbstractParser_WrongStringConversion; >- >- /** >- * @generated >- */ >- public static String AbstractParser_UnknownLiteral; >- >- /** >- * @generated >- */ >- public static String MessageFormatParser_InvalidInputError; >- >- /** >- * @generated >- */ >- public static String SysmlModelingAssistantProviderTitle; >- >- /** >- * @generated >- */ >- public static String SysmlModelingAssistantProviderMessage; >- >- // TODO: put accessor fields manually >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/ModelElementSelectionPage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/ModelElementSelectionPage.java >deleted file mode 100644 >index 136fd3b..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/ModelElementSelectionPage.java >+++ /dev/null >@@ -1,156 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.util.FeatureMap; >-import org.eclipse.emf.edit.provider.IWrapperItemProvider; >-import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; >-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; >-import org.eclipse.jface.viewers.ISelectionChangedListener; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.SelectionChangedEvent; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.jface.viewers.TreeViewer; >-import org.eclipse.jface.wizard.WizardPage; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Label; >- >-/** >- * Wizard page that allows to select element from model. >- * >- * @generated >- */ >-public class ModelElementSelectionPage extends WizardPage { >- >- /** >- * @generated >- */ >- protected EObject selectedModelElement; >- >- /** >- * @generated >- */ >- private TreeViewer modelViewer; >- >- /** >- * @generated >- */ >- public ModelElementSelectionPage(String pageName) { >- super(pageName); >- } >- >- /** >- * @generated >- */ >- public EObject getModelElement() { >- return selectedModelElement; >- } >- >- /** >- * @generated >- */ >- public void setModelElement(EObject modelElement) { >- selectedModelElement = modelElement; >- if(modelViewer != null) { >- if(selectedModelElement != null) { >- modelViewer.setInput(selectedModelElement.eResource()); >- modelViewer.setSelection(new StructuredSelection(selectedModelElement)); >- } else { >- modelViewer.setInput(null); >- } >- setPageComplete(validatePage()); >- } >- } >- >- /** >- * @generated >- */ >- public void createControl(Composite parent) { >- initializeDialogUnits(parent); >- >- Composite plate = new Composite(parent, SWT.NONE); >- plate.setLayoutData(new GridData(GridData.FILL_BOTH)); >- GridLayout layout = new GridLayout(); >- layout.marginWidth = 0; >- plate.setLayout(layout); >- setControl(plate); >- >- Label label = new Label(plate, SWT.NONE); >- label.setText(getSelectionTitle()); >- label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); >- >- modelViewer = new TreeViewer(plate, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >- GridData layoutData = new GridData(GridData.FILL_BOTH); >- layoutData.heightHint = 300; >- layoutData.widthHint = 300; >- modelViewer.getTree().setLayoutData(layoutData); >- modelViewer.setContentProvider(new AdapterFactoryContentProvider(SysmlDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory())); >- modelViewer.setLabelProvider(new AdapterFactoryLabelProvider(SysmlDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory())); >- if(selectedModelElement != null) { >- modelViewer.setInput(selectedModelElement.eResource()); >- modelViewer.setSelection(new StructuredSelection(selectedModelElement)); >- } >- modelViewer.addSelectionChangedListener(new ISelectionChangedListener() { >- >- public void selectionChanged(SelectionChangedEvent event) { >- ModelElementSelectionPage.this.updateSelection((IStructuredSelection)event.getSelection()); >- } >- }); >- >- setPageComplete(validatePage()); >- } >- >- /** >- * Override to provide custom model element description. >- * >- * @generated >- */ >- protected String getSelectionTitle() { >- return Messages.ModelElementSelectionPageMessage; >- } >- >- /** >- * @generated >- */ >- protected void updateSelection(IStructuredSelection selection) { >- selectedModelElement = null; >- if(selection.size() == 1) { >- Object selectedElement = selection.getFirstElement(); >- if(selectedElement instanceof IWrapperItemProvider) { >- selectedElement = ((IWrapperItemProvider)selectedElement).getValue(); >- } >- if(selectedElement instanceof FeatureMap.Entry) { >- selectedElement = ((FeatureMap.Entry)selectedElement).getValue(); >- } >- if(selectedElement instanceof EObject) { >- selectedModelElement = (EObject)selectedElement; >- } >- } >- setPageComplete(validatePage()); >- } >- >- /** >- * Override to provide specific validation of the selected model element. >- * >- * @generated >- */ >- protected boolean validatePage() { >- return true; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlCreationWizard.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlCreationWizard.java >deleted file mode 100644 >index dd958c5..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlCreationWizard.java >+++ /dev/null >@@ -1,167 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.lang.reflect.InvocationTargetException; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.jface.dialogs.ErrorDialog; >-import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.wizard.Wizard; >-import org.eclipse.ui.INewWizard; >-import org.eclipse.ui.IWorkbench; >-import org.eclipse.ui.PartInitException; >-import org.eclipse.ui.actions.WorkspaceModifyOperation; >- >-/** >- * @generated >- */ >-public class SysmlCreationWizard extends Wizard implements INewWizard { >- >- /** >- * @generated >- */ >- private IWorkbench workbench; >- >- /** >- * @generated >- */ >- protected IStructuredSelection selection; >- >- /** >- * @generated >- */ >- protected SysmlCreationWizardPage diagramModelFilePage; >- >- /** >- * @generated >- */ >- protected SysmlCreationWizardPage domainModelFilePage; >- >- /** >- * @generated >- */ >- protected Resource diagram; >- >- /** >- * @generated >- */ >- private boolean openNewlyCreatedDiagramEditor = true; >- >- /** >- * @generated >- */ >- public IWorkbench getWorkbench() { >- return workbench; >- } >- >- /** >- * @generated >- */ >- public IStructuredSelection getSelection() { >- return selection; >- } >- >- /** >- * @generated >- */ >- public final Resource getDiagram() { >- return diagram; >- } >- >- /** >- * @generated >- */ >- public final boolean isOpenNewlyCreatedDiagramEditor() { >- return openNewlyCreatedDiagramEditor; >- } >- >- /** >- * @generated >- */ >- public void setOpenNewlyCreatedDiagramEditor(boolean openNewlyCreatedDiagramEditor) { >- this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor; >- } >- >- /** >- * @generated >- */ >- public void init(IWorkbench workbench, IStructuredSelection selection) { >- this.workbench = workbench; >- this.selection = selection; >- setWindowTitle(Messages.SysmlCreationWizardTitle); >- setDefaultPageImageDescriptor(SysmlDiagramEditorPlugin.getBundledImageDescriptor("icons/wizban/NewResourceWizard.gif")); //$NON-NLS-1$ >- setNeedsProgressMonitor(true); >- } >- >- /** >- * @generated >- */ >- public void addPages() { >- diagramModelFilePage = new SysmlCreationWizardPage("DiagramModelFile", getSelection(), "sysml_diagram"); //$NON-NLS-1$ //$NON-NLS-2$ >- diagramModelFilePage.setTitle(Messages.SysmlCreationWizard_DiagramModelFilePageTitle); >- diagramModelFilePage.setDescription(Messages.SysmlCreationWizard_DiagramModelFilePageDescription); >- addPage(diagramModelFilePage); >- >- domainModelFilePage = new SysmlCreationWizardPage("DomainModelFile", getSelection(), "sysml") { //$NON-NLS-1$ //$NON-NLS-2$ >- >- public void setVisible(boolean visible) { >- if(visible) { >- String fileName = diagramModelFilePage.getFileName(); >- fileName = fileName.substring(0, fileName.length() - ".sysml_diagram".length()); //$NON-NLS-1$ >- setFileName(SysmlDiagramEditorUtil.getUniqueFileName(getContainerFullPath(), fileName, "sysml")); //$NON-NLS-1$ >- } >- super.setVisible(visible); >- } >- }; >- domainModelFilePage.setTitle(Messages.SysmlCreationWizard_DomainModelFilePageTitle); >- domainModelFilePage.setDescription(Messages.SysmlCreationWizard_DomainModelFilePageDescription); >- addPage(domainModelFilePage); >- } >- >- /** >- * @generated >- */ >- public boolean performFinish() { >- IRunnableWithProgress op = new WorkspaceModifyOperation(null) { >- >- protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException { >- diagram = SysmlDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), domainModelFilePage.getURI(), monitor); >- if(isOpenNewlyCreatedDiagramEditor() && diagram != null) { >- try { >- SysmlDiagramEditorUtil.openDiagram(diagram); >- } catch (PartInitException e) { >- ErrorDialog.openError(getContainer().getShell(), Messages.SysmlCreationWizardOpenEditorError, null, e.getStatus()); >- } >- } >- } >- }; >- try { >- getContainer().run(false, true, op); >- } catch (InterruptedException e) { >- return false; >- } catch (InvocationTargetException e) { >- if(e.getTargetException() instanceof CoreException) { >- ErrorDialog.openError(getContainer().getShell(), Messages.SysmlCreationWizardCreationError, null, ((CoreException)e.getTargetException()).getStatus()); >- } else { >- SysmlDiagramEditorPlugin.getInstance().logError("Error creating diagram", e.getTargetException()); //$NON-NLS-1$ >- } >- return false; >- } >- return diagram != null; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlCreationWizardPage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlCreationWizardPage.java >deleted file mode 100644 >index 6aba0fe..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlCreationWizardPage.java >+++ /dev/null >@@ -1,96 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.dialogs.WizardNewFileCreationPage; >- >-/** >- * @generated >- */ >-public class SysmlCreationWizardPage extends WizardNewFileCreationPage { >- >- /** >- * @generated >- */ >- private final String fileExtension; >- >- /** >- * @generated >- */ >- public SysmlCreationWizardPage(String pageName, IStructuredSelection selection, String fileExtension) { >- super(pageName, selection); >- this.fileExtension = fileExtension; >- } >- >- /** >- * Override to create files with this extension. >- * >- * @generated >- */ >- protected String getExtension() { >- return fileExtension; >- } >- >- /** >- * @generated >- */ >- public URI getURI() { >- return URI.createPlatformResourceURI(getFilePath().toString(), false); >- } >- >- /** >- * @generated >- */ >- protected IPath getFilePath() { >- IPath path = getContainerFullPath(); >- if(path == null) { >- path = new Path(""); //$NON-NLS-1$ >- } >- String fileName = getFileName(); >- if(fileName != null) { >- path = path.append(fileName); >- } >- return path; >- } >- >- /** >- * @generated >- */ >- public void createControl(Composite parent) { >- super.createControl(parent); >- setFileName(SysmlDiagramEditorUtil.getUniqueFileName(getContainerFullPath(), getFileName(), getExtension())); >- setPageComplete(validatePage()); >- } >- >- /** >- * @generated >- */ >- protected boolean validatePage() { >- if(!super.validatePage()) { >- return false; >- } >- String extension = getExtension(); >- if(extension != null && !getFilePath().toString().endsWith("." + extension)) { >- setErrorMessage(NLS.bind(Messages.SysmlCreationWizardPageExtensionError, extension)); >- return false; >- } >- return true; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramActionBarContributor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramActionBarContributor.java >deleted file mode 100644 >index b9d2b4a..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramActionBarContributor.java >+++ /dev/null >@@ -1,60 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramActionBarContributor; >-import org.eclipse.jface.action.GroupMarker; >-import org.eclipse.jface.action.IAction; >-import org.eclipse.jface.action.IMenuManager; >-import org.eclipse.ui.IActionBars; >-import org.eclipse.ui.IWorkbenchActionConstants; >-import org.eclipse.ui.IWorkbenchPage; >- >-/** >- * @generated >- */ >-public class SysmlDiagramActionBarContributor extends DiagramActionBarContributor { >- >- /** >- * @generated >- */ >- protected Class getEditorClass() { >- return SysmlDiagramEditor.class; >- } >- >- /** >- * @generated >- */ >- protected String getEditorId() { >- return SysmlDiagramEditor.ID; >- } >- >- /** >- * @generated >- */ >- public void init(IActionBars bars, IWorkbenchPage page) { >- super.init(bars, page); >- // print preview >- IMenuManager fileMenu = bars.getMenuManager().findMenuUsingPath(IWorkbenchActionConstants.M_FILE); >- assert fileMenu != null; >- fileMenu.remove("pageSetupAction"); //$NON-NLS-1$ >- IMenuManager editMenu = bars.getMenuManager().findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); >- assert editMenu != null; >- if(editMenu.find("validationGroup") == null) { //$NON-NLS-1$ >- editMenu.add(new GroupMarker("validationGroup")); //$NON-NLS-1$ >- } >- IAction validateAction = new ValidateAction(page); >- editMenu.appendToGroup("validationGroup", validateAction); //$NON-NLS-1$ >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditor.java >deleted file mode 100644 >index 55d95ca..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditor.java >+++ /dev/null >@@ -1,569 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.util.EventObject; >- >-import org.eclipse.core.commands.operations.IUndoableOperation; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IMarker; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; >-import org.eclipse.gef.GraphicalViewer; >-import org.eclipse.gef.KeyHandler; >-import org.eclipse.gef.Tool; >-import org.eclipse.gef.commands.CommandStackListener; >-import org.eclipse.gef.palette.PaletteRoot; >-import org.eclipse.gef.ui.palette.PaletteViewer; >-import org.eclipse.gef.ui.palette.PaletteViewerProvider; >-import org.eclipse.gmf.runtime.common.core.service.IProviderChangeListener; >-import org.eclipse.gmf.runtime.common.core.service.ProviderChangeEvent; >-import org.eclipse.gmf.runtime.common.ui.services.marker.MarkerNavigationService; >-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >-import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds; >-import org.eclipse.gmf.runtime.diagram.ui.internal.parts.PaletteToolTransferDragSourceListener; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.jface.util.LocalSelectionTransfer; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.papyrus.infra.gmfdiag.common.GmfMultiDiagramDocumentProvider; >-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; >-import org.eclipse.papyrus.infra.core.services.ServiceException; >-import org.eclipse.papyrus.infra.core.services.ServicesRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorItem; >-import org.eclipse.papyrus.uml.diagram.common.listeners.DropTargetListener; >-import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteContextMenuProvider; >-import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPaletteViewer; >-import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor; >-import org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.dnd.TransferData; >-import org.eclipse.swt.events.KeyEvent; >-import org.eclipse.swt.events.MouseEvent; >-import org.eclipse.swt.events.MouseListener; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.IEditorInput; >-import org.eclipse.ui.IEditorPart; >-import org.eclipse.ui.IWorkbenchPart; >-import org.eclipse.ui.ide.IGotoMarker; >-import org.eclipse.ui.navigator.resources.ProjectExplorer; >-import org.eclipse.ui.part.IShowInTargetList; >-import org.eclipse.ui.part.ShowInContext; >- >-/** >- * @generated >- */ >-public class SysmlDiagramEditor extends UmlGmfDiagramEditor implements IProviderChangeListener, IGotoMarker { >- >- /** >- * @generated >- */ >- public static final String ID = "org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorID"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static final String CONTEXT_ID = "org.eclipse.papyrus.sysml.diagram.parametric.ui.diagramContext"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- private KeyHandler paletteKeyHandler = null; >- >- /** >- * @generated >- */ >- private MouseListener paletteMouseListener = null; >- >- /** >- * @generated >- */ >- private IUndoableOperation savedOperation = null; >- >- /** >- * @generated >- */ >- private TransactionalEditingDomain editingDomain; >- >- /** >- * @generated >- */ >- private IDocumentProvider documentProvider; >- >- /** >- * @generated >- */ >- public SysmlDiagramEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws ServiceException { >- super(servicesRegistry, diagram); >- >- // adds a listener to the palette service, which reacts to palette customizations >- PapyrusPaletteService.getInstance().addProviderChangeListener(this); >- >- // Share the same editing provider >- editingDomain = servicesRegistry.getService(TransactionalEditingDomain.class); >- documentProvider = new GmfMultiDiagramDocumentProvider(editingDomain); >- >- // overrides editing domain created by super constructor >- setDocumentProvider(documentProvider); >- >- } >- >- /** >- * @generated >- */ >- @Override >- protected String getContextID() { >- return CONTEXT_ID; >- } >- >- /** >- * @generated >- */ >- @Override >- protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) { >- PaletteRoot paletteRoot; >- if(existingPaletteRoot == null) { >- paletteRoot = PapyrusPaletteService.getInstance().createPalette(this, getDefaultPaletteContent()); >- } else { >- PapyrusPaletteService.getInstance().updatePalette(existingPaletteRoot, this, getDefaultPaletteContent()); >- paletteRoot = existingPaletteRoot; >- } >- applyCustomizationsToPalette(paletteRoot); >- return paletteRoot; >- } >- >- /** >- * @generated >- */ >- @Override >- protected PreferencesHint getPreferencesHint() { >- return SysmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT; >- } >- >- /** >- * @generated >- */ >- @Override >- public String getContributorId() { >- return SysmlDiagramEditorPlugin.ID; >- } >- >- /** >- * @generated >- */ >- @Override >- public Object getAdapter(Class type) { >- if(type == IShowInTargetList.class) { >- return new IShowInTargetList() { >- >- public String[] getShowInTargetIds() { >- return new String[]{ ProjectExplorer.VIEW_ID }; >- } >- }; >- } >- return super.getAdapter(type); >- } >- >- /** >- * @generated >- */ >- @Override >- protected final IDocumentProvider getDocumentProvider(IEditorInput input) { >- return documentProvider; >- } >- >- /** >- * >- * @see org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor#getKeyHandler() >- * >- * @return >- * >- * @generated NOT >- */ >- @Override >- protected KeyHandler getKeyHandler() { >- //we remove all keybinding provided by GMF >- KeyHandler keyHandler = new KeyHandler(); >- return keyHandler; >- } >- >- /** >- * @generated >- */ >- @Override >- public TransactionalEditingDomain getEditingDomain() { >- return editingDomain; >- } >- >- /** >- * @generated >- */ >- @Override >- protected final void setDocumentProvider(IEditorInput input) { >- // Already set in the constructor >- } >- >- /** >- * @generated >- */ >- public void gotoMarker(IMarker marker) { >- MarkerNavigationService.getInstance().gotoMarker(this, marker); >- } >- >- /** >- * @generated >- */ >- @Override >- public boolean isSaveAsAllowed() { >- return true; >- } >- >- /** >- * @generated >- */ >- @Override >- public void doSaveAs() { >- performSaveAs(new NullProgressMonitor()); >- } >- >- /** >- * @generated >- */ >- @Override >- protected void performSaveAs(IProgressMonitor progressMonitor) { >- // Nothing >- } >- >- /** >- * @generated >- */ >- @Override >- public ShowInContext getShowInContext() { >- return new ShowInContext(getEditorInput(), getNavigatorSelection()); >- } >- >- /** >- * @generated >- */ >- private ISelection getNavigatorSelection() { >- IDiagramDocument document = getDiagramDocument(); >- if(document == null) { >- return StructuredSelection.EMPTY; >- } >- Diagram diagram = document.getDiagram(); >- if(diagram == null || diagram.eResource() == null) { >- return StructuredSelection.EMPTY; >- } >- IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); >- if(file != null) { >- SysmlNavigatorItem item = new SysmlNavigatorItem(diagram, file, false); >- return new StructuredSelection(item); >- } >- return StructuredSelection.EMPTY; >- } >- >- /** >- * @generated >- */ >- @Override >- protected void configureGraphicalViewer() { >- super.configureGraphicalViewer(); >- DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(this, getDiagramGraphicalViewer()); >- getDiagramGraphicalViewer().setContextMenu(provider); >- getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer()); >- } >- >- /** >- * @generated >- */ >- @Override >- protected TransactionalEditingDomain createEditingDomain() { >- // Already configured >- return editingDomain; >- } >- >- /** >- * @generated >- */ >- @Override >- protected void configureDiagramEditDomain() { >- super.configureDiagramEditDomain(); >- getDiagramEditDomain().getDiagramCommandStack().addCommandStackListener(new CommandStackListener() { >- >- public void commandStackChanged(EventObject event) { >- firePropertyChange(IEditorPart.PROP_DIRTY); >- } >- }); >- } >- >- /** >- * @generated >- */ >- @Override >- public void doSave(IProgressMonitor progressMonitor) { >- // The saving of the resource is done by the CoreMultiDiagramEditor >- savedOperation = getOperationHistory().getUndoOperation(getUndoContext()); >- } >- >- /** >- * @generated >- */ >- @Override >- public boolean isDirty() { >- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext()); >- return savedOperation != op; >- } >- >- /** >- * @generated >- */ >- public void providerChanged(ProviderChangeEvent event) { >- // update the palette if the palette service has changed >- if(PapyrusPaletteService.getInstance().equals(event.getSource())) { >- PapyrusPaletteService.getInstance().updatePalette(getPaletteViewer().getPaletteRoot(), this, getDefaultPaletteContent()); >- } >- } >- >- /** >- * @generated >- */ >- @Override >- public void dispose() { >- // remove palette service listener >- // remove preference listener >- PapyrusPaletteService.getInstance().removeProviderChangeListener(this); >- >- super.dispose(); >- } >- >- /** >- * @generated >- */ >- protected PaletteViewer getPaletteViewer() { >- return getEditDomain().getPaletteViewer(); >- } >- >- /** >- * @generated >- */ >- @Override >- protected PaletteViewer constructPaletteViewer() { >- return new PapyrusPaletteViewer(); >- } >- >- /** >- * @generated >- */ >- @Override >- protected PaletteViewerProvider createPaletteViewerProvider() { >- getEditDomain().setPaletteRoot(createPaletteRoot(null)); >- return new PaletteViewerProvider(getEditDomain()) { >- >- /** >- * Override to provide the additional behavior for the tools. Will intialize with a >- * PaletteEditPartFactory that has a TrackDragger that understand how to handle the >- * mouseDoubleClick event for shape creation tools. Also will initialize the palette >- * with a defaultTool that is the SelectToolEx that undestands how to handle the enter >- * key which will result in the creation of the shape also. >- */ >- protected void configurePaletteViewer(PaletteViewer viewer) { >- super.configurePaletteViewer(viewer); >- >- // customize menu... >- viewer.setContextMenu(new PapyrusPaletteContextMenuProvider(viewer)); >- >- viewer.getKeyHandler().setParent(getPaletteKeyHandler()); >- viewer.getControl().addMouseListener(getPaletteMouseListener()); >- >- // Add a transfer drag target listener that is supported on >- // palette template entries whose template is a creation tool. >- // This will enable drag and drop of the palette shape creation >- // tools. >- viewer.addDragSourceListener(new PaletteToolTransferDragSourceListener(viewer)); >- viewer.setCustomizer(createPaletteCustomizer()); >- } >- >- public PaletteViewer createPaletteViewer(Composite parent) { >- PaletteViewer pViewer = constructPaletteViewer(); >- pViewer.createControl(parent); >- configurePaletteViewer(pViewer); >- hookPaletteViewer(pViewer); >- return pViewer; >- } >- >- /** >- * @return Palette Key Handler for the palette >- */ >- private KeyHandler getPaletteKeyHandler() { >- >- if(paletteKeyHandler == null) { >- >- paletteKeyHandler = new KeyHandler() { >- >- /** >- * Processes a <i>key released </i> event. This method is called by the Tool >- * whenever a key is released, and the Tool is in the proper state. Override >- * to support pressing the enter key to create a shape or connection >- * (between two selected shapes) >- * >- * @param event >- * the KeyEvent >- * @return <code>true</code> if KeyEvent was handled in some way >- */ >- public boolean keyReleased(KeyEvent event) { >- >- if(event.keyCode == SWT.Selection) { >- >- Tool tool = getPaletteViewer().getActiveTool().createTool(); >- >- if(toolSupportsAccessibility(tool)) { >- >- tool.keyUp(event, getDiagramGraphicalViewer()); >- >- // deactivate current selection >- getPaletteViewer().setActiveTool(null); >- >- return true; >- } >- >- } >- return super.keyReleased(event); >- } >- >- }; >- >- } >- return paletteKeyHandler; >- } >- >- /** >- * @return Palette Mouse listener for the palette >- */ >- private MouseListener getPaletteMouseListener() { >- >- if(paletteMouseListener == null) { >- >- paletteMouseListener = new MouseListener() { >- >- /** >- * Flag to indicate that the current active tool should be cleared after a >- * mouse double-click event. >- */ >- private boolean clearActiveTool = false; >- >- /** >- * Override to support double-clicking a palette tool entry to create a >- * shape or connection (between two selected shapes). >- * >- * @see MouseListener#mouseDoubleClick(MouseEvent) >- */ >- public void mouseDoubleClick(MouseEvent e) { >- Tool tool = getPaletteViewer().getActiveTool().createTool(); >- >- if(toolSupportsAccessibility(tool)) { >- >- tool.setViewer(getDiagramGraphicalViewer()); >- tool.setEditDomain(getDiagramGraphicalViewer().getEditDomain()); >- tool.mouseDoubleClick(e, getDiagramGraphicalViewer()); >- >- // Current active tool should be deactivated, >- // but if it is down here it will get >- // reactivated deep in GEF palette code after >- // receiving mouse up events. >- clearActiveTool = true; >- } >- } >- >- public void mouseDown(MouseEvent e) { >- // do nothing >- } >- >- public void mouseUp(MouseEvent e) { >- // Deactivate current active tool here if a >- // double-click was handled. >- if(clearActiveTool) { >- getPaletteViewer().setActiveTool(null); >- clearActiveTool = false; >- } >- >- } >- }; >- >- } >- return paletteMouseListener; >- } >- >- }; >- } >- >- /** >- * @generated >- */ >- @Override >- public GraphicalViewer getGraphicalViewer() { >- return super.getGraphicalViewer(); >- } >- >- /** >- * @generated >- */ >- @Override >- protected void initializeGraphicalViewer() { >- super.initializeGraphicalViewer(); >- >- // Enable Drop >- getDiagramGraphicalViewer().addDropTargetListener(new DropTargetListener(getDiagramGraphicalViewer(), LocalSelectionTransfer.getTransfer()) { >- >- @Override >- protected Object getJavaObject(TransferData data) { >- return LocalSelectionTransfer.getTransfer().nativeToJava(data); >- } >- >- @Override >- protected TransactionalEditingDomain getTransactionalEditingDomain() { >- return getEditingDomain(); >- } >- }); >- >- } >- >- /** >- * @generated >- */ >- @Override >- public void selectionChanged(IWorkbenchPart part, ISelection selection) { >- if(getSite().getPage().getActiveEditor() instanceof IMultiDiagramEditor) { >- IMultiDiagramEditor editor = (IMultiDiagramEditor)getSite().getPage().getActiveEditor(); >- // If not the active editor, ignore selection changed. >- if(this.equals(editor.getActiveEditor())) { >- updateActions(getSelectionActions()); >- super.selectionChanged(part, selection); >- } else { >- super.selectionChanged(part, selection); >- } >- } else { >- super.selectionChanged(part, selection); >- } >- // from >- // org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.selectionChanged(IWorkbenchPart, >- // ISelection) >- if(part == this) { >- rebuildStatusLine(); >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditorPlugin.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditorPlugin.java >deleted file mode 100644 >index 5b4bbbc..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditorPlugin.java >+++ /dev/null >@@ -1,333 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.emf.common.notify.AdapterFactory; >-import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory; >-import org.eclipse.emf.edit.provider.ComposedAdapterFactory; >-import org.eclipse.emf.edit.provider.IItemLabelProvider; >-import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; >-import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; >-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator; >-import org.eclipse.papyrus.resource.provider.ResourceItemProviderAdapterFactory; >-import org.eclipse.papyrus.sysml.activities.provider.ActivitiesItemProviderAdapterFactory; >-import org.eclipse.papyrus.sysml.allocations.provider.AllocationsItemProviderAdapterFactory; >-import org.eclipse.papyrus.sysml.blocks.provider.BlocksItemProviderAdapterFactory; >-import org.eclipse.papyrus.sysml.constraints.provider.ConstraintsItemProviderAdapterFactory; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.policies.SysmlBaseItemSemanticEditPolicy; >-import org.eclipse.papyrus.sysml.diagram.parametric.preferences.DiagramPreferenceInitializer; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.ElementInitializers; >-import org.eclipse.papyrus.sysml.modelelements.provider.ModelelementsItemProviderAdapterFactory; >-import org.eclipse.papyrus.sysml.portandflows.provider.PortandflowsItemProviderAdapterFactory; >-import org.eclipse.papyrus.sysml.requirements.provider.RequirementsItemProviderAdapterFactory; >-import org.eclipse.papyrus.uml.standard.provider.StandardItemProviderAdapterFactory; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.ui.plugin.AbstractUIPlugin; >-import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory; >-import org.osgi.framework.BundleContext; >- >-/** >- * @generated >- */ >-public class SysmlDiagramEditorPlugin extends AbstractUIPlugin { >- >- /** >- * @generated >- */ >- public static final String ID = "org.eclipse.papyrus.sysml.diagram.parametric"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(ID); >- >- /** >- * @generated >- */ >- private static SysmlDiagramEditorPlugin instance; >- >- /** >- * @generated >- */ >- private ComposedAdapterFactory adapterFactory; >- >- /** >- * @generated >- */ >- private SysmlDocumentProvider documentProvider; >- >- /** >- * @generated >- */ >- private SysmlBaseItemSemanticEditPolicy.LinkConstraints linkConstraints; >- >- /** >- * @generated >- */ >- private ElementInitializers initializers; >- >- /** >- * @generated >- */ >- public SysmlDiagramEditorPlugin() { >- } >- >- /** >- * @generated >- */ >- public void start(BundleContext context) throws Exception { >- super.start(context); >- instance = this; >- PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, getPreferenceStore()); >- adapterFactory = createAdapterFactory(); >- DiagramPreferenceInitializer diagramPreferenceInitializer = new DiagramPreferenceInitializer(); >- diagramPreferenceInitializer.initializeDefaultPreferences(); >- } >- >- /** >- * @generated >- */ >- public void stop(BundleContext context) throws Exception { >- adapterFactory.dispose(); >- adapterFactory = null; >- linkConstraints = null; >- initializers = null; >- instance = null; >- super.stop(context); >- } >- >- /** >- * @generated >- */ >- public static SysmlDiagramEditorPlugin getInstance() { >- return instance; >- } >- >- /** >- * @generated >- */ >- public IPreferenceStore getPreferenceStore() { >- IPreferenceStore store = Activator.getDefault().getPreferenceStore(); >- return store; >- } >- >- /** >- * @generated >- */ >- protected ComposedAdapterFactory createAdapterFactory() { >- ArrayList<AdapterFactory> factories = new ArrayList<AdapterFactory>(); >- fillItemProviderFactories(factories); >- return new ComposedAdapterFactory(factories); >- } >- >- /** >- * @generated NOT >- */ >- protected void fillItemProviderFactories(List factories) { >- // factories.add(new SysmlItemProviderAdapterFactory()); >- factories.add(new ModelelementsItemProviderAdapterFactory()); >- factories.add(new BlocksItemProviderAdapterFactory()); >- factories.add(new PortandflowsItemProviderAdapterFactory()); >- factories.add(new ConstraintsItemProviderAdapterFactory()); >- factories.add(new ActivitiesItemProviderAdapterFactory()); >- factories.add(new AllocationsItemProviderAdapterFactory()); >- factories.add(new RequirementsItemProviderAdapterFactory()); >- // factories.add(new InteractionsItemProviderAdapterFactory()); >- // factories.add(new StatemachinesItemProviderAdapterFactory()); >- // factories.add(new UsecasesItemProviderAdapterFactory()); >- factories.add(new EcoreItemProviderAdapterFactory()); >- factories.add(new StandardItemProviderAdapterFactory()); >- factories.add(new UMLItemProviderAdapterFactory()); >- factories.add(new ResourceItemProviderAdapterFactory()); >- factories.add(new org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory()); >- factories.add(new ReflectiveItemProviderAdapterFactory()); >- } >- >- /** >- * @generated >- */ >- public AdapterFactory getItemProvidersAdapterFactory() { >- return adapterFactory; >- } >- >- /** >- * @generated >- */ >- public ImageDescriptor getItemImageDescriptor(Object item) { >- IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(item, IItemLabelProvider.class); >- if(labelProvider != null) { >- return ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item)); >- } >- return null; >- } >- >- /** >- * Returns an image descriptor for the image file at the given plug-in relative path. >- * >- * @generated >- * @param path >- * the path >- * @return the image descriptor >- */ >- public static ImageDescriptor getBundledImageDescriptor(String path) { >- return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path); >- } >- >- /** >- * Respects images residing in any plug-in. If path is relative, then this bundle is looked up >- * for the image, otherwise, for absolute path, first segment is taken as id of plug-in with >- * image >- * >- * @generated >- * @param path >- * the path to image, either absolute (with plug-in id as first segment), or relative >- * for bundled images >- * @return the image descriptor >- */ >- public static ImageDescriptor findImageDescriptor(String path) { >- final IPath p = new Path(path); >- if(p.isAbsolute() && p.segmentCount() > 1) { >- return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), p.removeFirstSegments(1).makeAbsolute().toString()); >- } else { >- return getBundledImageDescriptor(p.makeAbsolute().toString()); >- } >- } >- >- /** >- * Returns an image for the image file at the given plug-in relative path. Client do not need to >- * dispose this image. Images will be disposed automatically. >- * >- * @generated >- * @param path >- * the path >- * @return image instance >- */ >- public Image getBundledImage(String path) { >- Image image = getImageRegistry().get(path); >- if(image == null) { >- getImageRegistry().put(path, getBundledImageDescriptor(path)); >- image = getImageRegistry().get(path); >- } >- return image; >- } >- >- /** >- * Returns string from plug-in's resource bundle >- * >- * @generated >- */ >- public static String getString(String key) { >- return Platform.getResourceString(getInstance().getBundle(), "%" + key); //$NON-NLS-1$ >- } >- >- /** >- * @generated >- */ >- public SysmlDocumentProvider getDocumentProvider() { >- if(documentProvider == null) { >- documentProvider = new SysmlDocumentProvider(); >- } >- return documentProvider; >- } >- >- /** >- * @generated >- */ >- public SysmlBaseItemSemanticEditPolicy.LinkConstraints getLinkConstraints() { >- return linkConstraints; >- } >- >- /** >- * @generated >- */ >- public void setLinkConstraints(SysmlBaseItemSemanticEditPolicy.LinkConstraints lc) { >- this.linkConstraints = lc; >- } >- >- /** >- * @generated >- */ >- public ElementInitializers getElementInitializers() { >- return initializers; >- } >- >- /** >- * @generated >- */ >- public void setElementInitializers(ElementInitializers i) { >- this.initializers = i; >- } >- >- /** >- * @generated >- */ >- public void logError(String error) { >- logError(error, null); >- } >- >- /** >- * @generated >- */ >- public void logError(String error, Throwable throwable) { >- if(error == null && throwable != null) { >- error = throwable.getMessage(); >- } >- getLog().log(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, IStatus.OK, error, throwable)); >- debug(error, throwable); >- } >- >- /** >- * @generated >- */ >- public void logInfo(String message) { >- logInfo(message, null); >- } >- >- /** >- * @generated >- */ >- public void logInfo(String message, Throwable throwable) { >- if(message == null && throwable != null) { >- message = throwable.getMessage(); >- } >- getLog().log(new Status(IStatus.INFO, SysmlDiagramEditorPlugin.ID, IStatus.OK, message, throwable)); >- debug(message, throwable); >- } >- >- /** >- * @generated >- */ >- private void debug(String message, Throwable throwable) { >- if(!isDebugging()) { >- return; >- } >- if(message != null) { >- System.err.println(message); >- } >- if(throwable != null) { >- throwable.printStackTrace(); >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditorUtil.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditorUtil.java >deleted file mode 100644 >index 12598f3..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramEditorUtil.java >+++ /dev/null >@@ -1,377 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.io.IOException; >-import java.util.Collections; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >-import java.util.Set; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.commands.operations.OperationHistoryFactory; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.SubProgressMonitor; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.xmi.XMLResource; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.diagram.core.services.ViewService; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer; >-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart; >-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory; >-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.dialogs.IDialogSettings; >-import org.eclipse.jface.wizard.Wizard; >-import org.eclipse.jface.wizard.WizardDialog; >-import org.eclipse.papyrus.resource.ResourceFactory; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.IWorkbenchPage; >-import org.eclipse.ui.PartInitException; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.part.FileEditorInput; >- >-/** >- * @generated >- */ >-public class SysmlDiagramEditorUtil { >- >- /** >- * @generated >- */ >- public static Map<?, ?> getSaveOptions() { >- HashMap<String, Object> saveOptions = new HashMap<String, Object>(); >- saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$ >- saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); >- return saveOptions; >- } >- >- /** >- * @generated >- */ >- public static boolean openDiagram(Resource diagram) throws PartInitException { >- String path = diagram.getURI().toPlatformString(true); >- IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path)); >- if(workspaceResource instanceof IFile) { >- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >- return null != page.openEditor(new FileEditorInput((IFile)workspaceResource), SysmlDiagramEditor.ID); >- } >- return false; >- } >- >- /** >- * @generated >- */ >- public static void setCharset(IFile file) { >- if(file == null) { >- return; >- } >- try { >- file.setCharset("UTF-8", new NullProgressMonitor()); //$NON-NLS-1$ >- } catch (CoreException e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Unable to set charset for file " + file.getFullPath(), e); //$NON-NLS-1$ >- } >- } >- >- /** >- * @generated >- */ >- public static String getUniqueFileName(IPath containerFullPath, String fileName, String extension) { >- if(containerFullPath == null) { >- containerFullPath = new Path(""); //$NON-NLS-1$ >- } >- if(fileName == null || fileName.trim().length() == 0) { >- fileName = "default"; //$NON-NLS-1$ >- } >- IPath filePath = containerFullPath.append(fileName); >- if(extension != null && !extension.equals(filePath.getFileExtension())) { >- filePath = filePath.addFileExtension(extension); >- } >- extension = filePath.getFileExtension(); >- fileName = filePath.removeFileExtension().lastSegment(); >- int i = 1; >- while(ResourcesPlugin.getWorkspace().getRoot().exists(filePath)) { >- i++; >- filePath = containerFullPath.append(fileName + i); >- if(extension != null) { >- filePath = filePath.addFileExtension(extension); >- } >- } >- return filePath.lastSegment(); >- } >- >- /** >- * Runs the wizard in a dialog. >- * >- * @generated >- */ >- public static void runWizard(Shell shell, Wizard wizard, String settingsKey) { >- IDialogSettings pluginDialogSettings = SysmlDiagramEditorPlugin.getInstance().getDialogSettings(); >- IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey); >- if(wizardDialogSettings == null) { >- wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey); >- } >- wizard.setDialogSettings(wizardDialogSettings); >- WizardDialog dialog = new WizardDialog(shell, wizard); >- dialog.create(); >- dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500); >- dialog.open(); >- } >- >- /** >- * This method should be called within a workspace modify operation since it creates resources. >- * >- * @generated >- */ >- public static Resource createDiagram(URI diagramURI, URI modelURI, IProgressMonitor progressMonitor) { >- TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain(); >- progressMonitor.beginTask(Messages.SysmlDiagramEditorUtil_CreateDiagramProgressTask, 3); >- final Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI); >- final Resource modelResource = editingDomain.getResourceSet().createResource(modelURI); >- final String diagramName = diagramURI.lastSegment(); >- AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, Messages.SysmlDiagramEditorUtil_CreateDiagramCommandLabel, Collections.EMPTY_LIST) { >- >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- org.eclipse.papyrus.resource.Resource model = createInitialModel(); >- attachModelToResource(model, modelResource); >- >- Diagram diagram = ViewService.createDiagram(model, ParametricEditPart.MODEL_ID, SysmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); >- if(diagram != null) { >- diagramResource.getContents().add(diagram); >- diagram.setName(diagramName); >- diagram.setElement(model); >- } >- >- try { >- modelResource.save(org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorUtil.getSaveOptions()); >- diagramResource.save(org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorUtil.getSaveOptions()); >- } catch (IOException e) { >- >- SysmlDiagramEditorPlugin.getInstance().logError("Unable to store model and diagram resources", e); //$NON-NLS-1$ >- } >- return CommandResult.newOKCommandResult(); >- } >- }; >- try { >- OperationHistoryFactory.getOperationHistory().execute(command, new SubProgressMonitor(progressMonitor, 1), null); >- } catch (ExecutionException e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e); //$NON-NLS-1$ >- } >- setCharset(WorkspaceSynchronizer.getFile(modelResource)); >- setCharset(WorkspaceSynchronizer.getFile(diagramResource)); >- return diagramResource; >- } >- >- /** >- * Create a new instance of domain element associated with canvas. >- * <!-- begin-user-doc --> <!-- >- * end-user-doc --> >- * >- * @generated >- */ >- private static org.eclipse.papyrus.resource.Resource createInitialModel() { >- return ResourceFactory.eINSTANCE.createResource(); >- } >- >- /** >- * Store model element in the resource. >- * <!-- begin-user-doc --> <!-- end-user-doc --> >- * >- * @generated >- */ >- private static void attachModelToResource(org.eclipse.papyrus.resource.Resource model, Resource resource) { >- resource.getContents().add(model); >- } >- >- /** >- * @generated >- */ >- public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) { >- diagramPart.getDiagramGraphicalViewer().deselectAll(); >- >- EditPart firstPrimary = null; >- for(EditPart nextPart : editParts) { >- diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart); >- if(firstPrimary == null && nextPart instanceof IPrimaryEditPart) { >- firstPrimary = nextPart; >- } >- } >- >- if(!editParts.isEmpty()) { >- diagramPart.getDiagramGraphicalViewer().reveal(firstPrimary != null ? firstPrimary : (EditPart)editParts.get(0)); >- } >- } >- >- /** >- * @generated >- */ >- private static int findElementsInDiagramByID(DiagramEditPart diagramPart, EObject element, List<EditPart> editPartCollector) { >- IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer)diagramPart.getViewer(); >- final int intialNumOfEditParts = editPartCollector.size(); >- >- if(element instanceof View) { // support notation element lookup >- EditPart editPart = (EditPart)viewer.getEditPartRegistry().get(element); >- if(editPart != null) { >- editPartCollector.add(editPart); >- return 1; >- } >- } >- >- String elementID = EMFCoreUtil.getProxyID(element); >- @SuppressWarnings("unchecked") >- List<EditPart> associatedParts = viewer.findEditPartsForElement(elementID, IGraphicalEditPart.class); >- // perform the possible hierarchy disjoint -> take the top-most parts only >- for(EditPart nextPart : associatedParts) { >- EditPart parentPart = nextPart.getParent(); >- while(parentPart != null && !associatedParts.contains(parentPart)) { >- parentPart = parentPart.getParent(); >- } >- if(parentPart == null) { >- editPartCollector.add(nextPart); >- } >- } >- >- if(intialNumOfEditParts == editPartCollector.size()) { >- if(!associatedParts.isEmpty()) { >- editPartCollector.add(associatedParts.get(0)); >- } else { >- if(element.eContainer() != null) { >- return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector); >- } >- } >- } >- return editPartCollector.size() - intialNumOfEditParts; >- } >- >- /** >- * @generated >- */ >- public static View findView(DiagramEditPart diagramEditPart, EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) { >- boolean hasStructuralURI = false; >- if(targetElement.eResource() instanceof XMLResource) { >- hasStructuralURI = ((XMLResource)targetElement.eResource()).getID(targetElement) == null; >- } >- >- View view = null; >- LinkedList<EditPart> editPartHolder = new LinkedList<EditPart>(); >- if(hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) { >- view = lazyElement2ViewMap.getElement2ViewMap().get(targetElement); >- } else if(findElementsInDiagramByID(diagramEditPart, targetElement, editPartHolder) > 0) { >- EditPart editPart = editPartHolder.get(0); >- view = editPart.getModel() instanceof View ? (View)editPart.getModel() : null; >- } >- >- return (view == null) ? diagramEditPart.getDiagramView() : view; >- } >- >- /** >- * @generated >- */ >- public static class LazyElement2ViewMap { >- >- /** >- * @generated >- */ >- private Map<EObject, View> element2ViewMap; >- >- /** >- * @generated >- */ >- private View scope; >- >- /** >- * @generated >- */ >- private Set<? extends EObject> elementSet; >- >- /** >- * @generated >- */ >- public LazyElement2ViewMap(View scope, Set<? extends EObject> elements) { >- this.scope = scope; >- this.elementSet = elements; >- } >- >- /** >- * @generated >- */ >- public final Map<EObject, View> getElement2ViewMap() { >- if(element2ViewMap == null) { >- element2ViewMap = new HashMap<EObject, View>(); >- // map possible notation elements to itself as these can't be found by view.getElement() >- for(EObject element : elementSet) { >- if(element instanceof View) { >- View view = (View)element; >- if(view.getDiagram() == scope.getDiagram()) { >- element2ViewMap.put(element, view); // take only those that part of our diagram >- } >- } >- } >- >- buildElement2ViewMap(scope, element2ViewMap, elementSet); >- } >- return element2ViewMap; >- } >- >- /** >- * @generated >- */ >- private static boolean buildElement2ViewMap(View parentView, Map<EObject, View> element2ViewMap, Set<? extends EObject> elements) { >- if(elements.size() == element2ViewMap.size()) { >- return true; >- } >- >- if(parentView.isSetElement() && !element2ViewMap.containsKey(parentView.getElement()) && elements.contains(parentView.getElement())) { >- element2ViewMap.put(parentView.getElement(), parentView); >- if(elements.size() == element2ViewMap.size()) { >- return true; >- } >- } >- boolean complete = false; >- for(Iterator<?> it = parentView.getChildren().iterator(); it.hasNext() && !complete;) { >- complete = buildElement2ViewMap((View)it.next(), element2ViewMap, elements); >- } >- for(Iterator<?> it = parentView.getSourceEdges().iterator(); it.hasNext() && !complete;) { >- complete = buildElement2ViewMap((View)it.next(), element2ViewMap, elements); >- } >- for(Iterator<?> it = parentView.getTargetEdges().iterator(); it.hasNext() && !complete;) { >- complete = buildElement2ViewMap((View)it.next(), element2ViewMap, elements); >- } >- return complete; >- } >- } // LazyElement2ViewMap >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramUpdateCommand.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramUpdateCommand.java >deleted file mode 100644 >index 8e3daaf..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramUpdateCommand.java >+++ /dev/null >@@ -1,91 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.util.Iterator; >-import java.util.List; >- >-import org.eclipse.core.commands.ExecutionEvent; >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.commands.IHandler; >-import org.eclipse.core.commands.IHandlerListener; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * @generated >- */ >-public class SysmlDiagramUpdateCommand implements IHandler { >- >- /** >- * @generated >- */ >- public void addHandlerListener(IHandlerListener handlerListener) { >- } >- >- /** >- * @generated >- */ >- public void dispose() { >- } >- >- /** >- * @generated >- */ >- public Object execute(ExecutionEvent event) throws ExecutionException { >- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); >- if(selection instanceof IStructuredSelection) { >- IStructuredSelection structuredSelection = (IStructuredSelection)selection; >- if(structuredSelection.size() != 1) { >- return null; >- } >- if(structuredSelection.getFirstElement() instanceof EditPart && ((EditPart)structuredSelection.getFirstElement()).getModel() instanceof View) { >- EObject modelElement = ((View)((EditPart)structuredSelection.getFirstElement()).getModel()).getElement(); >- List editPolicies = CanonicalEditPolicy.getRegisteredEditPolicies(modelElement); >- for(Iterator it = editPolicies.iterator(); it.hasNext();) { >- CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy)it.next(); >- nextEditPolicy.refresh(); >- } >- >- } >- } >- return null; >- } >- >- /** >- * @generated >- */ >- public boolean isEnabled() { >- return true; >- } >- >- /** >- * @generated >- */ >- public boolean isHandled() { >- return true; >- } >- >- /** >- * @generated >- */ >- public void removeHandlerListener(IHandlerListener handlerListener) { >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramUpdater.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramUpdater.java >deleted file mode 100644 >index 665a576..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDiagramUpdater.java >+++ /dev/null >@@ -1,359 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.util.Collection; >-import java.util.Collections; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.emf.common.util.EList; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.resource.util.ResourceUtil; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.uml2.uml.Class; >-import org.eclipse.uml2.uml.ConnectableElement; >-import org.eclipse.uml2.uml.Connector; >-import org.eclipse.uml2.uml.ConnectorEnd; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.StructuredClassifier; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * @generated >- */ >-public class SysmlDiagramUpdater { >- >- /** >- * @generated >- */ >- public static List<SysmlNodeDescriptor> getSemanticChildren(View view) { >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- case ParametricEditPart.VISUAL_ID: >- return getResource_1000SemanticChildren(view); >- case ConstraintPropertyEditPart.VISUAL_ID: >- return getConstraintProperty_2003SemanticChildren(view); >- } >- return Collections.emptyList(); >- } >- >- /** >- * @generated NOT >- */ >- public static List getConstraintProperty_2003SemanticChildren(View view) { >- if(!view.isSetElement()) { >- return Collections.EMPTY_LIST; >- } >- ConstraintProperty modelElement = (ConstraintProperty)view.getElement(); >- List result = new LinkedList(); >- { >- Property childElement = modelElement.getBase_Property(); >- int visualID = SysmlVisualIDRegistry.getNodeVisualID(view, childElement); >- if(visualID == Property2EditPart.VISUAL_ID) { >- result.add(new SysmlNodeDescriptor(childElement, visualID)); >- } >- } >- return result; >- /* >- * if (!view.isSetElement()) { return Collections.EMPTY_LIST; } ConstraintProperty >- * modelElement = (ConstraintProperty) view.getElement(); List result = new LinkedList(); >- * >- * Object oclRuleResult = OCLUtils.runOclRule("self.base_Property.type", modelElement); if >- * (oclRuleResult != null) { if (oclRuleResult instanceof StructuredClassifier) { >- * StructuredClassifier aClass = (StructuredClassifier) oclRuleResult; for (Iterator it = >- * aClass.getAttributes().iterator(); it.hasNext();) { Property childElement = (Property) >- * it.next(); int visualID = SysmlVisualIDRegistry.getNodeVisualID(view, childElement); if >- * (visualID == Property2EditPart.VISUAL_ID) { result.add(new >- * SysmlNodeDescriptor(childElement, visualID)); //continue; } } } else { throw new >- * UnsupportedOperationException("Can't access with ..."); } } >- */ >- } >- >- /** >- * @generated NOT >- */ >- public static List getResource_1000SemanticChildren(View view) { >- if(!view.isSetElement()) { >- return Collections.EMPTY_LIST; >- } >- List result = new LinkedList(); >- EObject eObject = view.getElement(); >- // element is a block >- if(eObject instanceof Class) { >- Class modelElement = (Class)eObject; >- // we get the papyrus resource from the model object >- EList<EObject> eobjects = ResourceUtil.getResource(modelElement).getEobjects(); >- for(Iterator it = eobjects.iterator(); it.hasNext();) { >- EObject childElement = (EObject)it.next(); >- int visualID = SysmlVisualIDRegistry.getNodeVisualID(view, (EObject)childElement); >- if(visualID == ConstraintPropertyEditPart.VISUAL_ID) { >- result.add(new SysmlNodeDescriptor((EObject)childElement, visualID)); >- continue; >- } >- } >- for(Iterator it = modelElement.getOwnedAttributes().iterator(); it.hasNext();) { >- EObject obj = (EObject)it.next(); >- if(obj instanceof Property) { >- Property childElement = (Property)obj; >- int visualID = SysmlVisualIDRegistry.getNodeVisualID(view, childElement); >- if((visualID == PropertyEditPart.VISUAL_ID) && (childElement.getAppliedStereotype("SysML::Constraints::ConstraintProperty") == null)) { >- result.add(new SysmlNodeDescriptor(childElement, visualID)); >- continue; >- } >- } >- } >- } >- return result; >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getContainedLinks(View view) { >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- case ParametricEditPart.VISUAL_ID: >- return getResource_1000ContainedLinks(view); >- case ConstraintPropertyEditPart.VISUAL_ID: >- return getConstraintProperty_2003ContainedLinks(view); >- case PropertyEditPart.VISUAL_ID: >- return getProperty_2005ContainedLinks(view); >- case Property2EditPart.VISUAL_ID: >- return getProperty_3002ContainedLinks(view); >- case ConnectorEditPart.VISUAL_ID: >- return getConnector_4001ContainedLinks(view); >- } >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getIncomingLinks(View view) { >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- case ConstraintPropertyEditPart.VISUAL_ID: >- return getConstraintProperty_2003IncomingLinks(view); >- case PropertyEditPart.VISUAL_ID: >- return getProperty_2005IncomingLinks(view); >- case Property2EditPart.VISUAL_ID: >- return getProperty_3002IncomingLinks(view); >- case ConnectorEditPart.VISUAL_ID: >- return getConnector_4001IncomingLinks(view); >- } >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getOutgoingLinks(View view) { >- switch(SysmlVisualIDRegistry.getVisualID(view)) { >- case ConstraintPropertyEditPart.VISUAL_ID: >- return getConstraintProperty_2003OutgoingLinks(view); >- case PropertyEditPart.VISUAL_ID: >- return getProperty_2005OutgoingLinks(view); >- case Property2EditPart.VISUAL_ID: >- return getProperty_3002OutgoingLinks(view); >- case ConnectorEditPart.VISUAL_ID: >- return getConnector_4001OutgoingLinks(view); >- } >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getResource_1000ContainedLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getConstraintProperty_2003ContainedLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getProperty_2005ContainedLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getProperty_3002ContainedLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getConnector_4001ContainedLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getConstraintProperty_2003IncomingLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getProperty_2005IncomingLinks(View view) { >- Property modelElement = (Property)view.getElement(); >- Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources()); >- LinkedList<SysmlLinkDescriptor> result = new LinkedList<SysmlLinkDescriptor>(); >- result.addAll(getIncomingTypeModelFacetLinks_Connector_4001(modelElement, crossReferences)); >- return result; >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getProperty_3002IncomingLinks(View view) { >- Property modelElement = (Property)view.getElement(); >- Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources()); >- LinkedList<SysmlLinkDescriptor> result = new LinkedList<SysmlLinkDescriptor>(); >- result.addAll(getIncomingTypeModelFacetLinks_Connector_4001(modelElement, crossReferences)); >- return result; >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getConnector_4001IncomingLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getConstraintProperty_2003OutgoingLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getProperty_2005OutgoingLinks(View view) { >- Property modelElement = (Property)view.getElement(); >- LinkedList<SysmlLinkDescriptor> result = new LinkedList<SysmlLinkDescriptor>(); >- result.addAll(getOutgoingTypeModelFacetLinks_Connector_4001(modelElement)); >- return result; >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getProperty_3002OutgoingLinks(View view) { >- Property modelElement = (Property)view.getElement(); >- LinkedList<SysmlLinkDescriptor> result = new LinkedList<SysmlLinkDescriptor>(); >- result.addAll(getOutgoingTypeModelFacetLinks_Connector_4001(modelElement)); >- return result; >- } >- >- /** >- * @generated >- */ >- public static List<SysmlLinkDescriptor> getConnector_4001OutgoingLinks(View view) { >- return Collections.emptyList(); >- } >- >- /** >- * @generated NOT >- */ >- private static Collection getIncomingTypeModelFacetLinks_Connector_4001(ConnectableElement target, Map crossReferences) { >- Collection result = new LinkedList(); >- Collection settings = (Collection)crossReferences.get(target); >- for(Iterator it = settings.iterator(); it.hasNext();) { >- EStructuralFeature.Setting setting = (EStructuralFeature.Setting)it.next(); >- if(setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getConnectorEnd_Role() || false == setting.getEObject() instanceof ConnectorEnd) { >- continue; >- } >- ConnectorEnd connectorEnd = (ConnectorEnd)setting.getEObject(); >- Connector link = (Connector)connectorEnd.getOwner(); >- if(ConnectorEditPart.VISUAL_ID != SysmlVisualIDRegistry.getLinkWithClassVisualID(link)) { >- continue; >- } >- ConnectableElement src = null; >- EList<ConnectorEnd> ends = link.getEnds(); >- if(ends != null && !ends.isEmpty()) { >- src = ends.get(0).getRole(); >- } >- result.add(new SysmlLinkDescriptor(src, target, link, SysmlElementTypes.Connector_4001, ConnectorEditPart.VISUAL_ID)); >- } >- return result; >- } >- >- /** >- * @generated NOT >- */ >- private static Collection getOutgoingTypeModelFacetLinks_Connector_4001(ConnectableElement source) { >- StructuredClassifier container = null; >- // Find container element for the link. >- // Climb up by containment hierarchy starting from the source >- // and return the first element that is instance of the container class. >- for(EObject element = source; element != null && container == null; element = element.eContainer()) { >- if(element instanceof StructuredClassifier) { >- container = (StructuredClassifier)element; >- } >- } >- if(container == null) { >- return Collections.EMPTY_LIST; >- } >- Collection result = new LinkedList(); >- for(Iterator links = container.getOwnedConnectors().iterator(); links.hasNext();) { >- EObject linkObject = (EObject)links.next(); >- if(false == linkObject instanceof Connector) { >- continue; >- } >- Connector link = (Connector)linkObject; >- if(ConnectorEditPart.VISUAL_ID != SysmlVisualIDRegistry.getLinkWithClassVisualID(link)) { >- continue; >- } >- >- ConnectableElement src = null; >- ConnectableElement dst = null; >- EList<ConnectorEnd> ends = link.getEnds(); >- if(ends != null && !ends.isEmpty() && ends.size() > 1) { >- src = ends.get(0).getRole(); >- dst = ends.get(1).getRole(); >- } >- >- if(src != source) { >- continue; >- } >- result.add(new SysmlLinkDescriptor(src, dst, link, SysmlElementTypes.Connector_4001, ConnectorEditPart.VISUAL_ID)); >- >- } >- return result; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDocumentProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDocumentProvider.java >deleted file mode 100644 >index 3b0d09b..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlDocumentProvider.java >+++ /dev/null >@@ -1,988 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.io.IOException; >-import java.util.ArrayList; >-import java.util.Collections; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IResourceStatus; >-import org.eclipse.core.resources.IStorage; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.core.runtime.jobs.ISchedulingRule; >-import org.eclipse.core.runtime.jobs.MultiRule; >-import org.eclipse.emf.common.notify.Adapter; >-import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.common.notify.Notifier; >-import org.eclipse.emf.common.ui.URIEditorInput; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.ecore.util.EContentAdapter; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.emf.transaction.NotificationFilter; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes; >-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil; >-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.jface.operation.IRunnableContext; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.swt.widgets.Display; >-import org.eclipse.ui.IEditorInput; >-import org.eclipse.ui.part.FileEditorInput; >- >-/** >- * @generated >- */ >-public class SysmlDocumentProvider extends AbstractDocumentProvider implements IDiagramDocumentProvider { >- >- /** >- * @generated >- */ >- protected ElementInfo createElementInfo(Object element) throws CoreException { >- if(false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, 0, NLS.bind(Messages.SysmlDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ >- null)); >- } >- IEditorInput editorInput = (IEditorInput)element; >- IDiagramDocument document = (IDiagramDocument)createDocument(editorInput); >- >- ResourceSetInfo info = new ResourceSetInfo(document, editorInput); >- info.setModificationStamp(computeModificationStamp(info)); >- info.fStatus = null; >- return info; >- } >- >- /** >- * @generated >- */ >- protected IDocument createDocument(Object element) throws CoreException { >- if(false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, 0, NLS.bind(Messages.SysmlDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ >- null)); >- } >- IDocument document = createEmptyDocument(); >- setDocumentContent(document, (IEditorInput)element); >- setupDocument(element, document); >- return document; >- } >- >- /** >- * Sets up the given document as it would be provided for the given element. The content of the >- * document is not changed. This default implementation is empty. Subclasses may reimplement. >- * >- * @param element >- * the blue-print element >- * @param document >- * the document to set up >- * @generated >- */ >- protected void setupDocument(Object element, IDocument document) { >- // for subclasses >- } >- >- /** >- * @generated >- */ >- private long computeModificationStamp(ResourceSetInfo info) { >- int result = 0; >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- IFile file = WorkspaceSynchronizer.getFile(nextResource); >- if(file != null) { >- if(file.getLocation() != null) { >- result += file.getLocation().toFile().lastModified(); >- } else { >- result += file.getModificationStamp(); >- } >- } >- } >- return result; >- } >- >- /** >- * @generated >- */ >- protected IDocument createEmptyDocument() { >- DiagramDocument document = new DiagramDocument(); >- document.setEditingDomain(createEditingDomain()); >- return document; >- } >- >- /** >- * @generated >- */ >- private TransactionalEditingDomain createEditingDomain() { >- TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain(); >- editingDomain.setID("org.eclipse.papyrus.sysml.diagram.parametric.EditingDomain"); //$NON-NLS-1$ >- final NotificationFilter diagramResourceModifiedFilter = NotificationFilter.createNotifierFilter(editingDomain.getResourceSet()).and(NotificationFilter.createEventTypeFilter(Notification.ADD)).and(NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES)); >- editingDomain.getResourceSet().eAdapters().add(new Adapter() { >- >- private Notifier myTarger; >- >- public Notifier getTarget() { >- return myTarger; >- } >- >- public boolean isAdapterForType(Object type) { >- return false; >- } >- >- public void notifyChanged(Notification notification) { >- if(diagramResourceModifiedFilter.matches(notification)) { >- Object value = notification.getNewValue(); >- if(value instanceof Resource) { >- ((Resource)value).setTrackingModification(true); >- } >- } >- } >- >- public void setTarget(Notifier newTarget) { >- myTarger = newTarget; >- } >- >- }); >- >- return editingDomain; >- } >- >- /** >- * @generated >- */ >- protected void setDocumentContent(IDocument document, IEditorInput element) throws CoreException { >- IDiagramDocument diagramDocument = (IDiagramDocument)document; >- TransactionalEditingDomain domain = diagramDocument.getEditingDomain(); >- if(element instanceof FileEditorInput) { >- IStorage storage = ((FileEditorInput)element).getStorage(); >- Diagram diagram = DiagramIOUtil.load(domain, storage, true, getProgressMonitor()); >- document.setContent(diagram); >- } else if(element instanceof URIEditorInput) { >- URI uri = ((URIEditorInput)element).getURI(); >- Resource resource = null; >- try { >- resource = domain.getResourceSet().getResource(uri.trimFragment(), false); >- if(resource == null) { >- resource = domain.getResourceSet().createResource(uri.trimFragment()); >- } >- if(!resource.isLoaded()) { >- try { >- Map options = new HashMap(GMFResourceFactory.getDefaultLoadOptions()); >- // @see 171060 >- // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE); >- resource.load(options); >- } catch (IOException e) { >- resource.unload(); >- throw e; >- } >- } >- if(uri.fragment() != null) { >- EObject rootElement = resource.getEObject(uri.fragment()); >- if(rootElement instanceof Diagram) { >- document.setContent((Diagram)rootElement); >- return; >- } >- } else { >- for(Iterator it = resource.getContents().iterator(); it.hasNext();) { >- Object rootElement = it.next(); >- if(rootElement instanceof Diagram) { >- document.setContent((Diagram)rootElement); >- return; >- } >- } >- } >- throw new RuntimeException(Messages.SysmlDocumentProvider_NoDiagramInResourceError); >- } catch (Exception e) { >- CoreException thrownExcp = null; >- if(e instanceof CoreException) { >- thrownExcp = (CoreException)e; >- } else { >- String msg = e.getLocalizedMessage(); >- thrownExcp = new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, 0, msg != null ? msg : Messages.SysmlDocumentProvider_DiagramLoadingError, e)); >- } >- throw thrownExcp; >- } >- } else { >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, 0, NLS.bind(Messages.SysmlDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ >- null)); >- } >- } >- >- /** >- * @generated >- */ >- public long getModificationStamp(Object element) { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- return computeModificationStamp(info); >- } >- return super.getModificationStamp(element); >- } >- >- /** >- * @generated >- */ >- public boolean isDeleted(Object element) { >- IDiagramDocument document = getDiagramDocument(element); >- if(document != null) { >- Resource diagramResource = document.getDiagram().eResource(); >- if(diagramResource != null) { >- IFile file = WorkspaceSynchronizer.getFile(diagramResource); >- return file == null || file.getLocation() == null || !file.getLocation().toFile().exists(); >- } >- } >- return super.isDeleted(element); >- } >- >- /** >- * @generated >- */ >- public ResourceSetInfo getResourceSetInfo(Object editorInput) { >- return (ResourceSetInfo)super.getElementInfo(editorInput); >- } >- >- /** >- * @generated >- */ >- protected void disposeElementInfo(Object element, ElementInfo info) { >- if(info instanceof ResourceSetInfo) { >- ResourceSetInfo resourceSetInfo = (ResourceSetInfo)info; >- resourceSetInfo.dispose(); >- } >- super.disposeElementInfo(element, info); >- } >- >- /** >- * @generated >- */ >- protected void doValidateState(Object element, Object computationContext) throws CoreException { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- LinkedList<IFile> files2Validate = new LinkedList<IFile>(); >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- IFile file = WorkspaceSynchronizer.getFile(nextResource); >- if(file != null && file.isReadOnly()) { >- files2Validate.add(file); >- } >- } >- ResourcesPlugin.getWorkspace().validateEdit((IFile[])files2Validate.toArray(new IFile[files2Validate.size()]), computationContext); >- } >- >- super.doValidateState(element, computationContext); >- } >- >- /** >- * @generated >- */ >- public boolean isReadOnly(Object element) { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- if(info.isUpdateCache()) { >- try { >- updateCache(element); >- } catch (CoreException ex) { >- SysmlDiagramEditorPlugin.getInstance().logError(Messages.SysmlDocumentProvider_isModifiable, ex); >- // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable >- } >- } >- return info.isReadOnly(); >- } >- return super.isReadOnly(element); >- } >- >- /** >- * @generated >- */ >- public boolean isModifiable(Object element) { >- if(!isStateValidated(element)) { >- if(element instanceof FileEditorInput || element instanceof URIEditorInput) { >- return true; >- } >- } >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- if(info.isUpdateCache()) { >- try { >- updateCache(element); >- } catch (CoreException ex) { >- SysmlDiagramEditorPlugin.getInstance().logError(Messages.SysmlDocumentProvider_isModifiable, ex); >- // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable >- } >- } >- return info.isModifiable(); >- } >- return super.isModifiable(element); >- } >- >- /** >- * @generated >- */ >- protected void updateCache(Object element) throws CoreException { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- IFile file = WorkspaceSynchronizer.getFile(nextResource); >- if(file != null && file.isReadOnly()) { >- info.setReadOnly(true); >- info.setModifiable(false); >- return; >- } >- } >- info.setReadOnly(false); >- info.setModifiable(true); >- return; >- } >- } >- >- /** >- * @generated >- */ >- protected void doUpdateStateCache(Object element) throws CoreException { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- info.setUpdateCache(true); >- } >- super.doUpdateStateCache(element); >- } >- >- /** >- * @generated >- */ >- public boolean isSynchronized(Object element) { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- return info.isSynchronized(); >- } >- return super.isSynchronized(element); >- } >- >- /** >- * @generated >- */ >- protected ISchedulingRule getResetRule(Object element) { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>(); >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- IFile file = WorkspaceSynchronizer.getFile(nextResource); >- if(file != null) { >- rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(file)); >- } >- } >- return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected ISchedulingRule getSaveRule(Object element) { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>(); >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- IFile file = WorkspaceSynchronizer.getFile(nextResource); >- if(file != null) { >- rules.add(computeSchedulingRule(file)); >- } >- } >- return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected ISchedulingRule getSynchronizeRule(Object element) { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>(); >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- IFile file = WorkspaceSynchronizer.getFile(nextResource); >- if(file != null) { >- rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(file)); >- } >- } >- return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected ISchedulingRule getValidateStateRule(Object element) { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- LinkedList<ISchedulingRule> files = new LinkedList<ISchedulingRule>(); >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- IFile file = WorkspaceSynchronizer.getFile(nextResource); >- if(file != null) { >- files.add(file); >- } >- } >- return ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule((IFile[])files.toArray(new IFile[files.size()])); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) { >- if(toCreateOrModify.exists()) >- return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify); >- >- IResource parent = toCreateOrModify; >- do { >- /* >- * XXX This is a workaround for >- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601 >- * IResourceRuleFactory.createRule should iterate the hierarchy >- * itself. >- */ >- toCreateOrModify = parent; >- parent = toCreateOrModify.getParent(); >- } while(parent != null && !parent.exists()); >- >- return ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify); >- } >- >- /** >- * @generated >- */ >- protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- handleElementChanged(info, nextResource, monitor); >- } >- return; >- } >- super.doSynchronize(element, monitor); >- } >- >- /** >- * @generated >- */ >- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException { >- ResourceSetInfo info = getResourceSetInfo(element); >- if(info != null) { >- if(!overwrite && !info.isSynchronized()) { >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, IResourceStatus.OUT_OF_SYNC_LOCAL, Messages.SysmlDocumentProvider_UnsynchronizedFileSaveError, null)); >- } >- info.stopResourceListening(); >- fireElementStateChanging(element); >- try { >- monitor.beginTask(Messages.SysmlDocumentProvider_SaveDiagramTask, info.getResourceSet().getResources().size() + 1); //"Saving diagram" >- for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { >- Resource nextResource = it.next(); >- monitor.setTaskName(NLS.bind(Messages.SysmlDocumentProvider_SaveNextResourceTask, nextResource.getURI())); >- if(nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) { >- try { >- nextResource.save(SysmlDiagramEditorUtil.getSaveOptions()); >- } catch (IOException e) { >- fireElementStateChangeFailed(element); >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null)); >- } >- } >- monitor.worked(1); >- } >- monitor.done(); >- info.setModificationStamp(computeModificationStamp(info)); >- } catch (RuntimeException x) { >- fireElementStateChangeFailed(element); >- throw x; >- } finally { >- info.startResourceListening(); >- } >- } else { >- URI newResoruceURI; >- List<IFile> affectedFiles = null; >- if(element instanceof FileEditorInput) { >- IFile newFile = ((FileEditorInput)element).getFile(); >- affectedFiles = Collections.singletonList(newFile); >- newResoruceURI = URI.createPlatformResourceURI(newFile.getFullPath().toString(), true); >- } else if(element instanceof URIEditorInput) { >- newResoruceURI = ((URIEditorInput)element).getURI(); >- } else { >- fireElementStateChangeFailed(element); >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, 0, NLS.bind(Messages.SysmlDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ >- null)); >- } >- if(false == document instanceof IDiagramDocument) { >- fireElementStateChangeFailed(element); >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, 0, "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- IDiagramDocument diagramDocument = (IDiagramDocument)document; >- final Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource(newResoruceURI); >- final Diagram diagramCopy = (Diagram)EcoreUtil.copy(diagramDocument.getDiagram()); >- try { >- new AbstractTransactionalCommand(diagramDocument.getEditingDomain(), NLS.bind(Messages.SysmlDocumentProvider_SaveAsOperation, diagramCopy.getName()), affectedFiles) { >- >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- newResource.getContents().add(diagramCopy); >- return CommandResult.newOKCommandResult(); >- } >- }.execute(monitor, null); >- newResource.save(SysmlDiagramEditorUtil.getSaveOptions()); >- } catch (ExecutionException e) { >- fireElementStateChangeFailed(element); >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null)); >- } catch (IOException e) { >- fireElementStateChangeFailed(element); >- throw new CoreException(new Status(IStatus.ERROR, SysmlDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null)); >- } >- newResource.unload(); >- } >- } >- >- /** >- * @generated >- */ >- protected void handleElementChanged(ResourceSetInfo info, Resource changedResource, IProgressMonitor monitor) { >- IFile file = WorkspaceSynchronizer.getFile(changedResource); >- if(file != null) { >- try { >- file.refreshLocal(IResource.DEPTH_INFINITE, monitor); >- } catch (CoreException ex) { >- SysmlDiagramEditorPlugin.getInstance().logError(Messages.SysmlDocumentProvider_handleElementContentChanged, ex); >- // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged >- } >- } >- changedResource.unload(); >- >- fireElementContentAboutToBeReplaced(info.getEditorInput()); >- removeUnchangedElementListeners(info.getEditorInput(), info); >- info.fStatus = null; >- try { >- setDocumentContent(info.fDocument, info.getEditorInput()); >- } catch (CoreException e) { >- info.fStatus = e.getStatus(); >- } >- if(!info.fCanBeSaved) { >- info.setModificationStamp(computeModificationStamp(info)); >- } >- addUnchangedElementListeners(info.getEditorInput(), info); >- fireElementContentReplaced(info.getEditorInput()); >- } >- >- /** >- * @generated >- */ >- protected void handleElementMoved(IEditorInput input, URI uri) { >- if(input instanceof FileEditorInput) { >- IFile newFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(URI.decode(uri.path())).removeFirstSegments(1)); >- fireElementMoved(input, newFile == null ? null : new FileEditorInput(newFile)); >- return; >- } >- // TODO: append suffix to the URI! (use diagram as a parameter) >- fireElementMoved(input, new URIEditorInput(uri)); >- } >- >- /** >- * @generated >- */ >- public IEditorInput createInputWithEditingDomain(IEditorInput editorInput, TransactionalEditingDomain domain) { >- return editorInput; >- } >- >- /** >- * @generated >- */ >- public IDiagramDocument getDiagramDocument(Object element) { >- IDocument doc = getDocument(element); >- if(doc instanceof IDiagramDocument) { >- return (IDiagramDocument)doc; >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected IRunnableContext getOperationRunner(IProgressMonitor monitor) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected class ResourceSetInfo extends ElementInfo { >- >- /** >- * @generated >- */ >- private long myModificationStamp = IResource.NULL_STAMP; >- >- /** >- * @generated >- */ >- private WorkspaceSynchronizer mySynchronizer; >- >- /** >- * @generated >- */ >- private LinkedList<Resource> myUnSynchronizedResources = new LinkedList<Resource>(); >- >- /** >- * @generated >- */ >- private IDiagramDocument myDocument; >- >- /** >- * @generated >- */ >- private IEditorInput myEditorInput; >- >- /** >- * @generated >- */ >- private boolean myUpdateCache = true; >- >- /** >- * @generated >- */ >- private boolean myModifiable = false; >- >- /** >- * @generated >- */ >- private boolean myReadOnly = true; >- >- /** >- * @generated >- */ >- private ResourceSetModificationListener myResourceSetListener; >- >- /** >- * @generated >- */ >- public ResourceSetInfo(IDiagramDocument document, IEditorInput editorInput) { >- super(document); >- myDocument = document; >- myEditorInput = editorInput; >- startResourceListening(); >- myResourceSetListener = new ResourceSetModificationListener(this); >- getResourceSet().eAdapters().add(myResourceSetListener); >- } >- >- /** >- * @generated >- */ >- public long getModificationStamp() { >- return myModificationStamp; >- } >- >- /** >- * @generated >- */ >- public void setModificationStamp(long modificationStamp) { >- myModificationStamp = modificationStamp; >- } >- >- /** >- * @generated >- */ >- public TransactionalEditingDomain getEditingDomain() { >- return myDocument.getEditingDomain(); >- } >- >- /** >- * @generated >- */ >- public ResourceSet getResourceSet() { >- return getEditingDomain().getResourceSet(); >- } >- >- /** >- * @generated >- */ >- public Iterator<Resource> getLoadedResourcesIterator() { >- return new ArrayList<Resource>(getResourceSet().getResources()).iterator(); >- } >- >- /** >- * @generated >- */ >- public IEditorInput getEditorInput() { >- return myEditorInput; >- } >- >- /** >- * @generated >- */ >- public void dispose() { >- stopResourceListening(); >- getResourceSet().eAdapters().remove(myResourceSetListener); >- for(Iterator<Resource> it = getLoadedResourcesIterator(); it.hasNext();) { >- Resource resource = it.next(); >- resource.unload(); >- } >- getEditingDomain().dispose(); >- } >- >- /** >- * @generated >- */ >- public boolean isSynchronized() { >- return myUnSynchronizedResources.size() == 0; >- } >- >- /** >- * @generated >- */ >- public void setUnSynchronized(Resource resource) { >- myUnSynchronizedResources.add(resource); >- } >- >- /** >- * @generated >- */ >- public void setSynchronized(Resource resource) { >- myUnSynchronizedResources.remove(resource); >- } >- >- /** >- * @generated >- */ >- public final void stopResourceListening() { >- mySynchronizer.dispose(); >- mySynchronizer = null; >- } >- >- /** >- * @generated >- */ >- public final void startResourceListening() { >- mySynchronizer = new WorkspaceSynchronizer(getEditingDomain(), new SynchronizerDelegate()); >- } >- >- /** >- * @generated >- */ >- public boolean isUpdateCache() { >- return myUpdateCache; >- } >- >- /** >- * @generated >- */ >- public void setUpdateCache(boolean update) { >- myUpdateCache = update; >- } >- >- /** >- * @generated >- */ >- public boolean isModifiable() { >- return myModifiable; >- } >- >- /** >- * @generated >- */ >- public void setModifiable(boolean modifiable) { >- myModifiable = modifiable; >- } >- >- /** >- * @generated >- */ >- public boolean isReadOnly() { >- return myReadOnly; >- } >- >- /** >- * @generated >- */ >- public void setReadOnly(boolean readOnly) { >- myReadOnly = readOnly; >- } >- >- /** >- * @generated >- */ >- private class SynchronizerDelegate implements WorkspaceSynchronizer.Delegate { >- >- /** >- * @generated >- */ >- public void dispose() { >- } >- >- /** >- * @generated >- */ >- public boolean handleResourceChanged(final Resource resource) { >- synchronized(ResourceSetInfo.this) { >- if(ResourceSetInfo.this.fCanBeSaved) { >- ResourceSetInfo.this.setUnSynchronized(resource); >- return true; >- } >- } >- Display.getDefault().asyncExec(new Runnable() { >- >- public void run() { >- handleElementChanged(ResourceSetInfo.this, resource, null); >- } >- }); >- return true; >- } >- >- /** >- * @generated >- */ >- public boolean handleResourceDeleted(Resource resource) { >- synchronized(ResourceSetInfo.this) { >- if(ResourceSetInfo.this.fCanBeSaved) { >- ResourceSetInfo.this.setUnSynchronized(resource); >- return true; >- } >- } >- Display.getDefault().asyncExec(new Runnable() { >- >- public void run() { >- fireElementDeleted(ResourceSetInfo.this.getEditorInput()); >- } >- }); >- return true; >- } >- >- /** >- * @generated >- */ >- public boolean handleResourceMoved(Resource resource, final URI newURI) { >- synchronized(ResourceSetInfo.this) { >- if(ResourceSetInfo.this.fCanBeSaved) { >- ResourceSetInfo.this.setUnSynchronized(resource); >- return true; >- } >- } >- if(myDocument.getDiagram().eResource() == resource) { >- Display.getDefault().asyncExec(new Runnable() { >- >- public void run() { >- handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI); >- } >- }); >- } else { >- handleResourceDeleted(resource); >- } >- return true; >- } >- >- } >- >- } >- >- /** >- * @generated >- */ >- private class ResourceSetModificationListener extends EContentAdapter { >- >- /** >- * @generated >- */ >- private NotificationFilter myModifiedFilter; >- >- /** >- * @generated >- */ >- private ResourceSetInfo myInfo; >- >- /** >- * @generated >- */ >- public ResourceSetModificationListener(ResourceSetInfo info) { >- myInfo = info; >- myModifiedFilter = NotificationFilter.createEventTypeFilter(Notification.SET).or(NotificationFilter.createEventTypeFilter(Notification.UNSET)).and(NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__IS_MODIFIED)); >- } >- >- /** >- * @generated >- */ >- public void notifyChanged(Notification notification) { >- if(notification.getNotifier() instanceof ResourceSet) { >- super.notifyChanged(notification); >- } >- if(!notification.isTouch() && myModifiedFilter.matches(notification)) { >- if(notification.getNotifier() instanceof Resource) { >- Resource resource = (Resource)notification.getNotifier(); >- if(resource.isLoaded()) { >- boolean modified = false; >- for(Iterator/* <org.eclipse.emf.ecore.resource.Resource> */it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) { >- Resource nextResource = (Resource)it.next(); >- if(nextResource.isLoaded()) { >- modified = nextResource.isModified(); >- } >- } >- boolean dirtyStateChanged = false; >- synchronized(myInfo) { >- if(modified != myInfo.fCanBeSaved) { >- myInfo.fCanBeSaved = modified; >- dirtyStateChanged = true; >- } >- if(!resource.isModified()) { >- myInfo.setSynchronized(resource); >- } >- } >- if(dirtyStateChanged) { >- fireElementDirtyStateChanged(myInfo.getEditorInput(), modified); >- >- if(!modified) { >- myInfo.setModificationStamp(computeModificationStamp(myInfo)); >- } >- } >- } >- } >- } >- } >- >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlInitDiagramFileAction.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlInitDiagramFileAction.java >deleted file mode 100644 >index d24c925..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlInitDiagramFileAction.java >+++ /dev/null >@@ -1,99 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.common.util.WrappedException; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory; >-import org.eclipse.jface.action.IAction; >-import org.eclipse.jface.dialogs.MessageDialog; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.wizard.Wizard; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.IObjectActionDelegate; >-import org.eclipse.ui.IWorkbenchPart; >- >-/** >- * @generated >- */ >-public class SysmlInitDiagramFileAction implements IObjectActionDelegate { >- >- /** >- * @generated >- */ >- private IWorkbenchPart targetPart; >- >- /** >- * @generated >- */ >- private URI domainModelURI; >- >- /** >- * @generated >- */ >- public void setActivePart(IAction action, IWorkbenchPart targetPart) { >- this.targetPart = targetPart; >- } >- >- /** >- * @generated >- */ >- public void selectionChanged(IAction action, ISelection selection) { >- domainModelURI = null; >- action.setEnabled(false); >- if(selection instanceof IStructuredSelection == false || selection.isEmpty()) { >- return; >- } >- IFile file = (IFile)((IStructuredSelection)selection).getFirstElement(); >- domainModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); >- action.setEnabled(true); >- } >- >- /** >- * @generated >- */ >- private Shell getShell() { >- return targetPart.getSite().getShell(); >- } >- >- /** >- * @generated >- */ >- public void run(IAction action) { >- TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain(); >- ResourceSet resourceSet = editingDomain.getResourceSet(); >- EObject diagramRoot = null; >- try { >- Resource resource = resourceSet.getResource(domainModelURI, true); >- diagramRoot = (EObject)resource.getContents().get(0); >- } catch (WrappedException ex) { >- SysmlDiagramEditorPlugin.getInstance().logError("Unable to load resource: " + domainModelURI, ex); //$NON-NLS-1$ >- } >- if(diagramRoot == null) { >- MessageDialog.openError(getShell(), Messages.InitDiagramFile_ResourceErrorDialogTitle, Messages.InitDiagramFile_ResourceErrorDialogMessage); >- return; >- } >- Wizard wizard = new SysmlNewDiagramFileWizard(domainModelURI, diagramRoot, editingDomain); >- wizard.setWindowTitle(NLS.bind(Messages.InitDiagramFile_WizardTitle, ParametricEditPart.MODEL_ID)); >- SysmlDiagramEditorUtil.runWizard(getShell(), wizard, "InitDiagramFile"); //$NON-NLS-1$ >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlLinkDescriptor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlLinkDescriptor.java >deleted file mode 100644 >index 099c42c..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlLinkDescriptor.java >+++ /dev/null >@@ -1,105 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >- >-/** >- * @generated >- */ >-public class SysmlLinkDescriptor extends SysmlNodeDescriptor { >- >- /** >- * @generated >- */ >- private EObject mySource; >- >- /** >- * @generated >- */ >- private EObject myDestination; >- >- /** >- * @generated >- */ >- private IAdaptable mySemanticAdapter; >- >- /** >- * @generated >- */ >- private SysmlLinkDescriptor(EObject source, EObject destination, EObject linkElement, int linkVID) { >- super(linkElement, linkVID); >- mySource = source; >- myDestination = destination; >- } >- >- /** >- * @generated >- */ >- public SysmlLinkDescriptor(EObject source, EObject destination, IElementType elementType, int linkVID) { >- this(source, destination, (EObject)null, linkVID); >- final IElementType elementTypeCopy = elementType; >- mySemanticAdapter = new IAdaptable() { >- >- public Object getAdapter(Class adapter) { >- if(IElementType.class.equals(adapter)) { >- return elementTypeCopy; >- } >- return null; >- } >- }; >- } >- >- /** >- * @generated >- */ >- public SysmlLinkDescriptor(EObject source, EObject destination, EObject linkElement, IElementType elementType, int linkVID) { >- this(source, destination, linkElement, linkVID); >- final IElementType elementTypeCopy = elementType; >- mySemanticAdapter = new EObjectAdapter(linkElement) { >- >- public Object getAdapter(Class adapter) { >- if(IElementType.class.equals(adapter)) { >- return elementTypeCopy; >- } >- return super.getAdapter(adapter); >- } >- }; >- } >- >- /** >- * @generated >- */ >- public EObject getSource() { >- return mySource; >- } >- >- /** >- * @generated >- */ >- public EObject getDestination() { >- return myDestination; >- } >- >- /** >- * @generated >- */ >- public IAdaptable getSemanticAdapter() { >- return mySemanticAdapter; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlMatchingStrategy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlMatchingStrategy.java >deleted file mode 100644 >index 67bdb8b..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlMatchingStrategy.java >+++ /dev/null >@@ -1,47 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.emf.common.ui.URIEditorInput; >-import org.eclipse.ui.IEditorInput; >-import org.eclipse.ui.IEditorMatchingStrategy; >-import org.eclipse.ui.IEditorReference; >-import org.eclipse.ui.PartInitException; >- >-/** >- * @generated >- */ >-public class SysmlMatchingStrategy implements IEditorMatchingStrategy { >- >- /** >- * @generated >- */ >- public boolean matches(IEditorReference editorRef, IEditorInput input) { >- IEditorInput editorInput; >- try { >- editorInput = editorRef.getEditorInput(); >- } catch (PartInitException e) { >- return false; >- } >- >- if(editorInput.equals(input)) { >- return true; >- } >- if(editorInput instanceof URIEditorInput && input instanceof URIEditorInput) { >- return ((URIEditorInput)editorInput).getURI().equals(((URIEditorInput)input).getURI()); >- } >- return false; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlNewDiagramFileWizard.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlNewDiagramFileWizard.java >deleted file mode 100644 >index 665d8cb..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlNewDiagramFileWizard.java >+++ /dev/null >@@ -1,174 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.io.IOException; >-import java.util.LinkedList; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.commands.operations.OperationHistoryFactory; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gmf.runtime.common.core.command.CommandResult; >-import org.eclipse.gmf.runtime.diagram.core.services.ViewService; >-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation; >-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.jface.wizard.Wizard; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.ui.PartInitException; >-import org.eclipse.ui.dialogs.WizardNewFileCreationPage; >- >-/** >- * @generated >- */ >-public class SysmlNewDiagramFileWizard extends Wizard { >- >- /** >- * @generated >- */ >- private WizardNewFileCreationPage myFileCreationPage; >- >- /** >- * @generated >- */ >- private ModelElementSelectionPage diagramRootElementSelectionPage; >- >- /** >- * @generated >- */ >- private TransactionalEditingDomain myEditingDomain; >- >- /** >- * @generated >- */ >- public SysmlNewDiagramFileWizard(URI domainModelURI, EObject diagramRoot, TransactionalEditingDomain editingDomain) { >- assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$ >- assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$ >- assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$ >- >- myFileCreationPage = new WizardNewFileCreationPage(Messages.SysmlNewDiagramFileWizard_CreationPageName, StructuredSelection.EMPTY); >- myFileCreationPage.setTitle(Messages.SysmlNewDiagramFileWizard_CreationPageTitle); >- myFileCreationPage.setDescription(NLS.bind(Messages.SysmlNewDiagramFileWizard_CreationPageDescription, ParametricEditPart.MODEL_ID)); >- IPath filePath; >- String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment()); >- if(domainModelURI.isPlatformResource()) { >- filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true)); >- } else if(domainModelURI.isFile()) { >- filePath = new Path(domainModelURI.trimSegments(1).toFileString()); >- } else { >- // TODO : use some default path >- throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$ >- } >- myFileCreationPage.setContainerFullPath(filePath); >- myFileCreationPage.setFileName(SysmlDiagramEditorUtil.getUniqueFileName(filePath, fileName, "sysml_diagram")); //$NON-NLS-1$ >- >- diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(Messages.SysmlNewDiagramFileWizard_RootSelectionPageName); >- diagramRootElementSelectionPage.setTitle(Messages.SysmlNewDiagramFileWizard_RootSelectionPageTitle); >- diagramRootElementSelectionPage.setDescription(Messages.SysmlNewDiagramFileWizard_RootSelectionPageDescription); >- diagramRootElementSelectionPage.setModelElement(diagramRoot); >- >- myEditingDomain = editingDomain; >- } >- >- /** >- * @generated >- */ >- public void addPages() { >- addPage(myFileCreationPage); >- addPage(diagramRootElementSelectionPage); >- } >- >- /** >- * @generated >- */ >- public boolean performFinish() { >- LinkedList<IFile> affectedFiles = new LinkedList<IFile>(); >- IFile diagramFile = myFileCreationPage.createNewFile(); >- SysmlDiagramEditorUtil.setCharset(diagramFile); >- affectedFiles.add(diagramFile); >- URI diagramModelURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true); >- ResourceSet resourceSet = myEditingDomain.getResourceSet(); >- final Resource diagramResource = resourceSet.createResource(diagramModelURI); >- AbstractTransactionalCommand command = new AbstractTransactionalCommand(myEditingDomain, Messages.SysmlNewDiagramFileWizard_InitDiagramCommand, affectedFiles) { >- >- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >- int diagramVID = SysmlVisualIDRegistry.getDiagramVisualID(diagramRootElementSelectionPage.getModelElement()); >- if(diagramVID != ParametricEditPart.VISUAL_ID) { >- return CommandResult.newErrorCommandResult(Messages.SysmlNewDiagramFileWizard_IncorrectRootError); >- } >- Diagram diagram = ViewService.createDiagram(diagramRootElementSelectionPage.getModelElement(), ParametricEditPart.MODEL_ID, SysmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); >- diagramResource.getContents().add(diagram); >- return CommandResult.newOKCommandResult(); >- } >- }; >- try { >- OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null); >- diagramResource.save(SysmlDiagramEditorUtil.getSaveOptions()); >- SysmlDiagramEditorUtil.openDiagram(diagramResource); >- } catch (ExecutionException e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e); //$NON-NLS-1$ >- } catch (IOException ex) { >- SysmlDiagramEditorPlugin.getInstance().logError("Save operation failed for: " + diagramModelURI, ex); //$NON-NLS-1$ >- } catch (PartInitException ex) { >- SysmlDiagramEditorPlugin.getInstance().logError("Unable to open editor", ex); //$NON-NLS-1$ >- } >- return true; >- } >- >- /** >- * @generated >- */ >- private static class DiagramRootElementSelectionPage extends ModelElementSelectionPage { >- >- /** >- * @generated >- */ >- protected DiagramRootElementSelectionPage(String pageName) { >- super(pageName); >- } >- >- /** >- * @generated >- */ >- protected String getSelectionTitle() { >- return Messages.SysmlNewDiagramFileWizard_RootSelectionPageSelectionTitle; >- } >- >- /** >- * @generated >- */ >- protected boolean validatePage() { >- if(selectedModelElement == null) { >- setErrorMessage(Messages.SysmlNewDiagramFileWizard_RootSelectionPageNoSelectionMessage); >- return false; >- } >- boolean result = ViewService.getInstance().provides(new CreateDiagramViewOperation(new EObjectAdapter(selectedModelElement), ParametricEditPart.MODEL_ID, SysmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); >- setErrorMessage(result ? null : Messages.SysmlNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage); >- return result; >- } >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlNodeDescriptor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlNodeDescriptor.java >deleted file mode 100644 >index cd2274b..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlNodeDescriptor.java >+++ /dev/null >@@ -1,55 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.emf.ecore.EObject; >- >-/** >- * @generated >- */ >-public class SysmlNodeDescriptor { >- >- /** >- * @generated >- */ >- private final EObject myModelElement; >- >- /** >- * @generated >- */ >- private final int myVisualID; >- >- /** >- * @generated >- */ >- public SysmlNodeDescriptor(EObject modelElement, int visualID) { >- myModelElement = modelElement; >- myVisualID = visualID; >- } >- >- /** >- * @generated >- */ >- public EObject getModelElement() { >- return myModelElement; >- } >- >- /** >- * @generated >- */ >- public int getVisualID() { >- return myVisualID; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlPaletteFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlPaletteFactory.java >deleted file mode 100644 >index aa83177..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlPaletteFactory.java >+++ /dev/null >@@ -1,111 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.eclipse.gef.Tool; >-import org.eclipse.gmf.runtime.diagram.ui.services.palette.PaletteFactory; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeConnectionTool; >-import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool; >- >-/** >- * @generated >- */ >-public class SysmlPaletteFactory extends PaletteFactory.Adapter { >- >- /** >- * @generated >- */ >- private final static String CREATECONSTRAINTPROPERTY1CREATIONTOOL = "createConstraintProperty1CreationTool"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- private final static String CREATEPROPERTY2CREATIONTOOL = "createProperty2CreationTool"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- private final static String CREATECONNECTOR3CREATIONTOOL = "createConnector3CreationTool"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public SysmlPaletteFactory() { >- >- } >- >- /** >- * @generated >- */ >- public Tool createTool(String toolId) { >- if(toolId.equals(CREATECONSTRAINTPROPERTY1CREATIONTOOL)) { >- return createConstraintProperty1CreationTool(); >- } >- if(toolId.equals(CREATEPROPERTY2CREATIONTOOL)) { >- return createProperty2CreationTool(); >- } >- if(toolId.equals(CREATECONNECTOR3CREATIONTOOL)) { >- return createConnector3CreationTool(); >- } >- >- // default return: null >- return null; >- } >- >- public Object getTemplate(String templateId) { >- >- // default return: null >- return null; >- } >- >- /** >- * @generated >- */ >- private Tool createConstraintProperty1CreationTool() { >- List<IElementType> types = new ArrayList<IElementType>(1); >- types.add(SysmlElementTypes.ConstraintProperty_2003); >- >- Tool tool = new AspectUnspecifiedTypeCreationTool(types); >- return tool; >- } >- >- /** >- * @generated >- */ >- private Tool createProperty2CreationTool() { >- List<IElementType> types = new ArrayList<IElementType>(2); >- types.add(SysmlElementTypes.Property_3002); >- types.add(SysmlElementTypes.Property_2005); >- >- Tool tool = new AspectUnspecifiedTypeCreationTool(types); >- return tool; >- } >- >- /** >- * @generated >- */ >- private Tool createConnector3CreationTool() { >- List<IElementType> types = new ArrayList<IElementType>(1); >- types.add(SysmlElementTypes.Connector_4001); >- >- Tool tool = new AspectUnspecifiedTypeConnectionTool(types); >- return tool; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlUriEditorInputTester.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlUriEditorInputTester.java >deleted file mode 100644 >index f2a612d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlUriEditorInputTester.java >+++ /dev/null >@@ -1,35 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.core.expressions.PropertyTester; >-import org.eclipse.emf.common.ui.URIEditorInput; >- >-/** >- * @generated >- */ >-public class SysmlUriEditorInputTester extends PropertyTester { >- >- /** >- * @generated >- */ >- public boolean test(Object receiver, String method, Object[] args, Object expectedValue) { >- if(false == receiver instanceof URIEditorInput) { >- return false; >- } >- URIEditorInput editorInput = (URIEditorInput)receiver; >- return "sysml_diagram".equals(editorInput.getURI().fileExtension()); //$NON-NLS-1$ >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlVisualIDRegistry.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlVisualIDRegistry.java >deleted file mode 100644 >index 26e18ff..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/SysmlVisualIDRegistry.java >+++ /dev/null >@@ -1,283 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.resource.Resource; >-import org.eclipse.papyrus.sysml.constraints.ConstraintsPackage; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintLabelEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyName2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyNameEditPart; >-import org.eclipse.papyrus.uml.diagram.common.providers.BaseViewInfo; >-import org.eclipse.papyrus.uml.diagram.common.providers.ViewInfo; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * This registry is used to determine which type of visual object should be created for the >- * corresponding Diagram, Node, ChildNode or Link represented by a domain model object. >- * >- * @generated >- */ >-public class SysmlVisualIDRegistry { >- >- /** >- * @generated >- */ >- private static final String DEBUG_KEY = "org.eclipse.papyrus.sysml.diagram.parametric/debug/visualID"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static int getVisualID(View view) { >- if(view instanceof Diagram) { >- if(ParametricEditPart.MODEL_ID.equals(view.getType())) { >- return ParametricEditPart.VISUAL_ID; >- } else { >- return -1; >- } >- } >- return org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry.getVisualID(view.getType()); >- } >- >- /** >- * @generated >- */ >- public static String getModelID(View view) { >- View diagram = view.getDiagram(); >- while(view != diagram) { >- EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ >- if(annotation != null) { >- return (String)annotation.getDetails().get("modelID"); //$NON-NLS-1$ >- } >- view = (View)view.eContainer(); >- } >- return diagram != null ? diagram.getType() : null; >- } >- >- /** >- * @generated >- */ >- public static int getVisualID(String type) { >- try { >- return Integer.parseInt(type); >- } catch (NumberFormatException e) { >- if(Boolean.TRUE.toString().equalsIgnoreCase(Platform.getDebugOption(DEBUG_KEY))) { >- SysmlDiagramEditorPlugin.getInstance().logError("Unable to parse view type as a visualID number: " + type); >- } >- } >- return -1; >- } >- >- /** >- * @generated >- */ >- public static String getType(int visualID) { >- return Integer.toString(visualID); >- } >- >- /** >- * @generated NOT >- */ >- public static int getDiagramVisualID(EObject domainElement) { >- if(domainElement == null) { >- return -1; >- } >- // test if it is a class for the parametric diagram >- if(UMLPackage.eINSTANCE.getClass_().equals(domainElement.eClass())) { >- return ParametricEditPart.VISUAL_ID; >- } >- return -1; >- } >- >- /** >- * @generated >- */ >- public static int getNodeVisualID(View containerView, EObject domainElement) { >- if(domainElement == null) { >- return -1; >- } >- String containerModelID = org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry.getModelID(containerView); >- if(!ParametricEditPart.MODEL_ID.equals(containerModelID)) { >- return -1; >- } >- int containerVisualID; >- if(ParametricEditPart.MODEL_ID.equals(containerModelID)) { >- containerVisualID = org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry.getVisualID(containerView); >- } else { >- if(containerView instanceof Diagram) { >- containerVisualID = ParametricEditPart.VISUAL_ID; >- } else { >- return -1; >- } >- } >- switch(containerVisualID) { >- case ParametricEditPart.VISUAL_ID: >- if(ConstraintsPackage.eINSTANCE.getConstraintProperty().isSuperTypeOf(domainElement.eClass()) >- >- ) { >- return ConstraintPropertyEditPart.VISUAL_ID; >- } >- if(UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass()) >- >- ) { >- return PropertyEditPart.VISUAL_ID; >- } >- break; >- case ConstraintPropertyEditPart.VISUAL_ID: >- if(UMLPackage.eINSTANCE.getProperty().isSuperTypeOf(domainElement.eClass()) >- >- ) { >- return Property2EditPart.VISUAL_ID; >- } >- break; >- } >- return -1; >- } >- >- /** >- * @generated >- */ >- public static boolean canCreateNode(View containerView, int nodeVisualID) { >- String containerModelID = org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry.getModelID(containerView); >- if(!ParametricEditPart.MODEL_ID.equals(containerModelID)) { >- return false; >- } >- int containerVisualID; >- if(ParametricEditPart.MODEL_ID.equals(containerModelID)) { >- containerVisualID = org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry.getVisualID(containerView); >- } else { >- if(containerView instanceof Diagram) { >- containerVisualID = ParametricEditPart.VISUAL_ID; >- } else { >- return false; >- } >- } >- switch(containerVisualID) { >- case ParametricEditPart.VISUAL_ID: >- if(ConstraintPropertyEditPart.VISUAL_ID == nodeVisualID) { >- return true; >- } >- if(PropertyEditPart.VISUAL_ID == nodeVisualID) { >- return true; >- } >- break; >- case ConstraintPropertyEditPart.VISUAL_ID: >- if(ConstraintPropertyNameEditPart.VISUAL_ID == nodeVisualID) { >- return true; >- } >- if(ConstraintLabelEditPart.VISUAL_ID == nodeVisualID) { >- return true; >- } >- if(Property2EditPart.VISUAL_ID == nodeVisualID) { >- return true; >- } >- break; >- case PropertyEditPart.VISUAL_ID: >- if(PropertyNameEditPart.VISUAL_ID == nodeVisualID) { >- return true; >- } >- break; >- case Property2EditPart.VISUAL_ID: >- if(PropertyName2EditPart.VISUAL_ID == nodeVisualID) { >- return true; >- } >- break; >- case ConnectorEditPart.VISUAL_ID: >- if(ConnectorNameEditPart.VISUAL_ID == nodeVisualID) { >- return true; >- } >- break; >- } >- return false; >- } >- >- /** >- * @generated >- */ >- public static int getLinkWithClassVisualID(EObject domainElement) { >- if(domainElement == null) { >- return -1; >- } >- if(UMLPackage.eINSTANCE.getConnector().isSuperTypeOf(domainElement.eClass()) >- >- ) { >- return ConnectorEditPart.VISUAL_ID; >- } >- return -1; >- } >- >- /** >- * User can change implementation of this method to handle some specific situations not covered >- * by default logic. >- * >- * @generated >- */ >- private static boolean isDiagram(Resource element) { >- return true; >- } >- >- /** >- * @generated >- */ >- private static ViewInfo diagramViewInfo = null; >- >- /** >- * @generated >- */ >- public static ViewInfo getDiagramViewInfo() { >- if(diagramViewInfo == null) { >- diagramViewInfo = getResource_1000ViewInfo(); >- } >- return diagramViewInfo; >- } >- >- /** >- * @generated >- */ >- protected static ViewInfo getResource_1000ViewInfo() { >- ViewInfo root = new BaseViewInfo(1000, ViewInfo.Head, "", null, null); >- ViewInfo viewInfo = null; >- ViewInfo labelInfo = null; >- >- viewInfo = new BaseViewInfo(2003, ViewInfo.Node, "ConstraintProperty"); >- root.addNode(1000, viewInfo); >- >- viewInfo = new BaseViewInfo(2005, ViewInfo.Node, "Property"); >- root.addNode(1000, viewInfo); >- >- viewInfo = new BaseViewInfo(4001, ViewInfo.Edge, ""); >- root.addNode(1000, viewInfo); >- >- labelInfo = new BaseViewInfo(6001, ViewInfo.Label, "", null, viewInfo); >- viewInfo.getChildren().add(labelInfo); >- >- viewInfo = new BaseViewInfo(3002, ViewInfo.Node, "Property"); >- >- root.addNode(2003, viewInfo); >- >- return root; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/ValidateAction.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/ValidateAction.java >deleted file mode 100644 >index eeb491b..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/part/ValidateAction.java >+++ /dev/null >@@ -1,264 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.part; >- >-import java.lang.reflect.InvocationTargetException; >-import java.util.ArrayList; >-import java.util.HashSet; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Set; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.emf.common.util.Diagnostic; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.util.Diagnostician; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.transaction.util.TransactionUtil; >-import org.eclipse.emf.validation.model.EvaluationMode; >-import org.eclipse.emf.validation.model.IConstraintStatus; >-import org.eclipse.emf.validation.service.IBatchValidator; >-import org.eclipse.emf.validation.service.ModelValidationService; >-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; >-import org.eclipse.gef.EditPartViewer; >-import org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart; >-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.action.Action; >-import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlMarkerNavigationProvider; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlValidationProvider; >-import org.eclipse.ui.IEditorPart; >-import org.eclipse.ui.IWorkbenchPage; >-import org.eclipse.ui.IWorkbenchPart; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; >- >-/** >- * @generated >- */ >-public class ValidateAction extends Action { >- >- /** >- * @generated >- */ >- private IWorkbenchPage page; >- >- /** >- * @generated >- */ >- public ValidateAction(IWorkbenchPage page) { >- setText(Messages.ValidateActionMessage); >- this.page = page; >- } >- >- /** >- * @generated >- */ >- public void run() { >- IWorkbenchPart workbenchPart = page.getActivePart(); >- if(workbenchPart instanceof IDiagramWorkbenchPart) { >- final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart)workbenchPart; >- try { >- new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { >- >- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { >- runValidation(part.getDiagramEditPart(), part.getDiagram()); >- } >- }).run(new NullProgressMonitor()); >- } catch (Exception e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$ >- } >- } >- } >- >- /** >- * @generated >- */ >- public static void runValidation(View view) { >- try { >- if(SysmlDiagramEditorUtil.openDiagram(view.eResource())) { >- IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); >- if(editorPart instanceof IDiagramWorkbenchPart) { >- runValidation(((IDiagramWorkbenchPart)editorPart).getDiagramEditPart(), view); >- } else { >- runNonUIValidation(view); >- } >- } >- } catch (Exception e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$ >- } >- } >- >- /** >- * @generated >- */ >- public static void runNonUIValidation(View view) { >- DiagramEditPart diagramEditPart = OffscreenEditPartFactory.getInstance().createDiagramEditPart(view.getDiagram()); >- runValidation(diagramEditPart, view); >- } >- >- /** >- * @generated >- */ >- public static void runValidation(DiagramEditPart diagramEditPart, View view) { >- final DiagramEditPart fpart = diagramEditPart; >- final View fview = view; >- TransactionalEditingDomain txDomain = TransactionUtil.getEditingDomain(view); >- SysmlValidationProvider.runWithConstraints(txDomain, new Runnable() { >- >- public void run() { >- validate(fpart, fview); >- } >- }); >- } >- >- /** >- * @generated >- */ >- private static Diagnostic runEMFValidator(View target) { >- if(target.isSetElement() && target.getElement() != null) { >- return new Diagnostician() { >- >- public String getObjectLabel(EObject eObject) { >- return EMFCoreUtil.getQualifiedName(eObject, true); >- } >- }.validate(target.getElement()); >- } >- return Diagnostic.OK_INSTANCE; >- } >- >- /** >- * @generated >- */ >- private static void validate(DiagramEditPart diagramEditPart, View view) { >- IFile target = view.eResource() != null ? WorkspaceSynchronizer.getFile(view.eResource()) : null; >- if(target != null) { >- SysmlMarkerNavigationProvider.deleteMarkers(target); >- } >- Diagnostic diagnostic = runEMFValidator(view); >- createMarkers(target, diagnostic, diagramEditPart); >- IBatchValidator validator = (IBatchValidator)ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH); >- validator.setIncludeLiveConstraints(true); >- if(view.isSetElement() && view.getElement() != null) { >- IStatus status = validator.validate(view.getElement()); >- createMarkers(target, status, diagramEditPart); >- } >- } >- >- /** >- * @generated >- */ >- private static void createMarkers(IFile target, IStatus validationStatus, DiagramEditPart diagramEditPart) { >- if(validationStatus.isOK()) { >- return; >- } >- final IStatus rootStatus = validationStatus; >- List allStatuses = new ArrayList(); >- SysmlDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new SysmlDiagramEditorUtil.LazyElement2ViewMap(diagramEditPart.getDiagramView(), collectTargetElements(rootStatus, new HashSet<EObject>(), allStatuses)); >- for(Iterator it = allStatuses.iterator(); it.hasNext();) { >- IConstraintStatus nextStatus = (IConstraintStatus)it.next(); >- View view = SysmlDiagramEditorUtil.findView(diagramEditPart, nextStatus.getTarget(), element2ViewMap); >- addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), EMFCoreUtil.getQualifiedName(nextStatus.getTarget(), true), nextStatus.getMessage(), nextStatus.getSeverity()); >- } >- } >- >- /** >- * @generated >- */ >- private static void createMarkers(IFile target, Diagnostic emfValidationStatus, DiagramEditPart diagramEditPart) { >- if(emfValidationStatus.getSeverity() == Diagnostic.OK) { >- return; >- } >- final Diagnostic rootStatus = emfValidationStatus; >- List allDiagnostics = new ArrayList(); >- SysmlDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new SysmlDiagramEditorUtil.LazyElement2ViewMap(diagramEditPart.getDiagramView(), collectTargetElements(rootStatus, new HashSet<EObject>(), allDiagnostics)); >- for(Iterator it = emfValidationStatus.getChildren().iterator(); it.hasNext();) { >- Diagnostic nextDiagnostic = (Diagnostic)it.next(); >- List data = nextDiagnostic.getData(); >- if(data != null && !data.isEmpty() && data.get(0) instanceof EObject) { >- EObject element = (EObject)data.get(0); >- View view = SysmlDiagramEditorUtil.findView(diagramEditPart, element, element2ViewMap); >- addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), EMFCoreUtil.getQualifiedName(element, true), nextDiagnostic.getMessage(), diagnosticToStatusSeverity(nextDiagnostic.getSeverity())); >- } >- } >- } >- >- /** >- * @generated >- */ >- private static void addMarker(EditPartViewer viewer, IFile target, String elementId, String location, String message, int statusSeverity) { >- if(target == null) { >- return; >- } >- SysmlMarkerNavigationProvider.addMarker(target, elementId, location, message, statusSeverity); >- } >- >- /** >- * @generated >- */ >- private static int diagnosticToStatusSeverity(int diagnosticSeverity) { >- if(diagnosticSeverity == Diagnostic.OK) { >- return IStatus.OK; >- } else if(diagnosticSeverity == Diagnostic.INFO) { >- return IStatus.INFO; >- } else if(diagnosticSeverity == Diagnostic.WARNING) { >- return IStatus.WARNING; >- } else if(diagnosticSeverity == Diagnostic.ERROR || diagnosticSeverity == Diagnostic.CANCEL) { >- return IStatus.ERROR; >- } >- return IStatus.INFO; >- } >- >- /** >- * @generated >- */ >- private static Set<EObject> collectTargetElements(IStatus status, Set<EObject> targetElementCollector, List allConstraintStatuses) { >- if(status instanceof IConstraintStatus) { >- targetElementCollector.add(((IConstraintStatus)status).getTarget()); >- allConstraintStatuses.add(status); >- } >- if(status.isMultiStatus()) { >- IStatus[] children = status.getChildren(); >- for(int i = 0; i < children.length; i++) { >- collectTargetElements(children[i], targetElementCollector, allConstraintStatuses); >- } >- } >- return targetElementCollector; >- } >- >- /** >- * @generated >- */ >- private static Set<EObject> collectTargetElements(Diagnostic diagnostic, Set<EObject> targetElementCollector, List allDiagnostics) { >- List data = diagnostic.getData(); >- EObject target = null; >- if(data != null && !data.isEmpty() && data.get(0) instanceof EObject) { >- target = (EObject)data.get(0); >- targetElementCollector.add(target); >- allDiagnostics.add(diagnostic); >- } >- if(diagnostic.getChildren() != null && !diagnostic.getChildren().isEmpty()) { >- for(Iterator it = diagnostic.getChildren().iterator(); it.hasNext();) { >- collectTargetElements((Diagnostic)it.next(), targetElementCollector, allDiagnostics); >- } >- } >- return targetElementCollector; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomDefaultSemanticEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomDefaultSemanticEditPolicy.java >new file mode 100644 >index 0000000..7826ee2 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomDefaultSemanticEditPolicy.java >@@ -0,0 +1,94 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.policies; >+ >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.commands.UnexecutableCommand; >+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; >+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; >+import org.eclipse.papyrus.gmf.diagram.common.provider.IGraphicalTypeRegistry; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.CustomGraphicalTypeRegistry; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.GraphicalTypeRegistry; >+import org.eclipse.papyrus.uml.diagram.composite.edit.commands.CommentAnnotatedElementCreateCommand; >+import org.eclipse.papyrus.uml.diagram.composite.edit.commands.CommentAnnotatedElementReorientCommand; >+import org.eclipse.papyrus.uml.diagram.composite.edit.commands.ConstraintConstrainedElementCreateCommand; >+import org.eclipse.papyrus.uml.diagram.composite.edit.commands.ConstraintConstrainedElementReorientCommand; >+import org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants; >+ >+/** >+ * <pre> >+ * Custom semantic edit policy that replace DefaultSemanticEditPolicy >+ * in order to manage Class Diagram specific elements (reference >+ * relationships COMMENT_ANNOTATED_ELEMENT and CONSTRAINT_CONSTRAINED_ELEMENT). >+ * </pre> >+ */ >+public class CustomDefaultSemanticEditPolicy extends DefaultSemanticEditPolicy { >+ >+ /** Local graphical type registry for graphical elements */ >+ private IGraphicalTypeRegistry registry = new CustomGraphicalTypeRegistry(); >+ >+ /** Local graphical type registry for inherited graphical elements */ >+ private IGraphicalTypeRegistry inheritedRegistry = new GraphicalTypeRegistry(); >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) { >+ >+ if(ElementTypes.COMMENT_ANNOTATED_ELEMENT == req.getElementType()) { >+ return getGEFWrapper(new CommentAnnotatedElementCreateCommand(req, req.getSource(), req.getTarget())); >+ } >+ >+ if(ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT == req.getElementType()) { >+ return getGEFWrapper(new ConstraintConstrainedElementCreateCommand(req, req.getSource(), req.getTarget())); >+ } >+ >+ String newEdgeGraphicalType = registry.getEdgeGraphicalType(req.getElementType()); >+ >+ if(inheritedRegistry.isKnownEdgeType(newEdgeGraphicalType)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ if(!registry.isKnownEdgeType(newEdgeGraphicalType)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ return super.getCreateRelationshipCommand(req); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) { >+ >+ View reconnectedView = (View)req.getParameter(RequestParameterConstants.GRAPHICAL_RECONNECTED_EDGE); >+ String reconnectedViewType = (reconnectedView != null) ? reconnectedView.getType() : IGraphicalTypeRegistry.UNDEFINED_TYPE; >+ >+ if(ElementTypes.COMMENT_ANNOTATED_ELEMENT.getSemanticHint().equals(reconnectedViewType)) { >+ return getGEFWrapper(new CommentAnnotatedElementReorientCommand(req)); >+ } >+ >+ if(ElementTypes.CONSTRAINT_CONSTRAINED_ELEMENT.getSemanticHint().equals(reconnectedViewType)) { >+ return getGEFWrapper(new ConstraintConstrainedElementReorientCommand(req)); >+ } >+ >+ return super.getReorientReferenceRelationshipCommand(req); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomDragDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomDragDropEditPolicy.java >new file mode 100644 >index 0000000..2fe34bf >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomDragDropEditPolicy.java >@@ -0,0 +1,277 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.policies; >+ >+import java.util.Collection; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EReference; >+import org.eclipse.gmf.runtime.common.core.command.ICommand; >+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; >+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest; >+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; >+import org.eclipse.gmf.runtime.notation.Diagram; >+import org.eclipse.gmf.runtime.notation.NotationPackage; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.gmf.diagram.common.edit.policy.CommonDiagramDragDropEditPolicy; >+import org.eclipse.papyrus.sysml.blocks.NestedConnectorEnd; >+import org.eclipse.papyrus.sysml.diagram.internalblock.dnd.helper.CustomLinkMappingHelper; >+import org.eclipse.papyrus.sysml.diagram.internalblock.provider.CustomGraphicalTypeRegistry; >+import org.eclipse.papyrus.sysml.service.types.utils.ConnectorUtils; >+import org.eclipse.papyrus.uml.diagram.common.commands.CommonDeferredCreateConnectionViewCommand; >+import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.uml2.uml.Connector; >+import org.eclipse.uml2.uml.ConnectorEnd; >+import org.eclipse.uml2.uml.EncapsulatedClassifier; >+import org.eclipse.uml2.uml.Port; >+import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.util.UMLUtil; >+ >+/** Customization of the DND edit policy for the Internal Block Diagram */ >+public class CustomDragDropEditPolicy extends CommonDiagramDragDropEditPolicy { >+ >+ private ConnectorUtils utils = new ConnectorUtils(); >+ >+ /** Default constructor. */ >+ public CustomDragDropEditPolicy() { >+ super(new CustomLinkMappingHelper()); >+ registry = new CustomGraphicalTypeRegistry(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Set<String> getSpecificDropBehaviorTypes() { >+ Set<String> specificDropBehaviorTypes = new HashSet<String>(); >+ >+ specificDropBehaviorTypes.add(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID); >+ >+ return specificDropBehaviorTypes; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected ICommand getSpecificDropCommand(DropObjectsRequest dropRequest, EObject droppedEObject, String nodeType, String edgeType) { >+ if((UMLGraphicalTypes.LINK_UML_CONNECTOR_ID.equals(edgeType)) && (droppedEObject instanceof Connector)) { >+ return getConnectorDropCommand(dropRequest, (Connector)droppedEObject, edgeType); >+ } >+ >+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE; >+ } >+ >+ protected ICommand getConnectorDropCommand(DropObjectsRequest dropRequest, Connector droppedEObject, String edgeType) { >+ >+ // Only manage binary link during drop >+ if(droppedEObject.getEnds().size() != 2) { >+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE; >+ } >+ >+ ConnectorEnd source = droppedEObject.getEnds().get(0); >+ ConnectorEnd target = droppedEObject.getEnds().get(1); >+ >+ // Find views in current diagram representing source and target >+ Collection<View> sourceViews = getViewsForConnectorEnd(source); >+ Collection<View> targetViews = getViewsForConnectorEnd(target); >+ >+ IAdaptable sourceViewAdapter = null; >+ IAdaptable targetViewAdapter = null; >+ >+ // If either a source or target lacks create view for these elements, abort... >+ if(sourceViews.isEmpty() || targetViews.isEmpty()) { >+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE; >+ } >+ >+ View selectedSourceView = null; >+ View selectedTargetView = null; >+ // until a correct one is found, check that source and target views selected are correct given the current path for the connector... >+ for(View sourceView : sourceViews) { >+ View targetView = getFirstValidTargetViewForSource(sourceView, targetViews, droppedEObject); >+ if(targetView !=null) { >+ selectedSourceView = sourceView; >+ selectedTargetView = targetView; >+ break; >+ } >+ } >+ >+ >+ // Create source adapter >+ if(selectedSourceView!=null) { // sourceViewAdapter should still be null in this case >+ sourceViewAdapter = new SemanticAdapter(null, selectedSourceView); >+ } else { >+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE; >+ } >+ >+ // Create target adapter >+ if(selectedTargetView!=null) { // targetViewAdapter should still be null in this case >+ targetViewAdapter = new SemanticAdapter(null, selectedTargetView); >+ } else { >+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE; >+ } >+ >+ // Create a view for the dropped link between the source and target view adapters >+ IAdaptable droppedObjectAdapter = new SemanticAdapter(droppedEObject, null); >+ >+ CreateConnectionViewRequest.ConnectionViewDescriptor linkdescriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(droppedObjectAdapter, edgeType, getDiagramPreferencesHint()); >+ >+ CommonDeferredCreateConnectionViewCommand createConnectionViewCommand = new CommonDeferredCreateConnectionViewCommand(getEditingDomain(), edgeType, sourceViewAdapter, targetViewAdapter, getViewer(), getDiagramPreferencesHint(), linkdescriptor, null); >+ createConnectionViewCommand.setElement(droppedEObject); >+ >+ return createConnectionViewCommand; >+ } >+ >+ /** >+ * get the first valid target view for the given source. the couple source/target is valid if the path to them from the future container is valid >+ * @param sourceView >+ * @param targetViews >+ * @return >+ */ >+ private View getFirstValidTargetViewForSource(View sourceView, Collection<View> targetViews, Connector droppedConnector) { >+ for(View targetView : targetViews) { >+ if(isValidTargetViewForSource(sourceView, targetView, droppedConnector)) { >+ return targetView; >+ } >+ } >+ >+ return null; >+ } >+ >+ private boolean isValidTargetViewForSource(View sourceView, View targetView, Connector droppedConnector) { >+ if(!(utils.isCrossingEncapsulation(sourceView, targetView))) { >+ // no encapsulation. Computes the end paths >+ List<Property> sourceNestedPaths = utils.getNestedPropertyPath(sourceView, targetView); >+ List<Property> targetNestedPaths = utils.getNestedPropertyPath(targetView, sourceView); >+ >+ // check this is compatible with current connector >+ ConnectorEnd sourceConnectorEnd = utils.getSourceConnectorEnd(droppedConnector); >+ NestedConnectorEnd nestedSourceConnectorEnd = UMLUtil.getStereotypeApplication(sourceConnectorEnd, NestedConnectorEnd.class); >+ if(nestedSourceConnectorEnd!=null) { >+ List<Property> currentSourceConnectorPropertyPath = nestedSourceConnectorEnd.getPropertyPath(); >+ // compare the 2 list >+ if(!sourceNestedPaths.equals(currentSourceConnectorPropertyPath)) { >+ return false; >+ } >+ >+ } else { // no end for the current connector, so the sourceNestedPath should be empty >+ if(!sourceNestedPaths.isEmpty()) { >+ return false; >+ } >+ } >+ >+ >+ ConnectorEnd targetConnectorEnd = utils.getTargetConnectorEnd(droppedConnector); >+ NestedConnectorEnd nestedTargetConnectorEnd = UMLUtil.getStereotypeApplication(targetConnectorEnd, NestedConnectorEnd.class); >+ if(nestedTargetConnectorEnd!=null) { >+ List<Property> currentTargetConnectorPropertyPath = nestedTargetConnectorEnd.getPropertyPath(); >+ // compare the 2 list >+ if(!targetNestedPaths.equals(currentTargetConnectorPropertyPath)) { >+ return false; >+ } >+ >+ } else { // no end for the current connector, so the targetNestedPaths should be empty >+ if(!targetNestedPaths.isEmpty()) { >+ return false; >+ } >+ } >+ } >+ return true; >+ } >+ >+ /** >+ * This methods looks for views representing a given {@link ConnectorEnd} in the host diagram. >+ * >+ * @param end >+ * the {@link ConnectorEnd} to look for. >+ * @return the list of {@link View} representing the eObject. >+ */ >+ protected Set<View> getViewsForConnectorEnd(ConnectorEnd end) { >+ Set<View> views = new HashSet<View>(); >+ >+ // Retrieve host diagram >+ View hostView = ((IGraphicalEditPart)getHost()).getNotationView(); >+ View hostDiagram = (hostView instanceof Diagram) ? hostView : hostView.getDiagram(); >+ >+ // Retrieve all views for the ConnectorEnd role >+ EReference[] refs = { NotationPackage.eINSTANCE.getView_Element() }; >+ @SuppressWarnings("unchecked") >+ Collection<View> relatedViews = EMFCoreUtil.getReferencers(end.getRole(), refs); >+ >+ // TODO: We should filter views not only for the current diagram, >+ // but also consider only views nested within the owner of the connector that are closest to the host view >+ // (in case there are several instances of a Part within which the connector could appear). >+ // Connector connector = (Connector)end.getOwner(); >+ // StructuredClassifier connectorOwner = (StructuredClassifier)connector.getOwner(); >+ // Parse and select views from host diagram only >+ Iterator<View> it = relatedViews.iterator(); >+ while(it.hasNext()) { >+ View currentView = it.next(); >+ if(currentView.getDiagram() == hostDiagram) { // FIXME: Cf TODO above. >+ >+ boolean isInView = false; >+ View containerView = currentView; >+ while(containerView != null && !(containerView instanceof Diagram)) { >+ if(containerView == getReferenceViewForConnectorEnd()) { >+ isInView = true; >+ } >+ containerView = ViewUtil.getContainerView(containerView); >+ } >+ >+ if(isInView) { >+ >+ EObject containerElement = ViewUtil.getContainerView(currentView).getElement(); >+ >+ // If the ConnectorEnd partWithPort is not null, only select Views for which >+ // the graphical parent reference partWithPort. >+ if(end.getPartWithPort() != null) { >+ if(containerElement == end.getPartWithPort()) { >+ views.add(currentView); >+ } >+ } else { >+ // If the role is a Port, its graphical parent is a EncapsulatedClassifier >+ if(end.getRole() instanceof Port) { >+ if(containerElement instanceof EncapsulatedClassifier) { >+ views.add(currentView); >+ } else if(containerElement instanceof Property) { >+ Property property = (Property)containerElement; >+ if(property.getType() == end.getRole().getOwner()) { >+ views.add(currentView); >+ } >+ } >+ } else { // No further test needed >+ views.add(currentView); >+ } >+ >+ } >+ } >+ } >+ } >+ >+ return views; >+ } >+ >+ protected View getReferenceViewForConnectorEnd() { >+ return ((IGraphicalEditPart)getHost()).getNotationView(); >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomParametricSemanticPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomParametricSemanticPolicy.java >new file mode 100644 >index 0000000..589d591 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/CustomParametricSemanticPolicy.java >@@ -0,0 +1,38 @@ >+package org.eclipse.papyrus.sysml.diagram.parametric.policies; >+ >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.commands.UnexecutableCommand; >+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockPropertyCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.parametric.commands.CustomBindingConnectorCreateCommand; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.CustomBlockCompositeEditPartTN; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.policy.DiagramSemanticEditPolicy; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConstraintParameterAffixedNodeEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PortAffixedNodeEditPart; >+import org.eclipse.uml2.uml.UMLPackage; >+ >+public class CustomParametricSemanticPolicy extends DiagramSemanticEditPolicy { >+ >+ @Override >+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) { >+ if (req.getElementType().getEClass() == UMLPackage.eINSTANCE.getConnector()) { >+ if (getHost() instanceof CustomBlockCompositeEditPartTN) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ if (getHost() instanceof ConstraintBlockPropertyCompositeEditPart) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ if (getHost() instanceof ConstraintParameterAffixedNodeEditPart) { >+ return getGEFWrapper(new CustomBindingConnectorCreateCommand(req)); >+ } >+ if (getHost() instanceof PortAffixedNodeEditPart) { >+ return getGEFWrapper(new CustomBindingConnectorCreateCommand(req)); >+ } >+ if (getHost() instanceof BlockPropertyCompositeEditPart) { >+ return getGEFWrapper(new CustomBindingConnectorCreateCommand(req)); >+ } >+ } >+ return super.getCreateRelationshipCommand(req); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/StructureClassifierDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/StructureClassifierDropEditPolicy.java >new file mode 100644 >index 0000000..ad2d289 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/policies/StructureClassifierDropEditPolicy.java >@@ -0,0 +1,139 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.policies; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.emf.transaction.RunnableWithResult; >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.commands.UnexecutableCommand; >+import org.eclipse.gmf.runtime.common.core.command.ICommand; >+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.infra.gmfdiag.common.commands.SelectAndExecuteCommand; >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.CustomDragDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.parametric.utils.BlockDropHelper; >+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; >+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * <pre> >+ * Customization of the DND edit policy for the StructureClassifier compartments, that enables the direct >+ * creation of typed Part, Reference, Value, ActorPart or Property by dragging types in a Block structure compartment. >+ * </pre> >+ */ >+public class StructureClassifierDropEditPolicy extends CustomDragDropEditPolicy { >+ >+ /** Default constructor */ >+ public StructureClassifierDropEditPolicy() { >+ super(); >+ } >+ >+ /** >+ * {@inheritedDoc}. >+ */ >+ @Override >+ public Command getDropObjectsCommand(DropObjectsRequest dropRequest) { >+ >+ BlockDropHelper helper = new BlockDropHelper(getEditingDomain()); >+ >+ // Single drop management possible drop action list can be proposed >+ if(dropRequest.getObjects().size() == 1) { >+ >+ // List of available drop commands >+ final List<Command> commandChoice = new ArrayList<Command>(); >+ >+ // 1. Try to create a Part typed by the dropped object >+ Command dropAsTypedPart = helper.getDropAsStructureItem(dropRequest, (GraphicalEditPart)getHost(), SysMLElementTypes.PART_PROPERTY); >+ if((dropAsTypedPart != null) && (dropAsTypedPart.canExecute())) { >+ commandChoice.add(dropAsTypedPart); >+ } >+ >+ // 2. Try to create a Reference typed by the dropped object >+ Command dropAsTypedReference = helper.getDropAsStructureItem(dropRequest, (GraphicalEditPart)getHost(), SysMLElementTypes.REFERENCE_PROPERTY); >+ if((dropAsTypedReference != null) && (dropAsTypedReference.canExecute())) { >+ commandChoice.add(dropAsTypedReference); >+ } >+ >+ // 3. Try to create an ActorPart typed by the dropped object >+ Command dropAsTypedActorPart = helper.getDropAsStructureItem(dropRequest, (GraphicalEditPart)getHost(), SysMLElementTypes.ACTOR_PART_PROPERTY); >+ if((dropAsTypedActorPart != null) && (dropAsTypedActorPart.canExecute())) { >+ commandChoice.add(dropAsTypedActorPart); >+ } >+ >+ // 4. Try to create a Value typed by the dropped object >+ Command dropAsTypedValue = helper.getDropAsStructureItem(dropRequest, (GraphicalEditPart)getHost(), SysMLElementTypes.VALUE_PROPERTY); >+ if((dropAsTypedValue != null) && (dropAsTypedValue.canExecute())) { >+ commandChoice.add(dropAsTypedValue); >+ } >+ >+ // 5. Try to create a Property typed by the dropped object >+ Command dropAsTypedProperty = helper.getDropAsStructureItem(dropRequest, (GraphicalEditPart)getHost(), UMLElementTypes.PROPERTY); >+ if((dropAsTypedProperty != null) && (dropAsTypedProperty.canExecute())) { >+ commandChoice.add(dropAsTypedProperty); >+ } >+ >+ // 6. Try to create a ConstraintProperty typed by the dropped object >+ Command dropAsTypedConstraintProperty = helper.getDropAsStructureItem(dropRequest, (GraphicalEditPart)getHost(), SysMLElementTypes.CONSTRAINT_PROPERTY); >+ if((dropAsTypedConstraintProperty != null) && (dropAsTypedConstraintProperty.canExecute())) { >+ commandChoice.add(dropAsTypedConstraintProperty); >+ } >+ >+ // 7. Build default drop command (show view of the dropped object) >+ Command defaultDropCommand = super.getDropObjectsCommand(dropRequest); >+ defaultDropCommand.setLabel("Default drop (Show dropped object in diagram)"); >+ if((defaultDropCommand != null) && (defaultDropCommand.canExecute())) { >+ commandChoice.add(defaultDropCommand); >+ } >+ >+ // Prepare the selection command (if several command are available) or return the drop command >+ if(commandChoice.size() > 1) { >+ RunnableWithResult<ICommand> runnable; >+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<ICommand>() { >+ >+ public void run() { >+ setResult(new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice)); >+ } >+ }); >+ >+ ICommand selectCommand = runnable.getResult(); >+ >+ return new ICommandProxy(selectCommand); >+ >+ } else if(commandChoice.size() == 1) { >+ return commandChoice.get(0); >+ } >+ >+ // else (command choice is empty) >+ return UnexecutableCommand.INSTANCE; >+ >+ } >+ >+ return super.getDropObjectsCommand(dropRequest); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected View getReferenceViewForConnectorEnd() { >+ return ViewUtil.getContainerView(super.getReferenceViewForConnectorEnd()); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/BlockPropertyCompositePreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/BlockPropertyCompositePreferencePage.java >new file mode 100644 >index 0000000..a368629 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/BlockPropertyCompositePreferencePage.java >@@ -0,0 +1,42 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import org.eclipse.gmf.runtime.common.ui.preferences.AbstractPreferencePage; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.swt.widgets.Composite; >+ >+public class BlockPropertyCompositePreferencePage extends AbstractPreferencePage { >+ >+ /** Constructor */ >+ public BlockPropertyCompositePreferencePage() { >+ super(); >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ CustomBlockPropertyCompositePreferencePage.initDefaults(store); >+ /*CustomNestedBlockPropertyCompositePreferencePage.initDefaults(store);*/ >+ } >+ >+ @Override >+ protected void addFields(Composite parent) { >+ >+ } >+ >+ @Override >+ protected void initHelp() { >+ >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConnectorPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConnectorPreferencePage.java >deleted file mode 100644 >index 031e4ff..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConnectorPreferencePage.java >+++ /dev/null >@@ -1,88 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import java.util.Map; >-import java.util.TreeMap; >- >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.AbstractPapyrusLinkPreferencePage; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.uml.diagram.common.util.StringComparator; >- >-/** >- * @generated >- */ >-public class ConnectorPreferencePage extends AbstractPapyrusLinkPreferencePage { >- >- /** >- * @generated >- */ >- public ConnectorPreferencePage() { >- super(); >- setPreferenceKey(ParametricEditPart.MODEL_ID + "_Connector"); >- } >- >- /** >- * @generated >- */ >- @Override >- protected String getBundleId() { >- return SysmlDiagramEditorPlugin.ID; >- } >- >- /** >- * @generated >- */ >- public static void initDefaults(IPreferenceStore store) { >- >- String key = ParametricEditPart.MODEL_ID + "_Connector"; >- Map<String, Boolean> map = getStaticLabelVisibilityPreferences(); >- for(String role : map.keySet()) { >- String preferenceName = PreferenceConstantHelper.getLabelElementConstant(key, role, PreferenceConstantHelper.LABEL_VISIBILITY); >- store.setDefault(preferenceName, map.get(role)); >- } >- >- } >- >- /** >- * @generated >- */ >- private static TreeMap<String, String> getStaticLabelRole() { >- TreeMap<String, String> map = new TreeMap<String, String>(new StringComparator()); >- map.put("Name", "platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/name.png");//$NON-NLS-1$ //$NON-NLS-2$ >- return map; >- } >- >- /** >- * @generated >- */ >- private static TreeMap<String, Boolean> getStaticLabelVisibilityPreferences() { >- TreeMap<String, Boolean> map = new TreeMap<String, Boolean>(); >- >- map.put("Name", Boolean.FALSE);//$NON-NLS-1$ >- >- return map; >- } >- >- /** >- * @generated >- */ >- protected TreeMap<String, String> getLabelRole() { >- return getStaticLabelRole(); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintParameterAsBorderItemPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintParameterAsBorderItemPreferencePage.java >new file mode 100644 >index 0000000..3bba22a >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintParameterAsBorderItemPreferencePage.java >@@ -0,0 +1,302 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULTVALUE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DERIVE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MODIFIERS; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_NAME; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_UNDEFINED_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_VISIBILITY; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; >+ >+/** >+ * {@link Port} preference page. >+ */ >+public class ConstraintParameterAsBorderItemPreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.SHAPE_UML_PROPERTY_AS_AFFIXED_ID; //$NON-NLS-1$ >+ >+ public static String prefLabelKey = prefKey + "-" + UMLGraphicalTypes.AFFIXEDLABEL_UML_PORT_LABEL_ID; //$NON-NLS-1$ >+ >+ /** The labels default visibility for preferences */ >+ public static final Map<String, Boolean> labelDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ labelDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ labelDefaultVisibilityMap.put("Stereotype", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("Label", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(labelDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public ConstraintParameterAsBorderItemPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.SHAPE_UML_PROPERTY_AS_AFFIXED_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ store.setDefault(LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE), DISP_NAME | DISP_TYPE | DISP_MULTIPLICITY | DISP_UNDEFINED_TYPE); >+ >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 20); >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 20); >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.ELEMENTICON), 0); >+ >+ // Initialize default visibility for labels in preference page. >+ for(String labelName : labelDefaultVisibilityMap.keySet()) { >+ String showLabelKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, labelName, PreferenceConstantHelper.LABEL_VISIBILITY); >+ store.setDefault(showLabelKey, labelDefaultVisibilityMap.get(labelName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeLabelsList() { >+ for(String name : labelDefaultVisibilityMap.keySet()) { >+ this.labelsList.add(name); >+ } >+ } >+ >+ /** buttons to select the display mask of the label */ >+ protected Button bttnVisibility, bttnDerive, bttnName, bttnType, bttnUndefined_Type, bttnMultiplicity, bttnDefault_Multiplicity, bttnDefaultValue, bttnModifiers; >+ >+ private String labelDisplayPreferenceKey = LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE); >+ >+ /** current property display style */ >+ private int propertyValue = getPreferenceStore().getInt(labelDisplayPreferenceKey); >+ >+ /** >+ * Creates a button with the {@link SWT#CHECK} style. >+ * >+ * @param parent >+ * the parent of the button >+ * @param label >+ * the label of the button >+ * @param mask >+ * the value controlled by the button >+ * @return the button created >+ */ >+ protected Button createCheckButton(Composite parent, String label, int mask) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setText(label); >+ button.addSelectionListener(new AppearenceSelectionListener(mask)); >+ return button; >+ } >+ >+ /** >+ * Creates the group and check boxes to choose the kind of display >+ * >+ * @param parent >+ * the parent composite that holds the group >+ */ >+ protected void createLabelPreferencesButtons(Composite parent) { >+ // create group that host the buttons >+ Group group = new Group(parent, SWT.SHADOW_NONE); >+ group.setText("Label Display"); >+ group.setLayout(new FormLayout()); >+ >+ FormData data; >+ >+ bttnVisibility = createCheckButton(group, "Visibility", DISP_VISIBILITY); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(0, 0); >+ bttnVisibility.setLayoutData(data); >+ >+ bttnDerive = createCheckButton(group, "Derive", DISP_DERIVE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnDerive.setLayoutData(data); >+ >+ bttnName = createCheckButton(group, "Name", DISP_NAME); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnName.setLayoutData(data); >+ >+ bttnType = createCheckButton(group, "Type", DISP_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnType.setLayoutData(data); >+ >+ bttnUndefined_Type = createCheckButton(group, "Undefined_Type", DISP_UNDEFINED_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnUndefined_Type.setLayoutData(data); >+ >+ bttnMultiplicity = createCheckButton(group, "Multiplicity", DISP_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnMultiplicity.setLayoutData(data); >+ >+ bttnDefault_Multiplicity = createCheckButton(group, "Default_Multiplicity", DISP_DEFAULT_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnDefault_Multiplicity.setLayoutData(data); >+ >+ bttnDefaultValue = createCheckButton(group, "DefaultValue", DISP_DEFAULTVALUE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnDefaultValue.setLayoutData(data); >+ >+ bttnModifiers = createCheckButton(group, "Modifiers", DISP_MODIFIERS); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnUndefined_Type, ITabbedPropertyConstants.HSPACE); >+ bttnModifiers.setLayoutData(data); >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createPageContents(Composite parent) { >+ super.createPageContents(parent); >+ >+ // adds the label preferences check boxes >+ createLabelPreferencesButtons(parent); >+ >+ refreshButtons(); >+ } >+ >+ /** >+ * Load the default preferences of the fields contained in this page >+ */ >+ protected void loadDefaultPreferences() { >+ propertyValue = getPreferenceStore().getDefaultInt(labelDisplayPreferenceKey); >+ refreshButtons(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void performDefaults() { >+ loadDefaultPreferences(); >+ super.performDefaults(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean performOk() { >+ storePreferences(); >+ return super.performOk(); >+ } >+ >+ /** >+ * Refresh the buttons that manages the display. >+ */ >+ protected void refreshButtons() { >+ >+ bttnVisibility.setSelection((propertyValue & DISP_VISIBILITY) == DISP_VISIBILITY); >+ bttnDerive.setSelection((propertyValue & DISP_DERIVE) == DISP_DERIVE); >+ bttnName.setSelection((propertyValue & DISP_NAME) == DISP_NAME); >+ bttnType.setSelection((propertyValue & DISP_TYPE) == DISP_TYPE); >+ bttnUndefined_Type.setSelection((propertyValue & DISP_UNDEFINED_TYPE) == DISP_UNDEFINED_TYPE); >+ bttnMultiplicity.setSelection((propertyValue & DISP_MULTIPLICITY) == DISP_MULTIPLICITY); >+ bttnDefault_Multiplicity.setSelection((propertyValue & DISP_DEFAULT_MULTIPLICITY) == DISP_DEFAULT_MULTIPLICITY); >+ bttnDefaultValue.setSelection((propertyValue & DISP_DEFAULTVALUE) == DISP_DEFAULTVALUE); >+ bttnModifiers.setSelection((propertyValue & DISP_MODIFIERS) == DISP_MODIFIERS); >+ >+ } >+ >+ /** >+ * Stores the values of the fields contained in this page into the preference store. >+ */ >+ protected void storePreferences() { >+ super.storePreferences(); >+ IPreferenceStore store = getPreferenceStore(); >+ // checks the stored value and the actual one, so does not refresh diagram if it is not >+ // needed >+ if(propertyValue != store.getInt(labelDisplayPreferenceKey)) { >+ store.setValue(labelDisplayPreferenceKey, propertyValue); >+ } >+ } >+ >+ /** >+ * Listeners for the check buttons that select the display. >+ */ >+ private class AppearenceSelectionListener implements SelectionListener { >+ >+ /** The constant which refers the element to display or not. */ >+ final private int style; >+ >+ /** >+ * Default Constructor. >+ * >+ * @param style >+ */ >+ public AppearenceSelectionListener(int style) { >+ this.style = style; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ // add or remove the flag to the display property value (invert the current value) >+ propertyValue = propertyValue ^ style; >+ // refresh buttons to show current values >+ refreshButtons(); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintPropertyPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintPropertyPreferencePage.java >deleted file mode 100644 >index 90fd061..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/ConstraintPropertyPreferencePage.java >+++ /dev/null >@@ -1,64 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.AbstractPapyrusNodePreferencePage; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class ConstraintPropertyPreferencePage extends AbstractPapyrusNodePreferencePage { >- >- /** >- * @generated >- */ >- public ConstraintPropertyPreferencePage() { >- super(); >- setPreferenceKey(ParametricEditPart.MODEL_ID + "_ConstraintProperty"); >- } >- >- /** >- * @generated >- */ >- @Override >- protected String getBundleId() { >- return SysmlDiagramEditorPlugin.ID; >- } >- >- /** >- * @generated >- */ >- public static void initDefaults(IPreferenceStore store) { >- >- String key = ParametricEditPart.MODEL_ID + "_ConstraintProperty"; >- store.setDefault(PreferenceConstantHelper.getElementConstant(key, PreferenceConstantHelper.WIDTH), 40); >- store.setDefault(PreferenceConstantHelper.getElementConstant(key, PreferenceConstantHelper.HEIGHT), 40); >- >- //org.eclipse.jface.preference.PreferenceConverter.setDefault(store, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255)); >- //org.eclipse.jface.preference.PreferenceConverter.setDefault(store, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0)); >- >- // Set the default for the gradient >- //store.setDefault(org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.GRADIENT_POLICY),false); >- //org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter gradientPreferenceConverter = new org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter( >- // new org.eclipse.swt.graphics.RGB(255, 255, 255), >- // new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0); >- //store.setDefault(org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue()); >- >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomBlockPropertyCompositePreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomBlockPropertyCompositePreferencePage.java >new file mode 100644 >index 0000000..5d84d21 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomBlockPropertyCompositePreferencePage.java >@@ -0,0 +1,327 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULTVALUE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DERIVE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MODIFIERS; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_NAME; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_UNDEFINED_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_VISIBILITY; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; >+ >+/** >+ * Preference page for Part and References. >+ */ >+public class CustomBlockPropertyCompositePreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID; //$NON-NLS-1$ >+ >+ public static String prefLabelKey = prefKey + "-" + UMLGraphicalTypes.LABEL_UML_PROPERTY_LABEL_ID; //$NON-NLS-1$ >+ >+ /** The compartments default visibility for preferences */ >+ public static final Map<String, Boolean> compartmentDefaultVisibilityMap; >+ >+ /** The compartment titles default visibility for preferences */ >+ public static final Map<String, Boolean> compartmentTitleDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ compartmentDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ compartmentDefaultVisibilityMap.put("structure", Boolean.TRUE); //$NON-NLS-1$ >+ >+ compartmentTitleDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ compartmentTitleDefaultVisibilityMap.put("structure", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ compartmentTitleDefaultVisibilityMap.remove("structure"); //$NON-NLS-1$ >+ compartmentTitleDefaultVisibilityMap.put("structure", Boolean.FALSE); //$NON-NLS-1$ >+ // End of user code >+ >+ Collections.unmodifiableMap(compartmentDefaultVisibilityMap); >+ Collections.unmodifiableMap(compartmentTitleDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public CustomBlockPropertyCompositePreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 200); >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 100); >+ store.setDefault(LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE), DISP_NAME | DISP_TYPE | DISP_UNDEFINED_TYPE); >+ // End of user code >+ >+ // Initialize default visibility for compartments in preference page. >+ for(String compartmentName : compartmentDefaultVisibilityMap.keySet()) { >+ String showCompartmentKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_VISIBILITY); >+ store.setDefault(showCompartmentKey, compartmentDefaultVisibilityMap.get(compartmentName)); >+ } >+ >+ // Initialize default title visibility for compartments in preference page. >+ for(String compartmentName : compartmentTitleDefaultVisibilityMap.keySet()) { >+ String showCompartmentTitleKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY); >+ store.setDefault(showCompartmentTitleKey, compartmentTitleDefaultVisibilityMap.get(compartmentName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeCompartmentNamesList() { >+ for(String name : compartmentDefaultVisibilityMap.keySet()) { >+ this.compartmentNamesList.add(name); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeCompartmentTitlesList() { >+ for(String name : compartmentTitleDefaultVisibilityMap.keySet()) { >+ this.compartmentTitlesList.add(name); >+ } >+ } >+ >+ /** buttons to select the display mask of the label */ >+ protected Button bttnVisibility, bttnDerive, bttnName, bttnType, bttnUndefined_Type, bttnMultiplicity, bttnDefault_Multiplicity, bttnDefaultValue, bttnModifiers; >+ >+ private String labelDisplayPreferenceKey = LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE); >+ >+ /** current property display style */ >+ private int propertyValue = getPreferenceStore().getInt(labelDisplayPreferenceKey); >+ >+ /** >+ * Creates a button with the {@link SWT#CHECK} style. >+ * >+ * @param parent >+ * the parent of the button >+ * @param label >+ * the label of the button >+ * @param mask >+ * the value controlled by the button >+ * @return the button created >+ */ >+ protected Button createCheckButton(Composite parent, String label, int mask) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setText(label); >+ button.addSelectionListener(new AppearenceSelectionListener(mask)); >+ return button; >+ } >+ >+ /** >+ * Creates the group and check boxes to choose the kind of display >+ * >+ * @param parent >+ * the parent composite that holds the group >+ */ >+ protected void createLabelPreferencesButtons(Composite parent) { >+ // create group that host the buttons >+ Group group = new Group(parent, SWT.SHADOW_NONE); >+ group.setText("Label Display"); >+ group.setLayout(new FormLayout()); >+ >+ FormData data; >+ >+ bttnVisibility = createCheckButton(group, "Visibility", DISP_VISIBILITY); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(0, 0); >+ bttnVisibility.setLayoutData(data); >+ >+ bttnDerive = createCheckButton(group, "Derive", DISP_DERIVE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnDerive.setLayoutData(data); >+ >+ bttnName = createCheckButton(group, "Name", DISP_NAME); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnName.setLayoutData(data); >+ >+ bttnType = createCheckButton(group, "Type", DISP_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnType.setLayoutData(data); >+ >+ bttnUndefined_Type = createCheckButton(group, "Undefined_Type", DISP_UNDEFINED_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnUndefined_Type.setLayoutData(data); >+ >+ bttnMultiplicity = createCheckButton(group, "Multiplicity", DISP_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnMultiplicity.setLayoutData(data); >+ >+ bttnDefault_Multiplicity = createCheckButton(group, "Default_Multiplicity", DISP_DEFAULT_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnDefault_Multiplicity.setLayoutData(data); >+ >+ bttnDefaultValue = createCheckButton(group, "DefaultValue", DISP_DEFAULTVALUE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnDefaultValue.setLayoutData(data); >+ >+ bttnModifiers = createCheckButton(group, "Modifiers", DISP_MODIFIERS); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnUndefined_Type, ITabbedPropertyConstants.HSPACE); >+ bttnModifiers.setLayoutData(data); >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createPageContents(Composite parent) { >+ super.createPageContents(parent); >+ >+ // adds the label preferences check boxes >+ createLabelPreferencesButtons(parent); >+ >+ refreshButtons(); >+ } >+ >+ /** >+ * Load the default preferences of the fields contained in this page >+ */ >+ protected void loadDefaultPreferences() { >+ propertyValue = getPreferenceStore().getDefaultInt(labelDisplayPreferenceKey); >+ refreshButtons(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void performDefaults() { >+ loadDefaultPreferences(); >+ super.performDefaults(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean performOk() { >+ storePreferences(); >+ return super.performOk(); >+ } >+ >+ /** >+ * Refresh the buttons that manages the display. >+ */ >+ protected void refreshButtons() { >+ >+ bttnVisibility.setSelection((propertyValue & DISP_VISIBILITY) == DISP_VISIBILITY); >+ bttnDerive.setSelection((propertyValue & DISP_DERIVE) == DISP_DERIVE); >+ bttnName.setSelection((propertyValue & DISP_NAME) == DISP_NAME); >+ bttnType.setSelection((propertyValue & DISP_TYPE) == DISP_TYPE); >+ bttnUndefined_Type.setSelection((propertyValue & DISP_UNDEFINED_TYPE) == DISP_UNDEFINED_TYPE); >+ bttnMultiplicity.setSelection((propertyValue & DISP_MULTIPLICITY) == DISP_MULTIPLICITY); >+ bttnDefault_Multiplicity.setSelection((propertyValue & DISP_DEFAULT_MULTIPLICITY) == DISP_DEFAULT_MULTIPLICITY); >+ bttnDefaultValue.setSelection((propertyValue & DISP_DEFAULTVALUE) == DISP_DEFAULTVALUE); >+ bttnModifiers.setSelection((propertyValue & DISP_MODIFIERS) == DISP_MODIFIERS); >+ >+ } >+ >+ /** >+ * Stores the values of the fields contained in this page into the preference store. >+ */ >+ protected void storePreferences() { >+ super.storePreferences(); >+ IPreferenceStore store = getPreferenceStore(); >+ // checks the stored value and the actual one, so does not refresh diagram if it is not >+ // needed >+ if(propertyValue != store.getInt(labelDisplayPreferenceKey)) { >+ store.setValue(labelDisplayPreferenceKey, propertyValue); >+ } >+ } >+ >+ /** >+ * Listeners for the check buttons that select the display. >+ */ >+ private class AppearenceSelectionListener implements SelectionListener { >+ >+ /** The constant which refers the element to display or not. */ >+ final private int style; >+ >+ /** >+ * Default Constructor. >+ * >+ * @param style >+ */ >+ public AppearenceSelectionListener(int style) { >+ this.style = style; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ // add or remove the flag to the display property value (invert the current value) >+ propertyValue = propertyValue ^ style; >+ // refresh buttons to show current values >+ refreshButtons(); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomConnectorPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomConnectorPreferencePage.java >new file mode 100644 >index 0000000..8c200be >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomConnectorPreferencePage.java >@@ -0,0 +1,464 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_NAME; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_UNDEFINED_TYPE; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Group; >+ >+/** >+ * {@link Connector} preference page. >+ */ >+public class CustomConnectorPreferencePage extends ParametricDiagramLinkPreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_CONNECTOR_ID; //$NON-NLS-1$ >+ >+ /** The labels default visibility for preferences */ >+ public static final Map<String, Boolean> labelDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ labelDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ labelDefaultVisibilityMap.put("Stereotype", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("Label", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("SourceMultiplicity", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("TargetMultiplicity", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(labelDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public CustomConnectorPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_CONNECTOR_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+ >+ // Label default masks initialization >+ store.setDefault(LabelPreferenceHelper.getPreferenceConstant(labelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE), DISP_NAME | DISP_TYPE); >+ store.setDefault(LabelPreferenceHelper.getPreferenceConstant(sourceMultLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE), DISP_MULTIPLICITY); >+ store.setDefault(LabelPreferenceHelper.getPreferenceConstant(targetMultLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE), DISP_MULTIPLICITY); >+ >+ // End of user code >+ >+ // Initialize default visibility for labels in preference page. >+ for(String labelName : labelDefaultVisibilityMap.keySet()) { >+ String showLabelKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, labelName, PreferenceConstantHelper.LABEL_VISIBILITY); >+ store.setDefault(showLabelKey, labelDefaultVisibilityMap.get(labelName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeLabelsList() { >+ for(String name : labelDefaultVisibilityMap.keySet()) { >+ this.labelsList.add(name); >+ } >+ } >+ >+ // Label display mask management in preference page >+ >+ /** buttons to select the display mask of the label */ >+ protected Button bttnName, bttnType, bttnUndefined_Type; >+ >+ /** buttons to select the display mask of the source labels */ >+ protected Button bttnSourceMultMultiplicity, bttnSourceMultDefault_Multiplicity; >+ >+ /** buttons to select the display mask of the target labels */ >+ protected Button bttnTargetMultMultiplicity, bttnTargetMultDefault_Multiplicity; >+ >+ /** Preference keys */ >+ public static String labelKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_CONNECTOR_ID + "-" + UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_LABEL_ID; //$NON-NLS-1$ >+ >+ public static String sourceMultLabelKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_CONNECTOR_ID + "-" + UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_SOURCE_MULTIPLICITY_ID; //$NON-NLS-1$ >+ >+ public static String targetMultLabelKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.LINK_UML_CONNECTOR_ID + "-" + UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_TARGET_MULTIPLICITY_ID; //$NON-NLS-1$ >+ >+ private String labelDisplayPreferenceKey = LabelPreferenceHelper.getPreferenceConstant(labelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE); >+ >+ private String sourceMultLabelDisplayPreferenceKey = LabelPreferenceHelper.getPreferenceConstant(sourceMultLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE); >+ >+ private String targetMultLabelDisplayPreferenceKey = LabelPreferenceHelper.getPreferenceConstant(targetMultLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE); >+ >+ /** Current property display styles for labels */ >+ private int labelDisplayValue = getPreferenceStore().getInt(labelDisplayPreferenceKey); >+ >+ private int sourceMultDisplayValue = getPreferenceStore().getInt(sourceMultLabelDisplayPreferenceKey); >+ >+ private int targetMultDisplayValue = getPreferenceStore().getInt(targetMultLabelDisplayPreferenceKey); >+ >+ /** >+ * Creates the group and check boxes to choose the kind of display >+ * >+ * @param parent >+ * the parent composite that holds the group >+ */ >+ protected void createLabelPreferencesButtons(Composite parent) { >+ // create group that host the buttons >+ Group group = new Group(parent, SWT.SHADOW_NONE); >+ group.setText("Label Display"); >+ group.setLayout(new FormLayout()); >+ >+ FormData data; >+ >+ bttnName = createLabelCheckButton(group, "Name", DISP_NAME); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(0, 0); >+ bttnName.setLayoutData(data); >+ >+ bttnType = createLabelCheckButton(group, "Type", DISP_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnType.setLayoutData(data); >+ >+ bttnUndefined_Type = createLabelCheckButton(group, "Undefined_Type", DISP_UNDEFINED_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnType, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnUndefined_Type.setLayoutData(data); >+ } >+ >+ /** >+ * Creates the group and check boxes to choose the kind of display >+ * >+ * @param parent >+ * the parent composite that holds the group >+ */ >+ protected void createSourceMultLabelPreferencesButtons(Composite parent) { >+ // create group that host the buttons >+ Group group = new Group(parent, SWT.SHADOW_NONE); >+ group.setText("Source Multiplicity Label Display"); >+ group.setLayout(new FormLayout()); >+ >+ FormData data; >+ >+ bttnSourceMultMultiplicity = createSourceMultCheckButton(group, "Multiplicity", DISP_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(0, 0); >+ bttnSourceMultMultiplicity.setLayoutData(data); >+ >+ bttnSourceMultDefault_Multiplicity = createSourceMultCheckButton(group, "Default_Multiplicity", DISP_DEFAULT_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnSourceMultMultiplicity, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnSourceMultDefault_Multiplicity.setLayoutData(data); >+ } >+ >+ /** >+ * Creates the group and check boxes to choose the kind of display >+ * >+ * @param parent >+ * the parent composite that holds the group >+ */ >+ protected void createTargetMultLabelPreferencesButtons(Composite parent) { >+ // create group that host the buttons >+ Group group = new Group(parent, SWT.SHADOW_NONE); >+ group.setText("Target Multiplicity Label Display"); >+ group.setLayout(new FormLayout()); >+ >+ FormData data; >+ >+ bttnTargetMultMultiplicity = createTargetMultCheckButton(group, "Multiplicity", DISP_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(0, 0); >+ bttnTargetMultMultiplicity.setLayoutData(data); >+ >+ bttnTargetMultDefault_Multiplicity = createTargetMultCheckButton(group, "Default_Multiplicity", DISP_DEFAULT_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnTargetMultMultiplicity, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnTargetMultDefault_Multiplicity.setLayoutData(data); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createPageContents(Composite parent) { >+ super.createPageContents(parent); >+ >+ // adds the label preferences check boxes >+ createLabelPreferencesButtons(parent); >+ createSourceMultLabelPreferencesButtons(parent); >+ createTargetMultLabelPreferencesButtons(parent); >+ >+ refreshButtons(); >+ } >+ >+ /** >+ * Load the default preferences of the fields contained in this page >+ */ >+ protected void loadDefaultPreferences() { >+ labelDisplayValue = getPreferenceStore().getDefaultInt(labelDisplayPreferenceKey); >+ sourceMultDisplayValue = getPreferenceStore().getDefaultInt(sourceMultLabelDisplayPreferenceKey); >+ targetMultDisplayValue = getPreferenceStore().getDefaultInt(targetMultLabelDisplayPreferenceKey); >+ >+ refreshButtons(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void performDefaults() { >+ loadDefaultPreferences(); >+ super.performDefaults(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean performOk() { >+ storePreferences(); >+ return super.performOk(); >+ } >+ >+ /** >+ * Refresh the buttons that manages the display. >+ */ >+ protected void refreshButtons() { >+ >+ // Label refresh buttons >+ bttnName.setSelection((labelDisplayValue & DISP_NAME) == DISP_NAME); >+ bttnType.setSelection((labelDisplayValue & DISP_TYPE) == DISP_TYPE); >+ bttnUndefined_Type.setSelection((labelDisplayValue & DISP_UNDEFINED_TYPE) == DISP_UNDEFINED_TYPE); >+ >+ // Source Label Buttons >+ bttnSourceMultMultiplicity.setSelection((sourceMultDisplayValue & DISP_MULTIPLICITY) == DISP_MULTIPLICITY); >+ bttnSourceMultDefault_Multiplicity.setSelection((sourceMultDisplayValue & DISP_DEFAULT_MULTIPLICITY) == DISP_DEFAULT_MULTIPLICITY); >+ >+ // Target Label Buttons >+ bttnTargetMultMultiplicity.setSelection((targetMultDisplayValue & DISP_MULTIPLICITY) == DISP_MULTIPLICITY); >+ bttnTargetMultDefault_Multiplicity.setSelection((targetMultDisplayValue & DISP_DEFAULT_MULTIPLICITY) == DISP_DEFAULT_MULTIPLICITY); >+ >+ } >+ >+ /** >+ * Stores the values of the fields contained in this page into the preference store. >+ */ >+ protected void storePreferences() { >+ super.storePreferences(); >+ IPreferenceStore store = getPreferenceStore(); >+ // checks the stored value and the actual one, so does not refresh diagram if it is not >+ // needed >+ if(labelDisplayValue != store.getInt(labelDisplayPreferenceKey)) { >+ store.setValue(labelDisplayPreferenceKey, labelDisplayValue); >+ } >+ if(sourceMultDisplayValue != store.getInt(sourceMultLabelDisplayPreferenceKey)) { >+ store.setValue(sourceMultLabelDisplayPreferenceKey, sourceMultDisplayValue); >+ } >+ if(targetMultDisplayValue != store.getInt(targetMultLabelDisplayPreferenceKey)) { >+ store.setValue(targetMultLabelDisplayPreferenceKey, targetMultDisplayValue); >+ } >+ } >+ >+ /** >+ * Creates a button with the {@link SWT#CHECK} style. >+ * >+ * @param parent >+ * the parent of the button >+ * @param label >+ * the label of the button >+ * @param mask >+ * the value controlled by the button >+ * @return the button created >+ */ >+ protected Button createLabelCheckButton(Composite parent, String label, int mask) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setText(label); >+ button.addSelectionListener(new LabelAppearenceSelectionListener(mask)); >+ return button; >+ } >+ >+ /** >+ * Creates a button with the {@link SWT#CHECK} style. >+ * >+ * @param parent >+ * the parent of the button >+ * @param label >+ * the label of the button >+ * @param mask >+ * the value controlled by the button >+ * @return the button created >+ */ >+ protected Button createSourceMultCheckButton(Composite parent, String label, int mask) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setText(label); >+ button.addSelectionListener(new SourceMultAppearenceSelectionListener(mask)); >+ return button; >+ } >+ >+ /** >+ * Creates a button with the {@link SWT#CHECK} style. >+ * >+ * @param parent >+ * the parent of the button >+ * @param label >+ * the label of the button >+ * @param mask >+ * the value controlled by the button >+ * @return the button created >+ */ >+ protected Button createTargetMultCheckButton(Composite parent, String label, int mask) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setText(label); >+ button.addSelectionListener(new TargetMultAppearenceSelectionListener(mask)); >+ return button; >+ } >+ >+ /** >+ * Listeners for the check buttons that select the label display. >+ */ >+ private class LabelAppearenceSelectionListener implements SelectionListener { >+ >+ /** The constant which refers the element to display or not. */ >+ final private int style; >+ >+ /** >+ * Default Constructor. >+ * >+ * @param style >+ */ >+ public LabelAppearenceSelectionListener(int style) { >+ this.style = style; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ // add or remove the flag to the display property value (invert the current value) >+ labelDisplayValue = labelDisplayValue ^ style; >+ >+ // refresh buttons to show current values >+ refreshButtons(); >+ } >+ } >+ >+ /** >+ * Listeners for the check buttons that select the source multiplicity display. >+ */ >+ private class SourceMultAppearenceSelectionListener implements SelectionListener { >+ >+ /** The constant which refers the element to display or not. */ >+ final private int style; >+ >+ /** >+ * Default Constructor. >+ * >+ * @param style >+ */ >+ public SourceMultAppearenceSelectionListener(int style) { >+ this.style = style; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ // add or remove the flag to the display property value (invert the current value) >+ sourceMultDisplayValue = sourceMultDisplayValue ^ style; >+ >+ // refresh buttons to show current values >+ refreshButtons(); >+ } >+ } >+ >+ /** >+ * Listeners for the check buttons that select the target multiplicity display. >+ */ >+ private class TargetMultAppearenceSelectionListener implements SelectionListener { >+ >+ /** The constant which refers the element to display or not. */ >+ final private int style; >+ >+ /** >+ * Default Constructor. >+ * >+ * @param style >+ */ >+ public TargetMultAppearenceSelectionListener(int style) { >+ this.style = style; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ // add or remove the flag to the display property value (invert the current value) >+ targetMultDisplayValue = targetMultDisplayValue ^ style; >+ >+ // refresh buttons to show current values >+ refreshButtons(); >+ } >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomConstraintPropertyCompositePreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomConstraintPropertyCompositePreferencePage.java >new file mode 100644 >index 0000000..78f3e67 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomConstraintPropertyCompositePreferencePage.java >@@ -0,0 +1,327 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULTVALUE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DERIVE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MODIFIERS; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_NAME; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_UNDEFINED_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_VISIBILITY; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; >+ >+/** >+ * Preference page for Part and References. >+ */ >+public class CustomConstraintPropertyCompositePreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_CONSTRAINTBLOCKPROPERTY_AS_COMPOSITE_ID; //$NON-NLS-1$ >+ >+ public static String prefLabelKey = prefKey + "-" + UMLGraphicalTypes.LABEL_UML_PROPERTY_LABEL_ID; //$NON-NLS-1$ >+ >+ /** The compartments default visibility for preferences */ >+ public static final Map<String, Boolean> compartmentDefaultVisibilityMap; >+ >+ /** The compartment titles default visibility for preferences */ >+ public static final Map<String, Boolean> compartmentTitleDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ compartmentDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ compartmentDefaultVisibilityMap.put("structure", Boolean.TRUE); //$NON-NLS-1$ >+ >+ compartmentTitleDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ compartmentTitleDefaultVisibilityMap.put("structure", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ compartmentTitleDefaultVisibilityMap.remove("structure"); //$NON-NLS-1$ >+ compartmentTitleDefaultVisibilityMap.put("structure", Boolean.FALSE); //$NON-NLS-1$ >+ // End of user code >+ >+ Collections.unmodifiableMap(compartmentDefaultVisibilityMap); >+ Collections.unmodifiableMap(compartmentTitleDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public CustomConstraintPropertyCompositePreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_BLOCKPROPERTY_AS_COMPOSITE_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ // Start of user code custom default initializations >+// store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 200); >+// store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 100); >+ store.setDefault(LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE), DISP_NAME | DISP_TYPE | DISP_UNDEFINED_TYPE); >+ // End of user code >+ >+ // Initialize default visibility for compartments in preference page. >+ for(String compartmentName : compartmentDefaultVisibilityMap.keySet()) { >+ String showCompartmentKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_VISIBILITY); >+ store.setDefault(showCompartmentKey, compartmentDefaultVisibilityMap.get(compartmentName)); >+ } >+ >+ // Initialize default title visibility for compartments in preference page. >+ for(String compartmentName : compartmentTitleDefaultVisibilityMap.keySet()) { >+ String showCompartmentTitleKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY); >+ store.setDefault(showCompartmentTitleKey, compartmentTitleDefaultVisibilityMap.get(compartmentName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeCompartmentNamesList() { >+ for(String name : compartmentDefaultVisibilityMap.keySet()) { >+ this.compartmentNamesList.add(name); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeCompartmentTitlesList() { >+ for(String name : compartmentTitleDefaultVisibilityMap.keySet()) { >+ this.compartmentTitlesList.add(name); >+ } >+ } >+ >+ /** buttons to select the display mask of the label */ >+ protected Button bttnVisibility, bttnDerive, bttnName, bttnType, bttnUndefined_Type, bttnMultiplicity, bttnDefault_Multiplicity, bttnDefaultValue, bttnModifiers; >+ >+ private String labelDisplayPreferenceKey = LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE); >+ >+ /** current property display style */ >+ private int propertyValue = getPreferenceStore().getInt(labelDisplayPreferenceKey); >+ >+ /** >+ * Creates a button with the {@link SWT#CHECK} style. >+ * >+ * @param parent >+ * the parent of the button >+ * @param label >+ * the label of the button >+ * @param mask >+ * the value controlled by the button >+ * @return the button created >+ */ >+ protected Button createCheckButton(Composite parent, String label, int mask) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setText(label); >+ button.addSelectionListener(new AppearenceSelectionListener(mask)); >+ return button; >+ } >+ >+ /** >+ * Creates the group and check boxes to choose the kind of display >+ * >+ * @param parent >+ * the parent composite that holds the group >+ */ >+ protected void createLabelPreferencesButtons(Composite parent) { >+ // create group that host the buttons >+ Group group = new Group(parent, SWT.SHADOW_NONE); >+ group.setText("Label Display"); >+ group.setLayout(new FormLayout()); >+ >+ FormData data; >+ >+ bttnVisibility = createCheckButton(group, "Visibility", DISP_VISIBILITY); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(0, 0); >+ bttnVisibility.setLayoutData(data); >+ >+ bttnDerive = createCheckButton(group, "Derive", DISP_DERIVE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnDerive.setLayoutData(data); >+ >+ bttnName = createCheckButton(group, "Name", DISP_NAME); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnName.setLayoutData(data); >+ >+ bttnType = createCheckButton(group, "Type", DISP_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnType.setLayoutData(data); >+ >+ bttnUndefined_Type = createCheckButton(group, "Undefined_Type", DISP_UNDEFINED_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnUndefined_Type.setLayoutData(data); >+ >+ bttnMultiplicity = createCheckButton(group, "Multiplicity", DISP_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnMultiplicity.setLayoutData(data); >+ >+ bttnDefault_Multiplicity = createCheckButton(group, "Default_Multiplicity", DISP_DEFAULT_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnDefault_Multiplicity.setLayoutData(data); >+ >+ bttnDefaultValue = createCheckButton(group, "DefaultValue", DISP_DEFAULTVALUE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnDefaultValue.setLayoutData(data); >+ >+ bttnModifiers = createCheckButton(group, "Modifiers", DISP_MODIFIERS); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnUndefined_Type, ITabbedPropertyConstants.HSPACE); >+ bttnModifiers.setLayoutData(data); >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createPageContents(Composite parent) { >+ super.createPageContents(parent); >+ >+ // adds the label preferences check boxes >+ createLabelPreferencesButtons(parent); >+ >+ refreshButtons(); >+ } >+ >+ /** >+ * Load the default preferences of the fields contained in this page >+ */ >+ protected void loadDefaultPreferences() { >+ propertyValue = getPreferenceStore().getDefaultInt(labelDisplayPreferenceKey); >+ refreshButtons(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void performDefaults() { >+ loadDefaultPreferences(); >+ super.performDefaults(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean performOk() { >+ storePreferences(); >+ return super.performOk(); >+ } >+ >+ /** >+ * Refresh the buttons that manages the display. >+ */ >+ protected void refreshButtons() { >+ >+ bttnVisibility.setSelection((propertyValue & DISP_VISIBILITY) == DISP_VISIBILITY); >+ bttnDerive.setSelection((propertyValue & DISP_DERIVE) == DISP_DERIVE); >+ bttnName.setSelection((propertyValue & DISP_NAME) == DISP_NAME); >+ bttnType.setSelection((propertyValue & DISP_TYPE) == DISP_TYPE); >+ bttnUndefined_Type.setSelection((propertyValue & DISP_UNDEFINED_TYPE) == DISP_UNDEFINED_TYPE); >+ bttnMultiplicity.setSelection((propertyValue & DISP_MULTIPLICITY) == DISP_MULTIPLICITY); >+ bttnDefault_Multiplicity.setSelection((propertyValue & DISP_DEFAULT_MULTIPLICITY) == DISP_DEFAULT_MULTIPLICITY); >+ bttnDefaultValue.setSelection((propertyValue & DISP_DEFAULTVALUE) == DISP_DEFAULTVALUE); >+ bttnModifiers.setSelection((propertyValue & DISP_MODIFIERS) == DISP_MODIFIERS); >+ >+ } >+ >+ /** >+ * Stores the values of the fields contained in this page into the preference store. >+ */ >+ protected void storePreferences() { >+ super.storePreferences(); >+ IPreferenceStore store = getPreferenceStore(); >+ // checks the stored value and the actual one, so does not refresh diagram if it is not >+ // needed >+ if(propertyValue != store.getInt(labelDisplayPreferenceKey)) { >+ store.setValue(labelDisplayPreferenceKey, propertyValue); >+ } >+ } >+ >+ /** >+ * Listeners for the check buttons that select the display. >+ */ >+ private class AppearenceSelectionListener implements SelectionListener { >+ >+ /** The constant which refers the element to display or not. */ >+ final private int style; >+ >+ /** >+ * Default Constructor. >+ * >+ * @param style >+ */ >+ public AppearenceSelectionListener(int style) { >+ this.style = style; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ // add or remove the flag to the display property value (invert the current value) >+ propertyValue = propertyValue ^ style; >+ // refresh buttons to show current values >+ refreshButtons(); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomPreferenceInitializer.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomPreferenceInitializer.java >new file mode 100644 >index 0000000..4bf9d94 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/CustomPreferenceInitializer.java >@@ -0,0 +1,80 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.Activator; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+ >+/** >+ * Custom preferences initializer. >+ */ >+public class CustomPreferenceInitializer extends ParametricDiagramPreferenceInitializer { >+ >+ protected IPreferenceStore getPreferenceStore() { >+ return Activator.getInstance().getPreferenceStore(); >+ } >+ >+ @Override >+ public void initializeDefaultPreferences() { >+ super.initializeDefaultPreferences(); >+ >+ IPreferenceStore store = getPreferenceStore(); >+ >+ PortAsBorderItemPreferencePage.initDefaults(store); >+ ConstraintParameterAsBorderItemPreferencePage.initDefaults(store); >+ FlowPortAsBorderItemPreferencePage.initDefaults(store); >+ BlockPropertyCompositePreferencePage.initDefaults(store); >+ CustomConstraintPropertyCompositePreferencePage.initDefaults(store); >+ CustomConnectorPreferencePage.initDefaults(store); >+ >+ // Initialize default positions for labels. >+ initDefaultPosition(UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID, UMLGraphicalTypes.LINKLABEL_UML_NAMEDELEMENT_NAME_ID, 0, -10); >+ initDefaultPosition(UMLGraphicalTypes.LINK_UML_DEPENDENCY_ID, UMLGraphicalTypes.LINKLABEL_UML_APPLIEDSTEREOTYPE_ID, 0, -30); >+ >+ initDefaultPosition(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID, UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_LABEL_ID, 0, -10); >+ initDefaultPosition(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID, UMLGraphicalTypes.LINKLABEL_UML_APPLIEDSTEREOTYPE_ID, 0, -30); >+ initDefaultPosition(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID, UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_SOURCE_MULTIPLICITY_ID, 0, 10); >+ initDefaultPosition(UMLGraphicalTypes.LINK_UML_CONNECTOR_ID, UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_TARGET_MULTIPLICITY_ID, 0, 10); >+ >+ initDefaultPosition(UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID, UMLGraphicalTypes.AFFIXEDLABEL_UML_PORT_LABEL_ID, 30, 0); >+ initDefaultPosition(UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID, UMLGraphicalTypes.AFFIXEDLABEL_UML_APPLIEDSTEREOTYPE_ID, 30, -20); >+ >+ initDefaultPosition(SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID, SysMLGraphicalTypes.AFFIXEDLABEL_SYSML_FLOWPORT_LABEL_ID, 30, 0); >+ initDefaultPosition(SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID, UMLGraphicalTypes.AFFIXEDLABEL_UML_APPLIEDSTEREOTYPE_ID, 30, -20); >+ } >+ >+ /** >+ * Initialize default position of a link label in preferences. >+ * >+ * @param parentGraphicalType >+ * the graphical type of the view owning the label >+ * @param graphicalType >+ * the graphical type of the label >+ * @param x >+ * @param y >+ */ >+ protected void initDefaultPosition(String parentGraphicalType, String graphicalType, int x, int y) { >+ IPreferenceStore store = getPreferenceStore(); >+ >+ String xKey = PreferenceConstantHelper.getElementConstant(ElementTypes.DIAGRAM_ID + "_" + parentGraphicalType + "-" + graphicalType, PreferenceConstantHelper.LOCATION_X); >+ String yKey = PreferenceConstantHelper.getElementConstant(ElementTypes.DIAGRAM_ID + "_" + parentGraphicalType + "-" + graphicalType, PreferenceConstantHelper.LOCATION_Y); >+ >+ store.setDefault(xKey, x); >+ store.setDefault(yKey, y); >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramAppearancePreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramAppearancePreferencePage.java >deleted file mode 100644 >index ac8ef06..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramAppearancePreferencePage.java >+++ /dev/null >@@ -1,31 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import org.eclipse.gmf.runtime.diagram.ui.preferences.AppearancePreferencePage; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class DiagramAppearancePreferencePage extends AppearancePreferencePage { >- >- /** >- * @generated >- */ >- public DiagramAppearancePreferencePage() { >- setPreferenceStore(SysmlDiagramEditorPlugin.getInstance().getPreferenceStore()); >- >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramConnectionsPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramConnectionsPreferencePage.java >deleted file mode 100644 >index 5434ff5..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramConnectionsPreferencePage.java >+++ /dev/null >@@ -1,31 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import org.eclipse.gmf.runtime.diagram.ui.preferences.ConnectionsPreferencePage; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class DiagramConnectionsPreferencePage extends ConnectionsPreferencePage { >- >- /** >- * @generated >- */ >- public DiagramConnectionsPreferencePage() { >- setPreferenceStore(SysmlDiagramEditorPlugin.getInstance().getPreferenceStore()); >- >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramGeneralPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramGeneralPreferencePage.java >deleted file mode 100644 >index a6f94f2..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramGeneralPreferencePage.java >+++ /dev/null >@@ -1,33 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.DiagramPreferencePage; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class DiagramGeneralPreferencePage extends DiagramPreferencePage { >- >- /** >- * @generated >- */ >- public DiagramGeneralPreferencePage() { >- setPreferenceStore(SysmlDiagramEditorPlugin.getInstance().getPreferenceStore()); >- setPreferenceKey(ParametricEditPart.MODEL_ID); >- >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramPreferenceInitializer.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramPreferenceInitializer.java >deleted file mode 100644 >index 3a217ec..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramPreferenceInitializer.java >+++ /dev/null >@@ -1,45 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class DiagramPreferenceInitializer extends AbstractPreferenceInitializer { >- >- /** >- * @generated >- */ >- public void initializeDefaultPreferences() { >- IPreferenceStore store = getPreferenceStore(); >- >- ConstraintPropertyPreferencePage.initDefaults(store); >- >- PropertyPreferencePage.initDefaults(store); >- >- ConnectorPreferencePage.initDefaults(store); >- >- } >- >- /** >- * @generated >- */ >- protected IPreferenceStore getPreferenceStore() { >- return SysmlDiagramEditorPlugin.getInstance().getPreferenceStore(); >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramPrintingPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramPrintingPreferencePage.java >deleted file mode 100644 >index 4965ef4..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramPrintingPreferencePage.java >+++ /dev/null >@@ -1,31 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import org.eclipse.gmf.runtime.diagram.ui.preferences.PrintingPreferencePage; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class DiagramPrintingPreferencePage extends PrintingPreferencePage { >- >- /** >- * @generated >- */ >- public DiagramPrintingPreferencePage() { >- setPreferenceStore(SysmlDiagramEditorPlugin.getInstance().getPreferenceStore()); >- >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramRulersAndGridPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramRulersAndGridPreferencePage.java >deleted file mode 100644 >index fd700ed..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/DiagramRulersAndGridPreferencePage.java >+++ /dev/null >@@ -1,31 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import org.eclipse.gmf.runtime.diagram.ui.preferences.RulerGridPreferencePage; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class DiagramRulersAndGridPreferencePage extends RulerGridPreferencePage { >- >- /** >- * @generated >- */ >- public DiagramRulersAndGridPreferencePage() { >- setPreferenceStore(SysmlDiagramEditorPlugin.getInstance().getPreferenceStore()); >- >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/FlowPortAsBorderItemPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/FlowPortAsBorderItemPreferencePage.java >new file mode 100644 >index 0000000..277a5cd >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/FlowPortAsBorderItemPreferencePage.java >@@ -0,0 +1,310 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULTVALUE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DERIVE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DIRECTION; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MODIFIERS; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_NAME; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_UNDEFINED_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_VISIBILITY; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; >+ >+/** >+ * FlowPort preference page. >+ */ >+public class FlowPortAsBorderItemPreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID; //$NON-NLS-1$ >+ >+ public static String prefLabelKey = prefKey + "-" + SysMLGraphicalTypes.AFFIXEDLABEL_SYSML_FLOWPORT_LABEL_ID; //$NON-NLS-1$ >+ >+ /** The labels default visibility for preferences */ >+ public static final Map<String, Boolean> labelDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ labelDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ labelDefaultVisibilityMap.put("Stereotype", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("Label", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(labelDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public FlowPortAsBorderItemPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ >+ store.setDefault(LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE), DISP_DIRECTION | DISP_NAME | DISP_TYPE | DISP_UNDEFINED_TYPE); >+ >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 20); >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 20); >+ >+ // Initialize default visibility for labels in preference page. >+ for(String labelName : labelDefaultVisibilityMap.keySet()) { >+ String showLabelKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, labelName, PreferenceConstantHelper.LABEL_VISIBILITY); >+ store.setDefault(showLabelKey, labelDefaultVisibilityMap.get(labelName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeLabelsList() { >+ for(String name : labelDefaultVisibilityMap.keySet()) { >+ this.labelsList.add(name); >+ } >+ } >+ >+ /** buttons to select the display mask of the label */ >+ protected Button bttnDirection, bttnVisibility, bttnDerive, bttnName, bttnType, bttnUndefined_Type, bttnMultiplicity, bttnDefault_Multiplicity, bttnDefaultValue, bttnModifiers; >+ >+ private String labelDisplayPreferenceKey = LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE); >+ >+ /** current property display style */ >+ private int propertyValue = getPreferenceStore().getInt(labelDisplayPreferenceKey); >+ >+ /** >+ * Creates a button with the {@link SWT#CHECK} style. >+ * >+ * @param parent >+ * the parent of the button >+ * @param label >+ * the label of the button >+ * @param mask >+ * the value controlled by the button >+ * @return the button created >+ */ >+ protected Button createCheckButton(Composite parent, String label, int mask) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setText(label); >+ button.addSelectionListener(new AppearenceSelectionListener(mask)); >+ return button; >+ } >+ >+ /** >+ * Creates the group and check boxes to choose the kind of display >+ * >+ * @param parent >+ * the parent composite that holds the group >+ */ >+ protected void createLabelPreferencesButtons(Composite parent) { >+ // create group that host the buttons >+ Group group = new Group(parent, SWT.SHADOW_NONE); >+ group.setText("Label Display"); >+ group.setLayout(new FormLayout()); >+ >+ FormData data; >+ >+ bttnDirection = createCheckButton(group, "Direction", DISP_DIRECTION); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(0, 0); >+ bttnDirection.setLayoutData(data); >+ >+ bttnVisibility = createCheckButton(group, "Visibility", DISP_VISIBILITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDirection, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnVisibility.setLayoutData(data); >+ >+ bttnDerive = createCheckButton(group, "Derive", DISP_DERIVE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnDerive.setLayoutData(data); >+ >+ bttnName = createCheckButton(group, "Name", DISP_NAME); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnName.setLayoutData(data); >+ >+ bttnType = createCheckButton(group, "Type", DISP_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnDirection, ITabbedPropertyConstants.HSPACE); >+ bttnType.setLayoutData(data); >+ >+ bttnUndefined_Type = createCheckButton(group, "Undefined_Type", DISP_UNDEFINED_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDirection, 85); >+ data.top = new FormAttachment(bttnDirection, ITabbedPropertyConstants.HSPACE); >+ bttnUndefined_Type.setLayoutData(data); >+ >+ bttnMultiplicity = createCheckButton(group, "Multiplicity", DISP_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(bttnDirection, ITabbedPropertyConstants.HSPACE); >+ bttnMultiplicity.setLayoutData(data); >+ >+ bttnDefault_Multiplicity = createCheckButton(group, "Default_Multiplicity", DISP_DEFAULT_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(bttnDirection, ITabbedPropertyConstants.HSPACE); >+ bttnDefault_Multiplicity.setLayoutData(data); >+ >+ bttnDefaultValue = createCheckButton(group, "DefaultValue", DISP_DEFAULTVALUE); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnType, ITabbedPropertyConstants.HSPACE); >+ bttnDefaultValue.setLayoutData(data); >+ >+ bttnModifiers = createCheckButton(group, "Modifiers", DISP_MODIFIERS); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDirection, 85); >+ data.top = new FormAttachment(bttnType, ITabbedPropertyConstants.HSPACE); >+ bttnModifiers.setLayoutData(data); >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createPageContents(Composite parent) { >+ super.createPageContents(parent); >+ >+ // adds the label preferences check boxes >+ createLabelPreferencesButtons(parent); >+ >+ refreshButtons(); >+ } >+ >+ /** >+ * Load the default preferences of the fields contained in this page >+ */ >+ protected void loadDefaultPreferences() { >+ propertyValue = getPreferenceStore().getDefaultInt(labelDisplayPreferenceKey); >+ refreshButtons(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void performDefaults() { >+ loadDefaultPreferences(); >+ super.performDefaults(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean performOk() { >+ storePreferences(); >+ return super.performOk(); >+ } >+ >+ /** >+ * Refresh the buttons that manages the display. >+ */ >+ protected void refreshButtons() { >+ >+ bttnDirection.setSelection((propertyValue & DISP_DIRECTION) == DISP_DIRECTION); >+ bttnVisibility.setSelection((propertyValue & DISP_VISIBILITY) == DISP_VISIBILITY); >+ bttnDerive.setSelection((propertyValue & DISP_DERIVE) == DISP_DERIVE); >+ bttnName.setSelection((propertyValue & DISP_NAME) == DISP_NAME); >+ bttnType.setSelection((propertyValue & DISP_TYPE) == DISP_TYPE); >+ bttnUndefined_Type.setSelection((propertyValue & DISP_UNDEFINED_TYPE) == DISP_UNDEFINED_TYPE); >+ bttnMultiplicity.setSelection((propertyValue & DISP_MULTIPLICITY) == DISP_MULTIPLICITY); >+ bttnDefault_Multiplicity.setSelection((propertyValue & DISP_DEFAULT_MULTIPLICITY) == DISP_DEFAULT_MULTIPLICITY); >+ bttnDefaultValue.setSelection((propertyValue & DISP_DEFAULTVALUE) == DISP_DEFAULTVALUE); >+ bttnModifiers.setSelection((propertyValue & DISP_MODIFIERS) == DISP_MODIFIERS); >+ >+ } >+ >+ /** >+ * Stores the values of the fields contained in this page into the preference store. >+ */ >+ protected void storePreferences() { >+ super.storePreferences(); >+ IPreferenceStore store = getPreferenceStore(); >+ // checks the stored value and the actual one, so does not refresh diagram if it is not >+ // needed >+ if(propertyValue != store.getInt(labelDisplayPreferenceKey)) { >+ store.setValue(labelDisplayPreferenceKey, propertyValue); >+ } >+ } >+ >+ /** >+ * Listeners for the check buttons that select the display. >+ */ >+ private class AppearenceSelectionListener implements SelectionListener { >+ >+ /** The constant which refers the element to display or not. */ >+ final private int style; >+ >+ /** >+ * Default Constructor. >+ * >+ * @param style >+ */ >+ public AppearenceSelectionListener(int style) { >+ this.style = style; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ // add or remove the flag to the display property value (invert the current value) >+ propertyValue = propertyValue ^ style; >+ // refresh buttons to show current values >+ refreshButtons(); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PortAsBorderItemPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PortAsBorderItemPreferencePage.java >new file mode 100644 >index 0000000..5848eef >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PortAsBorderItemPreferencePage.java >@@ -0,0 +1,301 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >+ >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULTVALUE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_DERIVE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MODIFIERS; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_MULTIPLICITY; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_NAME; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_UNDEFINED_TYPE; >+import static org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants.DISP_VISIBILITY; >+ >+import java.util.Collections; >+import java.util.LinkedHashMap; >+import java.util.Map; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; >+import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; >+import org.eclipse.papyrus.sysml.diagram.parametric.provider.ElementTypes; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; >+ >+/** >+ * {@link Port} preference page. >+ */ >+public class PortAsBorderItemPreferencePage extends ParametricDiagramNodePreferencePage { >+ >+ /** Constant key to access preferences */ >+ public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID; //$NON-NLS-1$ >+ >+ public static String prefLabelKey = prefKey + "-" + UMLGraphicalTypes.AFFIXEDLABEL_UML_PORT_LABEL_ID; //$NON-NLS-1$ >+ >+ /** The labels default visibility for preferences */ >+ public static final Map<String, Boolean> labelDefaultVisibilityMap; >+ >+ /** Static attribute initialization */ >+ static { >+ labelDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); >+ labelDefaultVisibilityMap.put("Stereotype", Boolean.TRUE); //$NON-NLS-1$ >+ labelDefaultVisibilityMap.put("Label", Boolean.TRUE); //$NON-NLS-1$ >+ >+ // Start of user code custom static initializations >+ // End of user code >+ >+ Collections.unmodifiableMap(labelDefaultVisibilityMap); >+ } >+ >+ /** Constructor */ >+ public PortAsBorderItemPreferencePage() { >+ super(); >+ setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID); //$NON-NLS-1$ >+ } >+ >+ /** Default preferences initializer */ >+ public static void initDefaults(IPreferenceStore store) { >+ store.setDefault(LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE), DISP_NAME | DISP_TYPE | DISP_MULTIPLICITY | DISP_UNDEFINED_TYPE); >+ >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 20); >+ store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 20); >+ >+ // Initialize default visibility for labels in preference page. >+ for(String labelName : labelDefaultVisibilityMap.keySet()) { >+ String showLabelKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, labelName, PreferenceConstantHelper.LABEL_VISIBILITY); >+ store.setDefault(showLabelKey, labelDefaultVisibilityMap.get(labelName)); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void initializeLabelsList() { >+ for(String name : labelDefaultVisibilityMap.keySet()) { >+ this.labelsList.add(name); >+ } >+ } >+ >+ /** buttons to select the display mask of the label */ >+ protected Button bttnVisibility, bttnDerive, bttnName, bttnType, bttnUndefined_Type, bttnMultiplicity, bttnDefault_Multiplicity, bttnDefaultValue, bttnModifiers; >+ >+ private String labelDisplayPreferenceKey = LabelPreferenceHelper.getPreferenceConstant(prefLabelKey, ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE); >+ >+ /** current property display style */ >+ private int propertyValue = getPreferenceStore().getInt(labelDisplayPreferenceKey); >+ >+ /** >+ * Creates a button with the {@link SWT#CHECK} style. >+ * >+ * @param parent >+ * the parent of the button >+ * @param label >+ * the label of the button >+ * @param mask >+ * the value controlled by the button >+ * @return the button created >+ */ >+ protected Button createCheckButton(Composite parent, String label, int mask) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setText(label); >+ button.addSelectionListener(new AppearenceSelectionListener(mask)); >+ return button; >+ } >+ >+ /** >+ * Creates the group and check boxes to choose the kind of display >+ * >+ * @param parent >+ * the parent composite that holds the group >+ */ >+ protected void createLabelPreferencesButtons(Composite parent) { >+ // create group that host the buttons >+ Group group = new Group(parent, SWT.SHADOW_NONE); >+ group.setText("Label Display"); >+ group.setLayout(new FormLayout()); >+ >+ FormData data; >+ >+ bttnVisibility = createCheckButton(group, "Visibility", DISP_VISIBILITY); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(0, 0); >+ bttnVisibility.setLayoutData(data); >+ >+ bttnDerive = createCheckButton(group, "Derive", DISP_DERIVE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnDerive.setLayoutData(data); >+ >+ bttnName = createCheckButton(group, "Name", DISP_NAME); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnName.setLayoutData(data); >+ >+ bttnType = createCheckButton(group, "Type", DISP_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(0, 0); >+ bttnType.setLayoutData(data); >+ >+ bttnUndefined_Type = createCheckButton(group, "Undefined_Type", DISP_UNDEFINED_TYPE); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnUndefined_Type.setLayoutData(data); >+ >+ bttnMultiplicity = createCheckButton(group, "Multiplicity", DISP_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnVisibility, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnMultiplicity.setLayoutData(data); >+ >+ bttnDefault_Multiplicity = createCheckButton(group, "Default_Multiplicity", DISP_DEFAULT_MULTIPLICITY); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnDerive, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnDefault_Multiplicity.setLayoutData(data); >+ >+ bttnDefaultValue = createCheckButton(group, "DefaultValue", DISP_DEFAULTVALUE); >+ data = new FormData(); >+ data.left = new FormAttachment(bttnName, 85); >+ data.top = new FormAttachment(bttnVisibility, ITabbedPropertyConstants.HSPACE); >+ bttnDefaultValue.setLayoutData(data); >+ >+ bttnModifiers = createCheckButton(group, "Modifiers", DISP_MODIFIERS); >+ data = new FormData(); >+ data.left = new FormAttachment(0, 0); >+ data.top = new FormAttachment(bttnUndefined_Type, ITabbedPropertyConstants.HSPACE); >+ bttnModifiers.setLayoutData(data); >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void createPageContents(Composite parent) { >+ super.createPageContents(parent); >+ >+ // adds the label preferences check boxes >+ createLabelPreferencesButtons(parent); >+ >+ refreshButtons(); >+ } >+ >+ /** >+ * Load the default preferences of the fields contained in this page >+ */ >+ protected void loadDefaultPreferences() { >+ propertyValue = getPreferenceStore().getDefaultInt(labelDisplayPreferenceKey); >+ refreshButtons(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected void performDefaults() { >+ loadDefaultPreferences(); >+ super.performDefaults(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean performOk() { >+ storePreferences(); >+ return super.performOk(); >+ } >+ >+ /** >+ * Refresh the buttons that manages the display. >+ */ >+ protected void refreshButtons() { >+ >+ bttnVisibility.setSelection((propertyValue & DISP_VISIBILITY) == DISP_VISIBILITY); >+ bttnDerive.setSelection((propertyValue & DISP_DERIVE) == DISP_DERIVE); >+ bttnName.setSelection((propertyValue & DISP_NAME) == DISP_NAME); >+ bttnType.setSelection((propertyValue & DISP_TYPE) == DISP_TYPE); >+ bttnUndefined_Type.setSelection((propertyValue & DISP_UNDEFINED_TYPE) == DISP_UNDEFINED_TYPE); >+ bttnMultiplicity.setSelection((propertyValue & DISP_MULTIPLICITY) == DISP_MULTIPLICITY); >+ bttnDefault_Multiplicity.setSelection((propertyValue & DISP_DEFAULT_MULTIPLICITY) == DISP_DEFAULT_MULTIPLICITY); >+ bttnDefaultValue.setSelection((propertyValue & DISP_DEFAULTVALUE) == DISP_DEFAULTVALUE); >+ bttnModifiers.setSelection((propertyValue & DISP_MODIFIERS) == DISP_MODIFIERS); >+ >+ } >+ >+ /** >+ * Stores the values of the fields contained in this page into the preference store. >+ */ >+ protected void storePreferences() { >+ super.storePreferences(); >+ IPreferenceStore store = getPreferenceStore(); >+ // checks the stored value and the actual one, so does not refresh diagram if it is not >+ // needed >+ if(propertyValue != store.getInt(labelDisplayPreferenceKey)) { >+ store.setValue(labelDisplayPreferenceKey, propertyValue); >+ } >+ } >+ >+ /** >+ * Listeners for the check buttons that select the display. >+ */ >+ private class AppearenceSelectionListener implements SelectionListener { >+ >+ /** The constant which refers the element to display or not. */ >+ final private int style; >+ >+ /** >+ * Default Constructor. >+ * >+ * @param style >+ */ >+ public AppearenceSelectionListener(int style) { >+ this.style = style; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ // add or remove the flag to the display property value (invert the current value) >+ propertyValue = propertyValue ^ style; >+ // refresh buttons to show current values >+ refreshButtons(); >+ } >+ } >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PropertyPreferencePage.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PropertyPreferencePage.java >deleted file mode 100644 >index 543e336..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/preferences/PropertyPreferencePage.java >+++ /dev/null >@@ -1,64 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.preferences; >- >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.AbstractPapyrusNodePreferencePage; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class PropertyPreferencePage extends AbstractPapyrusNodePreferencePage { >- >- /** >- * @generated >- */ >- public PropertyPreferencePage() { >- super(); >- setPreferenceKey(ParametricEditPart.MODEL_ID + "_Property"); >- } >- >- /** >- * @generated >- */ >- @Override >- protected String getBundleId() { >- return SysmlDiagramEditorPlugin.ID; >- } >- >- /** >- * @generated >- */ >- public static void initDefaults(IPreferenceStore store) { >- >- String key = ParametricEditPart.MODEL_ID + "_Property"; >- store.setDefault(PreferenceConstantHelper.getElementConstant(key, PreferenceConstantHelper.WIDTH), 40); >- store.setDefault(PreferenceConstantHelper.getElementConstant(key, PreferenceConstantHelper.HEIGHT), 40); >- >- //org.eclipse.jface.preference.PreferenceConverter.setDefault(store, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255)); >- //org.eclipse.jface.preference.PreferenceConverter.setDefault(store, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0)); >- >- // Set the default for the gradient >- //store.setDefault(org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.GRADIENT_POLICY),false); >- //org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter gradientPreferenceConverter = new org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter( >- // new org.eclipse.swt.graphics.RGB(255, 255, 255), >- // new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0); >- //store.setDefault(org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue()); >- >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomEditPolicyProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomEditPolicyProvider.java >new file mode 100644 >index 0000000..4dcdad1 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/provider/CustomEditPolicyProvider.java >@@ -0,0 +1,188 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import org.eclipse.gef.EditPart; >+import org.eclipse.gef.EditPolicy; >+import org.eclipse.gmf.runtime.common.core.service.IOperation; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; >+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; >+import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultCreationEditPolicy; >+import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultGraphicalNodeEditPolicy; >+import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultXYLayoutEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.BlockPropertyStructureCompartmentEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.ConstraintBlockPropertyCompositeEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.FlowPortAffixedNodeEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.part.StructureCompartmentEditPart; >+import org.eclipse.papyrus.sysml.diagram.common.edit.policy.CustomDuplicatePasteEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.part.InternalBlockDiagramEditPart; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomBlockCompositeSemanticEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomBlockPropertyCompositeDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomDefaultSemanticEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomDiagramDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.CustomDragDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.EncapsulatedClassifierDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.StructureClassifierDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy.TypedElementDropEditPolicy; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.CustomBlockCompositeEditPartTN; >+import org.eclipse.papyrus.sysml.diagram.parametric.edit.part.ParametricDiagramEditPart; >+import org.eclipse.papyrus.sysml.diagram.parametric.policies.CustomParametricSemanticPolicy; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementBorderEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementLinkEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConnectorEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.ConstraintParameterAffixedNodeEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.DependencyEditPart; >+import org.eclipse.papyrus.uml.diagram.common.edit.part.PortAffixedNodeEditPart; >+import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy; >+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CommentEditPart; >+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CommentEditPartCN; >+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConstraintEditPart; >+import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConstraintEditPartCN; >+ >+/** >+ * Custom edit policy provider. >+ */ >+public class CustomEditPolicyProvider extends ParametricDiagramEditPolicyProvider { >+ >+ @Override >+ public boolean provides(IOperation operation) { >+ >+ CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation)operation; >+ if(!(epOperation.getEditPart() instanceof IGraphicalEditPart)) { >+ return false; >+ } >+ >+ // Make sure this concern Parametric Diagram only >+ IGraphicalEditPart gep = (IGraphicalEditPart)epOperation.getEditPart(); >+ String diagramType = gep.getNotationView().getDiagram().getType(); >+ if(!ElementTypes.DIAGRAM_ID.equals(diagramType)) { >+ return false; >+ } >+ >+ // provides for the main diagram edit part >+ if(gep instanceof ParametricDiagramEditPart) { >+ return true; >+ } >+ >+ // Provides for edit parts that represent nodes in Internal Block diagram >+ if(gep instanceof AbstractElementEditPart) { >+ return true; >+ } >+ if(gep instanceof AbstractElementBorderEditPart) { >+ return true; >+ } >+ >+ // Provides for edit parts that represent edges in Internal Block diagram >+ if(gep instanceof AbstractElementLinkEditPart) { >+ return true; >+ } >+ >+ if(gep instanceof ResizableCompartmentEditPart) { >+ return true; >+ } >+ >+ return super.provides(operation); >+ } >+ >+ @Override >+ public void createEditPolicies(EditPart editPart) { >+ super.createEditPolicies(editPart); >+ >+ if(editPart instanceof InternalBlockDiagramEditPart) { >+ editPart.installEditPolicy(DuplicatePasteEditPolicy.PASTE_ROLE, new CustomDuplicatePasteEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDropEditPolicy()); >+ // no installation of other policies. >+ return; >+ } >+ >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDragDropEditPolicy()); >+ >+ if((editPart instanceof ConstraintEditPart) || (editPart instanceof ConstraintEditPartCN)) { >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultSemanticEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); >+ editPart.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); >+ } >+ >+ if((editPart instanceof CommentEditPart) || (editPart instanceof CommentEditPartCN)) { >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultSemanticEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); >+ editPart.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); >+ } >+ >+ if(editPart instanceof FlowPortAffixedNodeEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new TypedElementDropEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+ >+ if(editPart instanceof PortAffixedNodeEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new TypedElementDropEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+ >+ if(editPart instanceof BlockPropertyCompositeEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomBlockPropertyCompositeDropEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+ >+ /* >+ * if(editPart instanceof NestedBlockPropertyCompositeEditPart) { >+ * editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomBlockPropertyCompositeDropEditPolicy()); >+ * editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomNestedBlockPropertyCompositeSemanticEditPolicy()); >+ * } >+ */ >+ >+ if(editPart instanceof BlockPropertyStructureCompartmentEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy()); >+ editPart.installEditPolicy(EditPolicy.LAYOUT_ROLE, new DefaultXYLayoutEditPolicy()); >+ } >+ >+ if(editPart instanceof BlockCompositeEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new EncapsulatedClassifierDropEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomBlockCompositeSemanticEditPolicy()); >+ } >+ >+ if(editPart instanceof StructureCompartmentEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new StructureClassifierDropEditPolicy()); >+ editPart.installEditPolicy(EditPolicy.LAYOUT_ROLE, new DefaultXYLayoutEditPolicy()); >+ } >+ >+ if(editPart instanceof DependencyEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultSemanticEditPolicy()); >+ } >+ >+ if(editPart instanceof ConnectorEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultSemanticEditPolicy()); >+ } >+ >+ if(editPart instanceof ConstraintBlockPropertyCompositeEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomBlockPropertyCompositeDropEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+ if(editPart instanceof ConstraintParameterAffixedNodeEditPart) { >+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new TypedElementDropEditPolicy()); >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+ if(editPart instanceof CustomBlockCompositeEditPartTN) { >+ editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomParametricSemanticPolicy()); >+ } >+ >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParserProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParserProvider.java >new file mode 100644 >index 0000000..f671379 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/provider/ParserProvider.java >@@ -0,0 +1,107 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.provider; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; >+import org.eclipse.gmf.runtime.common.core.service.IOperation; >+import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation; >+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider; >+import org.eclipse.gmf.runtime.notation.Diagram; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.sysml.diagram.common.parser.FlowPortLabelParser; >+import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes; >+import org.eclipse.papyrus.sysml.diagram.parametric.parser.ParametricFrameParser; >+import org.eclipse.papyrus.uml.diagram.common.parser.ConnectorLabelParser; >+import org.eclipse.papyrus.uml.diagram.common.parser.ConstraintLabelParser; >+import org.eclipse.papyrus.uml.diagram.common.parser.MultiplicityElementLabelParser; >+import org.eclipse.papyrus.uml.diagram.common.parser.NamedElementLabelParser; >+import org.eclipse.papyrus.uml.diagram.common.parser.PropertyLabelParser; >+import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; >+ >+/** >+ * Parser provider for labels used by this diagram. >+ */ >+public class ParserProvider extends AbstractProvider implements IParserProvider { >+ >+ /** map from graphical hint to parsers */ >+ private static final Map<String, IParser> graphicalHintToParser = new HashMap<String, IParser>(); >+ >+ static { >+ graphicalHintToParser.put(SysMLGraphicalTypes.LABEL_SYSML_BLOCK_NAME_ID, new ParametricFrameParser()); >+ graphicalHintToParser.put(UMLGraphicalTypes.LABEL_UML_PROPERTY_LABEL_ID, new PropertyLabelParser()); >+ graphicalHintToParser.put(UMLGraphicalTypes.SHAPE_UML_CONSTRAINT_AS_LABEL_ID, new ConstraintLabelParser()); >+ >+ graphicalHintToParser.put(UMLGraphicalTypes.AFFIXEDLABEL_UML_PORT_LABEL_ID, new PropertyLabelParser()); >+ graphicalHintToParser.put(SysMLGraphicalTypes.AFFIXEDLABEL_SYSML_FLOWPORT_LABEL_ID, new FlowPortLabelParser()); >+ >+ graphicalHintToParser.put(UMLGraphicalTypes.LINKLABEL_UML_NAMEDELEMENT_NAME_ID, new NamedElementLabelParser()); >+ graphicalHintToParser.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_LABEL_ID, new ConnectorLabelParser()); >+ graphicalHintToParser.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_SOURCE_MULTIPLICITY_ID, new MultiplicityElementLabelParser()); >+ graphicalHintToParser.put(UMLGraphicalTypes.LINKLABEL_UML_CONNECTOR_TARGET_MULTIPLICITY_ID, new MultiplicityElementLabelParser()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean provides(IOperation operation) { >+ if(operation instanceof GetParserOperation) { >+ IAdaptable hint = ((GetParserOperation)operation).getHint(); >+ >+ if(!ElementTypes.DIAGRAM_ID.equals(getDiagramType(hint))) { >+ return false; >+ } >+ >+ return getParser(hint) != null; >+ } >+ return false; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IParser getParser(IAdaptable hint) { >+ String parserHint = (String)hint.getAdapter(String.class); >+ if(parserHint != null) { >+ IParser parser = graphicalHintToParser.get(parserHint); >+ if(parser != null) { >+ return parser; >+ } >+ } >+ >+ View view = (View)hint.getAdapter(View.class); >+ if(view != null) { >+ IParser parser = graphicalHintToParser.get(view.getType()); >+ if(parser != null) { >+ return parser; >+ } >+ } >+ >+ return null; >+ } >+ >+ private String getDiagramType(IAdaptable hint) { >+ Diagram diagram = (Diagram)hint.getAdapter(Diagram.class); >+ if(diagram != null) { >+ return diagram.getType(); >+ } >+ >+ return "undefined"; >+ } >+ >+} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ElementInitializers.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ElementInitializers.java >deleted file mode 100644 >index 6d0aabf..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/ElementInitializers.java >+++ /dev/null >@@ -1,38 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >- >-/** >- * @generated >- */ >-public class ElementInitializers { >- >- protected ElementInitializers() { >- // use #getInstance to access cached instance >- } >- >- /** >- * @generated >- */ >- public static ElementInitializers getInstance() { >- ElementInitializers cached = SysmlDiagramEditorPlugin.getInstance().getElementInitializers(); >- if(cached == null) { >- SysmlDiagramEditorPlugin.getInstance().setElementInitializers(cached = new ElementInitializers()); >- } >- return cached; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlEditPartProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlEditPartProvider.java >deleted file mode 100644 >index 9676592..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlEditPartProvider.java >+++ /dev/null >@@ -1,154 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import java.lang.ref.WeakReference; >- >-import org.eclipse.gef.EditPart; >-import org.eclipse.gef.EditPartFactory; >-import org.eclipse.gmf.runtime.common.core.service.IOperation; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.services.editpart.AbstractEditPartProvider; >-import org.eclipse.gmf.runtime.diagram.ui.services.editpart.CreateGraphicEditPartOperation; >-import org.eclipse.gmf.runtime.diagram.ui.services.editpart.IEditPartOperation; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.SysmlEditPartFactory; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >- >-/** >- * @generated >- */ >-public class SysmlEditPartProvider extends AbstractEditPartProvider { >- >- /** >- * @generated >- */ >- private EditPartFactory factory; >- >- /** >- * @generated >- */ >- private boolean allowCaching; >- >- /** >- * @generated >- */ >- private WeakReference cachedPart; >- >- /** >- * @generated >- */ >- private WeakReference cachedView; >- >- /** >- * @generated >- */ >- public SysmlEditPartProvider() { >- setFactory(new SysmlEditPartFactory()); >- setAllowCaching(true); >- } >- >- /** >- * @generated >- */ >- public final EditPartFactory getFactory() { >- return factory; >- } >- >- /** >- * @generated >- */ >- protected void setFactory(EditPartFactory factory) { >- this.factory = factory; >- } >- >- /** >- * @generated >- */ >- public final boolean isAllowCaching() { >- return allowCaching; >- } >- >- /** >- * @generated >- */ >- protected synchronized void setAllowCaching(boolean allowCaching) { >- this.allowCaching = allowCaching; >- if(!allowCaching) { >- cachedPart = null; >- cachedView = null; >- } >- } >- >- /** >- * @generated >- */ >- protected IGraphicalEditPart createEditPart(View view) { >- EditPart part = factory.createEditPart(null, view); >- if(part instanceof IGraphicalEditPart) { >- return (IGraphicalEditPart)part; >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected IGraphicalEditPart getCachedPart(View view) { >- if(cachedView != null && cachedView.get() == view) { >- return (IGraphicalEditPart)cachedPart.get(); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- public synchronized IGraphicalEditPart createGraphicEditPart(View view) { >- if(isAllowCaching()) { >- IGraphicalEditPart part = getCachedPart(view); >- cachedPart = null; >- cachedView = null; >- if(part != null) { >- return part; >- } >- } >- return createEditPart(view); >- } >- >- /** >- * @generated >- */ >- public synchronized boolean provides(IOperation operation) { >- if(operation instanceof CreateGraphicEditPartOperation) { >- View view = ((IEditPartOperation)operation).getView(); >- if(!ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID(view))) { >- return false; >- } >- if(isAllowCaching() && getCachedPart(view) != null) { >- return true; >- } >- IGraphicalEditPart part = createEditPart(view); >- if(part != null) { >- if(isAllowCaching()) { >- cachedPart = new WeakReference(part); >- cachedView = new WeakReference(view); >- } >- return true; >- } >- } >- return false; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlElementTypes.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlElementTypes.java >deleted file mode 100644 >index 68610eb..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlElementTypes.java >+++ /dev/null >@@ -1,252 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import java.util.HashSet; >-import java.util.IdentityHashMap; >-import java.util.Map; >-import java.util.Set; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.ecore.EClass; >-import org.eclipse.emf.ecore.EClassifier; >-import org.eclipse.emf.ecore.ENamedElement; >-import org.eclipse.emf.ecore.EStructuralFeature; >-import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.jface.resource.ImageRegistry; >-import org.eclipse.papyrus.resource.ResourcePackage; >-import org.eclipse.papyrus.sysml.constraints.ConstraintsPackage; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.uml2.uml.UMLPackage; >- >-/** >- * @generated >- */ >-public class SysmlElementTypes { >- >- /** >- * @generated >- */ >- private SysmlElementTypes() { >- } >- >- /** >- * @generated >- */ >- private static Map<IElementType, ENamedElement> elements; >- >- /** >- * @generated >- */ >- private static ImageRegistry imageRegistry; >- >- /** >- * @generated >- */ >- private static Set<IElementType> KNOWN_ELEMENT_TYPES; >- >- /** >- * @generated >- */ >- public static final IElementType Resource_1000 = getElementType("org.eclipse.papyrus.sysml.diagram.parametric.Resource_1000"); //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static final IElementType ConstraintProperty_2003 = getElementType("org.eclipse.papyrus.sysml.diagram.parametric.ConstraintProperty_2003"); //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static final IElementType Property_2005 = getElementType("org.eclipse.papyrus.sysml.diagram.parametric.Property_2005"); //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static final IElementType Property_3002 = getElementType("org.eclipse.papyrus.sysml.diagram.parametric.Property_3002"); //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- public static final IElementType Connector_4001 = getElementType("org.eclipse.papyrus.sysml.diagram.parametric.Connector_4001"); //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- private static ImageRegistry getImageRegistry() { >- if(imageRegistry == null) { >- imageRegistry = new ImageRegistry(); >- } >- return imageRegistry; >- } >- >- /** >- * @generated >- */ >- private static String getImageRegistryKey(ENamedElement element) { >- return element.getName(); >- } >- >- /** >- * @generated >- */ >- private static ImageDescriptor getProvidedImageDescriptor(ENamedElement element) { >- if(element instanceof EStructuralFeature) { >- EStructuralFeature feature = ((EStructuralFeature)element); >- EClass eContainingClass = feature.getEContainingClass(); >- EClassifier eType = feature.getEType(); >- if(eContainingClass != null && !eContainingClass.isAbstract()) { >- element = eContainingClass; >- } else if(eType instanceof EClass && !((EClass)eType).isAbstract()) { >- element = eType; >- } >- } >- if(element instanceof EClass) { >- EClass eClass = (EClass)element; >- if(!eClass.isAbstract()) { >- return SysmlDiagramEditorPlugin.getInstance().getItemImageDescriptor(eClass.getEPackage().getEFactoryInstance().create(eClass)); >- } >- } >- // TODO : support structural features >- return null; >- } >- >- /** >- * @generated >- */ >- public static ImageDescriptor getImageDescriptor(ENamedElement element) { >- String key = getImageRegistryKey(element); >- ImageDescriptor imageDescriptor = getImageRegistry().getDescriptor(key); >- if(imageDescriptor == null) { >- imageDescriptor = getProvidedImageDescriptor(element); >- if(imageDescriptor == null) { >- imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); >- } >- getImageRegistry().put(key, imageDescriptor); >- } >- return imageDescriptor; >- } >- >- /** >- * @generated >- */ >- public static Image getImage(ENamedElement element) { >- String key = getImageRegistryKey(element); >- Image image = getImageRegistry().get(key); >- if(image == null) { >- ImageDescriptor imageDescriptor = getProvidedImageDescriptor(element); >- if(imageDescriptor == null) { >- imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); >- } >- getImageRegistry().put(key, imageDescriptor); >- image = getImageRegistry().get(key); >- } >- return image; >- } >- >- /** >- * @generated >- */ >- public static ImageDescriptor getImageDescriptor(IAdaptable hint) { >- ENamedElement element = getElement(hint); >- if(element == null) { >- return null; >- } >- return getImageDescriptor(element); >- } >- >- /** >- * @generated >- */ >- public static Image getImage(IAdaptable hint) { >- ENamedElement element = getElement(hint); >- if(element == null) { >- return null; >- } >- return getImage(element); >- } >- >- /** >- * Returns 'type' of the ecore object associated with the hint. >- * >- * @generated >- */ >- public static ENamedElement getElement(IAdaptable hint) { >- Object type = hint.getAdapter(IElementType.class); >- if(elements == null) { >- elements = new IdentityHashMap<IElementType, ENamedElement>(); >- >- elements.put(Resource_1000, ResourcePackage.eINSTANCE.getResource()); >- >- elements.put(ConstraintProperty_2003, ConstraintsPackage.eINSTANCE.getConstraintProperty()); >- >- elements.put(Property_2005, UMLPackage.eINSTANCE.getProperty()); >- >- elements.put(Property_3002, UMLPackage.eINSTANCE.getProperty()); >- >- elements.put(Connector_4001, UMLPackage.eINSTANCE.getConnector()); >- } >- return (ENamedElement)elements.get(type); >- } >- >- /** >- * @generated >- */ >- private static IElementType getElementType(String id) { >- return ElementTypeRegistry.getInstance().getType(id); >- } >- >- /** >- * @generated >- */ >- public static boolean isKnownElementType(IElementType elementType) { >- if(KNOWN_ELEMENT_TYPES == null) { >- KNOWN_ELEMENT_TYPES = new HashSet<IElementType>(); >- KNOWN_ELEMENT_TYPES.add(Resource_1000); >- KNOWN_ELEMENT_TYPES.add(ConstraintProperty_2003); >- KNOWN_ELEMENT_TYPES.add(Property_2005); >- KNOWN_ELEMENT_TYPES.add(Property_3002); >- KNOWN_ELEMENT_TYPES.add(Connector_4001); >- } >- return KNOWN_ELEMENT_TYPES.contains(elementType); >- } >- >- /** >- * @generated >- */ >- public static IElementType getElementType(int visualID) { >- switch(visualID) { >- case ParametricEditPart.VISUAL_ID: >- return Resource_1000; >- case ConstraintPropertyEditPart.VISUAL_ID: >- return ConstraintProperty_2003; >- case PropertyEditPart.VISUAL_ID: >- return Property_2005; >- case Property2EditPart.VISUAL_ID: >- return Property_3002; >- case ConnectorEditPart.VISUAL_ID: >- return Connector_4001; >- } >- return null; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlIconProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlIconProvider.java >deleted file mode 100644 >index 59bfd52..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlIconProvider.java >+++ /dev/null >@@ -1,44 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; >-import org.eclipse.gmf.runtime.common.core.service.IOperation; >-import org.eclipse.gmf.runtime.common.ui.services.icon.GetIconOperation; >-import org.eclipse.gmf.runtime.common.ui.services.icon.IIconProvider; >-import org.eclipse.swt.graphics.Image; >- >-/** >- * @generated >- */ >-public class SysmlIconProvider extends AbstractProvider implements IIconProvider { >- >- /** >- * @generated >- */ >- public Image getIcon(IAdaptable hint, int flags) { >- return SysmlElementTypes.getImage(hint); >- } >- >- /** >- * @generated >- */ >- public boolean provides(IOperation operation) { >- if(operation instanceof GetIconOperation) { >- return ((GetIconOperation)operation).execute(this) != null; >- } >- return false; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlMarkerNavigationProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlMarkerNavigationProvider.java >deleted file mode 100644 >index 208d295..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlMarkerNavigationProvider.java >+++ /dev/null >@@ -1,94 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import java.util.Arrays; >-import java.util.Map; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IMarker; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; >-import org.eclipse.gmf.runtime.emf.ui.providers.marker.AbstractModelMarkerNavigationProvider; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorUtil; >- >-/** >- * @generated >- */ >-public class SysmlMarkerNavigationProvider extends AbstractModelMarkerNavigationProvider { >- >- /** >- * @generated >- */ >- public static final String MARKER_TYPE = SysmlDiagramEditorPlugin.ID + ".diagnostic"; //$NON-NLS-1$ >- >- /** >- * @generated >- */ >- protected void doGotoMarker(IMarker marker) { >- String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null); >- if(elementId == null || !(getEditor() instanceof DiagramEditor)) { >- return; >- } >- DiagramEditor editor = (DiagramEditor)getEditor(); >- Map editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry(); >- EObject targetView = editor.getDiagram().eResource().getEObject(elementId); >- if(targetView == null) { >- return; >- } >- EditPart targetEditPart = (EditPart)editPartRegistry.get(targetView); >- if(targetEditPart != null) { >- SysmlDiagramEditorUtil.selectElementsInDiagram(editor, Arrays.asList(new EditPart[]{ targetEditPart })); >- } >- } >- >- /** >- * @generated >- */ >- public static void deleteMarkers(IResource resource) { >- try { >- resource.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_ZERO); >- } catch (CoreException e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Failed to delete validation markers", e); //$NON-NLS-1$ >- } >- } >- >- /** >- * @generated >- */ >- public static IMarker addMarker(IFile file, String elementId, String location, String message, int statusSeverity) { >- IMarker marker = null; >- try { >- marker = file.createMarker(MARKER_TYPE); >- marker.setAttribute(IMarker.MESSAGE, message); >- marker.setAttribute(IMarker.LOCATION, location); >- marker.setAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, elementId); >- int markerSeverity = IMarker.SEVERITY_INFO; >- if(statusSeverity == IStatus.WARNING) { >- markerSeverity = IMarker.SEVERITY_WARNING; >- } else if(statusSeverity == IStatus.ERROR || statusSeverity == IStatus.CANCEL) { >- markerSeverity = IMarker.SEVERITY_ERROR; >- } >- marker.setAttribute(IMarker.SEVERITY, markerSeverity); >- } catch (CoreException e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Failed to create validation marker", e); //$NON-NLS-1$ >- } >- return marker; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlModelingAssistantProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlModelingAssistantProvider.java >deleted file mode 100644 >index d156ebc..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlModelingAssistantProvider.java >+++ /dev/null >@@ -1,202 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.Collections; >-import java.util.HashSet; >-import java.util.Iterator; >-import java.util.List; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >-import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.ui.services.modelingassistant.ModelingAssistantProvider; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.jface.viewers.ILabelProvider; >-import org.eclipse.jface.window.Window; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.Messages; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.swt.widgets.Display; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.dialogs.ElementListSelectionDialog; >- >-/** >- * @generated >- */ >-public class SysmlModelingAssistantProvider extends ModelingAssistantProvider { >- >- /** >- * @generated >- */ >- public List getTypesForPopupBar(IAdaptable host) { >- IGraphicalEditPart editPart = (IGraphicalEditPart)host.getAdapter(IGraphicalEditPart.class); >- if(editPart instanceof ParametricEditPart) { >- ArrayList<IElementType> types = new ArrayList<IElementType>(2); >- types.add(SysmlElementTypes.ConstraintProperty_2003); >- types.add(SysmlElementTypes.Property_2005); >- return types; >- } >- if(editPart instanceof ConstraintPropertyEditPart) { >- ArrayList<IElementType> types = new ArrayList<IElementType>(1); >- types.add(SysmlElementTypes.Property_3002); >- return types; >- } >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public List getRelTypesOnSource(IAdaptable source) { >- IGraphicalEditPart sourceEditPart = (IGraphicalEditPart)source.getAdapter(IGraphicalEditPart.class); >- if(sourceEditPart instanceof PropertyEditPart) { >- return ((PropertyEditPart)sourceEditPart).getMARelTypesOnSource(); >- } >- if(sourceEditPart instanceof Property2EditPart) { >- return ((Property2EditPart)sourceEditPart).getMARelTypesOnSource(); >- } >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public List getRelTypesOnTarget(IAdaptable target) { >- IGraphicalEditPart targetEditPart = (IGraphicalEditPart)target.getAdapter(IGraphicalEditPart.class); >- if(targetEditPart instanceof PropertyEditPart) { >- return ((PropertyEditPart)targetEditPart).getMARelTypesOnTarget(); >- } >- if(targetEditPart instanceof Property2EditPart) { >- return ((Property2EditPart)targetEditPart).getMARelTypesOnTarget(); >- } >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public List getRelTypesOnSourceAndTarget(IAdaptable source, IAdaptable target) { >- IGraphicalEditPart sourceEditPart = (IGraphicalEditPart)source.getAdapter(IGraphicalEditPart.class); >- IGraphicalEditPart targetEditPart = (IGraphicalEditPart)target.getAdapter(IGraphicalEditPart.class); >- if(sourceEditPart instanceof PropertyEditPart) { >- return ((PropertyEditPart)sourceEditPart).getMARelTypesOnSourceAndTarget(targetEditPart); >- } >- if(sourceEditPart instanceof Property2EditPart) { >- return ((Property2EditPart)sourceEditPart).getMARelTypesOnSourceAndTarget(targetEditPart); >- } >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public List getTypesForSource(IAdaptable target, IElementType relationshipType) { >- IGraphicalEditPart targetEditPart = (IGraphicalEditPart)target.getAdapter(IGraphicalEditPart.class); >- if(targetEditPart instanceof PropertyEditPart) { >- return ((PropertyEditPart)targetEditPart).getMATypesForSource(relationshipType); >- } >- if(targetEditPart instanceof Property2EditPart) { >- return ((Property2EditPart)targetEditPart).getMATypesForSource(relationshipType); >- } >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public List getTypesForTarget(IAdaptable source, IElementType relationshipType) { >- IGraphicalEditPart sourceEditPart = (IGraphicalEditPart)source.getAdapter(IGraphicalEditPart.class); >- if(sourceEditPart instanceof PropertyEditPart) { >- return ((PropertyEditPart)sourceEditPart).getMATypesForTarget(relationshipType); >- } >- if(sourceEditPart instanceof Property2EditPart) { >- return ((Property2EditPart)sourceEditPart).getMATypesForTarget(relationshipType); >- } >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- public EObject selectExistingElementForSource(IAdaptable target, IElementType relationshipType) { >- return selectExistingElement(target, getTypesForSource(target, relationshipType)); >- } >- >- /** >- * @generated >- */ >- public EObject selectExistingElementForTarget(IAdaptable source, IElementType relationshipType) { >- return selectExistingElement(source, getTypesForTarget(source, relationshipType)); >- } >- >- /** >- * @generated >- */ >- protected EObject selectExistingElement(IAdaptable host, Collection types) { >- if(types.isEmpty()) { >- return null; >- } >- IGraphicalEditPart editPart = (IGraphicalEditPart)host.getAdapter(IGraphicalEditPart.class); >- if(editPart == null) { >- return null; >- } >- Diagram diagram = (Diagram)editPart.getRoot().getContents().getModel(); >- HashSet<EObject> elements = new HashSet<EObject>(); >- for(Iterator<EObject> it = diagram.getElement().eAllContents(); it.hasNext();) { >- EObject element = it.next(); >- if(isApplicableElement(element, types)) { >- elements.add(element); >- } >- } >- if(elements.isEmpty()) { >- return null; >- } >- return selectElement((EObject[])elements.toArray(new EObject[elements.size()])); >- } >- >- /** >- * @generated >- */ >- protected boolean isApplicableElement(EObject element, Collection types) { >- IElementType type = ElementTypeRegistry.getInstance().getElementType(element); >- return types.contains(type); >- } >- >- /** >- * @generated >- */ >- protected EObject selectElement(EObject[] elements) { >- Shell shell = Display.getCurrent().getActiveShell(); >- ILabelProvider labelProvider = new AdapterFactoryLabelProvider(SysmlDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory()); >- ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, labelProvider); >- dialog.setMessage(Messages.SysmlModelingAssistantProviderMessage); >- dialog.setTitle(Messages.SysmlModelingAssistantProviderTitle); >- dialog.setMultipleSelection(false); >- dialog.setElements(elements); >- EObject selected = null; >- if(dialog.open() == Window.OK) { >- selected = (EObject)dialog.getFirstResult(); >- } >- return selected; >- } >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlParserProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlParserProvider.java >deleted file mode 100644 >index 069a392..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlParserProvider.java >+++ /dev/null >@@ -1,205 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; >-import org.eclipse.gmf.runtime.common.core.service.IOperation; >-import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider; >-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintLabelEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyName2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.parsers.ConnectorLabelParser; >-import org.eclipse.papyrus.sysml.diagram.parametric.parsers.ConstraintLabelParser; >-import org.eclipse.papyrus.sysml.diagram.parametric.parsers.ConstraintPropertyLabelParser; >-import org.eclipse.papyrus.sysml.diagram.parametric.parsers.PropertyLabelParser; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >- >-/** >- * @generated >- */ >-public class SysmlParserProvider extends AbstractProvider implements IParserProvider { >- >- /** >- * @generated >- */ >- private ConstraintPropertyLabelParser constraintPropertyLabel_5001Parser; >- >- /** >- * @generated >- */ >- private IParser getConstraintPropertyLabel_5001Parser() { >- if(constraintPropertyLabel_5001Parser == null) { >- constraintPropertyLabel_5001Parser = new ConstraintPropertyLabelParser(); >- } >- return constraintPropertyLabel_5001Parser; >- } >- >- /** >- * @generated >- */ >- private ConstraintLabelParser constraintPropertyLabel_5004Parser; >- >- /** >- * @generated >- */ >- private IParser getConstraintPropertyLabel_5004Parser() { >- if(constraintPropertyLabel_5004Parser == null) { >- constraintPropertyLabel_5004Parser = new ConstraintLabelParser(); >- } >- return constraintPropertyLabel_5004Parser; >- } >- >- /** >- * @generated >- */ >- private PropertyLabelParser propertyName_5002Parser; >- >- /** >- * @generated >- */ >- private IParser getPropertyName_5002Parser() { >- if(propertyName_5002Parser == null) { >- propertyName_5002Parser = new PropertyLabelParser(); >- } >- return propertyName_5002Parser; >- } >- >- /** >- * @generated >- */ >- private PropertyLabelParser propertyName_5003Parser; >- >- /** >- * @generated >- */ >- private IParser getPropertyName_5003Parser() { >- if(propertyName_5003Parser == null) { >- propertyName_5003Parser = new PropertyLabelParser(); >- } >- return propertyName_5003Parser; >- } >- >- /** >- * @generated >- */ >- private ConnectorLabelParser connectorName_6001Parser; >- >- /** >- * @generated >- */ >- private IParser getConnectorName_6001Parser() { >- if(connectorName_6001Parser == null) { >- connectorName_6001Parser = new ConnectorLabelParser(); >- } >- return connectorName_6001Parser; >- } >- >- /** >- * @generated >- */ >- protected IParser getParser(int visualID) { >- switch(visualID) { >- case ConstraintPropertyNameEditPart.VISUAL_ID: >- return getConstraintPropertyLabel_5001Parser(); >- case ConstraintLabelEditPart.VISUAL_ID: >- return getConstraintPropertyLabel_5004Parser(); >- case PropertyNameEditPart.VISUAL_ID: >- return getPropertyName_5002Parser(); >- case PropertyName2EditPart.VISUAL_ID: >- return getPropertyName_5003Parser(); >- case ConnectorNameEditPart.VISUAL_ID: >- return getConnectorName_6001Parser(); >- } >- return null; >- } >- >- /** >- * Utility method that consults ParserService >- * >- * @generated >- */ >- public static IParser getParser(IElementType type, EObject object, String parserHint) { >- return ParserService.getInstance().getParser(new HintAdapter(type, object, parserHint)); >- } >- >- /** >- * @generated >- */ >- public IParser getParser(IAdaptable hint) { >- String vid = (String)hint.getAdapter(String.class); >- if(vid != null) { >- return getParser(SysmlVisualIDRegistry.getVisualID(vid)); >- } >- View view = (View)hint.getAdapter(View.class); >- if(view != null) { >- return getParser(SysmlVisualIDRegistry.getVisualID(view)); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- public boolean provides(IOperation operation) { >- if(operation instanceof GetParserOperation) { >- IAdaptable hint = ((GetParserOperation)operation).getHint(); >- if(SysmlElementTypes.getElement(hint) == null) { >- return false; >- } >- return getParser(hint) != null; >- } >- return false; >- } >- >- /** >- * @generated >- */ >- private static class HintAdapter extends ParserHintAdapter { >- >- /** >- * @generated >- */ >- private final IElementType elementType; >- >- /** >- * @generated >- */ >- public HintAdapter(IElementType type, EObject object, String parserHint) { >- super(object, parserHint); >- assert type != null; >- elementType = type; >- } >- >- /** >- * @generated >- */ >- public Object getAdapter(Class adapter) { >- if(IElementType.class.equals(adapter)) { >- return elementType; >- } >- return super.getAdapter(adapter); >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlValidationProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlValidationProvider.java >deleted file mode 100644 >index d2ef28d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlValidationProvider.java >+++ /dev/null >@@ -1,166 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2010 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.validation.AbstractModelConstraint; >-import org.eclipse.emf.validation.IValidationContext; >-import org.eclipse.emf.validation.model.IClientSelector; >-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.papyrus.sysml.blocks.NestedConnectorEnd; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.helper.ModelValidationHelper; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditorPlugin; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.uml2.uml.Connector; >-import org.eclipse.uml2.uml.ConnectorEnd; >-import org.eclipse.uml2.uml.Property; >- >-/** >- * @generated >- */ >-public class SysmlValidationProvider { >- >- /** >- * @generated >- */ >- private static boolean constraintsActive = false; >- >- /** >- * @generated >- */ >- public static boolean shouldConstraintsBePrivate() { >- return false; >- } >- >- /** >- * @generated >- */ >- public static void runWithConstraints(TransactionalEditingDomain editingDomain, Runnable operation) { >- final Runnable op = operation; >- Runnable task = new Runnable() { >- >- public void run() { >- try { >- constraintsActive = true; >- op.run(); >- } finally { >- constraintsActive = false; >- } >- } >- }; >- if(editingDomain != null) { >- try { >- editingDomain.runExclusive(task); >- } catch (Exception e) { >- SysmlDiagramEditorPlugin.getInstance().logError("Validation failed", e); //$NON-NLS-1$ >- } >- } else { >- task.run(); >- } >- } >- >- /** >- * @generated >- */ >- static boolean isInDefaultEditorContext(Object object) { >- if(shouldConstraintsBePrivate() && !constraintsActive) { >- return false; >- } >- if(object instanceof View) { >- return constraintsActive && ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID((View)object)); >- } >- return true; >- } >- >- /** >- * @generated >- */ >- public static class DefaultCtx implements IClientSelector { >- >- /** >- * @generated >- */ >- public boolean selects(Object object) { >- return isInDefaultEditorContext(object); >- } >- } >- >- /** >- * @generated >- */ >- public static class Adapter1 extends AbstractModelConstraint { >- >- /** >- * @generated >- */ >- public IStatus validate(IValidationContext ctx) { >- Connector context = (Connector)ctx.getTarget(); >- return ModelValidationHelper.validateConnector(context, ctx); >- } >- } >- >- /** >- * @generated >- */ >- public static class Adapter2 extends AbstractModelConstraint { >- >- /** >- * @generated >- */ >- public IStatus validate(IValidationContext ctx) { >- Property context = (Property)ctx.getTarget(); >- return ModelValidationHelper.validateProperty(context, ctx); >- } >- } >- >- /** >- * @generated >- */ >- public static class Adapter3 extends AbstractModelConstraint { >- >- /** >- * @generated >- */ >- public IStatus validate(IValidationContext ctx) { >- ConnectorEnd context = (ConnectorEnd)ctx.getTarget(); >- return ModelValidationHelper.validateConnectorEnd(context, ctx); >- } >- } >- >- /** >- * @generated >- */ >- public static class Adapter4 extends AbstractModelConstraint { >- >- /** >- * @generated >- */ >- public IStatus validate(IValidationContext ctx) { >- NestedConnectorEnd context = (NestedConnectorEnd)ctx.getTarget(); >- return ModelValidationHelper.validateNestedConnectorEnd(context, ctx); >- } >- } >- >- /** >- * @generated >- */ >- static String formatElement(EObject object) { >- return EMFCoreUtil.getQualifiedName(object, true); >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlViewProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlViewProvider.java >deleted file mode 100644 >index 626f32b..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/providers/SysmlViewProvider.java >+++ /dev/null >@@ -1,489 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.providers; >- >-import java.util.ArrayList; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.ecore.EAnnotation; >-import org.eclipse.emf.ecore.EObject; >-import org.eclipse.emf.ecore.EcoreFactory; >-import org.eclipse.emf.transaction.util.TransactionUtil; >-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; >-import org.eclipse.gmf.runtime.common.core.service.IOperation; >-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >-import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider; >-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation; >-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation; >-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation; >-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation; >-import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation; >-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >-import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; >-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.emf.type.core.IHintedType; >-import org.eclipse.gmf.runtime.notation.Connector; >-import org.eclipse.gmf.runtime.notation.DecorationNode; >-import org.eclipse.gmf.runtime.notation.Diagram; >-import org.eclipse.gmf.runtime.notation.Edge; >-import org.eclipse.gmf.runtime.notation.FillStyle; >-import org.eclipse.gmf.runtime.notation.FontStyle; >-import org.eclipse.gmf.runtime.notation.Location; >-import org.eclipse.gmf.runtime.notation.MeasurementUnit; >-import org.eclipse.gmf.runtime.notation.Node; >-import org.eclipse.gmf.runtime.notation.NotationFactory; >-import org.eclipse.gmf.runtime.notation.NotationPackage; >-import org.eclipse.gmf.runtime.notation.RelativeBendpoints; >-import org.eclipse.gmf.runtime.notation.Shape; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.jface.preference.PreferenceConverter; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter; >-import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; >-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConnectorNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintLabelEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ConstraintPropertyNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.ParametricEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.Property2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyName2EditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.edit.parts.PropertyNameEditPart; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.uml2.uml.Property; >-import org.eclipse.uml2.uml.StructuredClassifier; >-import org.eclipse.uml2.uml.Type; >- >-/** >- * @generated >- */ >-public class SysmlViewProvider extends AbstractProvider implements IViewProvider { >- >- /** >- * @generated >- */ >- public final boolean provides(IOperation operation) { >- if(operation instanceof CreateViewForKindOperation) { >- return provides((CreateViewForKindOperation)operation); >- } >- assert operation instanceof CreateViewOperation; >- if(operation instanceof CreateDiagramViewOperation) { >- return provides((CreateDiagramViewOperation)operation); >- } else if(operation instanceof CreateEdgeViewOperation) { >- return provides((CreateEdgeViewOperation)operation); >- } else if(operation instanceof CreateNodeViewOperation) { >- return provides((CreateNodeViewOperation)operation); >- } >- return false; >- } >- >- /** >- * @generated >- */ >- protected boolean provides(CreateViewForKindOperation op) { >- /* >- * if (op.getViewKind() == Node.class) >- * return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; >- * if (op.getViewKind() == Edge.class) >- * return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; >- */ >- >- // check Diagram Type should be the class diagram >- String modelID = SysmlVisualIDRegistry.getModelID(op.getContainerView()); >- if(!getDiagramProvidedId().equals(modelID)) { >- return false; >- } >- >- int visualID = SysmlVisualIDRegistry.getVisualID(op.getSemanticHint()); >- if(Node.class.isAssignableFrom(op.getViewKind())) { >- return SysmlVisualIDRegistry.canCreateNode(op.getContainerView(), visualID); >- } >- >- return true; >- } >- >- /** >- * @generated >- */ >- protected String getDiagramProvidedId() { >- /* >- * Indicates for which diagram this provider works for. >- * <p> >- * This method can be overloaded when diagram editor inherits from another one, but should never be <code>null</code> >- * </p> >- * >- * @return the unique identifier of the diagram for which views are provided. >- */ >- return ParametricEditPart.MODEL_ID; >- } >- >- /** >- * @generated >- */ >- protected boolean provides(CreateDiagramViewOperation op) { >- return ParametricEditPart.MODEL_ID.equals(op.getSemanticHint()) && SysmlVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter())) != -1; >- } >- >- /** >- * @generated >- */ >- protected boolean provides(CreateNodeViewOperation op) { >- if(op.getContainerView() == null) { >- return false; >- } >- IElementType elementType = getSemanticElementType(op.getSemanticAdapter()); >- EObject domainElement = getSemanticElement(op.getSemanticAdapter()); >- int visualID; >- if(op.getSemanticHint() == null) { >- // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy. >- // In this situation there should be NO elementType, visualID will be determined >- // by VisualIDRegistry.getNodeVisualID() for domainElement. >- if(elementType != null || domainElement == null) { >- return false; >- } >- visualID = SysmlVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement); >- } else { >- visualID = SysmlVisualIDRegistry.getVisualID(op.getSemanticHint()); >- if(elementType != null) { >- if(!SysmlElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) { >- return false; // foreign element type >- } >- String elementTypeHint = ((IHintedType)elementType).getSemanticHint(); >- if(!op.getSemanticHint().equals(elementTypeHint)) { >- return false; // if semantic hint is specified it should be the same as in element type >- } >- if(domainElement != null && visualID != SysmlVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) { >- return false; // visual id for node EClass should match visual id from element type >- } >- } else { >- if(!ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID(op.getContainerView()))) { >- return false; // foreign diagram >- } >- switch(visualID) { >- case ConstraintPropertyEditPart.VISUAL_ID: >- case Property2EditPart.VISUAL_ID: >- case PropertyEditPart.VISUAL_ID: >- if(domainElement == null || visualID != SysmlVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) { >- return false; // visual id in semantic hint should match visual id for domain element >- } >- break; >- default: >- return false; >- } >- } >- } >- return ConstraintPropertyEditPart.VISUAL_ID == visualID || PropertyEditPart.VISUAL_ID == visualID || Property2EditPart.VISUAL_ID == visualID; >- } >- >- /** >- * @generated >- */ >- protected boolean provides(CreateEdgeViewOperation op) { >- IElementType elementType = getSemanticElementType(op.getSemanticAdapter()); >- if(!SysmlElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) { >- return false; // foreign element type >- } >- String elementTypeHint = ((IHintedType)elementType).getSemanticHint(); >- if(elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) { >- return false; // our hint is visual id and must be specified, and it should be the same as in element type >- } >- int visualID = SysmlVisualIDRegistry.getVisualID(elementTypeHint); >- EObject domainElement = getSemanticElement(op.getSemanticAdapter()); >- if(domainElement != null && visualID != SysmlVisualIDRegistry.getLinkWithClassVisualID(domainElement)) { >- return false; // visual id for link EClass should match visual id from element type >- } >- return true; >- } >- >- /** >- * @generated >- */ >- public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) { >- Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); >- diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle()); >- diagram.setType(ParametricEditPart.MODEL_ID); >- diagram.setElement(getSemanticElement(semanticAdapter)); >- diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL); >- return diagram; >- } >- >- /** >- * @generated >- */ >- public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { >- final EObject domainElement = getSemanticElement(semanticAdapter); >- final int visualID; >- if(semanticHint == null) { >- visualID = SysmlVisualIDRegistry.getNodeVisualID(containerView, domainElement); >- } else { >- visualID = SysmlVisualIDRegistry.getVisualID(semanticHint); >- } >- switch(visualID) { >- case ConstraintPropertyEditPart.VISUAL_ID: >- return createConstraintProperty_2003(domainElement, containerView, index, persisted, preferencesHint); >- case PropertyEditPart.VISUAL_ID: >- return createProperty_2005(domainElement, containerView, index, persisted, preferencesHint); >- case Property2EditPart.VISUAL_ID: >- return createProperty_3002(domainElement, containerView, index, persisted, preferencesHint); >- } >- // can't happen, provided #provides(CreateNodeViewOperation) is correct >- return null; >- } >- >- /** >- * @generated >- */ >- public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { >- IElementType elementType = getSemanticElementType(semanticAdapter); >- String elementTypeHint = ((IHintedType)elementType).getSemanticHint(); >- switch(SysmlVisualIDRegistry.getVisualID(elementTypeHint)) { >- case ConnectorEditPart.VISUAL_ID: >- return createConnector_4001(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint); >- } >- // can never happen, provided #provides(CreateEdgeViewOperation) is correct >- return null; >- } >- >- /** >- * @generated NOT >- */ >- public Node createConstraintProperty_2003(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { >- Shape node = NotationFactory.eINSTANCE.createShape(); >- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); >- node.setType(SysmlVisualIDRegistry.getType(ConstraintPropertyEditPart.VISUAL_ID)); >- ViewUtil.insertChildView(containerView, node, index, persisted); >- node.setElement(domainElement); >- // node.setElement(((ConstraintProperty) domainElement).getBase_Property()); >- >- stampShortcut(containerView, node); >- // initializeFromPreferences >- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); >- >- initForegroundFromPrefs(node, prefStore, "ConstraintProperty"); >- >- initFontStyleFromPrefs(node, prefStore, "ConstraintProperty"); >- >- initBackgroundFromPrefs(node, prefStore, "ConstraintProperty"); >- >- Node label5001 = createLabel(node, SysmlVisualIDRegistry.getType(ConstraintPropertyNameEditPart.VISUAL_ID)); >- Node label5004 = createLabel(node, SysmlVisualIDRegistry.getType(ConstraintLabelEditPart.VISUAL_ID)); >- >- // create the associated properties >- Type type = ((ConstraintProperty)domainElement).getBase_Property().getType(); >- if(type != null && type instanceof StructuredClassifier) { >- for(Property property : ((StructuredClassifier)type).getOwnedAttributes()) { >- createProperty_3002(property, node, index, persisted, preferencesHint); >- } >- } >- return node; >- } >- >- /** >- * @generated >- */ >- public Node createProperty_2005(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { >- Shape node = NotationFactory.eINSTANCE.createShape(); >- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); >- node.setType(SysmlVisualIDRegistry.getType(PropertyEditPart.VISUAL_ID)); >- ViewUtil.insertChildView(containerView, node, index, persisted); >- node.setElement(domainElement); >- stampShortcut(containerView, node); >- // initializeFromPreferences >- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); >- >- PreferenceInitializerForElementHelper.initForegroundFromPrefs(node, prefStore, "Property"); >- >- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Property"); >- >- PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, prefStore, "Property"); >- >- Node label5002 = createLabel(node, SysmlVisualIDRegistry.getType(PropertyNameEditPart.VISUAL_ID)); >- >- return node; >- } >- >- /** >- * @generated >- */ >- public Node createProperty_3002(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { >- Shape node = NotationFactory.eINSTANCE.createShape(); >- node.getStyles().add(NotationFactory.eINSTANCE.createHintedDiagramLinkStyle()); >- node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); >- node.setType(SysmlVisualIDRegistry.getType(Property2EditPart.VISUAL_ID)); >- ViewUtil.insertChildView(containerView, node, index, persisted); >- node.setElement(domainElement); >- // initializeFromPreferences >- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); >- >- PreferenceInitializerForElementHelper.initForegroundFromPrefs(node, prefStore, "Property"); >- >- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Property"); >- >- PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, prefStore, "Property"); >- >- Node label5003 = createLabel(node, SysmlVisualIDRegistry.getType(PropertyName2EditPart.VISUAL_ID)); >- label5003.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); >- >- Location location5003 = (Location)label5003.getLayoutConstraint(); >- location5003.setX(0); >- location5003.setY(5); >- >- return node; >- } >- >- /** >- * @generated >- */ >- public Edge createConnector_4001(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { >- Connector edge = NotationFactory.eINSTANCE.createConnector(); >- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); >- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); >- ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); >- points.add(new RelativeBendpoint()); >- points.add(new RelativeBendpoint()); >- bendpoints.setPoints(points); >- edge.setBendpoints(bendpoints); >- ViewUtil.insertChildView(containerView, edge, index, persisted); >- edge.setType(SysmlVisualIDRegistry.getType(ConnectorEditPart.VISUAL_ID)); >- edge.setElement(domainElement); >- // initializePreferences >- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); >- >- PreferenceInitializerForElementHelper.initForegroundFromPrefs(edge, prefStore, "Connector"); >- >- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Connector"); >- >- //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); >- //if (routing != null) { >- // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); >- //} >- >- PreferenceInitializerForElementHelper.initRountingFromPrefs(edge, prefStore, "Connector"); >- >- Node label6001 = createLabel(edge, SysmlVisualIDRegistry.getType(ConnectorNameEditPart.VISUAL_ID)); >- label6001.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); >- Location location6001 = (Location)label6001.getLayoutConstraint(); >- location6001.setX(0); >- location6001.setY(40); >- >- PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "Connector"); >- >- return edge; >- } >- >- /** >- * @generated >- */ >- protected void stampShortcut(View containerView, Node target) { >- if(!ParametricEditPart.MODEL_ID.equals(SysmlVisualIDRegistry.getModelID(containerView))) { >- EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); >- shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$ >- shortcutAnnotation.getDetails().put("modelID", ParametricEditPart.MODEL_ID); //$NON-NLS-1$ >- target.getEAnnotations().add(shortcutAnnotation); >- } >- } >- >- /** >- * @generated >- */ >- protected Node createLabel(View owner, String hint) { >- DecorationNode rv = NotationFactory.eINSTANCE.createDecorationNode(); >- rv.setType(hint); >- ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true); >- return rv; >- } >- >- /** >- * @generated >- */ >- protected EObject getSemanticElement(IAdaptable semanticAdapter) { >- if(semanticAdapter == null) { >- return null; >- } >- EObject eObject = (EObject)semanticAdapter.getAdapter(EObject.class); >- if(eObject != null) { >- return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected IElementType getSemanticElementType(IAdaptable semanticAdapter) { >- if(semanticAdapter == null) { >- return null; >- } >- return (IElementType)semanticAdapter.getAdapter(IElementType.class); >- } >- >- /** >- * @generated >- */ >- private void initFontStyleFromPrefs(View view, final IPreferenceStore store, String elementName) { >- String fontConstant = PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.FONT); >- String fontColorConstant = PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.COLOR_FONT); >- >- FontStyle viewFontStyle = (FontStyle)view.getStyle(NotationPackage.Literals.FONT_STYLE); >- if(viewFontStyle != null) { >- FontData fontData = PreferenceConverter.getFontData(store, fontConstant); >- viewFontStyle.setFontName(fontData.getName()); >- viewFontStyle.setFontHeight(fontData.getHeight()); >- viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); >- viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); >- >- org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant); >- viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); >- } >- } >- >- /** >- * @generated >- */ >- private void initForegroundFromPrefs(View view, final IPreferenceStore store, String elementName) { >- String lineColorConstant = PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.COLOR_LINE); >- org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(store, lineColorConstant); >- ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); >- } >- >- /** >- * @generated >- */ >- private void initBackgroundFromPrefs(View view, final IPreferenceStore store, String elementName) { >- String fillColorConstant = PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.COLOR_FILL); >- String gradientColorConstant = PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.COLOR_GRADIENT); >- String gradientPolicyConstant = PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.GRADIENT_POLICY); >- >- org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant); >- ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); >- >- FillStyle fillStyle = (FillStyle)view.getStyle(NotationPackage.Literals.FILL_STYLE); >- fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue()); >- >- ; >- if(store.getBoolean(gradientPolicyConstant)) { >- GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(store.getString(gradientColorConstant)); >- fillStyle.setGradient(gradientPreferenceConverter.getGradientData()); >- fillStyle.setTransparency(gradientPreferenceConverter.getTransparency()); >- } >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/sheet/SysmlPropertySection.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/sheet/SysmlPropertySection.java >deleted file mode 100644 >index 5ffcc9d..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/sheet/SysmlPropertySection.java >+++ /dev/null >@@ -1,123 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.sheet; >- >-import java.util.ArrayList; >-import java.util.Iterator; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.emf.common.notify.AdapterFactory; >-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; >-import org.eclipse.emf.edit.provider.IItemPropertySource; >-import org.eclipse.emf.edit.ui.provider.PropertySource; >-import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.emf.transaction.util.TransactionUtil; >-import org.eclipse.gef.EditPart; >-import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.ui.IWorkbenchPart; >-import org.eclipse.ui.views.properties.IPropertySource; >-import org.eclipse.ui.views.properties.IPropertySourceProvider; >- >-/** >- * @generated >- */ >-public class SysmlPropertySection extends AdvancedPropertySection implements IPropertySourceProvider { >- >- /** >- * @generated >- */ >- public IPropertySource getPropertySource(Object object) { >- if(object instanceof IPropertySource) { >- return (IPropertySource)object; >- } >- AdapterFactory af = getAdapterFactory(object); >- if(af != null) { >- IItemPropertySource ips = (IItemPropertySource)af.adapt(object, IItemPropertySource.class); >- if(ips != null) { >- return new PropertySource(object, ips); >- } >- } >- if(object instanceof IAdaptable) { >- return (IPropertySource)((IAdaptable)object).getAdapter(IPropertySource.class); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- protected IPropertySourceProvider getPropertySourceProvider() { >- return this; >- } >- >- /** >- * Modify/unwrap selection. >- * >- * @generated >- */ >- protected Object transformSelection(Object selected) { >- >- if(selected instanceof EditPart) { >- Object model = ((EditPart)selected).getModel(); >- return model instanceof View ? ((View)model).getElement() : null; >- } >- if(selected instanceof View) { >- return ((View)selected).getElement(); >- } >- if(selected instanceof IAdaptable) { >- View view = (View)((IAdaptable)selected).getAdapter(View.class); >- if(view != null) { >- return view.getElement(); >- } >- } >- return selected; >- } >- >- /** >- * @generated >- */ >- public void setInput(IWorkbenchPart part, ISelection selection) { >- if(selection.isEmpty() || false == selection instanceof StructuredSelection) { >- super.setInput(part, selection); >- return; >- } >- final StructuredSelection structuredSelection = ((StructuredSelection)selection); >- ArrayList transformedSelection = new ArrayList(structuredSelection.size()); >- for(Iterator it = structuredSelection.iterator(); it.hasNext();) { >- Object r = transformSelection(it.next()); >- if(r != null) { >- transformedSelection.add(r); >- } >- } >- super.setInput(part, new StructuredSelection(transformedSelection)); >- } >- >- /** >- * @generated >- */ >- protected AdapterFactory getAdapterFactory(Object object) { >- if(getEditingDomain() instanceof AdapterFactoryEditingDomain) { >- return ((AdapterFactoryEditingDomain)getEditingDomain()).getAdapterFactory(); >- } >- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(object); >- if(editingDomain != null) { >- return ((AdapterFactoryEditingDomain)editingDomain).getAdapterFactory(); >- } >- return null; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/sheet/SysmlSheetLabelProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/sheet/SysmlSheetLabelProvider.java >deleted file mode 100644 >index c4f8dcb..0000000 >--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/sheet/SysmlSheetLabelProvider.java >+++ /dev/null >@@ -1,91 +0,0 @@ >-/***************************************************************************** >- * Copyright (c) 2009 Atos Origin. >- * >- * >- * 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: >- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation >- * >- *****************************************************************************/ >-package org.eclipse.papyrus.sysml.diagram.parametric.sheet; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >-import org.eclipse.gmf.runtime.notation.View; >-import org.eclipse.jface.viewers.BaseLabelProvider; >-import org.eclipse.jface.viewers.ILabelProvider; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.papyrus.sysml.diagram.parametric.navigator.SysmlNavigatorGroup; >-import org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlVisualIDRegistry; >-import org.eclipse.papyrus.sysml.diagram.parametric.providers.SysmlElementTypes; >-import org.eclipse.swt.graphics.Image; >- >-/** >- * @generated >- */ >-public class SysmlSheetLabelProvider extends BaseLabelProvider implements ILabelProvider { >- >- /** >- * @generated >- */ >- public String getText(Object element) { >- element = unwrap(element); >- if(element instanceof SysmlNavigatorGroup) { >- return ((SysmlNavigatorGroup)element).getGroupName(); >- } >- IElementType etype = getElementType(getView(element)); >- return etype == null ? "" : etype.getDisplayName(); >- } >- >- /** >- * @generated >- */ >- public Image getImage(Object element) { >- IElementType etype = getElementType(getView(unwrap(element))); >- return etype == null ? null : SysmlElementTypes.getImage(etype); >- } >- >- /** >- * @generated >- */ >- private Object unwrap(Object element) { >- if(element instanceof IStructuredSelection) { >- return ((IStructuredSelection)element).getFirstElement(); >- } >- return element; >- } >- >- /** >- * @generated >- */ >- private View getView(Object element) { >- if(element instanceof View) { >- return (View)element; >- } >- if(element instanceof IAdaptable) { >- return (View)((IAdaptable)element).getAdapter(View.class); >- } >- return null; >- } >- >- /** >- * @generated >- */ >- private IElementType getElementType(View view) { >- // For intermediate views climb up the containment hierarchy to find the one associated with an element type. >- while(view != null) { >- int vid = SysmlVisualIDRegistry.getVisualID(view); >- IElementType etype = SysmlElementTypes.getElementType(vid); >- if(etype != null) { >- return etype; >- } >- view = view.eContainer() instanceof View ? (View)view.eContainer() : null; >- } >- return null; >- } >- >-} >diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/utils/BlockDropHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/utils/BlockDropHelper.java >new file mode 100644 >index 0000000..b242063 >--- /dev/null >+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.parametric/src/org/eclipse/papyrus/sysml/diagram/parametric/utils/BlockDropHelper.java >@@ -0,0 +1,239 @@ >+/***************************************************************************** >+ * 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: >+ * >+ * CEA LIST - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.diagram.parametric.utils; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.transaction.TransactionalEditingDomain; >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.commands.CompoundCommand; >+import org.eclipse.gef.commands.UnexecutableCommand; >+import org.eclipse.gmf.runtime.common.core.command.ICommand; >+import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; >+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; >+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; >+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; >+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >+import org.eclipse.gmf.runtime.notation.Node; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.papyrus.infra.gmfdiag.common.utils.ViewDescriptorUtil; >+import org.eclipse.papyrus.infra.services.edit.commands.ConfigureFeatureCommandFactory; >+import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; >+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; >+import org.eclipse.papyrus.uml.diagram.common.helper.ElementHelper; >+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; >+import org.eclipse.uml2.uml.Actor; >+import org.eclipse.uml2.uml.Association; >+import org.eclipse.uml2.uml.DataType; >+import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.TypedElement; >+import org.eclipse.uml2.uml.UMLPackage; >+ >+/** >+ * This class provides convenience methods to create Block specific drop action (Part or Reference creation). >+ */ >+public class BlockDropHelper extends ElementHelper { >+ >+ public BlockDropHelper(TransactionalEditingDomain editDomain) { >+ this.editDomain = editDomain; >+ } >+ >+ public Command getDropAsStructureItemOnPart(DropObjectsRequest request, GraphicalEditPart host, IElementType elementType) { >+ String label = ""; >+ if(elementType == SysMLElementTypes.PART_PROPERTY) { >+ label = "Create a new Part"; >+ } >+ if(elementType == SysMLElementTypes.REFERENCE_PROPERTY) { >+ label = "Create a new Reference"; >+ } >+ if(elementType == SysMLElementTypes.ACTOR_PART_PROPERTY) { >+ label = "Create a new ActorPart"; >+ } >+ if(elementType == SysMLElementTypes.VALUE_PROPERTY) { >+ label = "Create a new Value"; >+ } >+ if(elementType == UMLElementTypes.PROPERTY) { >+ label = "Create a new Property"; >+ } >+ CompoundCommand cc = new CompoundCommand(label); >+ >+ Object droppedEObject = request.getObjects().get(0); >+ if(!isValidStructureItemType(droppedEObject, elementType)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ // Verify target nature >+ EObject target = getHostEObject(host); >+ if((!(target instanceof TypedElement)) || (((TypedElement)target).getType() == null)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ // The target type has to be a Block (will hold the created Port) >+ Type targetType = ((TypedElement)target).getType(); >+ if(!((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(targetType)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ // Prepare a command for the element creation and the drop in diagram >+ >+ // 1. Prepare creation command >+ ICommand createElementCommand = null; >+ CreateElementRequest createElementRequest = new CreateElementRequest(getEditingDomain(), targetType, elementType); >+ createElementRequest.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new ConfigureFeatureCommandFactory(UMLPackage.eINSTANCE.getTypedElement_Type(), request.getObjects().get(0))); >+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetType); >+ if(provider != null) { >+ createElementCommand = provider.getEditCommand(createElementRequest); >+ } >+ IAdaptable createElementRequestAdapter = new CreateElementRequestAdapter(createElementRequest); >+ >+ // 2. Prepare the drop command >+ ViewDescriptor descriptor = new ViewDescriptor(createElementRequestAdapter, Node.class, /* explicit semantic hint is mandatory */ null, ViewDescriptorUtil.PERSISTED, host.getDiagramPreferencesHint()); >+ CreateViewRequest createViewRequest = new CreateViewRequest(descriptor); >+ createViewRequest.setLocation(request.getLocation().getCopy()); >+ Command viewCreateCommand = host.getCommand(createViewRequest); >+ >+ // 3. Create the compound command >+ cc.add(new ICommandProxy(createElementCommand)); >+ cc.add(viewCreateCommand); >+ >+ return cc; >+ } >+ >+ public Command getDropAsStructureItem(DropObjectsRequest request, GraphicalEditPart host, IElementType elementType) { >+ Object droppedEObject = request.getObjects().get(0); >+ String label = ""; >+ >+ // Filter part/reference : a property type by a ConstraintBlock MUST be a ConstraintProperty >+ if(elementType == SysMLElementTypes.PART_PROPERTY) { >+ label = "Create a new Part"; >+ if (droppedEObject instanceof Type) { >+ if (((ISpecializationType)SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches((Type)droppedEObject)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ } >+ } >+ if(elementType == SysMLElementTypes.REFERENCE_PROPERTY) { >+ label = "Create a new Reference"; >+ if (droppedEObject instanceof Type) { >+ if (((ISpecializationType)SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches((Type)droppedEObject)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ } >+ } >+ if(elementType == SysMLElementTypes.ACTOR_PART_PROPERTY) { >+ label = "Create a new ActorPart"; >+ } >+ if(elementType == SysMLElementTypes.VALUE_PROPERTY) { >+ label = "Create a new Value"; >+ } >+ if(elementType == UMLElementTypes.PROPERTY) { >+ label = "Create a new Property"; >+ } >+ >+ if(elementType == SysMLElementTypes.CONSTRAINT_PROPERTY) { >+ label = "Create a new ConstraintProperty"; >+ // Constraint Property on ConstraintBlock strictly >+ if (droppedEObject instanceof Type) { >+ if (!((ISpecializationType)SysMLElementTypes.CONSTRAINT_BLOCK).getMatcher().matches((Type)droppedEObject)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ } >+ } >+ CompoundCommand cc = new CompoundCommand(label); >+ >+ if(!isValidStructureItemType(droppedEObject, elementType)) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ // Prepare a command for the element creation and the drop in diagram >+ >+ // 1. Prepare creation command >+ ICommand createElementCommand = null; >+ CreateElementRequest createElementRequest = new CreateElementRequest(getEditingDomain(), getHostEObject(host), elementType); >+ createElementRequest.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new ConfigureFeatureCommandFactory(UMLPackage.eINSTANCE.getTypedElement_Type(), request.getObjects().get(0))); >+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(getHostEObject(host)); >+ if(provider != null) { >+ createElementCommand = provider.getEditCommand(createElementRequest); >+ } >+ IAdaptable createElementRequestAdapter = new CreateElementRequestAdapter(createElementRequest); >+ >+ // 2. Prepare the drop command >+ ViewDescriptor descriptor = new ViewDescriptor(createElementRequestAdapter, Node.class, /* explicit semantic hint is mandatory */ null, ViewDescriptorUtil.PERSISTED, host.getDiagramPreferencesHint()); >+ CreateViewRequest createViewRequest = new CreateViewRequest(descriptor); >+ createViewRequest.setLocation(request.getLocation().getCopy()); >+ Command viewCreateCommand = host.getCommand(createViewRequest); >+ >+ // 3. Create the compound command >+ cc.add(new ICommandProxy(createElementCommand)); >+ cc.add(viewCreateCommand); >+ >+ return cc; >+ } >+ >+ private boolean isValidStructureItemType(Object object, IElementType elementType) { >+ boolean isValid = false; >+ >+ if((object != null) && (object instanceof Type) && !(object instanceof Association)) { >+ >+ Type type = (Type)object; >+ if((elementType == SysMLElementTypes.PART_PROPERTY) || (elementType == SysMLElementTypes.REFERENCE_PROPERTY)) { >+ if(((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(type)) { >+ isValid = true; >+ } >+ } >+ if(elementType == SysMLElementTypes.ACTOR_PART_PROPERTY) { >+ if(type instanceof Actor) { >+ isValid = true; >+ } >+ } >+ if(elementType == SysMLElementTypes.VALUE_PROPERTY) { >+ if(((ISpecializationType)SysMLElementTypes.VALUE_TYPE).getMatcher().matches(type) || (type instanceof DataType)) { >+ isValid = true; >+ } >+ } >+ if((elementType == SysMLElementTypes.CONSTRAINT_PROPERTY)) { >+ if(((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(type)) { >+ isValid = true; >+ } >+ } >+ if(elementType == UMLElementTypes.PROPERTY) { >+ if(!((ISpecializationType)SysMLElementTypes.BLOCK).getMatcher().matches(type) >+ && !(type instanceof Actor) >+ && !(type instanceof DataType) >+ && !((ISpecializationType)SysMLElementTypes.VALUE_TYPE).getMatcher().matches(type)) { >+ isValid = true; >+ } >+ } >+ } >+ >+ return isValid; >+ } >+ >+ /** >+ * return the host Edit Part's semantic element, if the semantic element >+ * is <code>null</code> or unresolvable it will return <code>null</code> >+ * >+ * @return EObject >+ */ >+ protected EObject getHostEObject(GraphicalEditPart host) { >+ return ViewUtil.resolveSemanticElement((View)host.getModel()); >+ } >+} >diff --git a/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/src-gen/org/eclipse/papyrus/sysml/modelexplorer/handler/ConstraintPropertyHandler.java b/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/src-gen/org/eclipse/papyrus/sysml/modelexplorer/handler/ConstraintPropertyHandler.java >index 9a34c29..d70faf6 100644 >--- a/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/src-gen/org/eclipse/papyrus/sysml/modelexplorer/handler/ConstraintPropertyHandler.java >+++ b/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/src-gen/org/eclipse/papyrus/sysml/modelexplorer/handler/ConstraintPropertyHandler.java >@@ -11,7 +11,18 @@ > *****************************************************************************/ > package org.eclipse.papyrus.sysml.modelexplorer.handler; > >+import org.eclipse.emf.common.command.Command; >+import org.eclipse.emf.common.command.UnexecutableCommand; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EReference; >+import org.eclipse.gmf.runtime.common.core.command.ICommand; > import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; >+import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory; >+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; >+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; >+import org.eclipse.papyrus.sysml.diagram.common.commands.CreateConstraintPropertyWithTypeConfigureCommandFactory; >+import org.eclipse.papyrus.sysml.diagram.common.commands.CreatePartWithTypeConfigureCommandFactory; > import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes; > > /** >@@ -37,4 +48,37 @@ > protected IElementType getElementTypeToCreate() { > return SysMLElementTypes.CONSTRAINT_PROPERTY; > } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Command buildCommand() { >+ >+ if(getCommandContext() == null) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ EObject container = getCommandContext().getContainer(); >+ EReference reference = getCommandContext().getReference(); >+ >+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(container); >+ if(provider == null) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ CreateElementRequest createRequest = null; >+ if(reference == null) { >+ createRequest = new CreateElementRequest(container, getElementTypeToCreate()); >+ } else { >+ createRequest = new CreateElementRequest(container, getElementTypeToCreate(), reference); >+ } >+ createRequest.setParameter(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new CreateConstraintPropertyWithTypeConfigureCommandFactory()); >+ >+ // Retrieve create command from the Element Edit service >+ ICommand createGMFCommand = provider.getEditCommand(createRequest); >+ Command emfCommand = new org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper(createGMFCommand); >+ return emfCommand; >+ } >+ > } >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 >new file mode 100644 >index 0000000..61fdd09 >--- /dev/null >+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/ConstraintParameterEditHelperAdvice.java >@@ -0,0 +1,50 @@ >+/***************************************************************************** >+ * 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 >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.sysml.service.types.helper; >+ >+import org.eclipse.emf.ecore.EObject; >+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.ConfigureRequest; >+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; >+import org.eclipse.papyrus.sysml.constraints.ConstraintBlock; >+import org.eclipse.papyrus.sysml.constraints.ConstraintProperty; >+import org.eclipse.uml2.uml.Class; >+import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.util.UMLUtil; >+ >+/** Specific advice for Property creation owned by a {@link ConstraintBlock} >+ * ConstraintParameter are defined in ConstraintProperty but really owned by ConstraintBlock >+ */ >+public class ConstraintParameterEditHelperAdvice extends AbstractEditHelperAdvice { >+ >+ @Override >+ public ICommand getBeforeEditCommand(IEditCommandRequest request) { >+ if (request instanceof ConfigureRequest) { >+ EObject elementToConfigure = ((ConfigureRequest)request).getElementToConfigure(); >+ if (elementToConfigure != null && elementToConfigure instanceof Property) { >+ EObject container = elementToConfigure.eContainer(); >+ if (container != null && container instanceof Property) { >+ Property constraintProperty = (Property) container; >+ if (UMLUtil.getStereotypeApplication(constraintProperty, ConstraintProperty.class) != null) { >+ Type type = constraintProperty.getType(); >+ if (type != null && type instanceof Class && UMLUtil.getStereotypeApplication(type, ConstraintBlock.class) != null) { >+ ((Class)type).getOwnedAttributes().add((Property)elementToConfigure); >+ } >+ } >+ } >+ } >+ } >+ return super.getBeforeEditCommand(request); >+ } >+ >+} >diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/ConstraintParameterPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/ConstraintParameterPositionLocator.java >new file mode 100644 >index 0000000..a335bf0 >--- /dev/null >+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/ConstraintParameterPositionLocator.java >@@ -0,0 +1,108 @@ >+/***************************************************************************** >+ * Copyright (c) 2009-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 >+ * Vincent Lorenzo(CEA-List) vincent.lorenzo@cea.fr - getCurrentSideOfParent() >+ *****************************************************************************/ >+package org.eclipse.papyrus.uml.diagram.common.locator; >+ >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.geometry.Rectangle; >+ >+/** >+ * >+ * This code comes form composite diagram. I was copied to avoid dependencies >+ * This class is used to constrain the position of ConstraintParameter when they are added on a ConstraintProperty >+ * >+ * <pre> >+ * +-------------------+ >+ * | [Constraint] | >+ * +-------------------+ >+ * | | >+ * | | >+ * | +-+ - Expected position of ConstraintParameter >+ * | +-+ >+ * | | >+ * +-------------------+ >+ * >+ * </pre> >+ * >+ * <pre> >+ * TODO : The ConstraintParameter is not re-sizable >+ * </pre> >+ */ >+public class ConstraintParameterPositionLocator extends PortPositionLocator { >+ >+ /** the width of the area surrounding the parent figure where border item can be put */ >+ >+ private int constraintParameterSize = 20; >+ >+ /** Constructor **/ >+ public ConstraintParameterPositionLocator(IFigure parentFigure, int preferredSide) { >+ super(parentFigure, preferredSide); >+ borderItemOffset = 0; >+ } >+ >+ /** >+ * >+ * @param proposedLocation >+ * the proposed location >+ * @return a possible location on parent figure border >+ */ >+ public Rectangle getPreferredLocation(Rectangle proposedLocation) { >+ >+ // Initialize port location with proposed location >+ // and resolve the bounds of it graphical parent >+ Rectangle realLocation = new Rectangle(proposedLocation); >+ >+ Rectangle parentRec = getParentFigure().getBounds().getCopy(); >+ >+ // Calculate Max position around the graphical parent (1/2 size or the port around >+ // the graphical parent bounds. >+ int xMin = parentRec.x; >+ int xMax = parentRec.x + parentRec.width - constraintParameterSize; >+ int yMin = parentRec.y; >+ int yMax = parentRec.y + parentRec.height - constraintParameterSize; >+ >+ // Modify Port location if MAX X or Y are exceeded >+ if(realLocation.x < xMin) { >+ realLocation.x = xMin; >+ } >+ >+ if(realLocation.x > xMax) { >+ realLocation.x = xMax; >+ } >+ >+ if(realLocation.y < yMin) { >+ realLocation.y = yMin; >+ } >+ >+ if(realLocation.y > yMax) { >+ realLocation.y = yMax; >+ } >+ >+ // Ensure the port is positioned on its parent borders and not in the middle. >+ // Modify position if needed. >+ if((realLocation.y != yMin) && (realLocation.y != yMax)) { >+ if((realLocation.x != xMin) && (realLocation.x != xMax)) { >+ >+ if(realLocation.x <= (xMin + (parentRec.width / 2))) { >+ realLocation.x = xMin; >+ } else { >+ realLocation.x = xMax; >+ } >+ } >+ } >+ >+ // Return constrained location >+ return realLocation; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 297816
: 233707 |
234574
|
234575
|
234689
|
236075
|
236536
|
236961
|
236962