private void moveToNext() {
   if (TuxGuitar.instance().getPlayer().isRunning()) {
     TuxGuitar.instance().getTransport().gotoNext();
   } else {
     Caret caret = getEditor().getTablature().getCaret();
     TGTrackImpl track = caret.getTrack();
     TGMeasure measure = getSongManager().getTrackManager().getNextMeasure(caret.getMeasure());
     if (track != null && measure != null) {
       caret.update(track.getNumber(), measure.getStart(), caret.getSelectedString().getNumber());
     }
   }
 }
Ejemplo n.º 2
0
 public void update() {
   if (!isDisposed()) {
     TGTrackImpl track =
         TuxGuitar.instance().getTablatureEditor().getTablature().getCaret().getTrack();
     int tracks = track.getSong().countTracks();
     boolean isFirst = (track.getNumber() == 1);
     boolean isLast = (track.getNumber() == tracks);
     boolean running = TuxGuitar.instance().getPlayer().isRunning();
     this.addTrack.setEnabled(!running);
     this.cloneTrack.setEnabled(!running);
     this.removeTrack.setEnabled(!running);
     this.moveUp.setEnabled(!running && tracks > 1);
     this.moveDown.setEnabled(!running && tracks > 1);
     this.first.setEnabled(!isFirst);
     this.previous.setEnabled(!isFirst);
     this.next.setEnabled(!isLast);
     this.last.setEnabled(!isLast);
     this.properties.setEnabled(!running);
     this.changeSolo.setSelection(track.isSolo());
     this.changeMute.setSelection(track.isMute());
   }
 }
  public void showDialog(Shell shell) {
    TGTrackImpl track = getEditor().getTablature().getCaret().getTrack();
    TGMeasureImpl measure = getEditor().getTablature().getCaret().getMeasure();
    if (measure != null) {
      final Shell dialog = DialogUtils.newDialog(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
      dialog.setLayout(new GridLayout());
      dialog.setText(TuxGuitar.getProperty("measure.clean"));

      // ----------------------------------------------------------------------
      Group range = new Group(dialog, SWT.SHADOW_ETCHED_IN);
      range.setLayout(new GridLayout(2, false));
      range.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      range.setText(TuxGuitar.getProperty("measure.clean"));

      int measureCount = 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.setMinimum(1);
      fromSpinner.setMaximum(measureCount);
      fromSpinner.setSelection(measure.getNumber());

      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(1);
      toSpinner.setMaximum(measureCount);
      toSpinner.setSelection(measure.getNumber());

      final int minSelection = 1;
      final int maxSelection = track.countMeasures();

      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);
              }
            }
          });

      // ------------------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) {
              cleanMeasures(fromSpinner.getSelection(), toSpinner.getSelection());
              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);
    }
  }