/*
   * @see IInformationControl#computeSizeHint()
   */
  public Point computeSizeHint() {
    // compute the preferred size
    int x = SWT.DEFAULT;
    int y = SWT.DEFAULT;
    Point size = fShell.computeSize(x, y);
    if (size.x > fMaxWidth) x = fMaxWidth;
    if (size.y > fMaxHeight) y = fMaxHeight;

    // recompute using the constraints if the preferred size is larger than the constraints
    if (x != SWT.DEFAULT || y != SWT.DEFAULT) size = fShell.computeSize(x, y, false);

    return size;
  }
Exemplo n.º 2
0
 /**
  * Sets the size of the shell to it's "packed" size, unless that makes it bigger than the display,
  * in which case set it to 9/10 of display size.
  */
 private static void setShellSize(Display display, Shell shell) {
   Rectangle bounds = display.getBounds();
   Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   if (size.x > bounds.width) size.x = bounds.width * 9 / 10;
   if (size.y > bounds.height) size.y = bounds.height * 9 / 10;
   shell.setSize(size);
 }
Exemplo n.º 3
0
 /** Adjusts form size according to contents dimensions */
 public void resize() {
   Shell sh = parentComposite.getShell();
   Point p0 = sh.getLocation();
   Point p1 = sh.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
   Rectangle r = sh.getDisplay().getClientArea();
   p1.x = Math.min(p1.x, (r.width - p0.x));
   p1.y = Math.min(p1.y, (r.height - p0.y));
   sh.setSize(p1);
 }
Exemplo n.º 4
0
  /*
   * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
   */
  @Override
  protected void initializeBounds() {
    super.initializeBounds();

    /* Dialog was not opened before */
    if (fFirstTimeOpen) {
      Shell shell = getShell();

      /* Minimum Size */
      int minWidth = convertHorizontalDLUsToPixels(OwlUI.MIN_DIALOG_WIDTH_DLU);
      int minHeight = shell.computeSize(minWidth, SWT.DEFAULT).y;

      /* Required Size */
      Point requiredSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

      shell.setSize(Math.max(minWidth, requiredSize.x), Math.max(minHeight, requiredSize.y));
      LayoutUtils.positionShell(shell);
    }
  }
Exemplo n.º 5
0
 public void resizeShell() {
   if (!resized) {
     Shell shell = getContainer().getShell();
     Point shellSize = shell.getSize();
     Point compSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
     if (shellSize.y < compSize.y) {
       shell.setSize(compSize);
       shell.layout(true);
     }
     resized = true;
   }
 }
Exemplo n.º 6
0
 private static void setShellSize(
     org.eclipse.swt.widgets.Display display, org.eclipse.swt.widgets.Shell shell) {
   org.eclipse.swt.graphics.Rectangle bounds = display.getBounds();
   org.eclipse.swt.graphics.Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   if (size.x > bounds.width) {
     size.x = bounds.width * 9 / 10;
   }
   if (size.y > bounds.height) {
     size.y = bounds.height * 9 / 10;
   }
   shell.setSize(size);
 }
Exemplo n.º 7
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final Table table = new Table(shell, SWT.BORDER);
   table.setHeaderVisible(true);
   final TableColumn column1 = new TableColumn(table, SWT.NONE);
   column1.setText("Column 1");
   final TableColumn column2 = new TableColumn(table, SWT.NONE);
   column2.setText("Column 2");
   TableItem item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"a", "3"});
   item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"b", "2"});
   item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"c", "1"});
   column1.setWidth(100);
   column2.setWidth(100);
   Listener sortListener =
       e -> {
         TableItem[] items = table.getItems();
         Collator collator = Collator.getInstance(Locale.getDefault());
         TableColumn column = (TableColumn) e.widget;
         int index = column == column1 ? 0 : 1;
         for (int i = 1; i < items.length; i++) {
           String value1 = items[i].getText(index);
           for (int j = 0; j < i; j++) {
             String value2 = items[j].getText(index);
             if (collator.compare(value1, value2) < 0) {
               String[] values = {items[i].getText(0), items[i].getText(1)};
               items[i].dispose();
               TableItem item1 = new TableItem(table, SWT.NONE, j);
               item1.setText(values);
               items = table.getItems();
               break;
             }
           }
         }
         table.setSortColumn(column);
       };
   column1.addListener(SWT.Selection, sortListener);
   column2.addListener(SWT.Selection, sortListener);
   table.setSortColumn(column1);
   table.setSortDirection(SWT.UP);
   shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
  /** Set initial size and layout for the window then open it */
  private void openWindow() {

    /*
     * Using initialMaxNumberOfPanels as a lower limit we exclude all other panels from the layout,
     * compute the window size, then finally we include all panels back into the layout
     *
     *  This ensures that the window will fit exactly the desired number of panels
     */
    Control[] controls = scrollChild.getChildren();
    for (int i = (initialMaxNumberOfPanels); i < controls.length; i++) {
      ((GridData) controls[i].getLayoutData()).exclude = true;
    }

    Point p = shell.computeSize(defaultShellWidth, SWT.DEFAULT);

    for (int i = 0; i < controls.length; i++) {
      ((GridData) controls[i].getLayoutData()).exclude = false;
    }
    formatLastPanel(null);
    scrollChild.layout();

    /*
     * Set the shell size if it's different that the computed size
     */
    if (false == shell.getSize().equals(p)) {
      shell.setSize(p);
      shell.layout(false);
    }

    /*
     * Centers the window
     */

    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (null == uiFunctions) {
      /*
       * Centers on the active monitor
       */
      Utils.centreWindow(shell);
    } else {
      /*
       * Centers on the main application window
       */
      Utils.centerWindowRelativeTo(shell, uiFunctions.getMainShell());
    }

    shell.open();
  }
  /*
   * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
   */
  @Override
  protected void initializeBounds() {
    super.initializeBounds();

    Shell shell = getShell();

    /* Minimum Size */
    int minWidth = convertHorizontalDLUsToPixels(DIALOG_WIDTH_DLUS);
    int minHeight = convertHorizontalDLUsToPixels(DIALOG_HEIGHT_DLUS);

    /* Required Size */
    Point requiredSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    /* Set Size */
    shell.setSize(Math.max(minWidth, requiredSize.x), Math.max(minHeight, requiredSize.y));

    /* Set Location */
    if (fFirstTimeOpen) LayoutUtils.positionShell(shell);
  }
  /**
   * When any <code>ProgressReporterPanel</code> in this window is expanded or collapsed re-layout
   * the controls and window appropriately
   */
  public void isCollapsed(boolean value) {
    if (null != shell && false == shell.isDisposed()) {
      scrollable.setRedraw(false);
      Rectangle r = scrollable.getClientArea();
      scrollable.setMinSize(scrollChild.computeSize(r.width, SWT.DEFAULT));

      /*
       * Resizing to fit the panel if there is only one
       */
      if (pReporters.length == 1) {
        Point p = shell.computeSize(defaultShellWidth, SWT.DEFAULT);
        if (shell.getSize().y != p.y) {
          p.x = shell.getSize().x;
          shell.setSize(p);
        }
      }

      scrollable.layout();
      scrollable.setRedraw(true);
    }
  }
Exemplo n.º 11
0
  void show(
      boolean owned,
      org.eclipse.swt.graphics.Point location,
      org.eclipse.swt.graphics.Point size,
      boolean addressBar,
      boolean menuBar,
      boolean statusBar,
      boolean toolBar) {
    final org.eclipse.swt.widgets.Shell shell = browser.getShell();
    if (owned) {
      if (location != null) {
        shell.setLocation(location);
      }
      if (size != null) {
        shell.setSize(shell.computeSize(size.x, size.y));
      }
    }
    org.eclipse.swt.layout.FormData data = null;
    if (toolBar) {
      toolbar = new org.eclipse.swt.widgets.ToolBar(parent, SWT.NONE);
      data = new org.eclipse.swt.layout.FormData();
      data.top = new org.eclipse.swt.layout.FormAttachment(0, 5);
      toolbar.setLayoutData(data);
      itemBack = new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemBack.setText(getResourceString("Back"));
      itemForward = new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemForward.setText(getResourceString("Forward"));
      final org.eclipse.swt.widgets.ToolItem itemStop =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemStop.setText(getResourceString("Stop"));
      final org.eclipse.swt.widgets.ToolItem itemRefresh =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemRefresh.setText(getResourceString("Refresh"));
      final org.eclipse.swt.widgets.ToolItem itemGo =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemGo.setText(getResourceString("Go"));
      itemBack.setEnabled(browser.isBackEnabled());
      itemForward.setEnabled(!browser.isForwardEnabled());
      org.eclipse.swt.widgets.Listener listener =
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event event) {
              org.eclipse.swt.widgets.ToolItem item =
                  (org.eclipse.swt.widgets.ToolItem) event.widget;
              if (item == itemBack) {
                browser.back();
              } else {
                if (item == itemForward) {
                  browser.forward();
                } else {
                  if (item == itemStop) {
                    browser.stop();
                  } else {
                    if (item == itemRefresh) {
                      browser.refresh();
                    } else {
                      if (item == itemGo) {
                        browser.setUrl(locationBar.getText());
                      }
                    }
                  }
                }
              }
            }
          };
      itemBack.addListener(SWT.Selection, listener);
      itemForward.addListener(SWT.Selection, listener);
      itemStop.addListener(SWT.Selection, listener);
      itemRefresh.addListener(SWT.Selection, listener);
      itemGo.addListener(SWT.Selection, listener);
      canvas = new org.eclipse.swt.widgets.Canvas(parent, SWT.NO_BACKGROUND);
      data = new org.eclipse.swt.layout.FormData();
      data.width = 24;
      data.height = 24;
      data.top = new org.eclipse.swt.layout.FormAttachment(0, 5);
      data.right = new org.eclipse.swt.layout.FormAttachment(100, -5);
      canvas.setLayoutData(data);
      final org.eclipse.swt.graphics.Rectangle rect = images[0].getBounds();
      canvas.addListener(
          SWT.Paint,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              org.eclipse.swt.graphics.Point pt =
                  ((org.eclipse.swt.widgets.Canvas) e.widget).getSize();
              e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y);
            }
          });
      canvas.addListener(
          SWT.MouseDown,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              browser.setUrl(getResourceString("Startup"));
            }
          });
      final org.eclipse.swt.widgets.Display display = parent.getDisplay();
      display.asyncExec(
          new java.lang.Runnable() {
            public void run() {
              if (canvas.isDisposed()) {
                return;
              }
              if (busy) {
                index++;
                if (index == images.length) {
                  index = 0;
                }
                canvas.redraw();
              }
              display.timerExec(150, this);
            }
          });
    }
    if (addressBar) {
      locationBar = new org.eclipse.swt.widgets.Text(parent, SWT.BORDER);
      data = new org.eclipse.swt.layout.FormData();
      if (toolbar != null) {
        data.top = new org.eclipse.swt.layout.FormAttachment(toolbar, 0, SWT.TOP);
        data.left = new org.eclipse.swt.layout.FormAttachment(toolbar, 5, SWT.RIGHT);
        data.right = new org.eclipse.swt.layout.FormAttachment(canvas, -5, SWT.DEFAULT);
      } else {
        data.top = new org.eclipse.swt.layout.FormAttachment(0, 0);
        data.left = new org.eclipse.swt.layout.FormAttachment(0, 0);
        data.right = new org.eclipse.swt.layout.FormAttachment(100, 0);
      }
      locationBar.setLayoutData(data);
      locationBar.addListener(
          SWT.DefaultSelection,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              browser.setUrl(locationBar.getText());
            }
          });
    }
    if (statusBar) {
      status = new org.eclipse.swt.widgets.Label(parent, SWT.NONE);
      progressBar = new org.eclipse.swt.widgets.ProgressBar(parent, SWT.NONE);
      data = new org.eclipse.swt.layout.FormData();
      data.left = new org.eclipse.swt.layout.FormAttachment(0, 5);
      data.right = new org.eclipse.swt.layout.FormAttachment(progressBar, 0, SWT.DEFAULT);
      data.bottom = new org.eclipse.swt.layout.FormAttachment(100, -5);
      status.setLayoutData(data);
      data = new org.eclipse.swt.layout.FormData();
      data.right = new org.eclipse.swt.layout.FormAttachment(100, -5);
      data.bottom = new org.eclipse.swt.layout.FormAttachment(100, -5);
      progressBar.setLayoutData(data);
      browser.addStatusTextListener(
          new org.eclipse.swt.browser.StatusTextListener() {
            public void changed(org.eclipse.swt.browser.StatusTextEvent event) {
              status.setText(event.text);
            }
          });
    }
    parent.setLayout(new org.eclipse.swt.layout.FormLayout());
    org.eclipse.swt.widgets.Control aboveBrowser =
        toolBar
            ? (org.eclipse.swt.widgets.Control) canvas
            : addressBar ? (org.eclipse.swt.widgets.Control) locationBar : null;
    data = new org.eclipse.swt.layout.FormData();
    data.left = new org.eclipse.swt.layout.FormAttachment(0, 0);
    data.top =
        aboveBrowser != null
            ? new org.eclipse.swt.layout.FormAttachment(aboveBrowser, 5, SWT.DEFAULT)
            : new org.eclipse.swt.layout.FormAttachment(0, 0);
    data.right = new org.eclipse.swt.layout.FormAttachment(100, 0);
    data.bottom =
        status != null
            ? new org.eclipse.swt.layout.FormAttachment(status, -5, SWT.DEFAULT)
            : new org.eclipse.swt.layout.FormAttachment(100, 0);
    browser.setLayoutData(data);
    if (statusBar || toolBar) {
      browser.addProgressListener(
          new org.eclipse.swt.browser.ProgressListener() {
            public void changed(org.eclipse.swt.browser.ProgressEvent event) {
              if (event.total == 0) {
                return;
              }
              int ratio = event.current * 100 / event.total;
              if (progressBar != null) {
                progressBar.setSelection(ratio);
              }
              busy = event.current != event.total;
              if (!busy) {
                index = 0;
                if (canvas != null) {
                  canvas.redraw();
                }
              }
            }

            public void completed(org.eclipse.swt.browser.ProgressEvent event) {
              if (progressBar != null) {
                progressBar.setSelection(0);
              }
              busy = false;
              index = 0;
              if (canvas != null) {
                itemBack.setEnabled(browser.isBackEnabled());
                itemForward.setEnabled(browser.isForwardEnabled());
                canvas.redraw();
              }
            }
          });
    }
    if (addressBar || statusBar || toolBar) {
      browser.addLocationListener(
          new org.eclipse.swt.browser.LocationListener() {
            public void changed(org.eclipse.swt.browser.LocationEvent event) {
              busy = true;
              if (event.top && locationBar != null) {
                locationBar.setText(event.location);
              }
            }

            public void changing(org.eclipse.swt.browser.LocationEvent event) {}
          });
    }
    if (title) {
      browser.addTitleListener(
          new org.eclipse.swt.browser.TitleListener() {
            public void changed(org.eclipse.swt.browser.TitleEvent event) {
              shell.setText(event.title + " - " + getResourceString("window.title"));
            }
          });
    }
    parent.layout(true);
    if (owned) {
      shell.open();
    }
  }
Exemplo n.º 12
0
  /**
   * Init with listener
   *
   * @param azureus_core
   * @param parent
   * @param linkURL
   * @param referrer
   * @param listener
   */
  public OpenUrlWindow(
      final Shell parent,
      String linkURL,
      boolean default_magnet,
      final String referrer,
      final TorrentDownloaderCallBackInterface listener) {

    final Shell shell =
        ShellFactory.createShell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
    shell.setText(MessageText.getString("openUrl.title"));
    Utils.setShellIcon(shell);

    GridData gridData;
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    shell.setLayout(layout);

    // URL field

    Label label = new Label(shell, SWT.NULL);
    label.setText(MessageText.getString("openUrl.url"));
    gridData = new GridData();
    label.setLayoutData(gridData);

    final Text url = new Text(shell, SWT.BORDER);

    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 400;
    gridData.horizontalSpan = 2;
    url.setLayoutData(gridData);
    if (linkURL == null) Utils.setTextLinkFromClipboard(shell, url, true, default_magnet);
    else url.setText(linkURL);
    url.setSelection(url.getText().length());

    // help field
    Label help_label = new Label(shell, SWT.NULL);
    help_label.setText(MessageText.getString("openUrl.url.info"));
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    help_label.setLayoutData(gridData);

    Label space = new Label(shell, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    space.setLayoutData(gridData);

    // referrer field

    Label referrer_label = new Label(shell, SWT.NULL);
    referrer_label.setText(MessageText.getString("openUrl.referrer"));
    gridData = new GridData();
    referrer_label.setLayoutData(gridData);

    final Combo referrer_combo = new Combo(shell, SWT.BORDER);

    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 150;
    gridData.grabExcessHorizontalSpace = true;
    referrer_combo.setLayoutData(gridData);

    final StringList referrers =
        COConfigurationManager.getStringListParameter("url_open_referrers");
    StringIterator iter = referrers.iterator();
    while (iter.hasNext()) {
      referrer_combo.add(iter.next());
    }

    if (referrer != null && referrer.length() > 0) {

      referrer_combo.setText(referrer);

    } else if (last_referrer != null) {

      referrer_combo.setText(last_referrer);
    }

    Label referrer_info = new Label(shell, SWT.NULL);
    referrer_info.setText(MessageText.getString("openUrl.referrer.info"));

    // line

    Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END);
    gridData.horizontalSpan = 3;
    labelSeparator.setLayoutData(gridData);

    // buttons

    Composite panel = new Composite(shell, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 3;
    panel.setLayout(layout);
    gridData =
        new GridData(
            GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END);
    gridData.horizontalSpan = 3;
    gridData.grabExcessHorizontalSpace = true;
    panel.setLayoutData(gridData);

    new Label(panel, SWT.NULL);

    Button ok = new Button(panel, SWT.PUSH);
    gridData =
        new GridData(
            GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END);
    gridData.widthHint = 70;
    gridData.grabExcessHorizontalSpace = true;
    ok.setLayoutData(gridData);
    ok.setText(MessageText.getString("Button.ok"));
    ok.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            last_referrer = referrer_combo.getText().trim();

            if (!referrers.contains(last_referrer)) {
              referrers.add(last_referrer);
              COConfigurationManager.setParameter("url_open_referrers", referrers);
              COConfigurationManager.save();
            }

            COConfigurationManager.setParameter(CONFIG_REFERRER_DEFAULT, last_referrer);
            COConfigurationManager.save();

            String url_str = url.getText();

            url_str = UrlUtils.parseTextForURL(url_str, true);

            if (url_str == null) {
              url_str = UrlUtils.parseTextForMagnets(url.getText());
            }

            if (url_str == null) {

              url_str = url.getText();
            }

            new FileDownloadWindow(parent, url_str, last_referrer, null, null, listener);
            shell.dispose();
          }
        });

    shell.setDefaultButton(ok);

    Button cancel = new Button(panel, SWT.PUSH);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.grabExcessHorizontalSpace = false;
    gridData.widthHint = 70;
    cancel.setLayoutData(gridData);
    cancel.setText(MessageText.getString("Button.cancel"));
    cancel.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            shell.dispose();
          }
        });

    shell.addListener(
        SWT.Traverse,
        new Listener() {

          public void handleEvent(Event e) {

            if (e.character == SWT.ESC) {
              shell.dispose();
            }
          }
        });

    Point p = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    if (p.x > 800) {

      p.x = 800;
    }

    shell.setSize(p);

    Utils.createURLDropTarget(shell, url);

    Utils.centreWindow(shell);

    shell.open();
  }
Exemplo n.º 13
0
  public Shell open(Display display) {
    clipboard = new Clipboard(display);
    shell = new Shell(display);
    shell.setText("SWT Clipboard");
    shell.setLayout(new FillLayout());

    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
    Composite parent = new Composite(sc, SWT.NONE);
    sc.setContent(parent);
    parent.setLayout(new GridLayout(2, true));

    Group copyGroup = new Group(parent, SWT.NONE);
    copyGroup.setText("Copy From:");
    GridData data = new GridData(GridData.FILL_BOTH);
    copyGroup.setLayoutData(data);
    copyGroup.setLayout(new GridLayout(3, false));

    Group pasteGroup = new Group(parent, SWT.NONE);
    pasteGroup.setText("Paste To:");
    data = new GridData(GridData.FILL_BOTH);
    pasteGroup.setLayoutData(data);
    pasteGroup.setLayout(new GridLayout(3, false));

    Group controlGroup = new Group(parent, SWT.NONE);
    controlGroup.setText("Control API:");
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    controlGroup.setLayoutData(data);
    controlGroup.setLayout(new GridLayout(5, false));

    Group typesGroup = new Group(parent, SWT.NONE);
    typesGroup.setText("Available Types");
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    typesGroup.setLayoutData(data);
    typesGroup.setLayout(new GridLayout(2, false));

    status = new Label(parent, SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    data.heightHint = 60;
    status.setLayoutData(data);

    createTextTransfer(copyGroup, pasteGroup);
    createRTFTransfer(copyGroup, pasteGroup);
    createHTMLTransfer(copyGroup, pasteGroup);
    createFileTransfer(copyGroup, pasteGroup);
    createMyTransfer(copyGroup, pasteGroup);
    createControlTransfer(controlGroup);
    createAvailableTypes(typesGroup);

    sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);

    Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle monitorArea = shell.getMonitor().getClientArea();
    shell.setSize(
        Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20));
    shell.open();
    return shell;
  }
Exemplo n.º 14
0
 private static void ensurePreferredHeight(Shell shell) {
   int preferredHeight = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
   Point size = shell.getSize();
   if (size.y < preferredHeight) shell.setSize(size.x, preferredHeight);
 }
Exemplo n.º 15
0
 /**
  * Sets the size of the shell to it's "packed" size, unless that makes it larger than the monitor
  * it is being displayed on, in which case just set the shell size to be slightly smaller than the
  * monitor.
  */
 static void setShellSize(ControlExample instance, Shell shell) {
   Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   Rectangle monitorArea = shell.getMonitor().getClientArea();
   shell.setSize(Math.min(size.x, monitorArea.width), Math.min(size.y, monitorArea.height));
 }