public static void main(final String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setText(SnippetMasterDetailsRidget003.class.getSimpleName());
    shell.setLayout(new FillLayout());

    final PersonMasterDetails details = new PersonMasterDetails(shell, SWT.NONE);

    final IMasterDetailsRidget ridget =
        (IMasterDetailsRidget) SwtRidgetFactory.createRidget(details);
    ridget.setDelegate(new PersonDelegate());
    final WritableList input = new WritableList(PersonFactory.createPersonList(), Person.class);
    final String[] properties = {Person.PROPERTY_LASTNAME, Person.PROPERTY_FIRSTNAME};
    final String[] headers = {"Last Name", "First Name"}; // $NON-NLS-1$ //$NON-NLS-2$
    ridget.bindToModel(input, Person.class, properties, headers);
    ridget.updateFromModel();

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    display.dispose();
  }
Ejemplo n.º 2
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new RowLayout());
   Combo combo = new Combo(shell, SWT.NONE);
   combo.setItems(new String[] {"A-1", "B-1", "C-1"});
   Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
   text.setText("some text");
   combo.addListener(
       SWT.DefaultSelection,
       new Listener() {
         public void handleEvent(Event e) {
           System.out.println(e.widget + " - Default Selection");
         }
       });
   text.addListener(
       SWT.DefaultSelection,
       new Listener() {
         public void handleEvent(Event e) {
           System.out.println(e.widget + " - Default Selection");
         }
       });
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Ejemplo n.º 3
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();
  }
Ejemplo n.º 4
0
  /**
   * Sets the size for the dialog based on its previous size. The width of the dialog is its
   * previous width, if it exists. Otherwise, it is simply the packed width of the dialog. The
   * maximum width is 40% of the workbench window's width. The dialog's height is the packed height
   * of the dialog to a maximum of half the height of the workbench window.
   *
   * @return The size of the dialog
   */
  private final Point configureSize() {
    final Shell shell = getShell();

    // Get the packed size of the shell.
    shell.pack();
    final Point size = shell.getSize();

    // Enforce maximum sizing.
    final Shell workbenchWindowShell = EditorUtils.getShell();
    if (workbenchWindowShell != null) {
      final Point workbenchWindowSize = workbenchWindowShell.getSize();
      final int maxWidth = workbenchWindowSize.x * 2 / 5;
      final int maxHeight = workbenchWindowSize.y / 2;
      if (size.x > maxWidth) {
        size.x = maxWidth;
      }
      if (size.y > maxHeight) {
        size.y = maxHeight;
      }
    }

    // Set the size for the shell.
    shell.setSize(size);
    return size;
  }
  /** Debug only */
  private static void drawModel(final SWTArranger a) {
    final Display d = new Display();
    Shell s = new Shell(d);
    s.setSize(500, 500);

    s.setLayout(new FillLayout());

    Canvas canvas = new Canvas(s, SWT.NONE);
    canvas.setSize(500, 500);
    canvas.setLocation(20, 20);
    canvas.addPaintListener(
        new PaintListener() {

          @Override
          public void paintControl(PaintEvent e) {
            Color c = new Color(d, 0x00, 0x00, 0x00);
            GC gc = e.gc;
            gc.setBackground(c);
            for (Block r : a.blocks) {
              gc.fillRectangle(r.x, r.y, r.width, r.height);
            }
            c.dispose();
            gc.dispose();
          }
        });
    s.pack();
    s.open();

    while (!s.isDisposed()) {
      if (!d.readAndDispatch()) {
        d.sleep();
      }
    }
    d.dispose();
  }
Ejemplo n.º 6
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setText("StyledText with underline and strike through");
   shell.setLayout(new FillLayout());
   StyledText text = new StyledText(shell, SWT.BORDER);
   text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ");
   // make 0123456789 appear underlined
   StyleRange style1 = new StyleRange();
   style1.start = 0;
   style1.length = 10;
   style1.underline = true;
   text.setStyleRange(style1);
   // make ABCDEFGHIJKLM have a strike through
   StyleRange style2 = new StyleRange();
   style2.start = 11;
   style2.length = 13;
   style2.strikeout = true;
   text.setStyleRange(style2);
   // make NOPQRSTUVWXYZ appear underlined and have a strike through
   StyleRange style3 = new StyleRange();
   style3.start = 25;
   style3.length = 13;
   style3.underline = true;
   style3.strikeout = true;
   text.setStyleRange(style3);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Ejemplo n.º 7
0
  public long open(long aLimit) {
    limit = aLimit;
    finalResult = -1L;
    buttonPressed = 0;
    if (sShell == null || sShell.isDisposed()) {
      createSShell();
    }

    sShell.pack();
    Manager.reduceDistance(getParent(), sShell);
    if (lastHexButtonSelected) {
      hexRadioButton.setSelection(true);
    } else {
      decRadioButton.setSelection(true);
    }
    label.setText(
        "Enter location number, 0 to " + limit + " (0x0 to 0x" + Long.toHexString(limit) + ")");
    text.setText(lastLocationText);
    text.selectAll();
    text.setFocus();
    sShell.open();
    Display display = getParent().getDisplay();
    while (!sShell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    return finalResult;
  }
  @Override
  public void processContents(MElementContainer<MUIElement> element) {
    if (!(((MUIElement) element) instanceof MWindow)) {
      return;
    }
    MWindow mWindow = (MWindow) ((MUIElement) element);
    Shell shell = (Shell) element.getWidget();

    // Populate the main menu
    IPresentationEngine2 renderer =
        (IPresentationEngine2) context.get(IPresentationEngine.class.getName());
    if (mWindow.getMainMenu() != null) {
      renderer.createGui(mWindow.getMainMenu(), element);
      shell.setMenuBar((Menu) mWindow.getMainMenu().getWidget());
    }

    // create Detached Windows
    for (MWindow dw : mWindow.getWindows()) {
      renderer.createGui(dw, element);
    }

    // Populate the trim (if any)
    if (mWindow instanceof MTrimmedWindow) {
      MTrimmedWindow tWindow = (MTrimmedWindow) mWindow;
      for (MTrimBar trimBar : tWindow.getTrimBars()) {
        renderer.createGui(trimBar, element);
      }
    }

    shell.pack();
    shell.open();
  }
  public static void main(final String[] args) {
    Display display = new Display();
    shell = new Shell(display);
    shell.setText("StackOverflow");
    shell.setLayout(new GridLayout(1, false));

    // createToolbar();
    scform = new ScrolledForm(shell);
    scform.setLayout(new GridLayout(1, false));
    scform.getBody().setLayout(new GridLayout(1, false));
    scform.setExpandHorizontal(true);
    scform.setExpandVertical(true);

    SashForm form = new SashForm(scform.getBody(), SWT.VERTICAL);
    form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    createTablePart(form);
    createMessagesPart(form);
    form.setWeights(new int[] {3, 1});

    shell.pack();
    shell.open();
    // shell.setSize(600, 450);
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
Ejemplo n.º 10
0
  public BarSettings open(Point location) {

    shell = new Shell(parent.getShell(), SWT.DIALOG_TRIM);
    shell.setText(MainGui.APP_NAME + " - Trend Display Settings ...");

    shell.addDisposeListener(
        new DisposeListener() {

          @Override
          public void widgetDisposed(DisposeEvent event) {
            MainPMScmd.getMyPrefs().flushy();
          }
        });

    initGui();

    shell.setLocation(location);

    shell.layout();
    shell.pack();

    shell.open();

    return barChartSettings;
  }
Ejemplo n.º 11
0
  public static void main(String[] args) {
    LoggerContext loggerContext = new LoggerContext();
    Display display = new Display();
    ResourceUtil.init(display);
    Shell shell = new Shell(display);
    final Tree tree = new Tree(shell, SWT.BORDER);
    Rectangle clientArea = shell.getClientArea();
    tree.setBounds(clientArea.x, clientArea.y, 200, 200);

    LoggerTree loggerTree = new LoggerTree(loggerContext, tree);
    tree.setMenu(TreeMenuBuilder.buildTreeMenu(loggerTree, null));
    loggerTree.update("com.foo.Bar");
    loggerTree.update("com.foo.Bar");

    loggerContext.getLogger("org.apache.struts").setLevel(Level.ERROR);

    loggerTree.update("org.apache.struts.BlahAction");

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Ejemplo n.º 12
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new RowLayout());

    DateTime calendar = new DateTime(shell, SWT.CALENDAR);
    calendar.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            System.out.println("calendar date changed");
          }
        });

    DateTime time = new DateTime(shell, SWT.TIME);
    time.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            System.out.println("time changed");
          }
        });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Ejemplo n.º 13
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new RowLayout());
   Text text = new Text(shell, SWT.MULTI | SWT.BORDER);
   String modifier = SWT.MOD1 == SWT.CTRL ? "Ctrl" : "Command";
   text.setText("Hit " + modifier + "+Return\nto see\nthe default button\nrun");
   text.addTraverseListener(
       e -> {
         switch (e.detail) {
           case SWT.TRAVERSE_RETURN:
             if ((e.stateMask & SWT.MOD1) != 0) e.doit = true;
         }
       });
   Button button = new Button(shell, SWT.PUSH);
   button.pack();
   button.setText("OK");
   button.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent e) {
           System.out.println("OK selected");
         }
       });
   shell.setDefaultButton(button);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Ejemplo n.º 14
0
 private static void restoreShellSize(Shell shell, Rectangle bufferedBounds, boolean isPacked) {
   if (isPacked) {
     shell.pack();
     ControlUtil.getControlAdapter(shell).clearPacked();
   } else {
     setShellSize(shell, bufferedBounds);
   }
 }
Ejemplo n.º 15
0
  public static void main(String[] args) {
    Display display = Display.getDefault();
    final Shell shell = new Shell(display, SWT.TITLE | SWT.CLOSE);
    shell.setText(TITLE);

    final String C10T_PATH = System.getenv("C10T_PATH");

    final C10tGraphicalInterface gui = new C10tGraphicalInterface(display, shell);
    final DetachedProcess detachedProcess = new C10tDetachedProcess(gui);
    final CommandExecutioner executioner =
        new CommandExecutioner("c10t", detachedProcess, C10T_PATH);

    gui.addRenderButtonListener(new RenderSelection(shell, gui, executioner));

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    gridLayout.marginBottom = 8;
    gridLayout.marginTop = 8;
    gridLayout.marginLeft = 8;
    gridLayout.marginRight = 8;

    shell.setLayout(gridLayout);
    shell.pack();
    shell.open();

    shell.setSize(500, shell.getSize().y);

    try {
      executioner.findCommand();
    } catch (CommandNotFoundException e) {
      MessageBox messageBox = new MessageBox(shell, SWT.ERROR);
      messageBox.setText("c10t - Command could not be found");
      messageBox.setMessage(
          "The program `"
              + executioner.getName()
              + "' could not be located anywhere in your PATH or in the current working directory\n\n"
              + "You must be fixed this by doing one of the following:\n\n"
              + " 1) Install the command `"
              + executioner.getName()
              + "' to somewhere in your PATH or the working directory of this program `"
              + System.getProperty("user.dir")
              + "'\n"
              + " 2) Specify where the command is with the environment variable `C10T_PATH'\n\n"
              + "Your PATH is: "
              + System.getenv("PATH"));
      messageBox.open();
    }

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    if (!display.isDisposed()) {
      display.dispose();
    }
  }
Ejemplo n.º 16
0
 public String open() {
   Shell shell = new Shell(getParent(), getStyle());
   shell.setText("Add project");
   createContents(shell);
   shell.pack();
   shell.setLocation(100, 100);
   shell.open();
   return null;
 }
Ejemplo n.º 17
0
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Widget");

    final Table table = new Table(shell, SWT.MULTI);
    table.setLinesVisible(true);
    table.setBounds(10, 10, 100, 100);
    for (int i = 0; i < 9; i++) {
      new TableItem(table, SWT.NONE).setText("item" + i);
    }

    Button button = new Button(shell, SWT.PUSH);
    button.setText("Capture");
    button.pack();
    button.setLocation(10, 140);
    button.addListener(
        SWT.Selection,
        event -> {
          Point tableSize = table.getSize();
          GC gc = new GC(table);
          final Image image = new Image(display, tableSize.x, tableSize.y);
          gc.copyArea(image, 0, 0);
          gc.dispose();

          Shell popup = new Shell(shell);
          popup.setText("Image");
          popup.addListener(SWT.Close, e -> image.dispose());

          Canvas canvas = new Canvas(popup, SWT.NONE);
          canvas.setBounds(10, 10, tableSize.x + 10, tableSize.y + 10);
          canvas.addPaintListener(e -> e.gc.drawImage(image, 0, 0));
          popup.pack();
          popup.open();
        });
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
 private void createFeedback() {
   dragShell = new Shell(SWT.NO_TRIM | SWT.NO_BACKGROUND);
   dragShell.setAlpha(175);
   ToolBar dragTB = new ToolBar(dragShell, SWT.RIGHT);
   ToolItem newTI = new ToolItem(dragTB, SWT.RADIO);
   newTI.setText(dragItem.getText());
   newTI.setImage(dragItem.getImage());
   dragTB.pack();
   dragShell.pack();
   dragShell.setVisible(true);
 }
Ejemplo n.º 19
0
  /** @param args */
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("Button 1");
    final Sash sash = new Sash(shell, SWT.VERTICAL);
    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("Button 2");

    final FormLayout form = new FormLayout();
    shell.setLayout(form);

    FormData button1Data = new FormData();
    button1Data.left = new FormAttachment(0, 0);
    button1Data.right = new FormAttachment(sash, 0);
    button1Data.top = new FormAttachment(0, 0);
    button1Data.bottom = new FormAttachment(100, 0);
    button1.setLayoutData(button1Data);

    final int limit = 20, percent = 50;
    final FormData sashData = new FormData();
    sashData.left = new FormAttachment(percent, 0);
    sashData.top = new FormAttachment(0, 0);
    sashData.bottom = new FormAttachment(100, 0);
    sash.setLayoutData(sashData);
    sash.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            Rectangle sashRect = sash.getBounds();
            Rectangle shellRect = shell.getClientArea();
            int right = shellRect.width - sashRect.width - limit;
            e.x = Math.max(Math.min(e.x, right), limit);
            if (e.x != sashRect.x) {
              sashData.left = new FormAttachment(0, e.x);
              shell.layout();
            }
          }
        });

    FormData button2Data = new FormData();
    button2Data.left = new FormAttachment(sash, 0);
    button2Data.right = new FormAttachment(100, 0);
    button2Data.top = new FormAttachment(0, 0);
    button2Data.bottom = new FormAttachment(100, 0);
    button2.setLayoutData(button2Data);

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Ejemplo n.º 20
0
 private static void start() {
   Display display = new Display();
   Shell shell = new Shell(display);
   MainPane mainPane = new MainPane(shell, SWT.NONE);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Ejemplo n.º 21
0
  public void show(int serverId, Rectangle r) {
    dialog = setDialogLayout(serverId);
    dialog.pack();

    UIUtil.setDialogDefaultFunctions(dialog);

    getOldDescription();

    dialog.setSize(400, 150);
    dialog.setLocation(r.x + 100, r.y + 100);
    dialog.open();
  }
  /*
   * @see IInformationControl#setSize(int, int)
   */
  public void setSize(int width, int height) {

    if (fStatusField != null) {
      GridData gd = (GridData) fViewer.getTextWidget().getLayoutData();
      Point statusSize = fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
      Point separatorSize = fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
      gd.heightHint = height - statusSize.y - separatorSize.y;
    }
    fShell.setSize(width, height);

    if (fStatusField != null) fShell.pack(true);
  }
Ejemplo n.º 23
0
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    final Button button = new Button(shell, SWT.NONE);
    button.setSize(100, 100);
    button.setText("Click");
    shell.pack();
    shell.open();
    button.addListener(
        SWT.MouseDown,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            System.out.println(
                "Mouse Down (button: " + e.button + " x: " + e.x + " y: " + e.y + ")");
          }
        });
    final Point pt = display.map(shell, null, 50, 50);
    new Thread() {
      Event event;

      @Override
      public void run() {
        try {
          Thread.sleep(300);
        } catch (InterruptedException e) {
        }
        event = new Event();
        event.type = SWT.MouseMove;
        event.x = pt.x;
        event.y = pt.y;
        display.post(event);
        try {
          Thread.sleep(300);
        } catch (InterruptedException e) {
        }
        event.type = SWT.MouseDown;
        event.button = 1;
        display.post(event);
        try {
          Thread.sleep(300);
        } catch (InterruptedException e) {
        }
        event.type = SWT.MouseUp;
        display.post(event);
      }
    }.start();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    // Create the layout.
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    // gridLayout.makeColumnsEqualWidth = true;
    shell.setLayout(gridLayout);
    // Create the children of the composite.

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("B1");
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    button1.setLayoutData(gridData);

    new Button(shell, SWT.PUSH).setText("Wide Button 2");

    Button button3 = new Button(shell, SWT.PUSH);
    button3.setText("Button 3");
    gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.verticalSpan = 2;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    button3.setLayoutData(gridData);

    Button button4 = new Button(shell, SWT.PUSH);
    button4.setText("B4");
    gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    button4.setLayoutData(gridData);

    new Button(shell, SWT.PUSH).setText("Button 5");

    String path = System.getProperty("user.dir") + "/util/";
    Image img = new Image(display, path + "grooveshark.ico");

    // row 1 column 1
    //		Label emptyLabel11 = new Label(shell, SWT.NONE);
    //		emptyLabel11.setImage(img);
    //		Color color = new Color(display , 22, 22, 22);
    //		emptyLabel11.setBackground(color);

    shell.pack();
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
Ejemplo n.º 25
0
  public void open(int minValue, int maxValue) {
    childShell = new Shell(shell.getDisplay(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    childShell.setText("Exporting to Excel.. please wait");

    progressBar = new ProgressBar(childShell, SWT.SMOOTH);
    progressBar.setMinimum(minValue);
    progressBar.setMaximum(maxValue);
    progressBar.setBounds(0, 0, 400, 25);
    progressBar.setFocus();

    childShell.pack();
    childShell.open();
  }
Ejemplo n.º 26
0
  public Object open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    final Shell shell = new Shell(parent);
    createContents(shell);

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return choiceMade;
  }
 public String open() {
   Shell shell = new Shell(getParent(), getStyle());
   shell.setText(getText());
   createContents(shell);
   shell.pack();
   shell.open();
   Display display = getParent().getDisplay();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   return name + " " + x + " " + y + " " + z;
 }
Ejemplo n.º 28
0
 public void run(IDemo demo) throws Exception {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new GridLayout(1, false));
   demo.createComposite(shell);
   shell.pack();
   shell.setText(demo.getClass().getName());
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
   demo.dispose();
 }
Ejemplo n.º 29
0
 /**
  * This does the same thing, but allows you to pass in a function to handle the z keypress, for
  * example, to generate a new random Tree.
  */
 public static RenderSWT render(
     Tree tree, KeyHandler z_handler, double hgap, double vgap, double zoom) {
   final Display display = new Display();
   final Shell shell = new Shell(display, SWT.SHELL_TRIM);
   shell.setLayout(new FillLayout());
   shell.setSize(1000, 800);
   RenderSWT r = new RenderSWT(shell, tree, z_handler, hgap, vgap, zoom);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (display != null && !display.readAndDispatch()) display.sleep();
   }
   display.dispose();
   return r;
 }
Ejemplo n.º 30
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.setText("Snippet 346");

    Text text = new Text(shell, SWT.PASSWORD | SWT.BORDER);
    text.setTextChars(new char[] {'p', 'a', 's', 's'});
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }