コード例 #1
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);
  }
コード例 #2
0
ファイル: MainOption.java プロジェクト: halfspiral/tuxguitar
  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();
  }