/***************************************************************************** * 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.pkg.provider; import static org.eclipse.papyrus.infra.core.Activator.log; 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.uml.diagram.pkg.edit.part.PackageDiagramEditPart; public class PackageDiagramEditPartProvider extends AbstractEditPartProvider { @Override public boolean provides(IOperation operation) { if(operation instanceof CreateGraphicEditPartOperation) { View view = ((IEditPartOperation)operation).getView(); // Ensure current diagram is Package 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 PackageDiagramEditPart.class; } log.error(new Exception("Could not create EditPart.")); return null; } }