Package jpianotrain

Examples of jpianotrain.ApplicationContext


* @author methke01
* @since 0.0.2
*/
public class ExternalURLHandler {
  public static void handle(URL u) {
    ApplicationContext ctx=ApplicationContext.getInstance();
    if (urlDialog==null) {
      urlDialog=new URLDialog(ctx.getDefaultDialogOwner());
    }
    urlDialog.setUrl(u);
    urlDialog.setVisible(true);
  }
View Full Code Here


  }

// ActionListener
  public void actionPerformed(ActionEvent e) {
    Object source=e.getSource();
    ApplicationContext ctx=ApplicationContext.getInstance();
    if (source==modeMidiFile) {
      ctx.setMode(ApplicationContext.Mode.MIDI_FILES);
    } else if (source==modeRandomNotes) {
      ctx.setMode(ApplicationContext.Mode.RANDOM_NOTES);
    } else if (source==modeLessons) {
      ctx.setMode(ApplicationContext.Mode.LESSONS);
    } else if (source==countIn) {
      ctx.setStartMode(ApplicationContext.StartMode.COUNT_IN);
    } else if (source==onFirstKey) {
      ctx.setStartMode(ApplicationContext.StartMode.ON_FIRST_KEY);
    }
  }
View Full Code Here

  }

  private void createUI() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc=new GridBagConstraints();
    ApplicationContext ctx=ApplicationContext.getInstance();
   
    JPanel p=new JPanel();
    gbc.weightx=1.0;
    gbc.insets=new Insets(2,3,2,3);
    add(p, gbc);
    gbc.weightx=0;
    gbc.gridy=0;
    // remember to fill from right to
    // left.
    gbc.anchor=GridBagConstraints.EAST;
    modeField=createField();
    modeField.setText(ctx.getMode().toString());
    modeField.setToolTipText(ResourceFactory.getMessage(
      TOOLTIP_MODE_STATUS,
      ApplicationContext.getInstance().getMode()));
    gbc.gridx++;
    add(modeField, gbc);

    midiField=createField();
    midiField.setText(ResourceFactory.getString(LABEL_MIDI)+
      " "+ResourceFactory.getString(MESSAGE_OFF));
    gbc.gridx++;
    add(midiField, gbc);
   
    spoolField=createField();
    spoolField.setText(ResourceFactory.getString(LABEL_SPOOL_MIDI)+
      " "+ResourceFactory.getString(MESSAGE_OFF));
    gbc.gridx++;
    add(spoolField, gbc);

    startModeField=createField();
    startModeField.setText(ctx.getStartMode().toString());
    gbc.gridx++;
    add(startModeField, gbc);
   
    hintField=createField();
    hintField.setText(ResourceFactory.getString(LABEL_SHOW_HINTS));
    hintField.setEnabled(ctx.isShowHints());
    hintColorChanged();
    gbc.gridx++;
    add(hintField);
   
    wrongField=createField();
    wrongField.setText(ResourceFactory.getString(LABEL_SHOW_WRONG_KEY));
    wrongField.setEnabled(ctx.isShowWrongKey());
    wrongColorChanged();
    gbc.gridx++;
    add(wrongField);
    updateEnabledState();
  }
View Full Code Here

      TOOLTIP_MODE_STATUS,
      ApplicationContext.getInstance().getMode()));
  }

  public void spoolChanged() {
    ApplicationContext ctx=ApplicationContext.getInstance();
    if (ctx.isSpoolMidi()) {
      spoolField.setText(ResourceFactory.getString(LABEL_SPOOL_MIDI)+
          " "+ResourceFactory.getString(MESSAGE_ON));
    } else {
      spoolField.setText(ResourceFactory.getString(LABEL_SPOOL_MIDI)+
          " "+ResourceFactory.getString(MESSAGE_OFF));
View Full Code Here

          " "+ResourceFactory.getString(MESSAGE_OFF));
    }
  }
 
  public void midiStatusChanged() {
    ApplicationContext ctx=ApplicationContext.getInstance();
    if (ctx.getMidiStatus()==ApplicationContext.MidiStatus.ON) {
      midiField.setText(ResourceFactory.getString(LABEL_MIDI)+
          " "+ResourceFactory.getString(MESSAGE_ON));
    } else {
      midiField.setText(ResourceFactory.getString(LABEL_MIDI)+
          " "+ResourceFactory.getString(MESSAGE_OFF));
View Full Code Here

  @Override
  public void saveData() {
    boolean flag=false;
    UserConfiguration uc=UserConfiguration.getInstance();
    ApplicationContext ctx=ApplicationContext.getInstance();
    try {
      this.midiOutIndex=midiOutBox.getSelectedIndex();
      uc.putProperty(MIDI_OUT_DEVICE, midiOutIndex);
      MidiDevice.Info outInfo=(MidiDevice.Info)midiOutBox.getSelectedItem();
     
      this.metronomeIndex=metronomeOutBox.getSelectedIndex();
      uc.putProperty(MIDI_METRONOME_DEVICE, metronomeIndex);
      MidiDevice.Info metronomeInfo=null;
      if (metronomeIndex>0) {
        metronomeInfo=(MidiDevice.Info)metronomeOutBox.getSelectedItem();
      }
      this.keyInIndex=keyboardInBox.getSelectedIndex();
      uc.putProperty(KEYBOARD_IN_DEVICE, keyInIndex);
      MidiDevice.Info keyInfo=(MidiDevice.Info)keyboardInBox.getSelectedItem();
      MidiDevice metroDev=null;
      if (metronomeInfo!=null) {
        metroDev=MidiSystem.getMidiDevice(metronomeInfo);
        if (metroDev.getMaxReceivers()==0) {
          JOptionPane.showMessageDialog(ctx.getDefaultDialogOwner(),
              ResourceFactory.getString(MESSAGE_NO_RECEIVER),
              ResourceFactory.getString(TITLE_MIDI_INIT_FAILED),
              JOptionPane.ERROR_MESSAGE);
        }
      }
      MidiDevice outDev=MidiSystem.getMidiDevice(outInfo);
      if (outDev.getMaxReceivers()==0) {
        JOptionPane.showMessageDialog(ctx.getDefaultDialogOwner(),
            ResourceFactory.getString(MESSAGE_NO_RECEIVER),
            ResourceFactory.getString(TITLE_MIDI_INIT_FAILED),
            JOptionPane.ERROR_MESSAGE);
      }
      MidiDevice keyDev=MidiSystem.getMidiDevice(keyInfo);
      if (keyDev.getMaxTransmitters()==0) {
        JOptionPane.showMessageDialog(ctx.getDefaultDialogOwner(),
            ResourceFactory.getString(MESSAGE_NO_TRANSMITTER),
            ResourceFactory.getString(TITLE_MIDI_INIT_FAILED),
            JOptionPane.ERROR_MESSAGE);
      }
      flag=MidiThread.getInstance().init(keyDev, outDev, metroDev);
    } catch (Exception ex) {
      log.error("failed to init midi thread", ex);
    }
    if (flag) {
      ctx.setMidiStatus(ApplicationContext.MidiStatus.ON);
    } else {
      ctx.setMidiStatus(ApplicationContext.MidiStatus.OFF);
      JOptionPane.showMessageDialog(ctx.getDefaultDialogOwner(),
          ResourceFactory.getString(MESSAGE_MIDI_INIT_FAILED),
          ResourceFactory.getString(TITLE_MIDI_INIT_FAILED),
          JOptionPane.ERROR_MESSAGE);
    }
  }
View Full Code Here

    UserConfiguration uc=UserConfiguration.getInstance();
    uc.putProperty(SYNTHESIZER_ENABLED, activateCheck.isSelected());
    uc.putProperty(SYNTHESIZER_BANK,
        ((SpinnerNumberModel)bankSpinner.getModel()).getNumber().intValue());
    uc.putProperty(SYNTHESIZER_INSTRUMENT, instrumentList.getSelectedIndex());
    ApplicationContext ctx=ApplicationContext.getInstance();
    if (synth.isOpen()) {
      synth.close();
    }
    boolean flag=false;
    try {
      this.keyInIndex=keyboardInBox.getSelectedIndex();
      uc.putProperty(KEYBOARD_IN_DEVICE, keyInIndex);
      MidiDevice.Info keyInfo=(MidiDevice.Info)keyboardInBox.getSelectedItem();
      MidiDevice keyDev=MidiSystem.getMidiDevice(keyInfo);
      if (keyDev.getMaxTransmitters()==0) {
        JOptionPane.showMessageDialog(ctx.getDefaultDialogOwner(),
            ResourceFactory.getString(MESSAGE_NO_TRANSMITTER),
            ResourceFactory.getString(TITLE_MIDI_INIT_FAILED),
            JOptionPane.ERROR_MESSAGE);
      }
      flag=MidiThread.getInstance().init(keyDev,
          synth,
          (Instrument)instrumentList.getSelectedItem());
    } catch (Exception ex) {
      log.error("failed to init midi thread", ex);
    }
    if (flag) {
      ctx.setMidiStatus(ApplicationContext.MidiStatus.ON);
    } else {
      ctx.setMidiStatus(ApplicationContext.MidiStatus.OFF);
      JOptionPane.showMessageDialog(ctx.getDefaultDialogOwner(),
          ResourceFactory.getString(MESSAGE_MIDI_INIT_FAILED),
          ResourceFactory.getString(TITLE_MIDI_INIT_FAILED),
          JOptionPane.ERROR_MESSAGE);
    }
  }
View Full Code Here

  }
 
  @Override
  public void saveData() {
    UserConfiguration uc=UserConfiguration.getInstance();
    ApplicationContext ctx=ApplicationContext.getInstance();
   
    log.debug("sending show wrong key status: "+showWrongKey.isSelected());
    ctx.setKeyWrongColor(keyWrongColor.getBackground());
    ctx.setShowWrongKey(showWrongKey.isSelected());
   
    ctx.setKeyHintColor(keyHintColor.getBackground());
    ctx.setShowHints(showHints.isSelected());
   
    uc.putProperty(COLOR_WRONG_KEY, keyWrongColor.getBackground());
    uc.putProperty(COLOR_HINTS, keyHintColor.getBackground());
    uc.putProperty(SHOW_WRONG_KEY, keyWrongColor.isEnabled());
    uc.putProperty(SHOW_HINTS, keyHintColor.isEnabled());
View Full Code Here

TOP

Related Classes of jpianotrain.ApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.