1.把焦点定位到编辑器中的指定模型上
public static void setScroll(CommonEditor editor, ICommonModel model)
{
GraphicalViewer viewer = editor.getGraphicalViewer();
Object part = viewer.getEditPartRegistry().get(model);
viewer.setSelection(new StructuredSelection(part));
FigureCanvas canvas = (FigureCanvas) editor.getGraphicalViewer()
.getControl();
Object obj = model.getConstraint();
if (obj instanceof Rectangle)
{
Rectangle rect = (Rectangle) obj;
canvas.scrollToX(rect.x - canvas.getBounds().width / 2);
canvas.scrollToY(rect.y - canvas.getBounds().height / 2);
}
}