예제 #1
0
  public void show() {
    this.dialog =
        DialogUtils.newDialog(TuxGuitar.instance().getShell(), SWT.DIALOG_TRIM | SWT.RESIZE);
    this.dialog.setLayout(getDialogLayout());
    this.dialog.setSize(EDITOR_WIDTH, EDITOR_HEIGHT);
    this.dialog.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            onDispose();
          }
        });

    this.track = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret().getTrack();
    this.loadComposites();
    this.loadProperties();
    this.loadIcons();
    this.updateItems();
    this.addListeners();
    DialogUtils.openDialog(this.dialog, DialogUtils.OPEN_STYLE_CENTER);
  }
  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);
  }
  public static PrintStyles open(Shell shell) {
    final PrintStyles styles = new PrintStyles();
    final Shell dialog = DialogUtils.newDialog(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    dialog.setLayout(new GridLayout());
    dialog.setText(TuxGuitar.getProperty("options"));

    // ------------------TRACK SELECTION------------------
    Group track = new Group(dialog, SWT.SHADOW_ETCHED_IN);
    track.setLayout(new GridLayout(2, false));
    track.setLayoutData(getGroupData());
    track.setText(TuxGuitar.getProperty("track"));

    Label trackLabel = new Label(track, SWT.NULL);
    trackLabel.setText(TuxGuitar.getProperty("track"));

    final Combo tracks = new Combo(track, SWT.DROP_DOWN | SWT.READ_ONLY);
    tracks.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    for (int number = 1;
        number <= TuxGuitar.instance().getSongManager().getSong().countTracks();
        number++) {
      tracks.add(TuxGuitar.instance().getSongManager().getTrack(number).getName());
    }
    tracks.select(
        TuxGuitar.instance().getTablatureEditor().getTablature().getCaret().getTrack().getNumber()
            - 1);

    // ------------------MEASURE RANGE------------------
    Group range = new Group(dialog, SWT.SHADOW_ETCHED_IN);
    range.setLayout(new GridLayout(2, false));
    range.setLayoutData(getGroupData());
    range.setText(TuxGuitar.getProperty("print.range"));

    final int minSelection = 1;
    final int maxSelection = TuxGuitar.instance().getSongManager().getSong().countMeasureHeaders();

    Label fromLabel = new Label(range, SWT.NULL);
    fromLabel.setText(TuxGuitar.getProperty("edit.from"));
    final Spinner fromSpinner = new Spinner(range, SWT.BORDER);
    fromSpinner.setLayoutData(getSpinnerData());
    fromSpinner.setMaximum(maxSelection);
    fromSpinner.setMinimum(minSelection);
    fromSpinner.setSelection(minSelection);

    Label toLabel = new Label(range, SWT.NULL);
    toLabel.setText(TuxGuitar.getProperty("edit.to"));
    final Spinner toSpinner = new Spinner(range, SWT.BORDER);
    toSpinner.setLayoutData(getSpinnerData());
    toSpinner.setMinimum(minSelection);
    toSpinner.setMaximum(maxSelection);
    toSpinner.setSelection(maxSelection);

    fromSpinner.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            int fromSelection = fromSpinner.getSelection();
            int toSelection = toSpinner.getSelection();

            if (fromSelection < minSelection) {
              fromSpinner.setSelection(minSelection);
            } else if (fromSelection > toSelection) {
              fromSpinner.setSelection(toSelection);
            }
          }
        });
    toSpinner.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            int toSelection = toSpinner.getSelection();
            int fromSelection = fromSpinner.getSelection();
            if (toSelection < fromSelection) {
              toSpinner.setSelection(fromSelection);
            } else if (toSelection > maxSelection) {
              toSpinner.setSelection(maxSelection);
            }
          }
        });
    // ------------------CHECK OPTIONS--------------------
    Group options = new Group(dialog, SWT.SHADOW_ETCHED_IN);
    options.setLayout(new GridLayout());
    options.setLayoutData(getGroupData());
    options.setText(TuxGuitar.getProperty("options"));

    final Button tablatureEnabled = new Button(options, SWT.CHECK);
    tablatureEnabled.setText(TuxGuitar.getProperty("export.tablature-enabled"));
    tablatureEnabled.setSelection(true);

    final Button scoreEnabled = new Button(options, SWT.CHECK);
    scoreEnabled.setText(TuxGuitar.getProperty("export.score-enabled"));
    scoreEnabled.setSelection(true);

    final Button chordNameEnabled = new Button(options, SWT.CHECK);
    chordNameEnabled.setText(TuxGuitar.getProperty("export.chord-name-enabled"));
    chordNameEnabled.setSelection(true);

    final Button chordDiagramEnabled = new Button(options, SWT.CHECK);
    chordDiagramEnabled.setText(TuxGuitar.getProperty("export.chord-diagram-enabled"));
    chordDiagramEnabled.setSelection(true);

    final Button blackAndWhite = new Button(options, SWT.CHECK);
    blackAndWhite.setText(TuxGuitar.getProperty("export.black-and-white"));
    blackAndWhite.setSelection(true);

    tablatureEnabled.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            if (!tablatureEnabled.getSelection()) {
              scoreEnabled.setSelection(true);
            }
          }
        });
    scoreEnabled.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            if (!scoreEnabled.getSelection()) {
              tablatureEnabled.setSelection(true);
            }
          }
        });

    // ------------------BUTTONS--------------------------
    Composite buttons = new Composite(dialog, SWT.NONE);
    buttons.setLayout(new GridLayout(2, false));
    buttons.setLayoutData(new GridData(SWT.END, 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) {
            int style = 0;
            style |= (scoreEnabled.getSelection() ? ViewLayout.DISPLAY_SCORE : 0);
            style |= (tablatureEnabled.getSelection() ? ViewLayout.DISPLAY_TABLATURE : 0);
            style |= (chordNameEnabled.getSelection() ? ViewLayout.DISPLAY_CHORD_NAME : 0);
            style |= (chordDiagramEnabled.getSelection() ? ViewLayout.DISPLAY_CHORD_DIAGRAM : 0);
            styles.setTrackNumber(tracks.getSelectionIndex() + 1);
            styles.setFromMeasure(fromSpinner.getSelection());
            styles.setToMeasure(toSpinner.getSelection());
            styles.setBlackAndWhite(blackAndWhite.getSelection());
            styles.setStyle(style);
            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);

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

    return ((styles.getTrackNumber() > 0) ? styles : null);
  }
  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);
  }