private void saveSize() {
   if (fCurrentPage instanceof PreviewWizardPage) {
     Control control = fPageContainer.getTopPage();
     Point size = control.getSize();
     fSettings.put(WIDTH, size.x);
     fSettings.put(HEIGHT, size.y);
   }
 }
  private void resize() {

    if (isFirstPage()) {
      getShell().setBounds(fInitialSize);
      return;
    }

    Control control = fPageContainer.getTopPage();
    Point size = control.getSize();
    int dw = Math.max(0, fPreviewWidth - size.x);
    int dh = Math.max(0, fPreviewHeight - size.y);
    int dx = dw / 2;
    int dy = dh / 2;
    Shell shell = getShell();
    Rectangle rect = shell.getBounds();
    Rectangle clientRect = shell.getMonitor().getClientArea();
    rect.x = Math.max(clientRect.x, rect.x - dx);
    rect.y = Math.max(clientRect.y, rect.y - dy);

    // limit with and height to monitor
    rect.width = Math.min(rect.width + dw, clientRect.width);
    rect.height = Math.min(rect.height + dh, clientRect.height);

    // Reposition the dialog so that it will be fully visible.
    // Normalize x and y relative to the client area.
    int xe = (rect.x - clientRect.x) + rect.width;
    if (xe > clientRect.width) {
      rect.x -= xe - clientRect.width;
    }
    int ye = (rect.y - clientRect.y) + rect.height;
    if (ye > clientRect.height) {
      rect.y -= ye - clientRect.height;
    }

    shell.setBounds(rect);
  }