Esempio n. 1
0
  /**
   * Creates the inner controls
   *
   * @param parent the parent composite
   */
  public void createControl(Composite parent) {
    // An swt canvas and lws drawing the figure.
    overview = new Canvas(parent, SWT.NONE);
    overview.setLayoutData(new GridData(GridData.FILL_BOTH));
    // A draw2d object linking swt and draw2d
    LightweightSystem lightweightSystem = new LightweightSystem(overview);

    // create the thumbnail
    thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
    thumbnail.setBorder(new MarginBorder(3));
    thumbnail.setSource(
        rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS /* SCALABLE_LAYERS */));
    lightweightSystem.setContents(thumbnail);
  }
  /** Initialize overview. */
  protected void initializeOverview() {
    LightweightSystem lws = new J2DLightweightSystem(overview);

    RootEditPart rep = editor.getGraphicalViewer().getRootEditPart();
    if (rep instanceof MainDesignerRootEditPart) {
      ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
      thumbnail =
          new JSSScrollableThumbnail(
              (Viewport) root.getFigure(), (MRoot) getViewer().getContents().getModel());
      thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS));
      lws.setContents(thumbnail);
      disposeListener =
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
              if (thumbnail != null) {
                thumbnail.deactivate();
                thumbnail = null;
              }
            }
          };
      editor.getEditor().addDisposeListener(disposeListener);
    }
    lws.setControl(overview);
  }