/** @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);
      }
    }
  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.º 3
0
  @Override
  public void run() {
    Display d = new Display();
    Shell s = new Shell(d);
    s.setBounds(50, 50, 300, 300);
    s.setLayout(new GridLayout());
    s.setText("Table Example");

    Table list = new Table(s, SWT.BORDER);

    TableColumn column = new TableColumn(list, SWT.NONE);
    column.setText("Col 1");

    column = new TableColumn(list, SWT.NONE);
    column.setText("Col 2");

    for (int i = 0; i < 30; i++) {
      TableItem item = new TableItem(list, SWT.NONE);
      item.setText(0, "Cell " + i + "/0");
      item.setText(1, "Cell " + i + "/1");
    }

    list.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    s.open();

    spinEventLoop();
  }
Exemplo n.º 4
0
  private void maximize() {
    mNonMaximizedLocation = mShell.getLocation();
    mNonMaximizedSize = mShell.getSize();

    Monitor monitor = mShell.getMonitor();
    mShell.setBounds(monitor.getBounds());
  }
Exemplo n.º 5
0
  /** @param args */
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("CDateTime");
    shell.setLayout(new GridLayout(3, true));

    final CDateTime date = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
    date.setNullText("<day>");
    date.setPattern("dd");
    date.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    final CDateTime month = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
    month.setNullText("<month>");
    month.setPattern("MMMM");
    month.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    final CDateTime year = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
    year.setNullText("<year>");
    year.setPattern("yyyy");
    year.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    shell.pack();
    Point size = shell.getSize();
    Rectangle screen = display.getMonitors()[0].getBounds();
    shell.setBounds((screen.width - size.x) / 2, (screen.height - size.y) / 2, size.x, size.y);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  @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;
  }
Exemplo n.º 7
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.º 8
0
 @Test
 public void testGetItemMetricsImageCutOffInSecondColumn() throws IOException {
   Image image = createImage(display, Fixture.IMAGE1);
   shell.setBounds(0, 0, 200, 200);
   shell.setLayout(new FillLayout());
   table.setHeaderVisible(true);
   TableColumn column = new TableColumn(table, SWT.NONE);
   column.setText("column1");
   column.setWidth(400);
   TableColumn column2 = new TableColumn(table, SWT.NONE);
   column2.setText("column2");
   column2.setWidth(30);
   ITableAdapter adapter = table.getAdapter(ITableAdapter.class);
   adapter.setLeftOffset(5);
   TableItem item1 = new TableItem(table, SWT.NONE);
   item1.setText("item1");
   TableItem item2 = new TableItem(table, SWT.NONE);
   item2.setText("item2");
   TableItem item3 = new TableItem(table, SWT.NONE);
   item3.setText("item3");
   item2.setImage(1, image);
   ItemMetrics[] metrics = TableLCA.getItemMetrics(table);
   assertEquals(403, metrics[1].imageLeft);
   assertEquals(27, metrics[1].imageWidth);
 }
Exemplo n.º 9
0
 private void centerWindow(Shell shell) {
   Rectangle bds = shell.getDisplay().getBounds();
   Point p = shell.getSize();
   int nLeft = (bds.width - p.x) / 2;
   int nTop = (bds.height - p.y) / 2;
   shell.setBounds(nLeft, nTop, p.x, p.y);
 }
 private void _setWndPosition() {
   Rectangle r = Display.getDefault().getBounds();
   int w = (80 * r.width) / 100;
   int h = (80 * r.height) / 100;
   int x = (r.width - w) / 2;
   int y = (r.height - h) / 2;
   m_shell.setBounds(x, y, w, h);
 }
Exemplo n.º 11
0
 protected void doSetUp() throws Exception {
   super.doSetUp();
   theShell = new Shell(Display.getCurrent(), SWT.NONE);
   theShell.setBounds(0, 0, 1024, 768);
   theShell.setVisible(true);
   img = UIPerformancePlugin.getImageDescriptor("icons/anything.gif").createImage();
   img2 = UIPerformancePlugin.getImageDescriptor("icons/view.gif").createImage();
 }
Exemplo n.º 12
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);
 }
 @Override
 protected void configureShell(Shell shell) {
   super.configureShell(shell);
   Shell s2 = shell.getParent().getShell();
   if (s2 != null) shell.setLocation(s2.getLocation());
   shell.setBounds(shell.getLocation().x, shell.getLocation().y, 550, 500);
   if (domain == null) shell.setText(CredentialMessages.AddACredentialDomain);
   else {
     shell.setText(CredentialMessages.EditACredentialDomain);
   }
 }
Exemplo n.º 14
0
  @Override
  protected void configureShell(Shell shell) {
    super.configureShell(shell);
    shell.setText("Traceview: " + mTraceName);

    InputStream in = getClass().getClassLoader().getResourceAsStream("icons/traceview-128.png");
    if (in != null) {
      shell.setImage(new Image(shell.getDisplay(), in));
    }

    shell.setBounds(100, 10, 1282, 900);
  }
 @Override
 public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) {
   if (element instanceof MWindow) {
     MWindow mWindow = (MWindow) element;
     Shell shell = new Shell(Display.getCurrent());
     shell.setText(mWindow.getLabel());
     shell.setLayout(new SimpleTrimLayout());
     shell.setBounds(mWindow.getX(), mWindow.getY(), mWindow.getWidth(), mWindow.getHeight());
     mWindow.getContext().set(Shell.class, shell);
     element.setWidget(shell);
   }
 }
Exemplo n.º 16
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(2, true));

    final Browser browser;
    try {
      browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
      System.out.println("Could not instantiate Browser: " + e.getMessage());
      display.dispose();
      return;
    }
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    browser.setLayoutData(data);

    Button headersButton = new Button(shell, SWT.PUSH);
    headersButton.setText("Send custom headers");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    headersButton.setLayoutData(data);
    headersButton.addListener(
        SWT.Selection,
        event ->
            browser.setUrl(
                "http://www.ericgiguere.com/tools/http-header-viewer.html",
                null,
                new String[] {"User-agent: SWT Browser", "Custom-header: this is just a demo"}));
    Button postDataButton = new Button(shell, SWT.PUSH);
    postDataButton.setText("Send post data");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    postDataButton.setLayoutData(data);
    postDataButton.addListener(
        SWT.Selection,
        event ->
            browser.setUrl(
                "https://bugs.eclipse.org/bugs/buglist.cgi",
                "emailassigned_to1=1&bug_severity=enhancement&bug_status=NEW&email1=platform-swt-inbox&emailtype1=substring",
                null));

    shell.setBounds(10, 10, 600, 600);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Exemplo n.º 17
0
  @Test
  public void testGetItemMetrics() throws IOException {
    Image image = createImage(display, Fixture.IMAGE1);
    shell.setBounds(0, 0, 800, 600);
    shell.setLayout(new FillLayout());
    table.setHeaderVisible(true);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setText("column1");
    column.setWidth(200);
    TableItem item1 = new TableItem(table, SWT.NONE);
    item1.setText("item1");
    TableItem item2 = new TableItem(table, SWT.NONE);
    item2.setText("item2");
    TableItem item3 = new TableItem(table, SWT.NONE);
    item3.setText("item3");

    item2.setImage(image);
    ItemMetrics[] metrics = TableLCA.getItemMetrics(table);
    assertTrue(metrics[0].imageWidth > 0);

    item1.setImage(image);
    metrics = TableLCA.getItemMetrics(table);
    int defaultLeftPadding = 3;
    assertEquals(defaultLeftPadding, metrics[0].imageLeft);
    assertTrue(metrics[0].imageWidth > 0);

    // spacing must be respected
    int defaultSpacing = 3;
    int expected = metrics[0].imageLeft + metrics[0].imageWidth + defaultSpacing;
    assertEquals(expected, metrics[0].textLeft);

    // left offset must be compensated
    ITableAdapter adapter = table.getAdapter(ITableAdapter.class);
    adapter.setLeftOffset(10);
    metrics = TableLCA.getItemMetrics(table);
    assertEquals(0, metrics[0].left);
    assertEquals(defaultLeftPadding, metrics[0].imageLeft);
    expected = metrics[0].imageLeft + metrics[0].imageWidth + defaultSpacing;
    assertEquals(expected, metrics[0].textLeft);

    // image must not exceed right column border
    column.setWidth(12);
    metrics = TableLCA.getItemMetrics(table);
    assertEquals(9, metrics[0].imageWidth);
  }
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setBounds(0, 0, 25, 25);
    shell.setLayout(new GridLayout());
    shell.setBackground(READY_COLOUR);
    RotationButtonComposite sliderComposite = new RotationButtonComposite(shell, SWT.UP, "Test");
    shell.setText(sliderComposite.getClass().getName());
    sliderComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    shell.pack();
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
Exemplo n.º 19
0
  /** @param args */
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("CDateTime");
    shell.setLayout(new GridLayout());

    final CDateTime cdt = new CDateTime(shell, CDT.BORDER | CDT.COMPACT | CDT.SIMPLE);
    cdt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    shell.pack();
    Point size = shell.getSize();
    Rectangle screen = display.getMonitors()[0].getBounds();
    shell.setBounds((screen.width - size.x) / 2, (screen.height - size.y) / 2, size.x, size.y);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Exemplo n.º 20
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));
  }
  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);
  }
Exemplo n.º 22
0
 public void setBounds(int x, int y, int width, int height) {
   shell.setBounds(x, y, width, height);
 }
Exemplo n.º 23
0
  protected void configureShell(Shell shell) {
    super.configureShell(shell);

    shell.setBounds(shell.getLocation().x, shell.getLocation().y, 400, 300);
  }
Exemplo n.º 24
0
 private void centerShell(Shell newShell) {
   Rectangle pDisplayBounds = newShell.getDisplay().getBounds();
   int nLeft = (pDisplayBounds.width - getInitialSize().x) / 2;
   int nTop = (pDisplayBounds.height - getInitialSize().y) / 2;
   newShell.setBounds(nLeft, nTop, getInitialSize().x, getInitialSize().y);
 }
Exemplo n.º 25
0
  /**
   * show one popup menu over the main window
   *
   * @param menu_entry actual entry which should be shown or disposed
   * @param move TRUE if the curser be moved over one entry, otherwise by clicking false
   */
  private void show(String menu_entry, boolean move) {
    Point abs;
    Group popup;
    Rectangle rect, popup_rect = new Rectangle(0, 0, 120, 100);
    TreeNodes node;
    RowLayout l;
    ArrayList<TreeNodes> nodes;
    ArrayList<Composite> comps;

    if (move && m_sMenu.equals("")) {
      return;
    }
    if (!m_sMenu.equals(menu_entry)) {
      if (m_popupShell != null) m_popupShell.dispose();
      popup = m_mRootEntrys.get(menu_entry);
      rect = popup.getBounds();
      m_popupShell = new Shell(m_oTopLevelShell, SWT.NO_TRIM);
      // popup_rect= m_popupShell.getClientArea();
      abs = LayoutLoader.getAbsoluteUseFieldPoint();
      popup_rect.x = m_oMenu.getBounds().x + abs.x + rect.x;
      popup_rect.y = abs.y + rect.y + rect.height;
      l = new RowLayout();
      l.type = SWT.VERTICAL;
      l.pack = false;
      l.marginBottom = 0;
      l.marginHeight = 0;
      l.marginLeft = 0;
      l.marginRight = 0;
      l.marginTop = 0;
      l.marginWidth = 0;
      l.spacing = 0;
      m_popupShell.setLayout(l);
      node = m_mRootNodes.get(menu_entry);
      nodes = node.getChilds();
      m_sMenu = menu_entry;
      if (nodes.size() == 0) {
        m_sMenu = "";
        return;
      }
      comps = new ArrayList<Composite>();
      for (TreeNodes subnode : nodes) {
        RowLayout layout = new RowLayout();
        Composite comp = new Group(m_popupShell, SWT.NONE);
        Label text = new Label(comp, SWT.NONE);
        HashMap<String, String> metablock = subnode.getMetaData();
        String popupspace = metablock.get("popupspace");
        final String entry;
        int space = 20;
        FontObject font = new FontObject();
        int popupsize = 0;
        boolean bold = false;
        boolean italic = false;
        String looks, ssize;
        MouseListener listener1, listener2;

        entry = m_sMenu + "/" + subnode.getName();
        ssize = metablock.get("popupfontsize");
        if (ssize != null) popupsize = Integer.parseInt(ssize);
        looks = metablock.get("popupstyle");
        if (looks != null) {
          String[] split;

          split = looks.split(",");
          for (int i = 0; i < split.length; ++i) {
            split[i] = split[i].trim().toLowerCase();
            if (split[i].equals("bold")) bold = true;
            else if (split[i].equals("italic")) italic = true;
          }
        }
        font.defineColor(popup, metablock.get("popupcolor"), colors.WIDGET, entry + " popup");
        font.defineColor(popup, metablock.get("popupfontcolor"), colors.TEXT, entry + " popup");
        font.defineFont(
            popup, metablock.get("popupfont"), popupsize, bold, italic, /*underline*/ false);
        text.setText(subnode.getTitle().trim());
        if (popupspace != null) space = Integer.parseInt(popupspace);
        layout.type = SWT.VERTICAL;
        layout.marginTop = space;
        layout.marginRight = space;
        layout.marginBottom = space;
        layout.marginLeft = space;
        comp.setLayout(layout);
        font.setDevice(comp);
        font.setDevice(text);
        font.dispose();
        comps.add(comp);
        text.addMouseListener(
            listener1 =
                new MouseAdapter() {
                  public void mouseDown(MouseEvent event) {
                    LayoutLoader loader;
                    Thread t = null;

                    if (HtmTags.lockDebug) {
                      t = Thread.currentThread();
                      System.out.println(t.getName() + " want to setActiveSideVisible of " + entry);
                    }
                    loader = LayoutLoader.instance();
                    loader.m_sAktFolder = entry;
                    synchronized (TreeNodes.m_DISPLAYLOCK) {
                      loader.setCurrentSideVisible(/*inform server by no body*/ true);
                    }
                    m_nPopup = m_popupShell.getBounds();
                    destroyPopupShell();
                    m_sMenu = "";
                  }
                });
        m_aPopupListeners.put(text, listener1);
        comp.addMouseListener(
            listener2 =
                new MouseAdapter() {
                  public void mouseDown(MouseEvent event) {
                    LayoutLoader loader;
                    Thread t = null;

                    if (HtmTags.lockDebug) {
                      t = Thread.currentThread();
                      System.out.println(t.getName() + " want to setActiveSideVisible of " + entry);
                    }
                    loader = LayoutLoader.instance();
                    loader.m_sAktFolder = entry;
                    synchronized (TreeNodes.m_DISPLAYLOCK) {
                      loader.setCurrentSideVisible(/*inform server by no body*/ true);
                    }
                    m_nPopup = m_popupShell.getBounds();
                    destroyPopupShell();
                    m_sMenu = "";
                  }
                });
        m_aPopupListeners.put(comp, listener2);
      }

      if (m_nPopup != null) popup_rect = m_nPopup;
      m_popupShell.setBounds(popup_rect);
      m_popupShell.setEnabled(false);
      m_popupShell.setVisible(false);
      m_popupShell.open();
      m_popupShell.pack();
      m_popupShell.setEnabled(true);
      m_popupShell.setVisible(true);

    } else if (!m_sMenu.equals("") && !move) { // actual popup is the same
      m_popupShell.dispose();
      m_sMenu = "";
    }
  }
  /** Instantiate the UI */
  public TankServerFrame() {
    messages = new LinkedBlockingQueue<String>();

    int width = (int) (Toolkit.getDefaultToolkit()).getScreenSize().getWidth();
    int height = (int) (Toolkit.getDefaultToolkit()).getScreenSize().getHeight();

    // Prepare the shell (window)
    display = new Display();
    shell = new Shell(display, SWT.MIN);
    shell.setText("Torpidity Tank Game - Server");
    shell.setBounds(width - 700, height - 335, 700, 300);

    // Layout setup
    int margin = 3;
    FormLayout layout = new FormLayout();
    layout.marginLeft = margin;
    layout.marginRight = margin;
    layout.marginTop = margin;
    layout.marginBottom = margin;
    shell.setLayout(layout);

    // Start button
    startButton = new Button(shell, SWT.PUSH);
    startButton.setText("Start Server");
    startButton.setEnabled(false);
    FormData startButtonData = new FormData();
    startButtonData.left = new FormAttachment(0);
    startButtonData.top = new FormAttachment(0);
    startButton.setLayoutData(startButtonData);

    // Stop button
    stopButton = new Button(shell, SWT.PUSH);
    stopButton.setText("Stop Server");
    FormData stopButtonData = new FormData();
    stopButtonData.left = new FormAttachment(startButton, margin);
    stopButtonData.top = new FormAttachment(0);
    stopButton.setLayoutData(stopButtonData);

    // Chat Log
    log = new Text(shell, SWT.WRAP | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
    log.setBackground(new Color(display, 255, 255, 255));
    FormData logData = new FormData();
    logData.left = new FormAttachment(stopButton, margin);
    logData.top = new FormAttachment(0);
    logData.right = new FormAttachment(100);
    logData.bottom = new FormAttachment(92);
    log.setLayoutData(logData);

    // Bandwidth meters
    bandwidth = new Label(shell, SWT.BORDER);
    FormData bandwidthData = new FormData();
    bandwidthData.left = new FormAttachment(0);
    bandwidthData.right = new FormAttachment(log, -margin);
    bandwidthData.top = new FormAttachment(log, margin);
    bandwidthData.bottom = new FormAttachment(100);
    bandwidth.setLayoutData(bandwidthData);

    // Status bar
    statusBar = new Label(shell, SWT.BORDER);
    FormData statusBarData = new FormData();
    statusBarData.left = new FormAttachment(bandwidth, margin);
    statusBarData.right = new FormAttachment(100);
    statusBarData.top = new FormAttachment(log, margin);
    statusBarData.bottom = new FormAttachment(100);
    statusBar.setLayoutData(statusBarData);

    // Player list
    playerList = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    FormData playerListData = new FormData();
    playerListData.left = new FormAttachment(0);
    playerListData.right = new FormAttachment(log, -margin);
    playerListData.top = new FormAttachment(startButton, margin);
    playerListData.bottom = new FormAttachment(statusBar, -margin);
    playerList.setLayoutData(playerListData);

    // Event handlers
    SelectionAdapter buttonsAdapter =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Button source = (Button) e.getSource();
            if (source == startButton) setStatus(true);
            else if (source == stopButton) setStatus(false);
          }
        };
    startButton.addSelectionListener(buttonsAdapter);
    stopButton.addSelectionListener(buttonsAdapter);
  }