[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[stp-commits] r3319 - org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram.sca/src/org/eclipse/stp/sca/diagram/sca/dnd

Author: sdrapeau
Date: 2009-09-15 06:44:39 -0400 (Tue, 15 Sep 2009)
New Revision: 3319

Added:
   org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram.sca/src/org/eclipse/stp/sca/diagram/sca/dnd/ScaCompositeFileImplementationDD.java
Log:
Added composite file DnD

Added: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram.sca/src/org/eclipse/stp/sca/diagram/sca/dnd/ScaCompositeFileImplementationDD.java
===================================================================
--- org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram.sca/src/org/eclipse/stp/sca/diagram/sca/dnd/ScaCompositeFileImplementationDD.java	                        (rev 0)
+++ org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram.sca/src/org/eclipse/stp/sca/diagram/sca/dnd/ScaCompositeFileImplementationDD.java	2009-09-15 10:44:39 UTC (rev 3319)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007-2008-2009 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
+ *    Maxime Porhel (Obeo) <maxime.porhel@xxxxxxx> - IDragDropHandler evolution. 
+ *    Jamil Shaikh (RIM) <jshaikh@xxxxxxx> - re-designed
+ */
+package org.eclipse.stp.sca.diagram.sca.dnd;
+
+import org.eclipse.emf.ecore.xml.type.internal.QName;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.stp.sca.Component;
+import org.eclipse.stp.sca.Composite;
+import org.eclipse.stp.sca.SCAImplementation;
+import org.eclipse.stp.sca.ScaPackage;
+import org.eclipse.stp.sca.diagram.edit.parts.ComponentComponentAreaEditPart;
+import org.eclipse.stp.sca.diagram.providers.ScaElementTypes;
+import org.eclipse.swt.dnd.DropTargetEvent;
+
+/**
+ * @author Stephane Drapeau - Obeo
+ */
+public class ScaCompositeFileImplementationDD extends AbstractCompositeFileDD {
+	
+	@Override
+	public boolean isEnabled(DropTargetEvent event, EditPart part) {
+		return true;
+	}
+
+	@Override
+	public boolean editPartIsOk(GraphicalEditPart editPart) {
+		return editPart instanceof ComponentComponentAreaEditPart;
+	}
+	
+	@Override
+	protected IElementType getType(GraphicalEditPart editPart) {
+		return ScaElementTypes.SCAImplementation_3025;
+	}
+
+	@Override
+	protected Component postTreatment(GraphicalEditPart editPart, View view,
+			Composite composite) {
+		SCAImplementation newMod = (SCAImplementation) view.getElement();
+		SetRequest reqSet = new SetRequest(
+		editPart.getEditingDomain(),
+		newMod,
+		ScaPackage.Literals.SCA_IMPLEMENTATION__NAME,
+		new QName(composite.getTargetNamespace(), composite.getName(), ""));//$NON-NLS-1$
+		SetValueCommand operation = new SetValueCommand(reqSet);
+		editPart.getDiagramEditDomain().getDiagramCommandStack().execute(
+				new ICommandProxy(operation));
+		return (Component) newMod.eContainer();
+	}
+
+	
+}


Property changes on: org.eclipse.stp.sca/trunk/org.eclipse.stp.sca.diagram.sca/src/org/eclipse/stp/sca/diagram/sca/dnd/ScaCompositeFileImplementationDD.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain