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);
  }
Exemplo n.º 2
0
  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);
  }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
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);
  }
Exemplo n.º 5
0
 private static void readBounds(final Shell shell) {
   Rectangle bounds = WidgetLCAUtil.readBounds(shell, shell.getBounds());
   Object adapter = shell.getAdapter(IShellAdapter.class);
   IShellAdapter shellAdapter = (IShellAdapter) adapter;
   shellAdapter.setBounds(bounds);
 }