Esempio n. 1
0
  public void createOption() {
    UIFactory uiFactory = this.getUIFactory();

    getToolItem().setText(TuxGuitar.getProperty("settings.config.language"));
    getToolItem().setImage(TuxGuitar.getInstance().getIconManager().getOptionLanguage());
    getToolItem().addSelectionListener(this);

    showLabel(getPanel(), TuxGuitar.getProperty("settings.config.language.choose"), true, 1, 1);

    UITableLayout compositeLayout = new UITableLayout();
    UIPanel composite = uiFactory.createPanel(getPanel(), false);
    composite.setLayout(compositeLayout);
    this.indent(composite, 2, 1);

    this.table = uiFactory.createTable(composite, true);
    this.table.setColumns(1);
    this.table.setColumnName(0, TuxGuitar.getProperty("settings.config.language.choose"));
    compositeLayout.set(
        this.table, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);
    compositeLayout.set(this.table, UITableLayout.PACKED_HEIGHT, PACKED_HEIGHT);

    this.loadConfig();
  }
Esempio n. 2
0
  public void show() {
    this.createEditableMarker();

    final UIFactory uiFactory = TGApplication.getInstance(this.context.getContext()).getFactory();
    final UIWindow uiParent = this.context.getAttribute(TGViewContext.ATTRIBUTE_PARENT2);
    final UITableLayout dialogLayout = new UITableLayout();

    this.dialog = uiFactory.createWindow(uiParent, true, false);
    this.dialog.setLayout(dialogLayout);
    this.dialog.setText(TuxGuitar.getProperty("marker"));

    // ----------------------------------------------------------------------
    UITableLayout groupLayout = new UITableLayout();
    UILegendPanel group = uiFactory.createLegendPanel(this.dialog);
    group.setLayout(groupLayout);
    group.setText(TuxGuitar.getProperty("marker"));
    dialogLayout.set(group, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    // Measure Number
    final int measureCount =
        TuxGuitar.getInstance().getDocumentManager().getSong().countMeasureHeaders();
    UILabel measureLabel = uiFactory.createLabel(group);
    measureLabel.setText(TuxGuitar.getProperty("measure"));
    groupLayout.set(
        measureLabel, 1, 1, UITableLayout.ALIGN_RIGHT, UITableLayout.ALIGN_CENTER, true, true);

    this.measureSpinner = uiFactory.createSpinner(group);
    this.measureSpinner.setMinimum(1);
    this.measureSpinner.setMaximum(measureCount);
    this.measureSpinner.setValue(this.marker.getMeasure());
    this.measureSpinner.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            int selection = TGMarkerEditor.this.measureSpinner.getValue();
            if (selection < 1) {
              TGMarkerEditor.this.measureSpinner.setValue(1);
            } else if (selection > measureCount) {
              TGMarkerEditor.this.measureSpinner.setValue(measureCount);
            }
          }
        });
    groupLayout.set(
        this.measureSpinner,
        1,
        2,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_CENTER,
        true,
        true,
        1,
        1,
        MINIMUM_CONTROL_WIDTH,
        null,
        null);

    // Title
    UILabel titleLabel = uiFactory.createLabel(group);
    titleLabel.setText(TuxGuitar.getProperty("title"));
    groupLayout.set(
        titleLabel, 2, 1, UITableLayout.ALIGN_RIGHT, UITableLayout.ALIGN_CENTER, true, true);

    this.titleText = uiFactory.createTextField(group);
    this.titleText.setText(this.marker.getTitle());
    groupLayout.set(
        this.titleText,
        2,
        2,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_CENTER,
        true,
        true,
        1,
        1,
        MINIMUM_CONTROL_WIDTH,
        null,
        null);

    // Color
    UILabel colorLabel = uiFactory.createLabel(group);
    colorLabel.setText(TuxGuitar.getProperty("color"));
    groupLayout.set(
        colorLabel, 3, 1, UITableLayout.ALIGN_RIGHT, UITableLayout.ALIGN_CENTER, true, true);

    this.colorButton = uiFactory.createButton(group);
    this.colorButton.setText(TuxGuitar.getProperty("choose"));
    this.colorButton.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            UIColorModel colorModel = new UIColorModel();
            colorModel.setRed(TGMarkerEditor.this.marker.getColor().getR());
            colorModel.setGreen(TGMarkerEditor.this.marker.getColor().getG());
            colorModel.setBlue(TGMarkerEditor.this.marker.getColor().getB());

            UIColorChooser colorChooser = uiFactory.createColorChooser(TGMarkerEditor.this.dialog);
            colorChooser.setDefaultModel(colorModel);
            colorChooser.setText(TuxGuitar.getProperty("choose-color"));
            colorChooser.choose(
                new UIColorChooserHandler() {
                  public void onSelectColor(UIColorModel selection) {
                    if (selection != null) {
                      TGMarkerEditor.this.marker.getColor().setR(selection.getRed());
                      TGMarkerEditor.this.marker.getColor().setG(selection.getGreen());
                      TGMarkerEditor.this.marker.getColor().setB(selection.getBlue());
                      TGMarkerEditor.this.setButtonColor(uiFactory);
                    }
                  }
                });
          }
        });
    this.colorButton.addDisposeListener(
        new UIDisposeListener() {
          public void onDispose(UIDisposeEvent event) {
            TGMarkerEditor.this.disposeButtonColor();
          }
        });
    this.setButtonColor(uiFactory);
    groupLayout.set(
        this.colorButton,
        3,
        2,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_CENTER,
        true,
        true,
        1,
        1,
        MINIMUM_CONTROL_WIDTH,
        null,
        null);

    // ------------------BUTTONS--------------------------
    UITableLayout buttonsLayout = new UITableLayout(0f);
    UIPanel buttons = uiFactory.createPanel(this.dialog, false);
    buttons.setLayout(buttonsLayout);
    dialogLayout.set(
        buttons, 2, 1, UITableLayout.ALIGN_RIGHT, UITableLayout.ALIGN_FILL, true, true);

    final UIButton buttonOK = uiFactory.createButton(buttons);
    buttonOK.setText(TuxGuitar.getProperty("ok"));
    buttonOK.setDefaultButton();
    buttonOK.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            updateMarker();
            TGMarkerEditor.this.dialog.dispose();
          }
        });
    buttonsLayout.set(
        buttonOK,
        1,
        1,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        MINIMUM_BUTTON_WIDTH,
        MINIMUM_BUTTON_HEIGHT,
        null);

    UIButton buttonCancel = uiFactory.createButton(buttons);
    buttonCancel.setText(TuxGuitar.getProperty("cancel"));
    buttonCancel.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            TGMarkerEditor.this.dialog.dispose();
          }
        });
    buttonsLayout.set(
        buttonCancel,
        1,
        2,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        MINIMUM_BUTTON_WIDTH,
        MINIMUM_BUTTON_HEIGHT,
        null);
    buttonsLayout.set(buttonCancel, UITableLayout.MARGIN_RIGHT, 0f);

    TGDialogUtil.openDialog(
        this.dialog, TGDialogUtil.OPEN_STYLE_CENTER | TGDialogUtil.OPEN_STYLE_PACK);
  }
  public void show(final TGViewContext context) {
    final TGSong song = context.getAttribute(TGDocumentContextAttributes.ATTRIBUTE_SONG);
    final TGPrintStylesHandler handler = context.getAttribute(ATTRIBUTE_HANDLER);

    final UIFactory uiFactory = TGApplication.getInstance(context.getContext()).getFactory();
    final UIWindow uiParent = context.getAttribute(TGViewContext.ATTRIBUTE_PARENT2);
    final UITableLayout dialogLayout = new UITableLayout();
    final UIWindow dialog = uiFactory.createWindow(uiParent, true, false);

    dialog.setLayout(dialogLayout);
    dialog.setText(TuxGuitar.getProperty("options"));

    // ------------------TRACK SELECTION------------------
    UITableLayout trackLayout = new UITableLayout();
    UILegendPanel track = uiFactory.createLegendPanel(dialog);
    track.setLayout(trackLayout);
    track.setText(TuxGuitar.getProperty("track"));
    dialogLayout.set(
        track,
        1,
        1,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        300f,
        null,
        null);

    UILabel trackLabel = uiFactory.createLabel(track);
    trackLabel.setText(TuxGuitar.getProperty("track"));
    trackLayout.set(
        trackLabel, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_CENTER, false, true);

    final UIDropDownSelect<Integer> tracks = uiFactory.createDropDownSelect(track);
    for (int number = 1; number <= song.countTracks(); number++) {
      tracks.addItem(
          new UISelectItem<Integer>(
              TuxGuitar.getInstance().getSongManager().getTrack(song, number).getName(), number));
    }
    tracks.setSelectedValue(
        TuxGuitar.getInstance()
            .getTablatureEditor()
            .getTablature()
            .getCaret()
            .getTrack()
            .getNumber());
    trackLayout.set(tracks, 1, 2, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    // ------------------MEASURE RANGE------------------
    UITableLayout rangeLayout = new UITableLayout();
    UILegendPanel range = uiFactory.createLegendPanel(dialog);
    range.setLayout(rangeLayout);
    range.setText(TuxGuitar.getProperty("print.range"));
    dialogLayout.set(
        range,
        2,
        1,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        300f,
        null,
        null);

    final int minSelection = 1;
    final int maxSelection = song.countMeasureHeaders();

    UILabel fromLabel = uiFactory.createLabel(range);
    fromLabel.setText(TuxGuitar.getProperty("edit.from"));
    rangeLayout.set(
        fromLabel, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_CENTER, false, true);

    final UISpinner fromSpinner = uiFactory.createSpinner(range);
    fromSpinner.setMaximum(maxSelection);
    fromSpinner.setMinimum(minSelection);
    fromSpinner.setValue(minSelection);
    rangeLayout.set(
        fromSpinner,
        1,
        2,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        60f,
        null,
        null);

    UILabel toLabel = uiFactory.createLabel(range);
    toLabel.setText(TuxGuitar.getProperty("edit.to"));
    rangeLayout.set(
        toLabel, 2, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_CENTER, false, true);

    final UISpinner toSpinner = uiFactory.createSpinner(range);
    toSpinner.setMinimum(minSelection);
    toSpinner.setMaximum(maxSelection);
    toSpinner.setValue(maxSelection);
    rangeLayout.set(
        toSpinner,
        2,
        2,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        60f,
        null,
        null);

    fromSpinner.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            int fromSelection = fromSpinner.getValue();
            int toSelection = toSpinner.getValue();

            if (fromSelection < minSelection) {
              fromSpinner.setValue(minSelection);
            } else if (fromSelection > toSelection) {
              fromSpinner.setValue(toSelection);
            }
          }
        });
    toSpinner.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            int toSelection = toSpinner.getValue();
            int fromSelection = fromSpinner.getValue();
            if (toSelection < fromSelection) {
              toSpinner.setValue(fromSelection);
            } else if (toSelection > maxSelection) {
              toSpinner.setValue(maxSelection);
            }
          }
        });

    // ------------------CHECK OPTIONS--------------------
    UITableLayout optionsLayout = new UITableLayout();
    UILegendPanel options = uiFactory.createLegendPanel(dialog);
    options.setLayout(optionsLayout);
    options.setText(TuxGuitar.getProperty("options"));
    dialogLayout.set(
        options,
        3,
        1,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        300f,
        null,
        null);

    final UICheckBox tablatureEnabled = uiFactory.createCheckBox(options);
    tablatureEnabled.setText(TuxGuitar.getProperty("export.tablature-enabled"));
    tablatureEnabled.setSelected(true);
    optionsLayout.set(
        tablatureEnabled, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    final UICheckBox scoreEnabled = uiFactory.createCheckBox(options);
    scoreEnabled.setText(TuxGuitar.getProperty("export.score-enabled"));
    scoreEnabled.setSelected(true);
    optionsLayout.set(
        scoreEnabled, 2, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    final UICheckBox chordNameEnabled = uiFactory.createCheckBox(options);
    chordNameEnabled.setText(TuxGuitar.getProperty("export.chord-name-enabled"));
    chordNameEnabled.setSelected(true);
    optionsLayout.set(
        chordNameEnabled, 3, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    final UICheckBox chordDiagramEnabled = uiFactory.createCheckBox(options);
    chordDiagramEnabled.setText(TuxGuitar.getProperty("export.chord-diagram-enabled"));
    chordDiagramEnabled.setSelected(true);
    optionsLayout.set(
        chordDiagramEnabled, 4, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    final UICheckBox blackAndWhite = uiFactory.createCheckBox(options);
    blackAndWhite.setText(TuxGuitar.getProperty("export.black-and-white"));
    blackAndWhite.setSelected(true);
    optionsLayout.set(
        blackAndWhite, 5, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    tablatureEnabled.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            if (!tablatureEnabled.isSelected()) {
              scoreEnabled.setSelected(true);
            }
          }
        });
    scoreEnabled.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            if (!scoreEnabled.isSelected()) {
              tablatureEnabled.setSelected(true);
            }
          }
        });

    // ------------------BUTTONS--------------------------
    UITableLayout buttonsLayout = new UITableLayout(0f);
    UIPanel buttons = uiFactory.createPanel(dialog, false);
    buttons.setLayout(buttonsLayout);
    dialogLayout.set(
        buttons, 4, 1, UITableLayout.ALIGN_RIGHT, UITableLayout.ALIGN_FILL, true, true);

    UIButton buttonOK = uiFactory.createButton(buttons);
    buttonOK.setText(TuxGuitar.getProperty("ok"));
    buttonOK.setDefaultButton();
    buttonOK.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            int style = 0;
            style |= (scoreEnabled.isSelected() ? TGLayout.DISPLAY_SCORE : 0);
            style |= (tablatureEnabled.isSelected() ? TGLayout.DISPLAY_TABLATURE : 0);
            style |= (chordNameEnabled.isSelected() ? TGLayout.DISPLAY_CHORD_NAME : 0);
            style |= (chordDiagramEnabled.isSelected() ? TGLayout.DISPLAY_CHORD_DIAGRAM : 0);
            style |= (blackAndWhite.isSelected() ? TGLayout.DISPLAY_MODE_BLACK_WHITE : 0);

            Integer trackNumber = tracks.getSelectedValue();
            PrintStyles printStyles = new PrintStyles();
            printStyles.setTrackNumber(trackNumber != null ? trackNumber : -1);
            printStyles.setFromMeasure(fromSpinner.getValue());
            printStyles.setToMeasure(toSpinner.getValue());
            printStyles.setStyle(style);

            dialog.dispose();

            handler.updatePrintStyles(printStyles);
          }
        });
    buttonsLayout.set(
        buttonOK,
        1,
        1,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        80f,
        25f,
        null);

    UIButton buttonCancel = uiFactory.createButton(buttons);
    buttonCancel.setText(TuxGuitar.getProperty("cancel"));
    buttonCancel.addSelectionListener(
        new UISelectionListener() {
          public void onSelect(UISelectionEvent event) {
            dialog.dispose();
          }
        });
    buttonsLayout.set(
        buttonCancel,
        1,
        2,
        UITableLayout.ALIGN_FILL,
        UITableLayout.ALIGN_FILL,
        true,
        true,
        1,
        1,
        80f,
        25f,
        null);
    buttonsLayout.set(buttonCancel, UITableLayout.MARGIN_RIGHT, 0f);

    TGDialogUtil.openDialog(dialog, TGDialogUtil.OPEN_STYLE_CENTER | TGDialogUtil.OPEN_STYLE_PACK);
  }
Esempio n. 4
0
  public void createOption() {
    UIFactory uiFactory = this.getUIFactory();

    getToolItem().setText(TuxGuitar.getProperty("settings.config.main"));
    getToolItem().setImage(TuxGuitar.getInstance().getIconManager().getOptionMain());
    getToolItem().addSelectionListener(this);

    showLabel(getPanel(), TuxGuitar.getProperty("settings.config.main.window-title"), true, 1, 1);

    UITableLayout titleSectionLayout = new UITableLayout();
    UIPanel titleSection = uiFactory.createPanel(getPanel(), false);
    titleSection.setLayout(titleSectionLayout);
    this.indent(titleSection, 2, 1);

    UITableLayout windowTitleLayout = new UITableLayout();
    UIPanel windowTitleComposite = uiFactory.createPanel(titleSection, false);
    windowTitleComposite.setLayout(windowTitleLayout);
    titleSectionLayout.set(
        windowTitleComposite, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    this.windowTitle = uiFactory.createTextField(windowTitleComposite);
    this.windowTitle.setTextLimit(80);
    windowTitleLayout.set(
        this.windowTitle, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    UITableLayout infoHeaderLayout = new UITableLayout();
    UIPanel infoHeader = uiFactory.createPanel(titleSection, false);
    infoHeader.setLayout(infoHeaderLayout);
    titleSectionLayout.set(
        infoHeader, 2, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    showImageLabel(infoHeader, TuxGuitar.getInstance().getIconManager().getStatusInfo(), 1, 1);
    showLabel(
        infoHeader, TuxGuitar.getProperty("settings.config.main.window-title.help"), false, 1, 2);

    UIPanel infoBody = uiFactory.createPanel(titleSection, false);
    infoBody.setLayout(new UITableLayout());
    titleSectionLayout.set(
        infoBody, 3, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    for (int i = 0; i < VAR_NAMES.length; i++) {
      showLabel(infoBody, this.getVar(VAR_NAMES[i]), true, (i + 1), 1);
      showLabel(
          infoBody,
          TuxGuitar.getProperty(
              "settings.config.main.window-title.var.description." + VAR_NAMES[i]),
          false,
          (i + 1),
          2);
    }

    showLabel(getPanel(), TuxGuitar.getProperty("settings.config.main.options"), true, 3, 1);

    UITableLayout optionsLayout = new UITableLayout();
    UIPanel options = uiFactory.createPanel(getPanel(), false);
    options.setLayout(optionsLayout);
    this.indent(options, 4, 1);

    this.autoSizeTable = uiFactory.createCheckBox(options);
    this.autoSizeTable.setText(
        TuxGuitar.getProperty("settings.config.main.table.auto-size.enabled"));
    optionsLayout.set(
        this.autoSizeTable, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    this.showSplash = uiFactory.createCheckBox(options);
    this.showSplash.setText(TuxGuitar.getProperty("settings.config.main.splash-enabled"));
    optionsLayout.set(
        this.showSplash, 2, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true);

    this.loadConfig();
  }