/** @see org.eclipse.jface.window.Window#constrainShellSize() */
    @Override
    protected void constrainShellSize() {
      super.constrainShellSize();

      final Shell shell = getShell();
      shell.setText(Messages.selectProcedureTypeDialogTitle);

      { // set size
        final Rectangle r = shell.getBounds();
        shell.setBounds(r.x, r.y, (int) (r.width * 0.67), r.height);
      }

      { // center on parent
        final Shell parentShell = (Shell) shell.getParent();
        final Rectangle parentBounds = parentShell.getBounds();
        final Point parentCenter =
            new Point(
                parentBounds.x + (parentBounds.width / 2),
                parentBounds.y + parentBounds.height / 2);

        final Rectangle r = shell.getBounds();
        final Point shellLocation =
            new Point(parentCenter.x - r.width / 2, parentCenter.y - r.height / 2);

        shell.setBounds(
            Math.max(0, shellLocation.x), Math.max(0, shellLocation.y), r.width, r.height);
      }
    }
Exemple #2
0
 private void centerShell(Shell parent, Shell shell) {
   Rectangle parentBounds = parent.getBounds();
   Rectangle childBounds = shell.getBounds();
   int x = parentBounds.x + (parentBounds.width - childBounds.width) / 2;
   int y = parentBounds.y + (parentBounds.height - childBounds.height) / 2;
   shell.setLocation(x, y);
 }
Exemple #3
0
 public static void placeDialogInCenter(Shell parent, Shell shell) {
   Rectangle parentSize = parent.getBounds();
   Rectangle mySize = shell.getBounds();
   int locationX, locationY;
   locationX = (parentSize.width - mySize.width) / 2 + parentSize.x;
   locationY = (parentSize.height - mySize.height) / 2 + parentSize.y;
   shell.setLocation(new Point(locationX, locationY));
 }
 /** Create contents of the dialog. */
 private void createContents() {
   shell = new Shell(getParent(), getStyle());
   shell.setSize(1200, 500);
   shell.setText("\u67E5\u770B\u7B7E\u540D");
   shell.setLayout(new FillLayout(SWT.HORIZONTAL));
   shell.setLocation(
       (Display.getDefault().getBounds().width - shell.getBounds().width) / 2,
       (Display.getDefault().getBounds().height - shell.getBounds().height) / 2);
 }
  @Override
  protected void configureShell(Shell newShell) {
    super.configureShell(newShell);
    newShell.setText(Messages.COMPILELOADER);

    Rectangle parentBounds = parentShell.getBounds();
    Rectangle shellBounds = newShell.getBounds();
    newShell.setLocation(
        parentBounds.x + (parentBounds.width - shellBounds.width) / 2,
        parentBounds.y + (parentBounds.height - shellBounds.height) / 2);
  }
  protected void setDialogPosition(Shell shell) {
    String position = this.getConfiguration().getProperty(CFG_POSITION, "left-top");
    if (DisplayManager.getDefaultDisplay() == null) {
      this.m_logger.severe("Could not get monitor device object for dialog.");
      return;
    }
    Monitor primaryMonitor = DisplayManager.getDefaultDisplay().getPrimaryMonitor();

    int offset = m_instance_count * 15;

    int x = 0, y = 0;

    // added 2008/04/07: set minimal width and height
    shell.setBounds(
        x, y, Math.max(shell.getBounds().width, 165), Math.max(shell.getBounds().height, 115));

    if (position.equalsIgnoreCase("left-top")) {
      x = 5 + offset;
      y = 5 + offset;
    }
    if (position.equalsIgnoreCase("right-top") || position.length() == 0) {
      y = 5 + offset;
      x = primaryMonitor.getClientArea().width - shell.getBounds().width - 30 - offset;
    }
    if (position.equalsIgnoreCase("left-bottom")) {
      x = 5;
      y = primaryMonitor.getClientArea().height - shell.getBounds().height - 35 - offset;
    }
    if (position.equalsIgnoreCase("right-bottom")) {
      x = primaryMonitor.getClientArea().width - shell.getBounds().width - 30 - offset;
      y = primaryMonitor.getClientArea().height - shell.getBounds().height - 35 - offset;
    }
    if (position.equalsIgnoreCase("center")) {
      x = (primaryMonitor.getClientArea().width / 2) - (shell.getBounds().width / 2) - 1 - offset;
      y =
          (primaryMonitor.getClientArea().height / 2)
              - (shell.getBounds().height / 2)
              - 35
              - offset;
    }

    // dialog has free defined position
    if (this.isFreePositioning()) {
      x = this.getFreePosX();
      y = this.getFreePosY();
    }

    shell.setBounds(x, y, shell.getBounds().width, shell.getBounds().height);
  }
  private void updateShellStructure() {
    Region region = new Region(mShell.getDisplay());
    int maxX = mShell.getBounds().width;
    int maxY = mShell.getBounds().height;

    region.add(0, 0, maxX, maxY);

    if (!getMaximized()) {
      // top left
      region.subtract(0, 0, 4, 1);
      region.subtract(0, 1, 2, 1);
      region.subtract(0, 2, 1, 1);
      region.subtract(0, 3, 1, 1);

      // bottom right
      region.subtract(maxX - 1, maxY - 4, 1, 4);
      region.subtract(maxX - 2, maxY - 2, 1, 2);
      region.subtract(maxX - 3, maxY - 1, 1, 1);
      region.subtract(maxX - 4, maxY - 1, 1, 1);

      // bottom left
      region.subtract(0, maxY - 4, 1, 4);
      region.subtract(1, maxY - 2, 1, 2);
      region.subtract(2, maxY - 1, 1, 1);
      region.subtract(3, maxY - 1, 1, 1);

      // top right
      region.subtract(maxX - 4, 0, 4, 1);
      region.subtract(maxX - 2, 1, 2, 1);
      region.subtract(maxX - 1, 2, 1, 1);
      region.subtract(maxX - 1, 3, 1, 1);
    }

    mShell.setRegion(region);
  }
  private void drawBackground(GC gc) {
    Rectangle bounds = mShell.getBounds();
    if (!getMaximized()) {
      Color borderColor = null;
      if (Display.getDefault().getActiveShell() == mShell)
        borderColor = AbstractShellPainter.outerBorderNonMaximized;
      else borderColor = AbstractShellPainter.outerBorderNonMaximized_Inactive;
      gc.setBackground(borderColor);

      gc.fillRectangle(0, 0, bounds.width, bounds.height);

      gc.setBackground(bgColor);
      gc.fillRectangle(1, 1, bounds.width - 2, bounds.height - 2);

      // draw pretty borders, only bottoms, the top borders (as the menubar needs to connect for the
      // big button to work)
      // are drawn in a similar fashion in the RibbonTabFolder

      gc.setForeground(borderColor);
      // bottom left
      gc.drawLine(1, bounds.height - 4, 1, bounds.height - 4);
      gc.drawLine(1, bounds.height - 3, 2, bounds.height - 3);
      gc.drawLine(2, bounds.height - 2, 3, bounds.height - 2);

      // bottom right
      gc.drawLine(bounds.width - 4, bounds.height - 2, bounds.width - 3, bounds.height - 2);
      gc.drawLine(bounds.width - 3, bounds.height - 3, bounds.width - 2, bounds.height - 3);
      gc.drawLine(bounds.width - 2, bounds.height - 4, bounds.width - 2, bounds.height - 4);
    } else {
      gc.setBackground(bgColor);
      gc.fillRectangle(bounds);
    }
  }
  public void positionWindow(boolean resetToDefault) {
    String mapWindow;

    mapShellBounds = mapShell.getBounds();
    mapWindow = prefs.get(RadarConsts.PREF_KEY_MAP_WINDOW, "");

    if (mapWindow.equals("") || resetToDefault) {
      Rectangle dispBounds, tableBounds;

      dispBounds = ((Display.getCurrent()).getPrimaryMonitor()).getClientArea();
      tableBounds = display.getShells()[1].getBounds();

      mapShellBounds.width = dispBounds.width - tableBounds.width;
      mapShellBounds.height = dispBounds.height;
      mapShellBounds.x = dispBounds.x + tableBounds.width;
      mapShellBounds.y = dispBounds.y;
    } else {
      String[] tokens = mapWindow.split(",");

      mapShellBounds =
          new Rectangle(
              new Integer(tokens[0]), // X value
              new Integer(tokens[1]), // Y value
              new Integer(tokens[2]), // Width
              new Integer(tokens[3]) // Height
              );
    }
    mapShell.setBounds(mapShellBounds);
  }
  @Override
  protected String browse(final Presentation context) {
    final Property property = property();

    final Shell parent = ((FormComponentPresentation) context).shell();
    final Rectangle bounds = parent.getBounds();

    // There is no means to compute the size of the color dialog. In the following
    // computations, measurements of the dialog on Windows 7 are used. Will need to
    // generalize in the future.

    final int x = bounds.x + bounds.width / 2 - 120;
    final int y = bounds.y + bounds.height / 2 - 170;

    final Shell shell = new Shell(parent);

    try {
      shell.setBounds(x, y, 0, 0);

      final ColorDialog dialog = new ColorDialog(shell);

      dialog.setText(property.definition().getLabel(false, CapitalizationType.TITLE_STYLE, false));
      dialog.setRGB(convert((Color) ((Value<?>) property).content()));

      final RGB pickedColor = dialog.open();

      if (pickedColor != null) {
        return convert(pickedColor).toString();
      }
    } finally {
      shell.dispose();
    }

    return null;
  }
 public void dispose() {
   props.setScreen(new WindowProperty(shell));
   bounds = shell.getBounds();
   hscroll = wFields.getHorizontalBar().getSelection();
   vscroll = wFields.getVerticalBar().getSelection();
   shell.dispose();
 }
 /**
  * Save the current dialog bounds if they have changed. To use this method, the corresponding
  * dialog must be set in the constructor.
  */
 public void saveBounds() {
   if (dialog == null)
     throw new IllegalStateException(
         "Corresponding dialog is not set when trying to save dialog bounds."); //$NON-NLS-1$
   Shell sh = dialog.getShell();
   if (sh != null && !sh.isDisposed() && isBoundsChanged()) saveBounds(sh.getBounds());
 }
 private static void enlargeShell(Shell shell) {
   Rectangle bounds = shell.getBounds();
   int xPos = bounds.x;
   int yPos = bounds.y;
   int width = bounds.width + RESIZE_OFFSET;
   int height = bounds.height + RESIZE_OFFSET;
   setShellSize(shell, new Rectangle(xPos, yPos, width, height));
 }
Exemple #14
0
 public static Point centerWindow(Shell shell) {
   Monitor m = Display.getCurrent().getPrimaryMonitor();
   Rectangle bounds = m.getBounds();
   Rectangle rect = shell.getBounds();
   int x = bounds.x + (bounds.width - rect.width) / 2;
   int y = bounds.y + (bounds.height - rect.height) / 2;
   return new Point(x, y);
 }
Exemple #15
0
 /** Center the supplied Shell */
 public static void centerShell(Shell shell) {
   Display d = shell.getDisplay();
   Rectangle db = d.getBounds();
   Rectangle sb = shell.getBounds();
   int xoffset = (db.width - sb.width) / 2;
   int yoffset = (db.height - sb.height) / 2;
   shell.setLocation(xoffset, yoffset);
 }
Exemple #16
0
 private void setHoverLocation(
     org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.graphics.Point position) {
   org.eclipse.swt.graphics.Rectangle displayBounds = shell.getDisplay().getBounds();
   org.eclipse.swt.graphics.Rectangle shellBounds = shell.getBounds();
   shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - shellBounds.width), 0);
   shellBounds.y =
       Math.max(Math.min(position.y + 16, displayBounds.height - shellBounds.height), 0);
   shell.setBounds(shellBounds);
 }
 public void setSizeAndLocation(WizardDialog wizardDialog) {
   wizardDialog.getShell().setSize(600, 500);
   Shell activeShell = this.window.getShell();
   Rectangle bounds = activeShell.getBounds();
   Rectangle rect = wizardDialog.getShell().getBounds();
   int x = bounds.x + (bounds.width - rect.width) / 2;
   int y = bounds.y + (bounds.height - rect.height) / 2;
   wizardDialog.getShell().setLocation(x, y);
 }
Exemple #18
0
  private static void center() {
    Rectangle bounds = GameOfLife.PRIMARY_MONITOR.getBounds();
    Rectangle rect = askShell.getBounds();

    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;

    askShell.setLocation(x, y);
  }
Exemple #19
0
  public void setBoundaryScalers() {
    int demoWidth = 1, demoHeight = 1;

    mapShellBounds = mapShell.getBounds();

    if (dp != null) {
      demoWidth = (dp.maxX - dp.minX) + (RadarConsts.WINDOW_BUFFER * 2);
      demoHeight = (dp.maxY - dp.minY) + (RadarConsts.WINDOW_BUFFER * 2);
    }
    boundsXScale = (float) mapShellBounds.width / demoWidth;
    boundsYScale = (float) mapShellBounds.height / demoHeight;
  }
Exemple #20
0
  /**
   * Centers a dialog (Shell) on the <b>primary</b> (active) display.
   *
   * @param shell Shell to center on screen
   * @see Shell
   */
  public static void centerDialogOnScreen(Shell shell) {
    // do it by monitor to support dual-head cards and still center things correctly onto the screen
    // people are on. -- Emil
    Monitor m = Display.getDefault().getPrimaryMonitor();
    Rectangle bounds = m.getBounds();

    int screen_x = bounds.width;
    int screen_y = bounds.height;

    shell.setLocation(
        screen_x / 2 - (shell.getBounds().width / 2),
        screen_y / 2 - (shell.getBounds().height / 2));
  }
Exemple #21
0
 protected Shell createSplash(Display display) {
   final Shell splash = new Shell(display, SWT.ON_TOP);
   splash.setLayout(new GridLayout(1, true));
   Label l = new Label(splash, SWT.NONE);
   l.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
   l.setText("Caleydo Sandbox");
   splash.setSize(200, 100);
   Rectangle splashRect = splash.getBounds();
   Rectangle displayRect = display.getBounds();
   int x = (displayRect.width - splashRect.width) / 2;
   int y = (displayRect.height - splashRect.height) / 2;
   splash.setLocation(x, y);
   return splash;
 }
 private static void forceShellRecalculations(Shell shell) {
   boolean isPacked = ControlUtil.getControlAdapter(shell).isPacked();
   Rectangle boundsBuffer = shell.getBounds();
   bufferScrolledCompositeOrigins(shell);
   clearLayoutBuffers(shell);
   setTemporaryResize(true);
   enlargeShell(shell);
   enlargeScrolledCompositeContent(shell);
   setTemporaryResize(false);
   clearLayoutBuffers(shell);
   markLayoutNeeded(shell);
   rePack(shell);
   restoreScrolledCompositeOrigins(shell);
   restoreShellSize(shell, boundsBuffer, isPacked);
 }
Exemple #23
0
  public boolean open() {
    display = Display.getCurrent();

    shell = new Shell(display, SWT.NO_TRIM | SWT.TOOL); // SWT.NO_TRIM | SWT.TOO
    shell.setLayout(new FillLayout());

    int[] size = CPerspective.getSplashSize();
    shell.setSize(size[0], size[1]);

    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new FillLayout());
    container = new FlashContainer(composite, "splash");

    container.addHookInterceptor(
        new OleHookInterceptor() {

          public boolean intercept(Msg message, int code, int param, int param2) {
            if (message.getMessage() == Win32Constant.WM_RBUTTONDOWN) {
              Point cursor =
                  container.getParent().toControl(Display.getCurrent().getCursorLocation());
              if (container.getBounds().contains(cursor) && container.isVisible()) {
                return true;
              }
            }
            return false;
          }
        });

    container.loadMovie(0, CPerspective.getSplashSwfPath());

    Monitor primary = shell.getMonitor();
    Rectangle bounds = primary.getBounds();
    Rectangle rect = shell.getBounds();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    if (x < 0) x = 0;
    if (y < 0) y = 0;
    shell.setLocation(x, y);

    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return true;
  }
Exemple #24
0
  public void saveWindowPosition() {
    String prefLine;

    mapShellBounds = mapShell.getBounds();

    prefLine =
        ""
            + mapShellBounds.x
            + ","
            + mapShellBounds.y
            + ","
            + mapShellBounds.width
            + ","
            + mapShellBounds.height;

    prefs.put(RadarConsts.PREF_KEY_MAP_WINDOW, prefLine);
  }
Exemple #25
0
 private void updateCalculations() {
   Rectangle bounds = mShell.getBounds();
   topLeftCorner = new Rectangle(0, 0, CORNER_FLEX, CORNER_FLEX);
   leftSide = new Rectangle(0, CORNER_FLEX, SIDE_FLEX, bounds.height - (CORNER_FLEX * 2));
   bottomLeftCorner = new Rectangle(0, bounds.height - CORNER_FLEX, CORNER_FLEX, CORNER_FLEX);
   bottomSide =
       new Rectangle(
           CORNER_FLEX, bounds.height - SIDE_FLEX, bounds.width - (CORNER_FLEX * 2), SIDE_FLEX);
   bottomRightCorner =
       new Rectangle(
           bounds.width - CORNER_FLEX, bounds.height - CORNER_FLEX, CORNER_FLEX, CORNER_FLEX);
   rightSide =
       new Rectangle(
           bounds.width - SIDE_FLEX, CORNER_FLEX, SIDE_FLEX, bounds.height - (CORNER_FLEX * 2));
   topRightCorner = new Rectangle(bounds.width - CORNER_FLEX, 0, CORNER_FLEX, CORNER_FLEX);
   topSide = new Rectangle(CORNER_FLEX, 0, bounds.width - (CORNER_FLEX * 2), SIDE_FLEX);
 }
  /** @param shell the shell. */
  public OlapInputAboutDialog(final Shell shell) {
    this.dialog = new Shell(shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;

    this.dialog.setLayout(gridLayout);
    this.dialog.setText(BaseMessages.getString(PKG, "OlapInputDialog.About.Shell.Title"));
    this.dialog.setImage(shell.getImage());

    this.buildIconCell();
    this.buildPluginInfoCell();
    this.buildOkButton();

    this.dialog.pack();
    Rectangle shellBounds = shell.getBounds();
    Point dialogSize = this.dialog.getSize();

    this.dialog.setLocation(
        shellBounds.x + (shellBounds.width - dialogSize.x) / 2,
        shellBounds.y + (shellBounds.height - dialogSize.y) / 2);
  }
Exemple #27
0
  /**
   * Sets the position for the dialog based on the position of the workbench window. The dialog is
   * flush with the bottom right corner of the workbench window. However, the dialog will not appear
   * outside of the display's client area.
   *
   * @param size The final size of the dialog; must not be <code>null</code>.
   */
  private final void configureLocation(final Point size) {
    final Shell shell = getShell();

    final Shell workbenchWindowShell = EditorUtils.getShell();
    final int xCoord;
    final int yCoord;
    if (workbenchWindowShell != null) {
      /*
       * Position the shell at the bottom right corner of the workbench
       * window
       */
      final Rectangle workbenchWindowBounds = workbenchWindowShell.getBounds();
      xCoord = workbenchWindowBounds.x + workbenchWindowBounds.width - size.x - 10;
      yCoord = workbenchWindowBounds.y + workbenchWindowBounds.height - size.y - 10;

    } else {
      xCoord = 0;
      yCoord = 0;
    }
    final Rectangle bounds = new Rectangle(xCoord, yCoord, size.x, size.y);
    shell.setBounds(getConstrainedShellBounds(bounds));
  }
  public boolean checkPassword(String[] savedUserInfos) {
    // center the dialog screen to the monitor
    Rectangle bounds = display.getBounds();
    Rectangle rect = shlObaLogin.getBounds();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shlObaLogin.setLocation(x, y);
    shlObaLogin.open();
    for (int i = 0; i < 100; i++) {
      try {
        Thread.sleep(10);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      bar.setSelection(i);
    }

    controller = OBAController.getInstance();
    boolean result = controller.loginWithSavePasswd(savedUserInfos);
    display.dispose();
    return result;
  }
  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);
  }
  private void showInputBox() {
    Display display = Display.getDefault();
    final Shell dialog = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    dialog.setText("Add a row");
    dialog.setLocation(
        shlTypeDocument.getBounds().x / 2 + shlTypeDocument.getBounds().width / 2,
        shlTypeDocument.getBounds().y / 2 + shlTypeDocument.getBounds().height / 2);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 10;
    formLayout.marginHeight = 10;
    formLayout.spacing = 10;
    dialog.setLayout(formLayout);

    Label label = new Label(dialog, SWT.NONE);
    label.setText("Type an identifier:");
    FormData data = new FormData();
    label.setLayoutData(data);

    Button cancel = new Button(dialog, SWT.PUSH);
    cancel.setText("Cancel");
    data = new FormData();
    data.width = 60;
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    cancel.setLayoutData(data);
    cancel.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            dialog.close();
          }
        });

    final Text text = new Text(dialog, SWT.BORDER);
    data = new FormData();
    data.width = 200;
    data.left = new FormAttachment(label, 0, SWT.DEFAULT);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(label, 0, SWT.CENTER);
    data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT);
    text.setLayoutData(data);

    Button ok = new Button(dialog, SWT.PUSH);
    ok.setText("OK");
    data = new FormData();
    data.width = 60;
    data.right = new FormAttachment(cancel, 0, SWT.DEFAULT);
    data.bottom = new FormAttachment(100, 0);
    ok.setLayoutData(data);
    ok.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = text.getText();
            dialog.close();
          }
        });

    dialog.setDefaultButton(ok);
    dialog.pack();
    dialog.open();
    while (!dialog.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }