private void initFretSearch(Composite parent) { Group group = new Group(parent, SWT.SHADOW_ETCHED_IN); group.setLayout(new GridLayout(4, false)); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); group.setText(TuxGuitar.getProperty("chord.settings.search-frets")); this.minFret = makeSpinner( group, TuxGuitar.getProperty("chord.settings.minimum-fret"), ChordSettings.instance().getFindChordsMin(), 0, 15); this.maxFret = makeSpinner( group, TuxGuitar.getProperty("chord.settings.maximum-fret"), ChordSettings.instance().getFindChordsMax(), 2, 25); this.minFret.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkMinimumFretValue(); } }); this.maxFret.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkMaximumFretValue(); } }); }
public void loadProperties() { if (!isDisposed()) { this.dialog.setText(TuxGuitar.getProperty("matrix.editor")); this.gridsLabel.setText(TuxGuitar.getProperty("matrix.grids")); this.settings.setToolTipText(TuxGuitar.getProperty("settings")); this.disposeBuffer(); this.layout(); this.redraw(); } }
private void initTypeCombo(Composite parent) { this.newLabel(parent, TuxGuitar.getProperty("chord.settings.type")); this.typeCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); this.typeCombo.setLayoutData(getGridData()); this.typeCombo.add(TuxGuitar.getProperty("chord.settings.type.most-common")); this.typeCombo.add(TuxGuitar.getProperty("chord.settings.type.inversions")); this.typeCombo.add(TuxGuitar.getProperty("chord.settings.type.close-voiced")); this.typeCombo.add(TuxGuitar.getProperty("chord.settings.type.open-voiced")); this.typeCombo.select(ChordSettings.instance().getChordTypeIndex()); }
public void show() { this.config = new MatrixConfig(); this.config.load(); this.dialog = DialogUtils.newDialog(TuxGuitar.instance().getShell(), SWT.DIALOG_TRIM | SWT.RESIZE); this.dialog.setText(TuxGuitar.getProperty("matrix.editor")); this.dialog.setImage(TuxGuitar.instance().getIconManager().getAppIcon()); this.dialog.setLayout(new GridLayout()); this.dialog.addDisposeListener(new DisposeListenerImpl()); this.bufferDisposer = new BufferDisposer(); this.composite = new Composite(this.dialog, SWT.NONE); this.composite.setLayout(new GridLayout()); this.composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this.initToolBar(); this.initEditor(); this.loadIcons(); this.addListeners(); this.dialog.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { removeListeners(); TuxGuitar.instance().updateCache(true); } }); DialogUtils.openDialog(this.dialog, DialogUtils.OPEN_STYLE_CENTER); }
private void initEmptyStringChords(Composite parent) { this.emptyStringChords = new Button(parent, SWT.CHECK); this.emptyStringChords.setSelection(ChordSettings.instance().isEmptyStringChords()); this.emptyStringChords.setText(TuxGuitar.getProperty("chord.settings.open-chords")); this.emptyStringChords.setSize(100, 20); this.emptyStringChords.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); }
private void initChordsToDisplay(Composite parent) { this.chordsToDisplay = makeSpinner( parent, TuxGuitar.getProperty("chord.settings.chords-to-display"), ChordSettings.instance().getChordsToDisplay(), 1, 100); }
protected void init() { Group group = new Group(this.dialog, SWT.SHADOW_ETCHED_IN); group.setLayout(new GridLayout()); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); group.setText(TuxGuitar.getProperty("chord.settings.tip")); Composite composite = new Composite(group, SWT.NONE); composite.setLayout(new GridLayout(2, false)); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); initTypeCombo(composite); initChordsToDisplay(composite); initEmptyStringChords(composite); initFretSearch(composite); // ------------------BUTTONS-------------------------- Composite buttons = new Composite(this.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() { @Override public void widgetSelected(SelectionEvent arg0) { dispose(true); } }); Button buttonCancel = new Button(buttons, SWT.PUSH); buttonCancel.setText(TuxGuitar.getProperty("cancel")); buttonCancel.setLayoutData(getButtonData()); buttonCancel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { dispose(false); } }); this.dialog.setDefaultButton(buttonOK); }
protected void setMenuItemTextAndAccelerator(MenuItem menuItem, String key, String action) { String text = TuxGuitar.getProperty(key); if (action != null) { KeyBinding keyBinding = TuxGuitar.instance().getKeyBindingManager().getKeyBindingForAction(action); if (keyBinding != null) { text += "\t" + keyBinding.toString() + "\u0000"; } } menuItem.setText(text); }
public LanguageOption( TGSettingsEditor configEditor, UIToolBar toolBar, UILayoutContainer parent) { super( configEditor, toolBar, parent, TuxGuitar.getProperty("settings.config.language"), UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL); this.initialized = false; }
public void openDirectoryDialog( final ImageExporterSettings settings, final TGSongStreamContext context, final Runnable callback) { DirectoryDialog dialog = new DirectoryDialog(TuxGuitar.getInstance().getShell()); dialog.setText(TuxGuitar.getProperty("tuxguitar-image.directory-dialog.title")); settings.setPath(dialog.open()); if (settings.getPath() != null) { context.setAttribute(ImageExporterSettings.class.getName(), settings); callback.run(); } }
private void updateChannelCombos(boolean playerRunning) { if (!isDisposed() && getChannel() != null) { List channels = getHandle().getFreeChannels(getChannel()); String channel1Prefix = TuxGuitar.getProperty("instrument.channel"); String channel2Prefix = TuxGuitar.getProperty("instrument.effect-channel"); this.reloadChannelCombo( this.channel1Combo, channels, getChannel().getChannel(), channel1Prefix); this.reloadChannelCombo( this.channel2Combo, channels, getChannel().getEffectChannel(), channel2Prefix); this.channel1Combo.setEnabled( !playerRunning && !getChannel().isPercussionChannel() && this.channel1Combo.getItemCount() > 0); this.channel2Combo.setEnabled( !playerRunning && !getChannel().isPercussionChannel() && this.channel2Combo.getItemCount() > 0); } }
public boolean open(Shell parent) { this.updated = false; this.dialog = DialogUtils.newDialog(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); this.dialog.setLayout(new GridLayout()); this.dialog.setText(TuxGuitar.getProperty("settings")); this.init(); DialogUtils.openDialog( this.dialog, DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT); return this.updated; }
public void loadProperties() { if (!isDisposed()) { this.percussionButton.setText(TuxGuitar.getProperty("instrument.percussion-channel")); this.removeChannelButton.setText(TuxGuitar.getProperty("remove")); this.volumeScale.setText(TuxGuitar.getProperty("instrument.volume")); this.balanceScale.setText(TuxGuitar.getProperty("instrument.balance")); this.reverbScale.setText(TuxGuitar.getProperty("instrument.reverb")); this.chorusScale.setText(TuxGuitar.getProperty("instrument.chorus")); this.tremoloScale.setText(TuxGuitar.getProperty("instrument.tremolo")); this.phaserScale.setText(TuxGuitar.getProperty("instrument.phaser")); this.updateChannelCombos(this.getHandle().isPlayerRunning()); } }
private void updateBankCombo(boolean playerRunning) { if (!isDisposed() && getChannel() != null) { if (this.bankCombo.getItemCount() == 0) { String bankPrefix = TuxGuitar.getProperty("instrument.bank"); for (int i = 0; i < 128; i++) { this.bankCombo.add((bankPrefix + " #" + i)); } } if (getChannel().getBank() >= 0 && getChannel().getBank() < this.bankCombo.getItemCount()) { this.bankCombo.select(getChannel().getBank()); } this.bankCombo.setEnabled(!getChannel().isPercussionChannel()); } }
public StylesOption(TGConfigEditor configEditor, ToolBar toolBar, final Composite parent) { super(configEditor, toolBar, parent, TuxGuitar.getProperty("settings.config.styles")); this.initialized = false; this.defaultFontData = new FontData(); this.noteFontData = new FontData(); this.timeSignatureFontData = new FontData(); this.textFontData = new FontData(); this.lyricFontData = new FontData(); this.printerDefaultFontData = new FontData(); this.printerNoteFontData = new FontData(); this.printerTSFontData = new FontData(); this.printerTextFontData = new FontData(); this.printerLyricFontData = new FontData(); }
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(); }
protected void initChordWidgets() { Composite alterationComposite = new Composite(this, SWT.NONE); alterationComposite.setLayout(this.dialog.gridLayout(1, true, 0, 0)); alterationComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite aboveComposite = new Composite(alterationComposite, SWT.NONE); aboveComposite.setLayout(this.dialog.gridLayout(2, true, 0, 0)); aboveComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite firstComposite = new Composite(aboveComposite, SWT.NONE); firstComposite.setLayout(this.dialog.gridLayout(1, false, 0, 0)); firstComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this.alterationList = new List(firstComposite, SWT.BORDER); this.alterationList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this.plusMinusList = new List(firstComposite, SWT.BORDER); this.plusMinusList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite secondComposite = new Composite(aboveComposite, SWT.NONE); secondComposite.setLayout(this.dialog.gridLayout(1, false, 0, 0)); secondComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this._5List = new List(secondComposite, SWT.BORDER); this._5List.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this._9List = new List(secondComposite, SWT.BORDER); this._9List.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this._11List = new List(secondComposite, SWT.BORDER); this._11List.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite bassComposite = new Composite(alterationComposite, SWT.NONE); bassComposite.setLayout(this.dialog.gridLayout(1, true, 0, 0)); bassComposite.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true)); this.addCheck = new Button(bassComposite, SWT.CHECK | SWT.LEFT); this.addCheck.setText("add"); // this.addCheck.setSelection(false); // this.addCheck.setEnabled(false); this.addCheck.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true)); Label separator = new Label(bassComposite, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true)); Label bText = new Label(bassComposite, SWT.LEFT); bText.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false)); bText.setText(TuxGuitar.getProperty("chord.bass")); this.bassCombo = new Combo(bassComposite, SWT.DROP_DOWN | SWT.READ_ONLY); this.bassCombo.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false)); }
protected List<LanguageItem> getLanguageItems(String[] languages) { List<LanguageItem> list = new ArrayList<LanguageItem>(); if (languages != null) { for (int i = 0; i < languages.length; i++) { list.add(new LanguageItem(languages[i], TuxGuitar.getProperty("locale." + languages[i]))); } Collections.sort( list, new Comparator<LanguageItem>() { public int compare(LanguageItem l1, LanguageItem l2) { if (l1 != null && l2 != null) { return l1.getValue().compareTo(l2.getValue()); } return 0; } }); } return list; }
private List getProgramNames() { List programNames = new ArrayList(); if (!getChannel().isPercussionChannel()) { MidiInstrument[] instruments = TuxGuitar.instance().getPlayer().getInstruments(); if (instruments != null) { int count = instruments.length; if (count > 128) { count = 128; } for (int i = 0; i < count; i++) { programNames.add(instruments[i].getName()); } } } if (programNames.isEmpty()) { String programPrefix = TuxGuitar.getProperty("instrument.program"); for (int i = 0; i < 128; i++) { programNames.add((programPrefix + " #" + i)); } } return programNames; }
public void showDialog(Shell shell) { 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("composition.tripletfeel")); dialog.setMinimumSize(300, 0); // -------------TIME SIGNATURE----------------------------------------------- Group tripletFeel = new Group(dialog, SWT.SHADOW_ETCHED_IN); tripletFeel.setLayout(new GridLayout()); tripletFeel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); tripletFeel.setText(TuxGuitar.getProperty("composition.tripletfeel")); // none final Button tripletFeelNone = new Button(tripletFeel, SWT.RADIO); tripletFeelNone.setText(TuxGuitar.getProperty("composition.tripletfeel.none")); tripletFeelNone.setSelection(measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_NONE); final Button tripletFeelEighth = new Button(tripletFeel, SWT.RADIO); tripletFeelEighth.setText(TuxGuitar.getProperty("composition.tripletfeel.eighth")); tripletFeelEighth.setSelection( measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_EIGHTH); final Button tripletFeelSixteenth = new Button(tripletFeel, SWT.RADIO); tripletFeelSixteenth.setText(TuxGuitar.getProperty("composition.tripletfeel.sixteenth")); tripletFeelSixteenth.setSelection( measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_SIXTEENTH); // --------------------To End Checkbox------------------------------- Group check = new Group(dialog, SWT.SHADOW_ETCHED_IN); check.setLayout(new GridLayout()); check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); check.setText(TuxGuitar.getProperty("options")); final Button toEnd = new Button(check, SWT.CHECK); toEnd.setText(TuxGuitar.getProperty("composition.tripletfeel.to-the-end")); toEnd.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) { final boolean toEndValue = toEnd.getSelection(); final int tripletFeel = getSelectedTripletFeel(tripletFeelNone, tripletFeelEighth, tripletFeelSixteenth); dialog.dispose(); try { TGSynchronizer.instance() .runLater( new TGSynchronizer.TGRunnable() { public void run() throws Throwable { ActionLock.lock(); TuxGuitar.instance().loadCursor(SWT.CURSOR_WAIT); setTripletFeel(tripletFeel, toEndValue); TuxGuitar.instance().updateCache(true); TuxGuitar.instance().loadCursor(SWT.CURSOR_ARROW); ActionLock.unlock(); } }); } catch (Throwable throwable) { MessageDialog.errorMessage(throwable); } } }); Button buttonCancel = new Button(buttons, SWT.PUSH); buttonCancel.setLayoutData(getButtonData()); buttonCancel.setText(TuxGuitar.getProperty("cancel")); 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); } }
public void loadProperties() { this.add.setToolTipText(TuxGuitar.getProperty("track.add")); this.remove.setToolTipText(TuxGuitar.getProperty("track.remove")); }
private void initToolBar() { GridLayout layout = new GridLayout(); layout.makeColumnsEqualWidth = false; layout.numColumns = 0; layout.marginWidth = 0; layout.marginHeight = 0; this.toolbar = new Composite(this.composite, SWT.NONE); // position layout.numColumns++; Button goLeft = new Button(this.toolbar, SWT.ARROW | SWT.LEFT); goLeft.addSelectionListener(TuxGuitar.instance().getAction(GoLeftAction.NAME)); layout.numColumns++; Button goRight = new Button(this.toolbar, SWT.ARROW | SWT.RIGHT); goRight.addSelectionListener(TuxGuitar.instance().getAction(GoRightAction.NAME)); // separator layout.numColumns++; makeToolSeparator(this.toolbar); // duration layout.numColumns++; Button decrement = new Button(this.toolbar, SWT.ARROW | SWT.MIN); decrement.addSelectionListener(TuxGuitar.instance().getAction(DecrementDurationAction.NAME)); layout.numColumns++; this.durationLabel = new Label(this.toolbar, SWT.BORDER); layout.numColumns++; Button increment = new Button(this.toolbar, SWT.ARROW | SWT.MAX); increment.addSelectionListener(TuxGuitar.instance().getAction(IncrementDurationAction.NAME)); // separator layout.numColumns++; makeToolSeparator(this.toolbar); // grids layout.numColumns++; this.gridsLabel = new Label(this.toolbar, SWT.NONE); this.gridsLabel.setText(TuxGuitar.getProperty("matrix.grids")); layout.numColumns++; final Combo divisionsCombo = new Combo(this.toolbar, SWT.DROP_DOWN | SWT.READ_ONLY); divisionsCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true)); for (int i = 0; i < DIVISIONS.length; i++) { divisionsCombo.add(Integer.toString(DIVISIONS[i])); if (this.grids == DIVISIONS[i]) { divisionsCombo.select(i); } } if (this.grids == 0) { divisionsCombo.select(0); } divisionsCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int index = divisionsCombo.getSelectionIndex(); if (index >= 0 && index < DIVISIONS.length) { setGrids(DIVISIONS[index]); } } }); // settings layout.numColumns++; this.settings = new Button(this.toolbar, SWT.PUSH); this.settings.setImage(TuxGuitar.instance().getIconManager().getSettings()); this.settings.setToolTipText(TuxGuitar.getProperty("settings")); this.settings.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true)); this.settings.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { configure(); } }); this.toolbar.setLayout(layout); this.toolbar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); }
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); }
public MainOption(TGSettingsEditor configEditor, ToolBar toolBar, final Composite parent) { super(configEditor, toolBar, parent, TuxGuitar.getProperty("settings.config.main")); this.initialized = false; }
@Override public void createOption() { getToolItem().setText(TuxGuitar.getProperty("settings.config.styles")); getToolItem().setImage(TuxGuitar.instance().getIconManager().getOptionStyle()); getToolItem().addSelectionListener(this); // =================================================== EDITOR STYLES // ===================================================// showLabel( getComposite(), SWT.TOP | SWT.LEFT | SWT.WRAP, SWT.BOLD, 0, TuxGuitar.getProperty("settings.config.styles.general")); Composite composite = new Composite(getComposite(), SWT.NONE); composite.setLayout(new GridLayout(2, false)); composite.setLayoutData(getTabbedData()); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.default")); this.defaultFontButton = new Button(composite, SWT.PUSH); this.defaultFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.defaultFontButton, this.defaultFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.note")); this.noteFontButton = new Button(composite, SWT.PUSH); this.noteFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.noteFontButton, this.noteFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.lyric")); this.lyricFontButton = new Button(composite, SWT.PUSH); this.lyricFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.lyricFontButton, this.lyricFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.text")); this.textFontButton = new Button(composite, SWT.PUSH); this.textFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.textFontButton, this.textFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.time-signature")); this.timeSignatureFontButton = new Button(composite, SWT.PUSH); this.timeSignatureFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.timeSignatureFontButton, this.timeSignatureFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.color.score-note")); this.scoreNoteColorButton = new ButtonColor(composite, SWT.PUSH, makeButtonData(), TuxGuitar.getProperty("choose")); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.color.tab-note")); this.tabNoteColorButton = new ButtonColor(composite, SWT.PUSH, makeButtonData(), TuxGuitar.getProperty("choose")); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.color.play-note")); this.playNoteColorButton = new ButtonColor(composite, SWT.PUSH, makeButtonData(), TuxGuitar.getProperty("choose")); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.color.lines")); this.linesColorButton = new ButtonColor(composite, SWT.PUSH, makeButtonData(), TuxGuitar.getProperty("choose")); // =================================================== PRINTER STYLES // ===================================================// showLabel( getComposite(), SWT.TOP | SWT.LEFT | SWT.WRAP, SWT.BOLD, 0, TuxGuitar.getProperty("settings.config.styles.printer")); composite = new Composite(getComposite(), SWT.NONE); composite.setLayout(new GridLayout(2, false)); composite.setLayoutData(getTabbedData()); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.default")); this.printerDefaultFontButton = new Button(composite, SWT.PUSH); this.printerDefaultFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.printerDefaultFontButton, this.printerDefaultFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.note")); this.printerNoteFontButton = new Button(composite, SWT.PUSH); this.printerNoteFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.printerNoteFontButton, this.printerNoteFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.lyric")); this.printerLyricFontButton = new Button(composite, SWT.PUSH); this.printerLyricFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.printerLyricFontButton, this.printerLyricFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.text")); this.printerTextFontButton = new Button(composite, SWT.PUSH); this.printerTextFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.printerTextFontButton, this.printerTextFontData); showLabel( composite, SWT.FILL, SWT.CENTER, SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.styles.font.time-signature")); this.printerTSFontButton = new Button(composite, SWT.PUSH); this.printerTSFontButton.setLayoutData(makeButtonData()); this.addFontButtonListeners(this.printerTSFontButton, this.printerTSFontData); this.loadConfig(); }
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 init() { Composite tonicComposite = new Composite(this, SWT.NONE); tonicComposite.setLayout(this.dialog.gridLayout(1, false, 0, 0)); tonicComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this.tonicList = new List(tonicComposite, SWT.BORDER); this.tonicList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // sharp & flat buttons Composite buttonsComposite = new Composite(tonicComposite, SWT.NONE); buttonsComposite.setLayout(this.dialog.gridLayout(2, true, 0, 0)); GridData buttonGd = new GridData(SWT.FILL, SWT.TOP, true, false); buttonGd.heightHint = 28; buttonGd.widthHint = 28; this.sharpButton = new Button(buttonsComposite, SWT.TOGGLE); this.sharpButton.setLayoutData(buttonGd); this.flatButton = new Button(buttonsComposite, SWT.TOGGLE); this.flatButton.setLayoutData(buttonGd); // TODO: maybe put an image instead of #,b this.sharpButton.setText("#"); this.flatButton.setText("b"); this.chordList = new List(this, SWT.BORDER); this.chordList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Label separator = new Label(tonicComposite, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true)); Button customizeButton = new Button(tonicComposite, SWT.PUSH); customizeButton.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false)); customizeButton.setText(TuxGuitar.getProperty("settings")); customizeButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { if (new ChordSettingsDialog().open(ChordSelector.this.getShell())) { new SyncThread( new Runnable() { @Override public void run() { ChordSelector.this.showChord(); getChordList().redraw(); } }) .start(); } } }); initChordWidgets(); // fill the List widgets with text insertTonicNames(true); for (int i = 0; i < ChordDatabase.length(); i++) { this.chordList.add(ChordDatabase.get(i).getName()); } /* Iterator chordInfo = ChordCreatorUtil.getChordData().getChords().iterator(); while(chordInfo.hasNext()) { this.chordList.add( ((ChordDatabase.ChordInfo)chordInfo.next()).getName() ); } */ this.chordList.setSelection(0); String[] alterationNames = getAlterationNames(); for (int i = 0; i < alterationNames.length; i++) { this.alterationList.add(alterationNames[i]); } this.alterationList.setSelection(0); String[] plusMinus = this.getPlusMinus(""); for (int i = 0; i < plusMinus.length; i++) { this.plusMinusList.add(plusMinus[i]); } this.plusMinusList.setSelection(0); String[] plus5Minus = this.getPlusMinus("/5"); for (int i = 0; i < plus5Minus.length; i++) { this._5List.add(plus5Minus[i]); } this._5List.setSelection(0); String[] plus9Minus = this.getPlusMinus("/9"); for (int i = 0; i < plus9Minus.length; i++) { this._9List.add(plus9Minus[i]); } this._9List.setSelection(0); String[] plus11Minus = this.getPlusMinus("/11"); for (int i = 0; i < plus11Minus.length; i++) { this._11List.add(plus11Minus[i]); } this._11List.setSelection(0); // LISTENERS this.tonicList.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (ChordSelector.this.getRefresh()) { if (getDialog().getEditor() != null && getDialog().getList() != null) { getBassCombo().select(getTonicList().getSelectionIndex()); showChord(); } } } }); this.bassCombo.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (ChordSelector.this.getRefresh()) { if (getDialog().getEditor() != null && getDialog().getList() != null) { showChord(); } } } }); this.chordList.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getDialog().getEditor() != null && getDialog().getList() != null) { adjustWidgetAvailability(); if (ChordSelector.this.getRefresh()) { showChord(); } } } }); this.alterationList.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getDialog().getEditor() != null && getDialog().getList() != null) { ChordSelector.this.adjustWidgetAvailability(); if (ChordSelector.this.getRefresh()) { showChord(); } } } }); this.addCheck.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { if (getDialog().getEditor() != null && getDialog().getList() != null) { ChordSelector.this.adjustWidgetAvailability(); /* if (getAddCheck().getSelection()) { updateWidget(get_9List(), false); updateWidget(get_11List(), false); } */ if (ChordSelector.this.getRefresh()) { showChord(); // ChordSelector.this.dialog.getList().redraw(); } } } }); this._5List.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getDialog().getEditor() != null && getDialog().getList() != null) { if (ChordSelector.this.getRefresh()) { showChord(); } } } }); this._9List.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getDialog().getEditor() != null && getDialog().getList() != null) { if (ChordSelector.this.getRefresh()) { showChord(); } } } }); this._11List.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getDialog().getEditor() != null && getDialog().getList() != null) { if (ChordSelector.this.getRefresh()) { showChord(); } } } }); this.plusMinusList.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getDialog().getEditor() != null && getDialog().getList() != null) { if (ChordSelector.this.getRefresh()) { showChord(); // ChordSelector.this.dialog.getList().redraw(); } } } }); this.sharpButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { insertTonicNames(true); } }); this.flatButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { insertTonicNames(false); } }); this.adjustWidgetAvailability(); }
public void openSettingsDialog(final TGSongStreamContext context, final Runnable callback) { final TGSong song = context.getAttribute(TGDocumentContextAttributes.ATTRIBUTE_SONG); final PrintStyles styles = createDefaultStyles(song); final Shell dialog = DialogUtils.newDialog( TuxGuitar.getInstance().getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new GridLayout()); dialog.setText(TuxGuitar.getProperty("options")); // ------------------FORMAT SELECTION------------------ Group formatGroup = new Group(dialog, SWT.SHADOW_ETCHED_IN); formatGroup.setLayout(new GridLayout(2, false)); formatGroup.setLayoutData(getGroupData()); formatGroup.setText(TuxGuitar.getProperty("tuxguitar-image.format")); Label formatLabel = new Label(formatGroup, SWT.NULL); formatLabel.setText(TuxGuitar.getProperty("tuxguitar-image.format")); final Combo formatCombo = new Combo(formatGroup, SWT.DROP_DOWN | SWT.READ_ONLY); formatCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); for (int i = 0; i < ImageFormat.IMAGE_FORMATS.length; i++) { formatCombo.add(ImageFormat.IMAGE_FORMATS[i].getName()); } formatCombo.select(0); // ------------------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 <= song.countTracks(); number++) { tracks.add(TuxGuitar.getInstance().getSongManager().getTrack(song, number).getName()); } tracks.select( TuxGuitar.getInstance() .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 = song.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 format = formatCombo.getSelectionIndex(); if (format < 0 || format >= ImageFormat.IMAGE_FORMATS.length) { format = 0; } int style = 0; style |= (scoreEnabled.getSelection() ? TGLayout.DISPLAY_SCORE : 0); style |= (tablatureEnabled.getSelection() ? TGLayout.DISPLAY_TABLATURE : 0); style |= (chordNameEnabled.getSelection() ? TGLayout.DISPLAY_CHORD_NAME : 0); style |= (chordDiagramEnabled.getSelection() ? TGLayout.DISPLAY_CHORD_DIAGRAM : 0); style |= (blackAndWhite.getSelection() ? TGLayout.DISPLAY_MODE_BLACK_WHITE : 0); styles.setTrackNumber(tracks.getSelectionIndex() + 1); styles.setFromMeasure(fromSpinner.getSelection()); styles.setToMeasure(toSpinner.getSelection()); styles.setStyle(style); dialog.dispose(); ImageExporterSettings settings = new ImageExporterSettings(); settings.setStyles(styles); settings.setFormat(ImageFormat.IMAGE_FORMATS[format]); openDirectoryDialog(settings, context, callback); } }); 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); }
public void createOption() { getToolItem().setText(TuxGuitar.getProperty("settings.config.main")); getToolItem().setImage(TuxGuitar.getInstance().getIconManager().getOptionMain()); getToolItem().addSelectionListener(this); showLabel( getComposite(), SWT.TOP | SWT.LEFT | SWT.WRAP, SWT.BOLD, 0, TuxGuitar.getProperty("settings.config.main.window-title")); Composite windowTitleComposite = new Composite(getComposite(), SWT.NONE); windowTitleComposite.setLayout(new GridLayout()); windowTitleComposite.setLayoutData(getTabbedData()); this.windowTitle = new Text(windowTitleComposite, SWT.BORDER); this.windowTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); this.windowTitle.setTextLimit(80); Composite infoHeader = new Composite(windowTitleComposite, SWT.NONE); infoHeader.setLayout(new GridLayout(2, false)); infoHeader.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); showImageLabel( infoHeader, SWT.NONE, infoHeader.getDisplay().getSystemImage(SWT.ICON_INFORMATION)); showLabel( infoHeader, SWT.TOP | SWT.LEFT | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty("settings.config.main.window-title.help")); Composite infoBody = new Composite(windowTitleComposite, SWT.NONE); infoBody.setLayout(new GridLayout(2, false)); infoBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); showLabel( infoBody, SWT.NONE, SWT.BOLD, -1, WindowTitleUtil.getVar(WindowTitleUtil.VAR_APP_NAME)); showLabel( infoBody, SWT.TOP | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty( "settings.config.main.window-title.var.description." + WindowTitleUtil.VAR_APP_NAME)); showLabel( infoBody, SWT.NONE, SWT.BOLD, -1, WindowTitleUtil.getVar(WindowTitleUtil.VAR_APP_VERSION)); showLabel( infoBody, SWT.TOP | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty( "settings.config.main.window-title.var.description." + WindowTitleUtil.VAR_APP_VERSION)); showLabel( infoBody, SWT.NONE, SWT.BOLD, -1, WindowTitleUtil.getVar(WindowTitleUtil.VAR_FILE_NAME)); showLabel( infoBody, SWT.TOP | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty( "settings.config.main.window-title.var.description." + WindowTitleUtil.VAR_FILE_NAME)); showLabel( infoBody, SWT.NONE, SWT.BOLD, -1, WindowTitleUtil.getVar(WindowTitleUtil.VAR_FILE_PATH)); showLabel( infoBody, SWT.TOP | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty( "settings.config.main.window-title.var.description." + WindowTitleUtil.VAR_FILE_PATH)); showLabel( infoBody, SWT.NONE, SWT.BOLD, -1, WindowTitleUtil.getVar(WindowTitleUtil.VAR_SONG_NAME)); showLabel( infoBody, SWT.TOP | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty( "settings.config.main.window-title.var.description." + WindowTitleUtil.VAR_SONG_NAME)); showLabel( infoBody, SWT.NONE, SWT.BOLD, -1, WindowTitleUtil.getVar(WindowTitleUtil.VAR_SONG_ALBUM)); showLabel( infoBody, SWT.TOP | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty( "settings.config.main.window-title.var.description." + WindowTitleUtil.VAR_SONG_ALBUM)); showLabel( infoBody, SWT.NONE, SWT.BOLD, -1, WindowTitleUtil.getVar(WindowTitleUtil.VAR_SONG_ARTIST)); showLabel( infoBody, SWT.TOP | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty( "settings.config.main.window-title.var.description." + WindowTitleUtil.VAR_SONG_ARTIST)); showLabel( infoBody, SWT.NONE, SWT.BOLD, -1, WindowTitleUtil.getVar(WindowTitleUtil.VAR_SONG_AUTHOR)); showLabel( infoBody, SWT.TOP | SWT.WRAP, SWT.NORMAL, 0, TuxGuitar.getProperty( "settings.config.main.window-title.var.description." + WindowTitleUtil.VAR_SONG_AUTHOR)); showLabel( getComposite(), SWT.BOTTOM | SWT.LEFT | SWT.WRAP, SWT.BOLD, 0, TuxGuitar.getProperty("settings.config.main.options")); Composite options = new Composite(getComposite(), SWT.NONE); options.setLayout(new GridLayout()); options.setLayoutData(getTabbedData()); this.autoSizeTable = new Button(options, SWT.CHECK); this.autoSizeTable.setText( TuxGuitar.getProperty("settings.config.main.table.auto-size.enabled")); this.showSplash = new Button(options, SWT.CHECK); this.showSplash.setText(TuxGuitar.getProperty("settings.config.main.splash-enabled")); this.loadConfig(); }
@Override public void loadProperties() { this.info.setToolTipText(TuxGuitar.getProperty("composition.properties")); }