Ejemplo n.º 1
0
  public void updateItems() {
    if (!isDisposed()) {
      boolean enabled = !TuxGuitar.instance().getPlayer().isRunning();

      this.listener.setEnabled(false);
      if (this.updated) {
        this.lastTrack = 0;
        this.lastTrackName = null;
        this.lastMeasuseCount = 0;
      }
      this.track = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret().getTrack();
      if (isTrackNameChanged()) {
        this.label.setText(this.track.getName());
      }
      if (isMeasureCountChanged()) {
        this.from.setMaximum(this.track.countMeasures());
      }
      if (isTrackChanged()) {
        this.from.setSelection(this.track.getLyrics().getFrom());
        this.text.setText(this.track.getLyrics().getLyrics());
        this.text.setSelection(
            (this.caretPosition >= 0 ? this.caretPosition : this.text.getCharCount()));
      }

      this.from.setEnabled(enabled && (this.track.countMeasures() > 1));
      this.text.setEnabled(enabled);

      this.setCaretPosition(-1);

      this.listener.setEnabled(enabled);
      this.updated = false;
    }
  }
Ejemplo n.º 2
0
 protected void dispose() {
   TGTableViewer.disposeColors();
   TuxGuitar.instance().getSongManager().clearSong();
   TuxGuitar.instance().getFretBoardEditor().dispose();
   TuxGuitar.instance().getTablatureEditor().getTablature().dispose();
   TuxGuitar.instance().getIconManager().disposeIcons();
   TuxGuitar.instance().getShell().dispose();
 }
Ejemplo n.º 3
0
 public void applicationDestroy() {
   TuxGuitar.instance().lock();
   TuxGuitar.instance().getPlayer().close();
   TuxGuitar.instance().getTablatureEditor().dispose();
   TuxGuitar.instance().getSongManager().clearSong();
   TuxGuitar.instance().unlock();
   this.removeAll();
 }
Ejemplo n.º 4
0
  public void undo() throws CannotUndoException {
    if (!canUndo()) {
      throw new CannotUndoException();
    }
    TuxGuitar.instance().getSongManager().removeTrack(cloneTrack(this.redoableTrack));
    TuxGuitar.instance().fireUpdate();
    TuxGuitar.instance().getMixer().update();
    this.undoCaret.update();

    this.doAction = REDO_ACTION;
  }
Ejemplo n.º 5
0
 public void update() {
   TGMeasure measure =
       TuxGuitar.instance().getTablatureEditor().getTablature().getCaret().getMeasure();
   MidiPlayerMode pm = TuxGuitar.instance().getPlayer().getMode();
   this.metronome.setSelection(TuxGuitar.instance().getPlayer().isMetronomeEnabled());
   this.loopSHeader.setEnabled(pm.isLoop());
   this.loopSHeader.setSelection(measure != null && measure.getNumber() == pm.getLoopSHeader());
   this.loopEHeader.setEnabled(pm.isLoop());
   this.loopEHeader.setSelection(measure != null && measure.getNumber() == pm.getLoopEHeader());
   this.loadIcons(false);
 }
Ejemplo n.º 6
0
  public void applicationInit() {
    this.initConfig();
    this.initSynchronizer();

    TuxGuitar.instance().setShell(this);

    this.setLayout(new BorderLayout());
    this.add(TuxGuitar.instance().getToolBar().getPanel(), BorderLayout.NORTH);
    this.add(TuxGuitar.instance().getTablatureEditor().getPanel(), BorderLayout.CENTER);
    this.add(TuxGuitar.instance().getTablatureEditor().getScrollBar(), BorderLayout.EAST);
    this.setVisible(true);
    this.setFocus();

    this.load();
  }
Ejemplo n.º 7
0
  public static void saveAndOpen(final String file) {
    ActionLock.lock();

    TuxGuitar.instance().getPlayer().reset();

    if (TuxGuitar.instance().getFileHistory().isUnsavedFile()) {
      ConfirmDialog confirm =
          new ConfirmDialog(TuxGuitar.getProperty("file.save-changes-question"));
      confirm.setDefaultStatus(ConfirmDialog.STATUS_CANCEL);
      int status =
          confirm.confirm(
              ConfirmDialog.BUTTON_YES | ConfirmDialog.BUTTON_NO | ConfirmDialog.BUTTON_CANCEL,
              ConfirmDialog.BUTTON_YES);
      if (status == ConfirmDialog.STATUS_CANCEL) {
        ActionLock.unlock();
        return;
      }
      if (status == ConfirmDialog.STATUS_YES) {
        final String fileName = FileActionUtils.getFileName();
        if (fileName == null) {
          ActionLock.unlock();
          return;
        }
        TuxGuitar.instance().loadCursor(SWT.CURSOR_WAIT);
        new Thread(
                new Runnable() {
                  public void run() {
                    if (!TuxGuitar.isDisposed()) {
                      FileActionUtils.save(fileName);
                      new SyncThread(
                              new Runnable() {
                                public void run() {
                                  if (!TuxGuitar.isDisposed()) {
                                    TuxGuitar.instance().loadCursor(SWT.CURSOR_ARROW);
                                    openFile(file);
                                  }
                                }
                              })
                          .start();
                    }
                  }
                })
            .start();
        return;
      }
    }
    openFile(file);
  }
Ejemplo n.º 8
0
 public void loadSong() {
   try {
     if (TGConfig.SONG_URL != null) {
       URL url = new URL(TGConfig.SONG_URL);
       InputStream stream = getInputStream(url.openStream());
       TGSong song =
           TGFileFormatManager.instance()
               .getLoader()
               .load(TuxGuitar.instance().getSongManager().getFactory(), stream);
       TuxGuitar.instance().fireNewSong(song);
     }
   } catch (Throwable t) {
     t.printStackTrace();
     TuxGuitar.instance().newSong();
   }
 }
Ejemplo n.º 9
0
 public void onDispose() {
   this.track = null;
   this.label = null;
   this.text = null;
   this.dialog = null;
   this.removeListeners();
   TuxGuitar.instance().updateCache(true);
 }
Ejemplo n.º 10
0
  protected int execute(TypedEvent e) {
    if (TuxGuitar.instance().getFileHistory().isUnsavedFile()) {
      ConfirmDialog confirm =
          new ConfirmDialog(TuxGuitar.getProperty("file.save-changes-question"));
      confirm.setDefaultStatus(ConfirmDialog.STATUS_CANCEL);
      int status =
          confirm.confirm(
              ConfirmDialog.BUTTON_YES | ConfirmDialog.BUTTON_NO | ConfirmDialog.BUTTON_CANCEL,
              ConfirmDialog.BUTTON_YES);
      if (status == ConfirmDialog.STATUS_CANCEL) {
        return AUTO_UNLOCK;
      }
      if (status == ConfirmDialog.STATUS_YES) {
        final String fileName = FileActionUtils.getFileName();
        if (fileName == null) {
          return AUTO_UNLOCK;
        }
        TuxGuitar.instance().loadCursor(SWT.CURSOR_WAIT);
        new Thread(
                new Runnable() {
                  public void run() {
                    if (!TuxGuitar.isDisposed()) {
                      FileActionUtils.save(fileName);
                      TuxGuitar.instance().loadCursor(SWT.CURSOR_ARROW);
                      new SyncThread(
                              new Runnable() {
                                public void run() {
                                  if (!TuxGuitar.isDisposed()) {
                                    newSong();
                                  }
                                }
                              })
                          .start();
                    }
                  }
                })
            .start();
        return 0;
      }
    }
    newSong();

    return 0;
  }
 protected void removePlugin() throws TGPluginException {
   if (this.loaded) {
     try {
       TuxGuitar.instance().getPlayer().removeSequencerProvider(this.provider);
       this.loaded = false;
     } catch (MidiPlayerException e) {
       throw new TGPluginException(e.getMessage(), e);
     }
   }
 }
Ejemplo n.º 12
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);
  }
Ejemplo n.º 13
0
  public void init() {
    if (TuxGuitar.instance().getConfig().getBooleanConfigValue(TGConfigKeys.SHOW_SPLASH)) {
      final Image image = TuxGuitar.instance().getIconManager().getAppSplash();

      this.shell = new Shell(TuxGuitar.instance().getDisplay(), SWT.NO_TRIM | SWT.NO_BACKGROUND);
      this.shell.setLayout(new FillLayout());
      this.shell.setBounds(getBounds(image));
      this.shell.setImage(TuxGuitar.instance().getIconManager().getAppIcon());
      this.shell.setText(TuxGuitar.APPLICATION_NAME);
      this.shell.addPaintListener(
          new PaintListener() {
            public void paintControl(PaintEvent e) {
              TGPainter painter = new TGPainter(e.gc);
              painter.drawImage(image, 0, 0);
            }
          });
      this.shell.open();
      this.shell.redraw();
      this.shell.update();
    }
  }
Ejemplo n.º 14
0
  public void showItems() {
    this.play = new MenuItem(this.menu, SWT.PUSH);
    this.play.addSelectionListener(TuxGuitar.instance().getAction(TransportPlayAction.NAME));

    this.stop = new MenuItem(this.menu, SWT.PUSH);
    this.stop.addSelectionListener(TuxGuitar.instance().getAction(TransportStopAction.NAME));

    // --SEPARATOR--
    new MenuItem(this.menu, SWT.SEPARATOR);

    this.metronome = new MenuItem(this.menu, SWT.CHECK);
    this.metronome.addSelectionListener(
        TuxGuitar.instance().getAction(TransportMetronomeAction.NAME));

    this.mode = new MenuItem(this.menu, SWT.PUSH);
    this.mode.addSelectionListener(TuxGuitar.instance().getAction(TransportModeAction.NAME));

    // --SEPARATOR--
    new MenuItem(this.menu, SWT.SEPARATOR);

    this.loopSHeader = new MenuItem(this.menu, SWT.CHECK);
    this.loopSHeader.addSelectionListener(
        TuxGuitar.instance().getAction(TransportSetLoopSHeaderAction.NAME));

    this.loopEHeader = new MenuItem(this.menu, SWT.CHECK);
    this.loopEHeader.addSelectionListener(
        TuxGuitar.instance().getAction(TransportSetLoopEHeaderAction.NAME));

    this.transportMenuItem.setMenu(this.menu);

    this.status = STATUS_STOPPED;
    this.loadIcons();
    this.loadProperties();
  }
Ejemplo n.º 15
0
 protected void newSong() {
   TuxGuitar.instance().loadCursor(SWT.CURSOR_WAIT);
   new Thread(
           new Runnable() {
             public void run() {
               if (!TuxGuitar.isDisposed()) {
                 TuxGuitar.instance().newSong();
                 TuxGuitar.instance().loadCursor(SWT.CURSOR_ARROW);
                 ActionLock.unlock();
               }
             }
           })
       .start();
 }
 public void open() {
   try {
     final Shell parent = TuxGuitar.instance().getShell();
     TGSynchronizer.instance()
         .runLater(
             new TGSynchronizer.TGRunnable() {
               public void run() throws Throwable {
                 open(parent);
               }
             });
   } catch (Throwable e) {
     LOG.error(e);
   }
 }
Ejemplo n.º 17
0
  protected int execute(TypedEvent e) {
    // comienza el undoable
    UndoableMeasureGeneric undoable = UndoableMeasureGeneric.startUndo();

    Caret caret = getEditor().getTablature().getCaret();
    getSongManager()
        .getMeasureManager()
        .changeGhostNote(
            caret.getMeasure(), caret.getPosition(), caret.getSelectedString().getNumber());
    TuxGuitar.instance().getFileHistory().setUnsavedFile();
    updateTablature();

    // termia el undoable
    addUndoableEdit(undoable.endUndo());

    return 0;
  }
Ejemplo n.º 18
0
 protected static void openFile(final String url) {
   if (url == null) {
     ActionLock.unlock();
     return;
   }
   TuxGuitar.instance().loadCursor(SWT.CURSOR_WAIT);
   new Thread(
           new Runnable() {
             public void run() {
               if (!TuxGuitar.isDisposed()) {
                 FileActionUtils.open(url);
                 TuxGuitar.instance().loadCursor(SWT.CURSOR_ARROW);
                 ActionLock.unlock();
               }
             }
           })
       .start();
 }
Ejemplo n.º 19
0
  public void loadIcons(boolean force) {
    int lastStatus = this.status;

    if (TuxGuitar.instance().getPlayer().isRunning()) {
      this.status = STATUS_RUNNING;
    } else if (TuxGuitar.instance().getPlayer().isPaused()) {
      this.status = STATUS_PAUSED;
    } else {
      this.status = STATUS_STOPPED;
    }

    if (force || lastStatus != this.status) {
      if (this.status == STATUS_RUNNING) {
        this.stop.setImage(TuxGuitar.instance().getIconManager().getTransportIconStop2());
        this.play.setImage(TuxGuitar.instance().getIconManager().getTransportIconPause());
      } else if (this.status == STATUS_PAUSED) {
        this.stop.setImage(TuxGuitar.instance().getIconManager().getTransportIconStop2());
        this.play.setImage(TuxGuitar.instance().getIconManager().getTransportIconPlay2());
      } else if (this.status == STATUS_STOPPED) {
        this.stop.setImage(TuxGuitar.instance().getIconManager().getTransportIconStop1());
        this.play.setImage(TuxGuitar.instance().getIconManager().getTransportIconPlay1());
      }
    }
  }
Ejemplo n.º 20
0
 protected TablatureEditor getEditor() {
   return TuxGuitar.instance().getTablatureEditor();
 }
Ejemplo n.º 21
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);
  }
Ejemplo n.º 22
0
 public void removeListeners() {
   TuxGuitar.instance().getIconManager().removeLoader(this);
   TuxGuitar.instance().getLanguageManager().removeLoader(this);
   TuxGuitar.instance().getEditorManager().removeUpdateListener(this);
 }
  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);
  }
Ejemplo n.º 24
0
 public void loadIcons() {
   this.loadIcons(true);
   this.mode.setImage(TuxGuitar.instance().getIconManager().getTransportMode());
   this.metronome.setImage(TuxGuitar.instance().getIconManager().getTransportMetronome());
 }
Ejemplo n.º 25
0
 public void loadIcons() {
   if (!isDisposed()) {
     this.dialog.setImage(TuxGuitar.instance().getIconManager().getAppIcon());
   }
 }
Ejemplo n.º 26
0
 protected void closeModules() {
   TuxGuitar.instance().getPlayer().close();
   TuxGuitar.instance().getPluginManager().closePlugins();
 }
Ejemplo n.º 27
0
  protected void saveConfig() {
    TGConfigManager config = TuxGuitar.instance().getConfig();

    config.setProperty(
        TGConfigKeys.LAYOUT_MODE, getEditor().getTablature().getViewLayout().getMode());
    config.setProperty(
        TGConfigKeys.LAYOUT_STYLE, getEditor().getTablature().getViewLayout().getStyle());
    config.setProperty(
        TGConfigKeys.SHOW_PIANO, !TuxGuitar.instance().getPianoEditor().isDisposed());
    config.setProperty(
        TGConfigKeys.SHOW_MATRIX, !TuxGuitar.instance().getMatrixEditor().isDisposed());
    config.setProperty(
        TGConfigKeys.SHOW_FRETBOARD, TuxGuitar.instance().getFretBoardEditor().isVisible());
    config.setProperty(TGConfigKeys.SHOW_MIXER, !TuxGuitar.instance().getMixer().isDisposed());
    config.setProperty(
        TGConfigKeys.SHOW_TRANSPORT, !TuxGuitar.instance().getTransport().isDisposed());
    config.setProperty(TGConfigKeys.SHOW_MARKERS, !MarkerList.instance().isDisposed());
    config.setProperty(TGConfigKeys.MAXIMIZED, TuxGuitar.instance().getShell().getMaximized());
    config.setProperty(TGConfigKeys.WIDTH, TuxGuitar.instance().getShell().getClientArea().width);
    config.setProperty(TGConfigKeys.HEIGHT, TuxGuitar.instance().getShell().getClientArea().height);
    config.setProperty(
        TGConfigKeys.EDITOR_MOUSE_MODE, getEditor().getTablature().getEditorKit().getMouseMode());
    config.setProperty(
        TGConfigKeys.MATRIX_GRIDS, TuxGuitar.instance().getMatrixEditor().getGrids());

    TuxGuitar.instance().getConfig().save();
  }
Ejemplo n.º 28
0
  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);
  }
Ejemplo n.º 29
0
 private static TGTrack cloneTrack(TGTrack track) {
   return track.clone(
       TuxGuitar.instance().getSongManager().getFactory(),
       TuxGuitar.instance().getSongManager().getSong());
 }