blob: b48b56a78af456e56b0b2685cb96b3c4a5364a2b [file] [log] [blame]
/*****************************************************************************
* 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.internalblock.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.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 InternalBlock 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;
}
}