Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Help! Reparent view
Help! Reparent view [message #244383] Thu, 17 July 2008 02:24 Go to next message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

This is a multi-part message in MIME format.
--------------010104080801050005080106
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I defined a simple ecore model as the attached image described.

There's two class one is Block, the other is CompositeBlock which is
inherited from Block

CompositeBlock is used to be Diagram model, both can be added in Diagram
as Nodes, that means there will be two CompositeBlockEditParts,
inherited from DiagramEditPart and ShapeNodeEditPart respectively.

I also set the *Related Diagram* property to *Canvas Mapping*(only one
canvas mapping defined) on CompositeBlock Node defeinition, so A new
diagram editor will open when I double click a CompositeBlock Node on
original editor, as you know, the two editor share same model.

Now, assume that I added three Block Node on original editor, and select
ed them all, then click *Merge* from context menu, the *Merge* action
will created a new CompositeBlock Node, attach a new created Diagram to
its HintedDiagramStyle. The most important step is move the selected
three Block Node to new created Diagram, in short, reparent view.

I tried several times as blow, but it failed.

MergeCommand:

Diagram diagram = getDiagram();

List<Node> selected = getSelectedNodes();

for(Node n : selected)
{
diagram.removeChild(n);
}

Node compositeBlockNode = newCreatedCompositeBlockNode();

HintedDiagramLinkStyle diagram_style = (HintedDiagramLinkStyle)
compositeBlockNode.getStyle(NotationPackage.eINSTANCE.getHin tedDiagramLinkStyle());

Diagram nestedDiagram = createLinkDiagramAndPersist(diagram_style);

for (Node n: selected)
{
nestedDiagram.insertChild(n);
}

persistAll();

I know above code doesn't work because the parent of all selected Nodes
still reference diagram not nestedDiagram, but I don't know how to
change it. Code may be like as blow:

CompositeBlock diagram_model = nestedDiagram.getElement();
for (Node n: selected)
{
changeViewParent(n, nestedDiagram);
changeModelParent(n.getElement, diagram_model);
nestedDiagram.insertChild(n);
}


Thanks!


--------------010104080801050005080106
Content-Type: image/jpeg;
name="ecore.JPG"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="ecore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ABRRR
QAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9k=
--------------010104080801050005080106--
Re: Help! Reparent view [message #244391 is a reply to message #244383] Thu, 17 July 2008 04:27 Go to previous message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

Sorry, please move this thread to GMF group, thanks!
David BY Chan wrote:
> I defined a simple ecore model as the attached image described.
>
> There's two class one is Block, the other is CompositeBlock which is
> inherited from Block
>
> CompositeBlock is used to be Diagram model, both can be added in Diagram
> as Nodes, that means there will be two CompositeBlockEditParts,
> inherited from DiagramEditPart and ShapeNodeEditPart respectively.
>
> I also set the *Related Diagram* property to *Canvas Mapping*(only one
> canvas mapping defined) on CompositeBlock Node defeinition, so A new
> diagram editor will open when I double click a CompositeBlock Node on
> original editor, as you know, the two editor share same model.
>
> Now, assume that I added three Block Node on original editor, and select
> ed them all, then click *Merge* from context menu, the *Merge* action
> will created a new CompositeBlock Node, attach a new created Diagram to
> its HintedDiagramStyle. The most important step is move the selected
> three Block Node to new created Diagram, in short, reparent view.
>
> I tried several times as blow, but it failed.
>
> MergeCommand:
>
> Diagram diagram = getDiagram();
>
> List<Node> selected = getSelectedNodes();
>
> for(Node n : selected)
> {
> diagram.removeChild(n);
> }
>
> Node compositeBlockNode = newCreatedCompositeBlockNode();
>
> HintedDiagramLinkStyle diagram_style = (HintedDiagramLinkStyle)
> compositeBlockNode.getStyle(NotationPackage.eINSTANCE.getHin tedDiagramLinkStyle());
>
>
> Diagram nestedDiagram = createLinkDiagramAndPersist(diagram_style);
>
> for (Node n: selected)
> {
> nestedDiagram.insertChild(n);
> }
>
> persistAll();
>
> I know above code doesn't work because the parent of all selected Nodes
> still reference diagram not nestedDiagram, but I don't know how to
> change it. Code may be like as blow:
>
> CompositeBlock diagram_model = nestedDiagram.getElement();
> for (Node n: selected)
> {
> changeViewParent(n, nestedDiagram);
> changeModelParent(n.getElement, diagram_model);
> nestedDiagram.insertChild(n);
> }
>
>
> Thanks!
>
>
> ------------------------------------------------------------ ------------
>
Previous Topic:[Announce] GEF 3.4.1 M200807161625 is available
Next Topic:Problem saving Draw2d diagram to image from within plugin (works standalone)
Goto Forum:
  


Current Time: Thu Dec 18 11:41:15 GMT 2014

Powered by FUDForum. Page generated in 0.02921 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software