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();
 }
  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();
  }
  /** Experimental. Switching themes at runtime does not yet work properly. */
  protected void createThemeSwitcher(final Composite parent) {
    final Button button = new Button(parent, SWT.PUSH);
    button.setText("Theme Switcher");
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            Shell shell = new Shell(parent.getShell(), SWT.DIALOG_TRIM);
            shell.setText("Theme Switcher");
            shell.setLayout(new GridLayout());
            Button themeButton = new Button(shell, SWT.PUSH);
            themeButton.setText("Switch Theme");
            themeButton.addSelectionListener(
                new SelectionAdapter() {
                  String[] availableThemeIds = ThemeUtil.getAvailableThemeIds();

                  public void widgetSelected(final SelectionEvent e) {
                    int index = 0;
                    String currThemeId = ThemeUtil.getCurrentThemeId();
                    for (int i = 0; i < availableThemeIds.length; i++) {
                      if (currThemeId.equals(availableThemeIds[i])) {
                        index = (i + 1) % availableThemeIds.length;
                      }
                    }
                    String newThemeId = availableThemeIds[index];
                    ThemeUtil.setCurrentThemeId(newThemeId);
                  }
                });
            shell.pack();
            shell.open();
          }
        });
  }
Beispiel #4
0
 /** Sets the state of the "Example" widgets. */
 void setExampleWidgetState() {
   super.setExampleWidgetState();
   Control[] controls = getExampleWidgets();
   if (controls.length != 0) {
     leftButton.setSelection((controls[0].getStyle() & SWT.LEFT) != 0);
     centerButton.setSelection((controls[0].getStyle() & SWT.CENTER) != 0);
     rightButton.setSelection((controls[0].getStyle() & SWT.RIGHT) != 0);
   }
 }
 private void setButtonEnabled(String configKey, Button b, boolean enabled) {
   Boolean previousValue = oldBulkAPIDependencies.put(b, b.getSelection());
   b.setSelection(
       enabled
           ? (previousValue != null
               ? previousValue
               : this.controller.getConfig().getBoolean(configKey))
           : false);
   b.setEnabled(enabled);
 }
Beispiel #6
0
  /** Creates the "Style" group. */
  void createStyleGroup() {
    super.createStyleGroup();

    /* Create the extra widgets */
    topButton = new Button(styleGroup, SWT.RADIO);
    topButton.setText("SWT.TOP");
    topButton.setSelection(true);
    bottomButton = new Button(styleGroup, SWT.RADIO);
    bottomButton.setText("SWT.BOTTOM");
    borderButton = new Button(styleGroup, SWT.CHECK);
    borderButton.setText("SWT.BORDER");
  }
 /**
  * Creates a checkbox that controls whether a background image is set on the registered controls.
  *
  * @return the created checkbox
  */
 protected Button createBgImageButton() {
   final Button button = new Button(styleComp, SWT.CHECK);
   button.setText("Background Image");
   button.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(final SelectionEvent event) {
           showBgImage = button.getSelection();
           updateBgImage();
         }
       });
   return button;
 }
 /**
  * Creates a button to change the background color of all registered controls.
  *
  * @return the created button
  */
 protected Button createBgColorButton() {
   bgColorChooser = new ColorChooser();
   final Button button = new Button(styleComp, SWT.PUSH);
   button.setText("Background");
   button.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(final SelectionEvent event) {
           bgIndex = (bgIndex + 1) % fgColors.length;
           updateBgColor();
         }
       });
   return button;
 }
 /**
  * Creates a checkbutton to enable / disabled the registered controls.
  *
  * @return the created checkbutton.
  */
 protected Button createEnablementButton() {
   final Button button = new Button(styleComp, SWT.CHECK);
   button.setText("Enabled");
   button.setSelection(enabled);
   button.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(final SelectionEvent event) {
           enabled = button.getSelection();
           updateEnabled();
         }
       });
   return button;
 }
 /**
  * Creates a checkbutton to show / hide the registered controls.
  *
  * @return the created checkbutton
  */
 protected Button createVisibilityButton() {
   final Button button = new Button(styleComp, SWT.CHECK);
   button.setText("Visible");
   button.setSelection(visible);
   button.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(final SelectionEvent event) {
           visible = button.getSelection();
           updateVisible();
         }
       });
   return button;
 }
 protected Button createStyleButton(final String name, final int style, final boolean checked) {
   Button button = new Button(styleComp, SWT.CHECK);
   button.setText(name);
   button.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(final SelectionEvent event) {
           createNew();
         }
       });
   button.setData("style", new Integer(style));
   button.setSelection(checked);
   return button;
 }
  private void createControls(Composite parent) {
    Group container = new Group(parent, SWT.SHADOW_ETCHED_OUT);
    container.setText("General interpreter properties");
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    container.setLayoutData(data);
    container.setLayout(new GridLayout(1, false));

    final Button saveButton = new Button(container, SWT.CHECK);
    saveButton.setText("Save file before loading in interpreter");
    saveButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            mSaveBeforeLoad = saveButton.getSelection();
          }
        });
    saveButton.setSelection(mSaveBeforeLoad);

    final Button surroundButton = new Button(container, SWT.CHECK);
    surroundButton.setText("Surround expressions with (begin ...  )");
    surroundButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            mSurroundWithBegin = surroundButton.getSelection();
          }
        });
    surroundButton.setSelection(mSurroundWithBegin);
  }
  private void createUI() {
    String newFile = "";

    parentShell = ((Spoon) SpoonFactory.getInstance()).getShell();

    Display display = parentShell.getDisplay();

    comp = new Composite(((Spoon) SpoonFactory.getInstance()).getShell(), SWT.BORDER);
    comp.setLayout(new GridLayout());
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));

    lbl = new Label(comp, SWT.CENTER | SWT.TOP);

    GridData ldata = new GridData(SWT.CENTER, SWT.TOP, true, false);
    lbl.setLayoutData(ldata);
    lbl.setText("Preview data returned from HPCC");

    Button fileButton = new Button(comp, SWT.PUSH | SWT.SINGLE | SWT.TOP);

    fileButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
    fileButton.setText("OPEN FILE");

    // Listener for the file open button (fileButton)
    Listener fileOpenListener =
        new Listener() {

          public void handleEvent(Event e) {
            String newFile = buildFileDialog();
            if (newFile != "") {
              fileName = newFile;
              // TODO: create new tab for file
              // openFile(fileName);
              openResultsXML(fileName);

              // int len = folder.getChildren().length;
              int len = folder.getItemCount();
              System.out.println("Number of tabs: " + len);
              folder.setSelection(len - 1);
            }
          }
        };

    fileButton.addListener(SWT.Selection, fileOpenListener);

    folder = new CTabFolder(comp, SWT.CLOSE);
    folder.setSimple(false);
    folder.setBorderVisible(true);
    folder.setLayoutData(new GridData(GridData.FILL_BOTH));
  }
 private void radioChanged() {
   if (exampleModelButton.getSelection()) {
     descriptionText.setText("This model displays an awesome simulation of something ...");
     titleText.setText("example");
     fileText.setText("example.gaml");
     updateStatus(null);
   }
   if (emptyModelButton.getSelection() || skeletonModelButton.getSelection()) {
     descriptionText.setText("");
     titleText.setText("new");
     fileText.setText("new.gaml");
     updateStatus(null);
   }
   dialogChanged();
 }
  void createRTFTransfer(Composite copyParent, Composite pasteParent) {
    //	RTF Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("RTFTransfer:"); // $NON-NLS-1$
    copyRtfText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyRtfText.setText("some\nrtf\ntext");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    copyRtfText.setLayoutData(data);
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = copyRtfText.getText();
            if (data.length() > 0) {
              status.setText("");
              data = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i " + data + "}";
              clipboard.setContents(
                  new Object[] {data}, new Transfer[] {RTFTransfer.getInstance()});
            } else {
              status.setText("nothing to copy");
            }
          }
        });

    l = new Label(pasteParent, SWT.NONE);
    l.setText("RTFTransfer:"); // $NON-NLS-1$
    pasteRtfText =
        new Text(pasteParent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    pasteRtfText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = (String) clipboard.getContents(RTFTransfer.getInstance());
            if (data != null && data.length() > 0) {
              status.setText("");
              pasteRtfText.setText("start paste>" + data + "<end paste");
            } else {
              status.setText("nothing to paste");
            }
          }
        });
  }
  public void addSelectedFilesToTargetList() {
    ISelection selection = sourceFileViewer.getSelection();

    if (isValidSourceFileViewerSelection(selection)) {
      java.util.List list = null;
      if (selection instanceof IStructuredSelection) {
        list = ((IStructuredSelection) selection).toList();

        if (list != null) {
          list = ((IStructuredSelection) selection).toList();
          for (Iterator i = list.iterator(); i.hasNext(); ) {
            IResource resource = (IResource) i.next();
            if (resource instanceof IFile) {
              // Check if its in the list. Don't add it if it is.
              String resourceName = resource.getFullPath().toString();
              if (selectedListBox.indexOf(resourceName) == -1) selectedListBox.add(resourceName);
            }
          }
          setFiles(selectedListBox.getItems());
        }

        setAddButtonEnabled(false);

        if (selectedListBox.getItemCount() > 0) {
          removeAllButton.setEnabled(true);
          if (isFileMandatory) setPageComplete(true);
          if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true);
          else setRemoveButtonEnabled(false);
        }
      }
    }
  }
  void createHTMLTransfer(Composite copyParent, Composite pasteParent) {
    //	HTML Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("HTMLTransfer:"); // $NON-NLS-1$
    copyHtmlText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyHtmlText.setText("<b>Hello World</b>");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    copyHtmlText.setLayoutData(data);
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = copyHtmlText.getText();
            if (data.length() > 0) {
              status.setText("");
              clipboard.setContents(
                  new Object[] {data}, new Transfer[] {HTMLTransfer.getInstance()});
            } else {
              status.setText("nothing to copy");
            }
          }
        });

    l = new Label(pasteParent, SWT.NONE);
    l.setText("HTMLTransfer:"); // $NON-NLS-1$
    pasteHtmlText =
        new Text(pasteParent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    pasteHtmlText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = (String) clipboard.getContents(HTMLTransfer.getInstance());
            if (data != null && data.length() > 0) {
              status.setText("");
              pasteHtmlText.setText("start paste>" + data + "<end paste");
            } else {
              status.setText("nothing to paste");
            }
          }
        });
  }
 public static void buttonTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Buttons");
   tab.setToolTipText("Different kinds of Buttons");
   Composite composite = new Composite(folder, SWT.NONE);
   composite.setLayout(new GridLayout(4, true));
   for (int dir : new int[] {SWT.UP, SWT.RIGHT, SWT.LEFT, SWT.DOWN}) {
     Button b = new Button(composite, SWT.ARROW | dir);
     b.addListener(SWT.MouseDown, listener);
   }
   newButton(composite, SWT.CHECK, "Check button");
   newButton(composite, SWT.PUSH, "Push button");
   newButton(composite, SWT.RADIO, "Radio button");
   newButton(composite, SWT.TOGGLE, "Toggle button");
   newButton(composite, SWT.FLAT, "Flat button");
   tab.setControl(composite);
 }
Beispiel #19
0
  /** Creates the "Other" group. */
  void createOtherGroup() {
    super.createOtherGroup();

    /* Create display controls specific to this example */
    caretButton = new Button(otherGroup, SWT.CHECK);
    caretButton.setText(ControlExample.getResourceString("Caret"));
    fillDamageButton = new Button(otherGroup, SWT.CHECK);
    fillDamageButton.setText(ControlExample.getResourceString("FillDamage"));

    /* Add the listeners */
    caretButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            setCaret();
          }
        });
  }
 public static void directoryDialogTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Directory Dialog");
   tab.setToolTipText("Select a directory");
   final Button b = new Button(folder, SWT.PUSH);
   b.setText("Select a Directory");
   b.addListener(
       SWT.MouseDown,
       new Listener() {
         public void handleEvent(Event e) {
           DirectoryDialog dd = new DirectoryDialog(shell);
           String path = dd.open();
           if (path != null) b.setText(path);
         }
       });
   tab.setControl(b);
 }
 protected Button createPropertyCheckbox(
     final String text, final String prop, final boolean checked) {
   final Button button = new Button(styleComp, SWT.CHECK);
   button.setText(text);
   button.setSelection(checked);
   button.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(final SelectionEvent e) {
           if (button.getSelection()) {
             properties.add(prop);
           } else {
             properties.remove(prop);
           }
           createNew();
         }
       });
   return button;
 }
 void createAvailableTypes(Composite parent) {
   final List list = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
   GridData data = new GridData(GridData.FILL_BOTH);
   data.heightHint = 100;
   list.setLayoutData(data);
   Button b = new Button(parent, SWT.PUSH);
   b.setText("Get Available Types");
   b.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           list.removeAll();
           String[] names = clipboard.getAvailableTypeNames();
           for (int i = 0; i < names.length; i++) {
             list.add(names[i]);
           }
         }
       });
 }
Beispiel #23
0
  /** Creates the "Example" widgets. */
  void createExampleWidgets() {

    /* Compute the widget style */
    int style = getDefaultStyle();
    if (topButton.getSelection()) style |= SWT.TOP;
    if (bottomButton.getSelection()) style |= SWT.BOTTOM;
    if (borderButton.getSelection()) style |= SWT.BORDER;

    /* Create the example widgets */
    tabFolder1 = new TabFolder(tabFolderGroup, style);
    for (int i = 0; i < TabItems1.length; i++) {
      TabItem item = new TabItem(tabFolder1, SWT.NONE);
      item.setText(TabItems1[i]);
      item.setToolTipText(ControlExample.getResourceString("Tooltip", new String[] {TabItems1[i]}));
      Text content = new Text(tabFolder1, SWT.WRAP | SWT.MULTI);
      content.setText(ControlExample.getResourceString("TabItem_content") + ": " + i);
      item.setControl(content);
    }
  }
 protected Button createFontChooser() {
   final Button button = new Button(styleComp, SWT.PUSH);
   button.setText("Font");
   button.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(final SelectionEvent event) {
           fontChooser = new SimpleFontDialog(getShell());
           Control control = (Control) controls.get(0);
           fontChooser.setFont(control.getFont());
           fontChooser.open(
               new Runnable() {
                 public void run() {
                   font = fontChooser.getFont();
                   updateFont();
                 }
               });
         }
       });
   return button;
 }
Beispiel #25
0
  private void createContent() {
    GridData termGD = new GridData(GridData.FILL_BOTH);
    termGD.heightHint = 400;
    termGD.widthHint = 400;
    termGD.horizontalSpan = 3;

    terminal = new Text(mainPane, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
    terminal.setLayoutData(termGD);

    pause = new Button(mainPane, SWT.TOGGLE);
    pause.setText("Pause");
    pause.setToolTipText("Pause Terminal");

    clear = new Button(mainPane, SWT.PUSH);
    clear.setText("Clear");
    clear.setToolTipText("Clear the Terminal");

    close = new Button(mainPane, SWT.PUSH);
    close.setText("Close");
  }
 protected int getStyle() {
   int result = SWT.NONE;
   Control[] ctrls = styleComp.getChildren();
   if (ctrls.length == 0) {
     result = defaultStyle;
   } else {
     for (int i = 0; i < ctrls.length; i++) {
       if (ctrls[i] instanceof Button) {
         Button button = (Button) ctrls[i];
         if (button.getSelection()) {
           Object data = button.getData("style");
           if (data instanceof Integer) {
             int style = ((Integer) data).intValue();
             result |= style;
           }
         }
       }
     }
   }
   return result;
 }
Beispiel #27
0
  /** Creates the "Example" widgets. */
  void createExampleWidgets() {

    /* Compute the widget style */
    int style = getDefaultStyle();
    if (horizontalButton.getSelection()) style |= SWT.H_SCROLL;
    if (verticalButton.getSelection()) style |= SWT.V_SCROLL;
    if (borderButton.getSelection()) style |= SWT.BORDER;
    if (noBackgroundButton.getSelection()) style |= SWT.NO_BACKGROUND;
    if (noFocusButton.getSelection()) style |= SWT.NO_FOCUS;
    if (noMergePaintsButton.getSelection()) style |= SWT.NO_MERGE_PAINTS;
    if (noRedrawResizeButton.getSelection()) style |= SWT.NO_REDRAW_RESIZE;

    /* Create the example widgets */
    paintCount = 0;
    cx = 0;
    cy = 0;
    canvas = new Canvas(canvasGroup, style);
    canvas.addPaintListener(
        new PaintListener() {
          public void paintControl(PaintEvent e) {
            paintCount++;
            GC gc = e.gc;
            if (fillDamageButton.getSelection()) {
              Color color = e.display.getSystemColor(colors[paintCount % colors.length]);
              gc.setBackground(color);
              gc.fillRectangle(e.x, e.y, e.width, e.height);
            }
            Point size = canvas.getSize();
            gc.drawArc(cx + 1, cy + 1, size.x - 2, size.y - 2, 0, 360);
            gc.drawRectangle(cx + (size.x - 10) / 2, cy + (size.y - 10) / 2, 10, 10);
          }
        });
    canvas.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent event) {
            Point size = canvas.getSize();
            maxX = size.x * 3 / 2;
            maxY = size.y * 3 / 2;
            resizeScrollBars();
          }
        });
    ScrollBar bar = canvas.getHorizontalBar();
    if (bar != null) {
      bar.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent event) {
              scrollHorizontal((ScrollBar) event.widget);
            }
          });
    }
    bar = canvas.getVerticalBar();
    if (bar != null) {
      bar.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent event) {
              scrollVertical((ScrollBar) event.widget);
            }
          });
    }
  }
Beispiel #28
0
  /** Creates the "Control" group. */
  void createControlGroup() {
    super.createControlGroup();

    /* Create the group */
    alignmentGroup = new Group(controlGroup, SWT.NONE);
    alignmentGroup.setLayout(new GridLayout());
    alignmentGroup.setLayoutData(
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    alignmentGroup.setText(ControlExample.getResourceString("Alignment"));

    /* Create the controls */
    leftButton = new Button(alignmentGroup, SWT.RADIO);
    leftButton.setText(ControlExample.getResourceString("Left"));
    centerButton = new Button(alignmentGroup, SWT.RADIO);
    centerButton.setText(ControlExample.getResourceString("Center"));
    rightButton = new Button(alignmentGroup, SWT.RADIO);
    rightButton.setText(ControlExample.getResourceString("Right"));

    /* Add the listeners */
    SelectionListener selectionListener =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            if (!((Button) event.widget).getSelection()) return;
            setExampleWidgetAlignment();
          }
        };
    leftButton.addSelectionListener(selectionListener);
    centerButton.addSelectionListener(selectionListener);
    rightButton.addSelectionListener(selectionListener);
  }
  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();
  }
  void createImportButton(Composite parent) {
    importButton = new Button(parent, SWT.PUSH);
    importButton.setText(Messages._UI_IMPORT_BUTTON);

    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.CENTER;
    importButton.setLayoutData(gridData);
    importButton.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent e) {}

          public void widgetSelected(SelectionEvent e) {
            FileSystemImportWizard importWizard = new FileSystemImportWizard();
            importWizard.init(workbench, selection);
            Shell shell = Display.getCurrent().getActiveShell();
            WizardDialog wizardDialog = new WizardDialog(shell, importWizard);
            wizardDialog.create();
            wizardDialog.open();
            sourceFileViewer.refresh();
          }
        });
    importButton.setToolTipText(Messages._UI_IMPORT_BUTTON_TOOL_TIP);
  }