1 | package de.ugoe.cs.swe.bnftools.ui.views.syntaxdiagram;
|
---|
2 |
|
---|
3 | import org.eclipse.draw2d.BorderLayout;
|
---|
4 | import org.eclipse.draw2d.ToolbarLayout;
|
---|
5 | import org.eclipse.draw2d.geometry.Dimension;
|
---|
6 |
|
---|
7 | public class OptionFigure extends SyntaxDiagramFigure {
|
---|
8 |
|
---|
9 | private BorderLayout layout;
|
---|
10 |
|
---|
11 | public OptionFigure(SyntaxDiagramFigure optionFigure) {
|
---|
12 | super();
|
---|
13 |
|
---|
14 | layout = new BorderLayout();
|
---|
15 |
|
---|
16 | setLayoutManager(layout);
|
---|
17 | addFigure(optionFigure);
|
---|
18 | setBorder(new LineMarginBorder(10,40,10,40,0));
|
---|
19 | }
|
---|
20 |
|
---|
21 | private void addFigure(SyntaxDiagramFigure f) {
|
---|
22 | SyntaxDiagramFigure upperContainer = new SyntaxDiagramFigure();
|
---|
23 | //upperContainer.setBorder(new LineBorder());
|
---|
24 | upperContainer.setPreferredSize(new Dimension(10,40));
|
---|
25 | ToolbarLayout loopLayout = new ToolbarLayout();
|
---|
26 | loopLayout.setStretchMinorAxis(false);
|
---|
27 | loopLayout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
|
---|
28 | loopLayout.setVertical(true);
|
---|
29 | upperContainer.setLayoutManager(loopLayout);
|
---|
30 | //upperContainer.setForegroundColor(ColorConstants.blue);
|
---|
31 | upperContainer.setVisible(true);
|
---|
32 | add(upperContainer, BorderLayout.TOP);
|
---|
33 | setLeftAnchor(new SideAnchor(this, upperContainer.getLeftAnchor(), SideAnchor.LEFT_SIDE));
|
---|
34 | setRightAnchor(new SideAnchor(this, upperContainer.getRightAnchor(), SideAnchor.RIGHT_SIDE));
|
---|
35 | layout.setConstraint(upperContainer, BorderLayout.TOP);
|
---|
36 |
|
---|
37 | SyntaxDiagramFigure dummy = new SyntaxDiagramFigure();
|
---|
38 | //dummy.setBorder(new LineBorder());
|
---|
39 | dummy.setPreferredSize(-1, upperContainer.getPreferredSize().height);
|
---|
40 | dummy.setVisible(true);
|
---|
41 | upperContainer.add(dummy);
|
---|
42 |
|
---|
43 | PathFigure upperGoThroughPath1 = new PathFigure();
|
---|
44 | upperGoThroughPath1.setSourceAnchor(upperContainer.getLeftAnchor());
|
---|
45 | upperGoThroughPath1.setTargetAnchor(dummy.getLeftAnchor());
|
---|
46 | upperContainer.add(upperGoThroughPath1);
|
---|
47 |
|
---|
48 | PathFigure upperGoThroughPath2 = new PathFigure();
|
---|
49 | upperGoThroughPath2.setSourceAnchor(dummy.getRightAnchor());
|
---|
50 | upperGoThroughPath2.setTargetAnchor(upperContainer.getRightAnchor());
|
---|
51 | upperContainer.add(upperGoThroughPath2);
|
---|
52 |
|
---|
53 | PathFigure upperGoThroughPath3 = new PathFigure();
|
---|
54 | upperGoThroughPath3.setTargetDecoration(null);
|
---|
55 | upperGoThroughPath3.setSourceAnchor(dummy.getRightAnchor());
|
---|
56 | upperGoThroughPath3.setTargetAnchor(this.getRightAnchor());
|
---|
57 | add(upperGoThroughPath3);
|
---|
58 |
|
---|
59 |
|
---|
60 | SyntaxDiagramFigure centerContainer = new SyntaxDiagramFigure();
|
---|
61 | centerContainer.setLayoutManager(new ToolbarLayout());
|
---|
62 | centerContainer.setVisible(true);
|
---|
63 | add(centerContainer, BorderLayout.CENTER);
|
---|
64 | layout.setConstraint(centerContainer, BorderLayout.CENTER);
|
---|
65 |
|
---|
66 | // PathFigure innerGoThroughPath = new PathFigure();
|
---|
67 | // innerGoThroughPath.setSourceAnchor(upperContainer.getLeftAnchor());
|
---|
68 | // innerGoThroughPath.setTargetAnchor(upperContainer.getRightAnchor());
|
---|
69 | // upperContainer.add(innerGoThroughPath);
|
---|
70 |
|
---|
71 | PathFigure innerGoThroughPath2 = new PathFigure();
|
---|
72 | // innerGoThroughPath2.setTargetDecoration(null);
|
---|
73 | innerGoThroughPath2.setSourceAnchor(this.getLeftAnchor());
|
---|
74 | innerGoThroughPath2.setTargetAnchor(upperContainer.getLeftAnchor());
|
---|
75 | add(innerGoThroughPath2);
|
---|
76 |
|
---|
77 | centerContainer.add(f);
|
---|
78 |
|
---|
79 | PathFigure leftPath = new PathFigure();
|
---|
80 | leftPath.setTargetDecoration(null);
|
---|
81 | leftPath.setSourceAnchor(this.getLeftAnchor());
|
---|
82 | leftPath.setTargetAnchor(f.getLeftAnchor());
|
---|
83 | add(leftPath);
|
---|
84 |
|
---|
85 | PathFigure rightPath = new PathFigure();
|
---|
86 | // rightPath.setTargetDecoration(null);
|
---|
87 | rightPath.setSourceAnchor(f.getRightAnchor());
|
---|
88 | rightPath.setTargetAnchor(this.getRightAnchor());
|
---|
89 | add(rightPath);
|
---|
90 |
|
---|
91 | }
|
---|
92 |
|
---|
93 | }
|
---|