1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/*******************************************************************************
* Copyright (c) 2001, 2007 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.wst.wsdl.ui.internal.asd.design.editparts;
import java.util.Iterator;
import java.util.List;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.gef.EditPart;
import org.eclipse.wst.wsdl.ui.internal.asd.design.DesignViewGraphicsConstants;
import org.eclipse.wst.wsdl.ui.internal.asd.design.figures.BoxComponentFigure;
//import org.eclipse.wst.wsdl.ui.internal.asd.design.figures.BaseLinkIconFigure;
import org.eclipse.wst.wsdl.ui.internal.asd.design.layouts.RowLayout;
import org.eclipse.wst.wsdl.ui.internal.asd.facade.IInterface;
import org.eclipse.wst.wsdl.ui.internal.asd.outline.ITreeElement;
public class InterfaceEditPart extends AbstractBoxtEditPart implements IFeedbackHandler
{
private RectangleFigure linkIconColumn;
protected BoxComponentFigure boxFigure;
public InterfaceEditPart()
{
columnData.setColumnWeight("MessageLabel", 0); //$NON-NLS-1$
columnData.setColumnWeight("MessageContentPane", 100); //$NON-NLS-1$
columnData.setColumnWeight("parameterName", 50); //$NON-NLS-1$
columnData.setColumnWeight("parameterType", 50); //$NON-NLS-1$
}
protected IFigure createFigure()
{
IFigure outer = new Figure() {
public void validate() {
super.validate();
// If we don't layout our Link Icon Column at this point, the link icons
// will not be properly updated in the scenario where a porttype is added
// or removed. The link icons of the existing porttypes will not be updated.
getLinkIconColumn().getLayoutManager().layout(getLinkIconColumn());
}
};
outer.setLayoutManager(new ToolbarLayout(true));
boxFigure = (BoxComponentFigure) super.createFigure();
if (getModel() instanceof ITreeElement) {
boxFigure.getLabel().setIcon(((ITreeElement) getModel()).getImage());
}
boxFigure.setBackgroundColor(ColorConstants.orange);
boxFigure.setBorder(new LineBorder(1));
ToolbarLayout toolbarLayout = new ToolbarLayout(false);
toolbarLayout.setStretchMinorAxis(true);
boxFigure.setLayoutManager(toolbarLayout);
outer.add(boxFigure);
linkIconColumn = new RectangleFigure();
linkIconColumn.setOutline(false);
linkIconColumn.setLayoutManager(new ToolbarLayout() {
public void layout(IFigure parent) {
super.layout(parent);
// We need to layout on the y-axis
Iterator children = parent.getChildren().iterator();
while (children.hasNext()) {
Object item = children.next();
if (item instanceof IFigure) {
IFigure figure = (IFigure) item;
figure.getLayoutManager().layout(figure);
}
}
}
protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
Dimension dimension = super.calculatePreferredSize(container, wHint, hHint);
// Calculate the height
Iterator it = container.getParent().getChildren().iterator();
while (it.hasNext()) {
Object item = it.next();
if (item instanceof BoxComponentFigure) {
dimension.height = ((IFigure) item).getPreferredSize().height;
break;
}
}
return dimension;
}
});
outer.add(linkIconColumn);
// rmah: The block of code below has been moved from refreshVisuals(). We're
// assuming the read-only state of the EditPart will never change once the
// EditPart has been created.
if (isReadOnly())
{
figure.getLabel().setForegroundColor(DesignViewGraphicsConstants.readOnlyLabelColor);
}
else
{
figure.getLabel().setForegroundColor(ColorConstants.black);
}
return outer;
}
public static void attachToInterfaceEditPart(EditPart editPart, RowLayout rowLayout)
{
for (EditPart parent = editPart.getParent(); parent != null; parent = parent.getParent())
{
if (parent instanceof InterfaceEditPart)
{
InterfaceEditPart interfaceEditPart = (InterfaceEditPart)parent;
rowLayout.setColumnData(interfaceEditPart.columnData);
break;
}
}
}
protected void refreshChildren()
{
super.refreshChildren();
}
protected void refreshVisuals()
{
super.refreshVisuals();
}
protected List getModelChildren()
{
IInterface theInterface = (IInterface)getModel();
return theInterface.getOperations();
}
public void addFeedback() {
super.addFeedback();
}
public void removeFeedback() {
super.removeFeedback();
}
public EditPart getRelativeEditPart(int direction)
{
if (direction == PositionConstants.WEST)
{
return EditPartNavigationHandlerUtil.getSourceConnectionEditPart(this);
}
return super.getRelativeEditPart(direction);
}
public IFigure getLinkIconColumn() {
return linkIconColumn;
}
}
|