public boolean isDisabled() {
   return TGCommunitySingleton.getInstance()
       .getConfig()
       .getBooleanConfigValue("community.welcome.disabled");
 }
Ejemplo n.º 2
0
  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 void setDisabled(boolean enabled) {
   TGCommunitySingleton.getInstance()
       .getConfig()
       .setProperty("community.welcome.disabled", enabled);
 }