Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Monitor


    fileShell.pack();
   
    //Center Shell
    if(View.getDisplay()==null && View.getDisplay().isDisposed())
        return;
    Monitor primary = View.getDisplay().getPrimaryMonitor ();
    Rectangle bounds = primary.getBounds ();
    Rectangle rect = fileShell.getBounds ();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y +(bounds.height - rect.height) / 2;
    fileShell.setLocation (x, y);
   
View Full Code Here


    public static void centerShellandOpen(Shell shell){
        //open shell
        shell.pack();
       
        //Center Shell
        Monitor primary = View.getDisplay().getPrimaryMonitor ();
        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;
        shell.setLocation (x, y);
       
View Full Code Here

     */
    protected Rectangle computeBoundsAboveBelow(Shell shell, Point preferred, int offset) {
      Control subjectControl= fContentAssistSubjectControlAdapter.getControl();
      Display display= subjectControl.getDisplay();
      Rectangle caret= getCaretRectangle(offset);
      Monitor monitor= getClosestMonitor(display, caret);
      Rectangle bounds= monitor.getClientArea();
      Geometry.moveInside(caret, bounds);

      int spaceAbove= caret.y - bounds.y;
      int caretLowerY= caret.y + caret.height;
      int spaceBelow= bounds.y + bounds.height - caretLowerY;
View Full Code Here

     */
    protected Rectangle computeBoundsBelowAbove(Shell shell, Point preferred, int offset, CompletionProposalPopup popup) {
      Control subjectControl= fContentAssistSubjectControlAdapter.getControl();
      Display display= subjectControl.getDisplay();
      Rectangle caret= getCaretRectangle(offset);
      Monitor monitor= getClosestMonitor(display, caret);
      Rectangle bounds= monitor.getClientArea();
      Geometry.moveInside(caret, bounds);

      int threshold= popup == null ? Integer.MAX_VALUE : popup.getMinimalHeight();
      int spaceAbove= caret.y - bounds.y;
      int spaceBelow= bounds.y + bounds.height - (caret.y + caret.height);
View Full Code Here

      p.y += size.y;

      p= parent.toDisplay(p);

      Point shellSize= shell.getSize();
      Monitor monitor= getClosestMonitor(parent.getDisplay(), new Rectangle(p.x, p.y, 0, 0));
      Rectangle displayBounds= monitor.getClientArea();
      constrainLocation(p, shellSize, displayBounds);

      return p;
    }
View Full Code Here

    private Monitor getClosestMonitor(Display toSearch, Rectangle rectangle) {
      int closest = Integer.MAX_VALUE;

      Point toFind= Geometry.centerPoint(rectangle);
      Monitor[] monitors = toSearch.getMonitors();
      Monitor result = monitors[0];

      for (int idx = 0; idx < monitors.length; idx++) {
        Monitor current = monitors[idx];

        Rectangle clientArea = current.getClientArea();

        if (clientArea.contains(toFind)) {
          return current;
        }
View Full Code Here

    int bestArea= Integer.MIN_VALUE;
    Anchor bestAnchor= null;
    do {

      upperLeft= computeLocation(subjectArea, controlSize, testAnchor);
      Monitor monitor= getClosestMonitor(subjectAreaDisplayRelative, testAnchor);
      if (updateLocation(upperLeft, controlSize, monitor.getClientArea(), testAnchor))
        return upperLeft;

      // compute available area for this anchor and update if better than best
      Rectangle available= computeAvailableArea(subjectAreaDisplayRelative, monitor.getClientArea(), testAnchor);
      Rectangle proposed= new Rectangle(upperLeft.x, upperLeft.y, controlSize.x, controlSize.y);
      available.intersect(proposed);
      int area= available.width * available.height;
      if (area > bestArea) {
        bestArea= area;
View Full Code Here

  private Monitor getClosestMonitor(Display display, Rectangle rectangle) {
    int closest = Integer.MAX_VALUE;

    Point toFind= Geometry.centerPoint(rectangle);
    Monitor[] monitors = display.getMonitors();
    Monitor result = monitors[0];

    for (int idx = 0; idx < monitors.length; idx++) {
      Monitor current = monitors[idx];

      Rectangle clientArea = current.getClientArea();

      if (clientArea.contains(toFind)) {
        return current;
      }
View Full Code Here

    final Shell shell = new Shell(d, SWT.TITLE | SWT.CLOSE | SWT.RESIZE);
    shell.setText("AgentWise Demo Control Centerâ„¢");
    shell.setLayout(new RowLayout(SWT.VERTICAL));

    final Monitor primary = d.getPrimaryMonitor();
    shell.setLocation(primary.getClientArea().x, primary.getClientArea().y);
    shell
        .setSize(primary.getClientArea().width, primary.getClientArea().height);

    final Composite controlsComposite = new Composite(shell, SWT.NONE);
    controlsComposite.setLayout(new RowLayout(SWT.HORIZONTAL));

    final Label timeLabel = new Label(controlsComposite, SWT.NONE);
    timeLabel.setText("End simulation time (in hours): ");

    final Text timeText = new Text(controlsComposite, SWT.NONE);
    timeText.setText("6.0");
    timeText.setLayoutData(new RowData(40, SWT.DEFAULT));

    timeText.addListener(SWT.Verify, new Listener() {
      @Override
      public void handleEvent(Event e) {
        final String string = e.text;
        final char[] chars = new char[string.length()];
        string.getChars(0, chars.length, chars, 0);
        for (int i = 0; i < chars.length; i++) {
          if (!('0' <= chars[i] && chars[i] <= '9') && chars[i] != '.') {
            e.doit = false;
            return;
          }
        }
        for (final DemoRunner dr : demoRunners) {
          dr.setTime(Double.parseDouble(e.text));
        }
      }
    });
    final List<Button> monitorCheckBoxes = newArrayList();
    for (int i = 0; i < d.getMonitors().length; i++) {
      final Monitor m = d.getMonitors()[i];
      final Button b = new Button(controlsComposite, SWT.CHECK);
      b.setData(m);
      final boolean isPrimary = m.equals(d.getPrimaryMonitor());
      b.setText(i + " " + m.getBounds().width + "x" + m.getBounds().height
          + (isPrimary ? " PRIMARY" : ""));
      b.setSelection(!isPrimary);
      monitorCheckBoxes.add(b);
    }

    final List<Button> demoCheckBoxes = newArrayList();
    for (final DemoType dt : DemoType.values()) {
      final Button b = new Button(controlsComposite, SWT.CHECK);
      demoCheckBoxes.add(b);
      b.setText(dt.name());
      b.setData(dt);
      b.setSelection(true);
    }

    final Button runButton = new Button(shell, SWT.TOGGLE);
    runButton.setSize(300, 100);
    runButton.setText("Start demo");

    final Font f = runButton.getFont();
    final FontData[] fontData = f.getFontData();
    for (int i = 0; i < fontData.length; i++) {
      fontData[i].setHeight(60);
    }
    final Font newFont = new Font(d, fontData);
    runButton.setFont(newFont);

    final Composite panelComposite = new Composite(shell, SWT.NONE);
    // panelComposite.setLayout(new RowLayout(SWT.HORIZONTAL));

    final List<DemoRunnerControlPanel> panels = newArrayList();
    runButton.addSelectionListener(new SelectionListener() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        // clear old runners
        for (final DemoRunner dr : demoRunners) {
          dr.setRunning(false);
        }
        demoRunners.clear();
        // close old shells
        for (final Shell s : d.getShells()) {
          if (s != shell) {
            s.close();
          }
        }

        for (final DemoRunnerControlPanel panel : panels) {
          panel.remove();
        }
        panels.clear();

        controlsComposite.setEnabled(!((Button) e.widget).getSelection());
        for (final Control c : controlsComposite.getChildren()) {

          c.setEnabled(!((Button) e.widget).getSelection());
        }

        if (((Button) e.widget).getSelection()) {
          runButton.setText("Stop demo");
        } else {
          runButton.setText("Start demo");
        }

        if (((Button) e.widget).getSelection()) {
          int index = 0;
          final List<DemoType> types = newArrayList();
          for (final Button b : demoCheckBoxes) {
            if (b.getSelection()) {
              types.add((DemoType) b.getData());
            }
          }
          final ImmutableList<DemoType> demoTypes = ImmutableList.copyOf(types);
          for (final Button b : monitorCheckBoxes) {
            if (b.getSelection()) {
              final Monitor m = (Monitor) b.getData();
              final DemoRunner dr = new DemoRunner(d, demoTypes, index);
              index++;

              dr.setTime(Double.parseDouble(timeText.getText()));
View Full Code Here

  public static void main(String[] args) {
    final long endTime = args != null && args.length >= 1 ? Long
        .parseLong(args[0]) : Long.MAX_VALUE;

    final Display d = new Display();
    @Nullable
    Monitor sec = null;
    for (final Monitor m : d.getMonitors()) {
      if (d.getPrimaryMonitor() != m) {
        sec = m;
        break;
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Monitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.