[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Programmatically drag and drop

The easiest way would be to create your abstract transactional command
that adds one component to a different container. This is equivalent of a
move since EMF will remove it from its previous container.

Execute that command on the operation history.

-vlad

On Mon, 15 Jan 2007 18:16:51 +0100, Jörg Weinmann wrote:

> Hi everybody,
> 
> I need some help with the various Request subclasses of GMF-runtime.
> In my EMF model the class "Component" has a reference "contains" to itself, 
> so that a Component can contain several other "Components". I already have a 
> GMF-generated editor for my model.
> 
> So for example, let C_A be a Component which contains Components C_A1 and 
> C_A2. And let C_B be an other Component.
> What I want to do is programmatically move C_A1 and C_A2 to C_B, so that C_B 
> contains C_A1 and C_A2 and C_A is "empty".
> 
> I already tried SetRequest&DestroyRequest and MoveRequest, but it is not 
> working like I exepected it. So basically all I want to do is simulate a d&d 
> programmtically.
> 
> 
> My underlying gmf model loks like this:
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage 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"; 
> name="ConnectorComponent"
>     nsURI="www.iese.fraunhofer.de/ConnectorComponent" nsPrefix="cmpnt">
>   <eClassifiers xsi:type="ecore:EClass" name="AbstractComponent" 
> abstract="true" eSuperTypes="#//ArchitecturalElements">
>     <eStructuralFeatures xsi:type="ecore:EReference" name="contains" 
> upperBound="-1"
>         eType="#//AbstractComponent" containment="true"/>
>     <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" 
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>   </eClassifiers>
>   <eClassifiers xsi:type="ecore:EClass" name="AbstractConnector" 
> abstract="true" eSuperTypes="#//ArchitecturalElements">
>     <eStructuralFeatures xsi:type="ecore:EReference" name="source" 
> lowerBound="1"
>         eType="#//AbstractComponent"/>
>     <eStructuralFeatures xsi:type="ecore:EReference" name="target" 
> lowerBound="1"
>         eType="#//AbstractComponent"/>
>     <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" 
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>   </eClassifiers>
>   <eClassifiers xsi:type="ecore:EClass" name="ArchitecturalDescription">
>     <eStructuralFeatures xsi:type="ecore:EReference" name="has" 
> upperBound="-1" eType="#//ArchitecturalElements"
>         containment="true"/>
>   </eClassifiers>
>   <eClassifiers xsi:type="ecore:EClass" name="ArchitecturalElements" 
> abstract="true"/>
>   <eClassifiers xsi:type="ecore:EClass" name="Connector" 
> eSuperTypes="#//AbstractConnector"/>
>   <eClassifiers xsi:type="ecore:EClass" name="Component" 
> eSuperTypes="#//AbstractComponent"/>
> </ecore:EPackage>
> 
> Input: