문제

I have a GEF Editor with the following RootEditPart.

public class MyProjectEditPart extends AbstractGraphicalEditPart {

@Override
protected IFigure createFigure() {
    ScalableFreeformLayeredPane layer = new ScalableFreeformLayeredPane();
    layer.setLayoutManager(new FreeformLayout());
    return layer;
  }

I'm using the editor to create a bottom-up tree:

     _7_
    /   \
   5     6
  / \   / \
 1   2 3   4 

1-7 are Rectangles, where 1-4 represent different model elements than 5-7. At the moment, all figures are laid out by foot (new Rectangle(x, y, w, h) + parent.setConstraint(this, figure, rectangle)). The position of figures 5-7 is calculated with a simple algorithm, based on the position on figures 1-4.

For the sake of practicality I'd like to be able to simply add 1-4 to a FlowLayouted Figure at the BorderLayout.BOTTOM of the RootFigure, and add the rest of the figures to the RootFigure's BorderLayout.CENTER.

However, I'm pretty new to GEF and can't get my head around how to do it. I fail to find the right method for adding the figures 1-4 in their respective EditPart's createFigure().

For example, I've tried stuff like parent.getFigure().getChildren().get(0).add(Figure_1) for example, with the RootEditPart's createFigure() method adding two new figures to BorderLayout.BOTTOM and CENTER respectively..

I'd be thankful for any starting points :).

도움이 되었습니까?

해결책

You need an EditPartFactory which "dispatches" the model elements to different EditParts. The toplevel editpart (7) should then implement getModelChildren to return the 5 and 6, whose editparts in turn should return as children the 1,2 and 3,4.

How about taking some time the GEF shape example and/or with http://www.redbooks.ibm.com/abstracts/sg246302.html ?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top