use of org.eclipse.wst.xsd.ui.internal.design.layouts.ContainerLayout in project webtools.sourceediting by eclipse.
the class CategoryEditPart method createFigure.
protected IFigure createFigure() {
outerPane = new Figure();
outerPane.setBorder(new RoundedLineBorder(1, 6));
createHeadingFigure();
int minHeight = SWT.DEFAULT;
switch(getType()) {
case CategoryAdapter.DIRECTIVES:
{
minHeight = 80;
break;
}
case CategoryAdapter.ATTRIBUTES:
case CategoryAdapter.GROUPS:
{
minHeight = 100;
break;
}
}
final int theMinHeight = minHeight;
ToolbarLayout outerLayout = new ToolbarLayout(false) {
protected Dimension calculatePreferredSize(IFigure parent, int width, int height) {
Dimension d = super.calculatePreferredSize(parent, width, height);
d.union(new Dimension(250, theMinHeight));
return d;
}
};
outerLayout.setStretchMinorAxis(true);
outerPane.setLayoutManager(outerLayout);
RectangleFigure line = new RectangleFigure() {
public Dimension getPreferredSize(int wHint, int hHint) {
Dimension d = super.getPreferredSize(wHint, hHint);
d.width += 20;
d.height = 1;
return d;
}
};
ToolbarLayout lineLayout = new ToolbarLayout(false);
lineLayout.setVertical(true);
lineLayout.setStretchMinorAxis(true);
line.setLayoutManager(lineLayout);
outerPane.add(line);
scrollpane = new ScrollPane();
// ScrollPane.ALWAYS);
scrollpane.setVerticalScrollBarVisibility(ScrollPane.AUTOMATIC);
outerPane.add(scrollpane);
Figure pane = new Figure();
pane.setBorder(new MarginBorder(5, 8, 5, 8));
ContainerLayout layout = new ContainerLayout();
layout.setHorizontal(false);
layout.setSpacing(0);
pane.setLayoutManager(layout);
Viewport viewport = new Viewport();
viewport.setContentsTracksHeight(true);
ViewportLayout viewportLayout = new ViewportLayout() {
protected Dimension calculatePreferredSize(IFigure parent, int width, int height) {
Dimension d = super.calculatePreferredSize(parent, width, height);
if (theMinHeight > 0)
d.height = Math.min(d.height, theMinHeight);
else {
double factor = getZoomManager().getZoom();
// adjust for other categories and spaces
int scaledHeight = (int) Math.round((getViewer().getControl().getBounds().height - minimumHeight) / factor);
d.height = Math.max(250, scaledHeight);
}
d.width = Math.min(d.width, 300);
return d;
}
};
viewport.setLayoutManager(viewportLayout);
scrollpane.setViewport(viewport);
scrollpane.setContents(pane);
return outerPane;
}
Aggregations