@Override
 protected void configureShell(Shell newShell) {
   //        newShell.setLayout(new GridLayout(1, false));
   GridData databaseSelectionData =
       new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
   databaseSelectionData.minimumWidth = MINIMUM_DIALOG_WIDTH;
   databaseSelectionData.widthHint = MINIMUM_DIALOG_WIDTH;
   newShell.setLayoutData(databaseSelectionData);
   super.configureShell(newShell);
 }
Exemple #2
0
  /**
   * The entry point for the example.
   *
   * @param args Program arguments.
   */
  public static void main(String[] args) {
    // Create the shell to hold the viewer.
    Display display = new Display();
    Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setLayout(new GridLayout());
    GridData data = new GridData(GridData.FILL_BOTH);
    shell.setLayoutData(data);
    Font font = new Font(display, "Courier", 10, SWT.NORMAL);

    // Create the table viewer.
    TableViewer tableViewer = new TableViewer(shell, SWT.BORDER);
    tableViewer.getControl().setLayoutData(data);

    // Create the data generator.
    // #ifdef exercises
    // TODO Exercise 5 - Use the DataGeneratorWithExecutor() instead.
    final IDataGenerator generator = new DataGeneratorWithThread();
    // #else
    // #        final IDataGenerator generator = new DataGeneratorWithExecutor();
    // #endif

    // Create the content provider which will populate the viewer.
    SyncDataViewer contentProvider = new SyncDataViewer(tableViewer, generator);
    tableViewer.setContentProvider(contentProvider);
    tableViewer.setInput(new Object());

    // Open the shell and service the display dispatch loop until user
    // closes the shell.
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    // The IDataGenerator.shutdown() method is asynchronous, this requires
    // using a query again in order to wait for its completion.
    Query<Object> shutdownQuery =
        new Query<Object>() {
          @Override
          protected void execute(DataRequestMonitor<Object> rm) {
            generator.shutdown(rm);
          }
        };
    ImmediateExecutor.getInstance().execute(shutdownQuery);
    try {
      shutdownQuery.get();
    } catch (Exception e) {
    }

    // Shut down the display.
    font.dispose();
    display.dispose();
  }
Exemple #3
0
 private void createShell(Display display) {
   spyShell = new Shell(display, SWT.SHELL_TRIM);
   spyShell.setText("SWT Spy");
   spyShell.setSize(400, 300);
   spyShell.setLayout(new FillLayout());
   spyShell.addShellListener(
       new ShellAdapter() {
         public void shellClosed(ShellEvent e) {
           e.doit = false;
         }
       });
   spyShell.setLayoutData(
       new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true));
 }
Exemple #4
0
  public FilterDialog(final Shell parent, final BuildToolWizardConfigurationPage caller) {
    super(parent);

    this.fCallingPage = caller;

    parent.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
    parent.setLocation(DIALOG_POSITION_X, DIALOG_POSITION_Y);

    // Set layouts
    parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData());

    // Label describes what is expected
    createLabelArea(parent);

    // Text allows user to enter a pattern
    createTextboxArea(parent);

    // Create a button area for adding
    createButtonArea(parent);
  }
  protected void open(Shell shell) {
    this.accepted = false;

    final Shell dialog = DialogUtils.newDialog(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

    dialog.setLayout(new GridLayout());
    dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    dialog.setImage(TuxGuitar.instance().getIconManager().getAppIcon());
    dialog.setText(TuxGuitar.getProperty("tuxguitar-community.share-dialog.title"));

    Group group = new Group(dialog, SWT.SHADOW_ETCHED_IN);
    group.setLayout(makeGroupLayout(5));
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    group.setText(TuxGuitar.getProperty("tuxguitar-community.share-dialog.details"));

    // -------USERNAME---------------------------------
    Label usernameLabel = new Label(group, SWT.NULL);
    usernameLabel.setLayoutData(makeLabelData());
    usernameLabel.setText(
        TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.user") + ":");

    final Text usernameText = new Text(group, SWT.BORDER | SWT.READ_ONLY);
    usernameText.setLayoutData(makeUsernameTextData());
    usernameText.setText(TGCommunitySingleton.getInstance().getAuth().getUsername());

    final Button usernameChooser = new Button(group, SWT.PUSH);
    usernameChooser.setText("...");
    usernameChooser.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            TGCommunityAuthDialog authDialog = new TGCommunityAuthDialog();
            authDialog.open(dialog);
            if (authDialog.isAccepted()) {
              TGCommunitySingleton.getInstance().getAuth().update();
              usernameText.setText(TGCommunitySingleton.getInstance().getAuth().getUsername());
            }
          }
        });

    // -------TITLE------------------------------------
    Label titleLabel = new Label(group, SWT.NULL);
    titleLabel.setLayoutData(makeLabelData());
    titleLabel.setText(
        TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.title") + ":");

    final Text titleText = new Text(group, SWT.BORDER);
    titleText.setLayoutData(makeTextData());
    titleText.setText(this.file.getTitle());

    // -------TAGKEYS------------------------------------
    Label tagkeysLabel = new Label(group, SWT.NULL);
    tagkeysLabel.setLayoutData(makeLabelData());
    tagkeysLabel.setText(
        TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.tagkeys") + ":");

    final Text tagkeysText = new Text(group, SWT.BORDER);
    tagkeysText.setLayoutData(makeTextData());
    tagkeysText.setText(this.file.getTagkeys());

    // -------DESCRIPTION------------------------------------
    Label descriptionLabel = new Label(group, SWT.NULL);
    descriptionLabel.setLayoutData(makeLabelData());
    descriptionLabel.setText(
        TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.description") + ":");

    final Text descriptionText = new Text(group, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    descriptionText.setLayoutData(makeTextAreaData());
    descriptionText.setText(this.file.getDescription());

    // ------------------BUTTONS--------------------------
    Composite buttons = new Composite(dialog, SWT.NONE);
    buttons.setLayout(new GridLayout(2, false));
    buttons.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));

    final Button buttonOK = new Button(buttons, SWT.PUSH);
    buttonOK.setText(TuxGuitar.getProperty("ok"));
    buttonOK.setLayoutData(getButtonData());
    buttonOK.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            update(titleText.getText(), tagkeysText.getText(), descriptionText.getText());

            dialog.dispose();
          }
        });

    Button buttonCancel = new Button(buttons, SWT.PUSH);
    buttonCancel.setText(TuxGuitar.getProperty("cancel"));
    buttonCancel.setLayoutData(getButtonData());
    buttonCancel.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            dialog.dispose();
          }
        });

    dialog.setDefaultButton(buttonOK);

    if (this.errors != null) {
      MessageDialog.errorMessage(dialog, this.errors);
    }
    DialogUtils.openDialog(
        dialog,
        DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT);
  }
  protected void open(Shell parent) {
    final Shell dialog = DialogUtils.newDialog(TuxGuitar.instance().getShell(), SWT.DIALOG_TRIM);
    dialog.setLayout(new GridLayout());
    dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    dialog.setImage(TuxGuitar.instance().getIconManager().getAppIcon());
    dialog.setText(TuxGuitar.getProperty("tuxguitar-community.welcome-dialog.title"));

    Composite composite = new Composite(dialog, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(MAIN_WIDTH, MAIN_HEIGHT));

    // ==============================================================//
    Composite top = new Composite(composite, SWT.NONE);
    top.setLayout(new GridLayout(2, false));
    top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite topLeft = new Composite(top, SWT.NONE);
    topLeft.setLayout(new GridLayout());
    topLeft.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));

    Label image = new Label(topLeft, SWT.NONE);
    image.setImage(TuxGuitar.instance().getIconManager().getAppIcon());

    Composite topRight = new Composite(top, SWT.NONE);
    topRight.setLayout(new GridLayout(2, false));
    topRight.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    addTitle(topRight, TuxGuitar.getProperty("tuxguitar-community.welcome-dialog.title"));

    addTipItem(topRight);
    addComment(topRight, TuxGuitar.getProperty("tuxguitar-community.welcome-dialog.tip-1"));

    addTipItem(topRight);
    addComment(topRight, TuxGuitar.getProperty("tuxguitar-community.welcome-dialog.tip-2"));

    // ==============================================================//
    Composite bottom = new Composite(composite, SWT.NONE);
    bottom.setLayout(new GridLayout());
    bottom.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    addComment(bottom, TuxGuitar.getProperty("tuxguitar-community.welcome-dialog.tip-bottom"));

    // ==============================================================//
    Composite buttons = new Composite(composite, SWT.NONE);
    buttons.setLayout(new GridLayout(2, false));
    buttons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Button buttonDisabled = new Button(buttons, SWT.CHECK);
    buttonDisabled.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true));
    buttonDisabled.setText(TuxGuitar.getProperty("tuxguitar-community.welcome-dialog.disable"));
    buttonDisabled.setSelection(this.isDisabled());

    final Button buttonOK = new Button(buttons, SWT.PUSH);
    buttonOK.setText(TuxGuitar.getProperty("ok"));
    buttonOK.setLayoutData(getButtonOkData());
    buttonOK.setFocus();
    buttonOK.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            setDisabled(buttonDisabled.getSelection());
            dialog.dispose();
          }
        });

    dialog.setDefaultButton(buttonOK);

    DialogUtils.openDialog(dialog, DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK);
  }