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();
  }
  /** Create contents of the window. */
  protected void createContents() {
    mAndroidSdkUpdater = new Shell(mParentShell, SWT.SHELL_TRIM);
    mAndroidSdkUpdater.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            onAndroidSdkUpdaterDispose(); // $hide$ (hide from SWT designer)
          }
        });

    FillLayout fl;
    mAndroidSdkUpdater.setLayout(fl = new FillLayout(SWT.HORIZONTAL));
    fl.marginHeight = fl.marginWidth = 5;
    mAndroidSdkUpdater.setMinimumSize(new Point(200, 50));
    mAndroidSdkUpdater.setSize(745, 433);
    mAndroidSdkUpdater.setText("Android SDK and AVD Manager");

    mSashForm = new SashForm(mAndroidSdkUpdater, SWT.NONE);

    mPageList = new List(mSashForm, SWT.BORDER);
    mPageList.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            onPageListSelected(); // $hide$ (hide from SWT designer)
          }
        });

    mPagesRootComposite = new Composite(mSashForm, SWT.NONE);
    mStackLayout = new StackLayout();
    mPagesRootComposite.setLayout(mStackLayout);

    createPages();

    mSashForm.setWeights(new int[] {150, 576});
  }
예제 #3
0
  private void open() {

    display = Display.getDefault();

    shell = new Shell();

    shell.setSize(250, 170);

    // ---------创建窗口中的其他界面组件-------------

    shell.setLayout(new GridLayout());

    createMainComp(shell); // 创建主面板

    createStatusbar(shell); // 创建工具栏
    // -----------------END------------------------

    shell.layout();

    shell.open();

    while (!shell.isDisposed()) {

      if (!display.readAndDispatch()) display.sleep();
    }

    display.dispose();
  }
예제 #4
0
  public void run(String trace) throws JDOMException, IOException, JniException {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Flightbox");
    shell.setSize(800, 800);
    shell.setLayout(new FillLayout(SWT.VERTICAL));

    IntervalView widget = new IntervalView(shell, SWT.NONE);
    VersionizedStack<String> stack = new VersionizedStack<String>();
    int i;
    int max = 1000;
    for (i = 0; i < max; i++) {
      long disp = i * 100;
      stack.push("FOO", 10L + disp);
      stack.push("BAR", 20L + disp);
      stack.pop(30L + disp);
      stack.pop(40L + disp);
    }

    widget.setStack(stack);

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

    shell.dispose();
  }
예제 #5
0
  public InputViewer(Shell parent, Properties properties, String resources) {
    sShell = new org.eclipse.swt.widgets.Shell(parent);
    sShell.setLocation(parent.getLocation().x + 200, parent.getLocation().y + 150);
    sShell.setSize(new org.eclipse.swt.graphics.Point(471, 146));
    sShell.setLayout(null);

    listeners = new Vector<DialogInputListener>();

    ApplicationFactory factory = new ApplicationFactory(sShell, resources, getClass().getName());

    factory.createLabel("lbl").setBounds(15, 15, 100, 20);

    txtName = factory.createText();
    txtName.setBounds(120, 15, 280, 20);
    txtName.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.keyCode != 13) return;
            enter();
          }
        });
    factory
        .createButton(
            "but",
            new SelectionAdapter() {
              @SuppressWarnings("unused")
              public void widgetSelected(SelectionEvent e) {
                enter();
              }
            })
        .setBounds(180, 50, 90, 20);

    sShell.setSize(420, 120);
    sShell.open();
  }
예제 #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();
 }
  private void createDialog(Shell applicationShell) {
    if (dialog == null || dialog.isDisposed()) {
      dialog = new Shell(applicationShell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);

      if (applicationShell.getImage() != null) {
        dialog.setImage(applicationShell.getImage());
      }

      dialog.addListener(
          SWT.Close,
          new Listener() {
            public void handleEvent(Event event) {
              hideCustomPanelChildren();
            }
          });

      dialog.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent arg0) {
              disposeImages();
            }
          });

      if (fileDialogMode != VFS_DIALOG_SAVEAS) {
        dialog.setText(Messages.getString("VfsFileChooserDialog.openFile")); // $NON-NLS-1$
      } else {
        dialog.setText(Messages.getString("VfsFileChooserDialog.saveAs")); // $NON-NLS-1$
      }
      dialog.setLayout(new GridLayout());
      dialog.setBackgroundMode(SWT.INHERIT_FORCE);
      dialog.setBackground(dialog.getDisplay().getSystemColor(SWT.COLOR_WHITE));
      createCustomUIPanel(dialog);
    }
  }
  /** @param args */
  public static void main(String[] args) {
    Display display = new Display();
    JFaceResources.getImageRegistry()
        .put(
            "IMG_1",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/cancel.png")));
    JFaceResources.getImageRegistry()
        .put(
            "IMG_2",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/filesave.png")));
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    new Snippet033CellEditorPerRowPre33(shell);
    shell.open();

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

    display.dispose();
  }
  public void testRealWorld() {

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    String json =
        "{ \"firstname\": \"Richard\", \"surname\": \"Kennard\", \"notes\": \"Software developer\" }";
    String jsonSchema =
        "{ properties: { \"firstname\": { \"required\": true }, \"notes\": { \"large\": true }}}";

    SwtMetawidget metawidget = new SwtMetawidget(shell, SWT.None);
    metawidget.setInspector(
        new CompositeInspector(
            new CompositeInspectorConfig()
                .setInspectors(
                    new JsonInspector(
                        new JsonInspectorConfig()
                            .setInputStream(new ByteArrayInputStream(json.getBytes()))),
                    new JsonSchemaInspector(
                        new JsonInspectorConfig()
                            .setInputStream(new ByteArrayInputStream(jsonSchema.getBytes()))))));
    metawidget.setInspectionPath("fooObject");

    assertEquals("Firstname*:", ((Label) metawidget.getChildren()[0]).getText());
    assertTrue(metawidget.getChildren()[1] instanceof Text);
    assertEquals("Surname:", ((Label) metawidget.getChildren()[2]).getText());
    assertTrue(metawidget.getChildren()[3] instanceof Text);
    assertEquals("Notes:", ((Label) metawidget.getChildren()[4]).getText());
    assertTrue(metawidget.getChildren()[5] instanceof Text);
    assertEquals((metawidget.getChildren()[5].getStyle() & SWT.MULTI), SWT.MULTI);
    assertEquals(6, metawidget.getChildren().length);
  }
예제 #10
0
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("SWT and Swing DND Example");
    GridLayout layout = new GridLayout(1, false);
    shell.setLayout(layout);

    Text swtText = new Text(shell, SWT.BORDER);
    swtText.setText("SWT Text");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    swtText.setLayoutData(data);
    setDragDrop(swtText);

    Composite comp = new Composite(shell, SWT.EMBEDDED);
    java.awt.Frame frame = SWT_AWT.new_Frame(comp);
    JTextField swingText = new JTextField(40);
    swingText.setText("Swing Text");
    swingText.setDragEnabled(true);
    frame.add(swingText);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = swingText.getPreferredSize().height;
    comp.setLayoutData(data);

    shell.setSize(400, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
예제 #11
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    final ScrolledComposite sc =
        new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    Composite c = new Composite(sc, SWT.NONE);
    c.setLayout(new GridLayout(10, true));
    for (int i = 0; i < 300; i++) {
      Button b = new Button(c, SWT.PUSH);
      b.setText("Button " + i);
    }
    sc.setContent(c);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setShowFocusedControl(true);

    shell.setSize(300, 500);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
예제 #12
0
  /** Create contents of the window. */
  protected void createContents() {
    shell = new Shell(SWT.NO_TRIM | SWT.BORDER);
    shell.setSize(850, 560);
    shell.setLayout(new FillLayout(SWT.HORIZONTAL));
    LayoutUtil.centerShell(Display.getCurrent(), shell);
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setBackgroundImage(SWTResourceManager.getImage(getClass(), "/res/bg.jpg"));
    composite.setBackgroundMode(SWT.INHERIT_FORCE);
    RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
    rowLayout.marginTop = 0;
    rowLayout.marginRight = 0;
    rowLayout.marginLeft = 0;
    rowLayout.spacing = 5;
    composite.setLayout(rowLayout);

    winTitle = createWinTitle(composite);
    winToolbar = createWinToolBar(composite);

    Composite winMainContent = new Composite(composite, SWT.NONE);
    winMainContent.setLayout(new StackLayout());
    winMainContent.setLayoutData(new RowData(850, 407));

    winStatusbar = createWinStatusBar(composite);
    addShellListener(winTitle, winToolbar, winStatusbar);
  }
예제 #13
0
파일: Snippet24.java 프로젝트: xx70235/Repo
 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();
 }
  /** 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();
  }
예제 #15
0
  public static void main(String[] args) {
    Display d = new Display();
    Shell shell = new Shell(d);
    shell.setText("GraphSnippet1");
    shell.setLayout(new FillLayout());
    shell.setSize(400, 400);

    final Graph g = new Graph(shell, SWT.NONE);

    hookMenu(g);

    SpaceTreeLayoutAlgorithm spaceTreeLayoutAlgorithm = new SpaceTreeLayoutAlgorithm();
    g.setLayoutAlgorithm(spaceTreeLayoutAlgorithm, false);
    g.setExpandCollapseManager(spaceTreeLayoutAlgorithm.getExpandCollapseManager());

    g.setSubgraphFactory(new DefaultSubgraph.LabelSubgraphFactory());

    for (int i = 0; i < 20; i++) {
      GraphNode graphNode = new GraphNode(g, SWT.NONE);
      graphNode.setText("" + i);
    }

    shell.open();
    while (!shell.isDisposed()) {
      while (!d.readAndDispatch()) {
        d.sleep();
      }
    }
  }
예제 #16
0
  public Main(String args[]) {
    //   must be before display is created (on Macs at least)
    Display.setAppName("BrailleZephyr");

    Display display = Display.getDefault();

    //   needed to catch Quit (Command-Q) on Macs
    display.addListener(SWT.Close, new CloseHandler());

    shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.setText("BrailleZephyr");
    shell.addShellListener(new ShellHandler());

    bzStyledText = new BZStyledText(shell);
    bzFile = new BZFile(bzStyledText);
    bzSettings = new BZSettings(bzStyledText);
    new BZMenu(bzStyledText, bzFile, bzSettings);

    //   assume any argument is a file to open
    if (args.length > 0) bzFile.openFile(args[0]);

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

    display.dispose();
  }
예제 #17
0
  public static void view(DrawModel d) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    Frame baseFrame = SWT_AWT.new_Frame(composite);

    baseFrame.setBounds(0, 0, 800, 600);

    Java3DViewer viewer = new Java3DViewer(baseFrame, d);
    baseFrame.add(viewer);

    shell.open();

    d.setFaceColor(Color.GREEN);
    d.circle(0.9);
    //		viewer.draw(d);

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

    baseFrame.dispose();
    shell.dispose();
    composite.dispose();
    display.dispose();
    System.exit(0);
  }
  public static void main(final String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final CompositeTable table = new CompositeTable(shell, SWT.NONE);
    new Header(table, SWT.NONE);
    new Row(table, SWT.NONE);
    table.setRunTime(true);

    final ICompositeTableRidget ridget =
        (ICompositeTableRidget) SwtRidgetFactory.createRidget(table);
    final WritableList input = new WritableList(PersonFactory.createPersonList(), Person.class);
    ridget.bindToModel(input, Person.class, RowRidget.class);
    ridget.updateFromModel();

    shell.setSize(400, 160);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    display.dispose();
  }
 public static void main(String[] args) {
   final Display display = new Display();
   final Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER);
   styledText.setText(text);
   FontData data = display.getSystemFont().getFontData()[0];
   Font font = new Font(display, data.getName(), 16, SWT.BOLD);
   styledText.setFont(font);
   styledText.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
   styledText.addListener(
       SWT.Resize,
       new Listener() {
         public void handleEvent(Event event) {
           Rectangle rect = styledText.getClientArea();
           Image newImage = new Image(display, 1, Math.max(1, rect.height));
           GC gc = new GC(newImage);
           gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
           gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
           gc.fillGradientRectangle(rect.x, rect.y, 1, rect.height, true);
           gc.dispose();
           styledText.setBackgroundImage(newImage);
           if (oldImage != null) oldImage.dispose();
           oldImage = newImage;
         }
       });
   shell.setSize(700, 400);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   if (oldImage != null) oldImage.dispose();
   font.dispose();
   display.dispose();
 }
  @Before
  public void setUp() {
    display = Display.getDefault();
    shell = new Shell(display);
    shell.setLayout(new FillLayout());

    SquareButton.SquareButtonBuilder builder = new SquareButton.SquareButtonBuilder();
    builder.setParent(shell).setText("one").setToggleable(true);
    toggleOne = builder.build();

    builder = new SquareButton.SquareButtonBuilder();
    builder.setParent(shell).setText("two").setToggleable(true);
    toggleTwo = builder.build();

    builder = new SquareButton.SquareButtonBuilder();
    builder.setParent(shell).setText("three").setToggleable(true);
    toggleThree = builder.build();

    builder = new SquareButton.SquareButtonBuilder();
    builder.setParent(shell).setText("non toggle");
    nonToggled = builder.build();

    group = new SquareButtonGroup(toggleOne, toggleTwo, toggleThree, nonToggled);

    shell.open();
  }
예제 #21
0
 public static void main(java.lang.String[] args) {
   org.eclipse.swt.widgets.Display display = new org.eclipse.swt.widgets.Display();
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell(display);
   shell.setLayout(new org.eclipse.swt.layout.FillLayout());
   shell.setText(getResourceString("window.title"));
   java.io.InputStream stream =
       (org.eclipse.swt.examples.browserexample.BrowserExample.class)
           .getResourceAsStream(iconLocation);
   org.eclipse.swt.graphics.Image icon = new org.eclipse.swt.graphics.Image(display, stream);
   shell.setImage(icon);
   try {
     stream.close();
   } catch (java.io.IOException e) {
     e.printStackTrace();
   }
   org.eclipse.swt.examples.browserexample.BrowserExample app =
       new org.eclipse.swt.examples.browserexample.BrowserExample(shell, true);
   app.setShellDecoration(icon, true);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   icon.dispose();
   app.dispose();
   display.dispose();
 }
예제 #22
0
  /** Create contents of the dialog. */
  private void createContents() {
    shell = new Shell(getParent());
    shell.setSize(334, 100);
    shell.setText(getText());
    shell.setLayout(new GridLayout(2, false));

    combo = new Combo(shell, SWT.READ_ONLY);
    combo.setItems(options);
    combo.select(0);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Button btnNewButton = new Button(shell, SWT.NONE);
    btnNewButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            result = combo.getText();
            shell.close();
          }
        });
    btnNewButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    btnNewButton.setText("Select");

    Button btnNewButton_1 = new Button(shell, SWT.NONE);
    btnNewButton_1.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            result = null;
            shell.close();
          }
        });
    btnNewButton_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    btnNewButton_1.setText("Cancel");
  }
예제 #23
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();
  }
  /** @param args ; */
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(1, false));

    final Combo combo = new Combo(shell, SWT.READ_ONLY);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    Button button = new Button(shell, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    button.setText("OK");
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            CustomMatchConditionDialog dialog = new CustomMatchConditionDialog(shell);
            int res = dialog.open();
            if (res == CustomMatchConditionDialog.OK) {}
          }
        });

    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
예제 #25
0
 /** Subclasses may override to create a shell. */
 protected void createShell() {
   if (shell == null || shell.isDisposed()) {
     shell = new Shell(display, SWT.SHELL_TRIM);
     shell.setLayout(new FillLayout());
     shell.setText("TITLE");
   }
 }
예제 #26
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();
 }
예제 #27
0
파일: AskShell.java 프로젝트: kejn/GOL
  private static void initShell() {
    askShell.setText("New Game of Life");
    askShell.setLayout(new GridLayout(2, true));
    askShell.addShellListener(
        new ShellListener() {
          @Override
          public void shellIconified(ShellEvent arg0) {}

          @Override
          public void shellDeiconified(ShellEvent arg0) {}

          @Override
          public void shellDeactivated(ShellEvent arg0) {}

          @Override
          public void shellClosed(ShellEvent arg0) {
            GameOfLife.CANCELLED = true;
          }

          @Override
          public void shellActivated(ShellEvent arg0) {}
        });
    askShell.addListener(
        SWT.OK,
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            askShell.dispose();
          }
        });
  }
예제 #28
0
  /** This method initializes lookforShell. */
  protected void createLookforShell() {
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.CENTER;
    GridData gridData1 = new GridData();
    gridData1.grabExcessHorizontalSpace = false;
    gridData1.horizontalAlignment = GridData.FILL;
    gridData1.verticalAlignment = GridData.CENTER;
    gridData1.grabExcessVerticalSpace = false;
    GridLayout gridLayout1 = new GridLayout();
    gridLayout1.numColumns = 5;
    gridLayout1.makeColumnsEqualWidth = true;
    // this line has to be commented in order to open with VISUAL EDITOR
    lookforShell = new Shell(PlatformUI.getWorkbench().getDisplay().getActiveShell());

    // lookforShell = new Shell();
    lookforShell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    createCTabFolder();
    lookforShell.setLayout(gridLayout1);
    lookforShell.setSize(new Point(501, 313));
    new Label(lookforShell, SWT.NONE);
    new Label(lookforShell, SWT.NONE);
    new Label(lookforShell, SWT.NONE);
    OKbutton = new Button(lookforShell, SWT.NONE);
    OKbutton.setText(Messages.AbstractLookForEditorShell_OK);
    OKbutton.setLayoutData(gridData1);
    OKbutton.setEnabled(false);
    cancelbutton = new Button(lookforShell, SWT.NONE);
    cancelbutton.setText(Messages.AbstractLookForEditorShell_Cancel);
    cancelbutton.setLayoutData(gridData2);
  }
예제 #29
0
  private void createControls() {
    GridLayout gLayout = new GridLayout();
    gLayout.marginHeight = 0;
    gLayout.marginWidth = 0;
    gLayout.verticalSpacing = 0;
    shell.setLayout(gLayout);
    Utils.setShellIcon(shell);

    topPanel = new Composite(shell, SWT.NONE);
    topPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    GridLayout gLayout1 = new GridLayout();
    gLayout1.marginBottom = 10;
    topPanel.setLayout(gLayout1);
    topPanel.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    topPanel.setBackgroundMode(SWT.INHERIT_FORCE);

    Label separator1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    contentPanel = new Composite(shell, SWT.NONE);
    contentPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    contentStackLayout = new StackLayout();
    contentPanel.setLayout(contentStackLayout);

    titleLabel = new Label(topPanel, SWT.NONE);
    titleLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    Utils.setFontHeight(titleLabel, 16, SWT.NORMAL);

    descriptionLabel = new Label(topPanel, SWT.WRAP);
    GridData gData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gData.horizontalIndent = 10;
    descriptionLabel.setLayoutData(gData);

    shell.layout(true, true);
  }
예제 #30
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);
 }