protected void reveal(GraphicalEditPart part) {
// there's no need to scroll to the main edit part because it is always visible
if (part instanceof MainTrayEditPart) return;
MainTrayEditPart mainPart = getMainTrayEditPart(part);
ScrollPane scrollpane = ((MainTrayEditPart.MainTrayContainerFigure)mainPart.getFigure()).getChildrenScrollPane();
Viewport viewport = scrollpane.getViewport();
Rectangle partBounds = part.getFigure().getBounds().getCopy();
Rectangle portBounds = viewport.getBounds();
if (!portBounds.contains(partBounds)) {
Point topLocation = partBounds.getTopLeft();
Point currentLocation = viewport.getViewLocation();
int step = getScrollStep(part);
if (currentLocation.getPosition(topLocation) == PositionConstants.NORTH) {
currentLocation.y -= step;
// ensure that we don't leave things "half-scrolled" at the top
currentLocation.y = (currentLocation.y < step) ? 0 : currentLocation.y;
} else {
currentLocation.y += step;
}
viewport.setViewLocation(currentLocation);
// refreshes the scrollbar so they can disppear if needed
ScrollBar scrollbar = scrollpane.getVerticalScrollBar();
scrollbar.invalidate();
scrollbar.validate();
}
}