public void actionPerformed(ActionEvent ae) {
   // Ambience Configuration
   if (ambiencesCombo.getSelectedIndex() == 0) {
     // display the wizard
     AmbienceWizard ambience = new AmbienceWizard();
     ambience.show();
     // Reset combo to last selected item
     ambiencesCombo.removeActionListener(ambienceListener);
     Ambience defaultAmbience =
         AmbienceManager.getInstance()
             .getAmbience(ConfigurationManager.getProperty(CONF_DEFAULT_AMBIENCE));
     if (defaultAmbience != null) {
       for (int i = 0; i < ambiencesCombo.getItemCount(); i++) {
         if (((JLabel) ambiencesCombo.getItemAt(i))
             .getText()
             .equals(defaultAmbience.getName())) {
           ambiencesCombo.setSelectedIndex(i);
           break;
         }
       }
     } else {
       ambiencesCombo.setSelectedIndex(1);
     }
     ambiencesCombo.addActionListener(ambienceListener);
   }
   // Selected 'Any" ambience
   else if (ambiencesCombo.getSelectedIndex() == 1) {
     // reset default ambience
     ConfigurationManager.setProperty(CONF_DEFAULT_AMBIENCE, "");
     ObservationManager.notify(new Event(EventSubject.EVENT_AMBIENCES_SELECTION_CHANGE));
   } else { // Selected an ambience
     Ambience ambience =
         AmbienceManager.getInstance()
             .getAmbienceByName(((JLabel) ambiencesCombo.getSelectedItem()).getText());
     ConfigurationManager.setProperty(CONF_DEFAULT_AMBIENCE, ambience.getID());
     ObservationManager.notify(new Event(EventSubject.EVENT_AMBIENCES_SELECTION_CHANGE));
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
  */
 public void actionPerformed(ActionEvent arg0) {
   if (arg0.getSource() == jcbLanguage) {
     // update index
     ConfigurationManager.setProperty(
         CONF_WIKIPEDIA_LANGUAGE,
         Messages.getLocalForDesc((String) jcbLanguage.getSelectedItem()));
     // force launch wikipedia search for this language
     launchSearch(true);
   } else if (arg0.getSource() == jbAlbumSearch) {
     type = Type.ALBUM;
     // force event
     launchSearch(true);
   } else if (arg0.getSource() == jbAuthorSearch) {
     type = Type.AUTHOR;
     // force event
     launchSearch(true);
   } else if (arg0.getSource() == jbTrackSearch) {
     type = Type.TRACK;
     // force event
     launchSearch(true);
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public void actionPerformed(final ActionEvent ae) {
   // do not run this in a separate thread because Player actions would die
   // with the thread
   try {
     if (ae.getSource() == jcbHistory) {
       HistoryItem hi;
       hi = History.getInstance().getHistoryItem(jcbHistory.getSelectedIndex());
       if (hi != null) {
         org.jajuk.base.File file = FileManager.getInstance().getFileByID(hi.getFileId());
         if (file != null) {
           try {
             FIFO.getInstance()
                 .push(
                     new StackItem(file, ConfigurationManager.getBoolean(CONF_STATE_REPEAT), true),
                     ConfigurationManager.getBoolean(CONF_OPTIONS_DEFAULT_ACTION_CLICK));
           } catch (JajukException je) {
             // can be thrown if file is null
           }
         } else {
           Messages.showErrorMessage(120);
           jcbHistory.setSelectedItem(null);
         }
       }
     } else if (ae.getSource().equals(jmiNoveltiesModeSong)) {
       ConfigurationManager.setProperty(CONF_NOVELTIES_MODE, MODE_TRACK);
     } else if (ae.getSource().equals(jmiNoveltiesModeAlbum)) {
       ConfigurationManager.setProperty(CONF_NOVELTIES_MODE, MODE_ALBUM);
     } else if (ae.getSource().equals(jmiShuffleModeSong)) {
       ConfigurationManager.setProperty(CONF_GLOBAL_RANDOM_MODE, MODE_TRACK);
     } else if (ae.getSource().equals(jmiShuffleModeAlbum)) {
       ConfigurationManager.setProperty(CONF_GLOBAL_RANDOM_MODE, MODE_ALBUM);
     } else if (ae.getSource().equals(jmiShuffleModeAlbum2)) {
       ConfigurationManager.setProperty(CONF_GLOBAL_RANDOM_MODE, MODE_ALBUM2);
     } else if (ae.getSource().equals(jmiShuffleModeAlbum2)) {
       ConfigurationManager.setProperty(CONF_GLOBAL_RANDOM_MODE, MODE_ALBUM2);
     }
   } catch (Exception e) {
     Log.error(e);
   } finally {
     ObservationManager.notify(new Event(EventSubject.EVENT_PLAYLIST_REFRESH));
   }
 }
Exemplo n.º 4
0
 /* (non-Javadoc)
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public void actionPerformed(final ActionEvent e) {
   // no thread, nothing requires long execution time and a SwingWorker is not adapted
   if (e.getActionCommand().equals(EVENT_EXIT)) {
     Main.exit(0);
   } else if (e.getActionCommand().equals(EVENT_OPEN_FILE)) {
     JajukFileChooser jfchooser = new JajukFileChooser();
     int returnVal = jfchooser.showOpenDialog(Main.getWindow());
     if (returnVal == JFileChooser.APPROVE_OPTION) {
       java.io.File[] files = jfchooser.getSelectedFiles();
       FIFO.getInstance().clear(); // stop all currently played tracks
       ArrayList alFiles = new ArrayList();
       for (int i = 0; i < files.length; i++) {
         if (Util.getExtension(files[i]).equals(EXT_PLAYLIST)) {
           BasicPlaylistFile bplf = new BasicPlaylistFile(files[i]);
           try {
             alFiles.addAll(bplf.getBasicFiles());
           } catch (JajukException je) {
             Log.error(je);
           }
         } else {
           alFiles.add(new BasicFile(files[i]));
         }
       }
       FIFO.getInstance().push(alFiles, false);
     }
   } else if (e.getActionCommand().equals(EVENT_REPEAT_MODE_STATUS_CHANGED)) {
     boolean bContinue = ConfigurationManager.getBoolean(CONF_STATE_CONTINUE);
     if (bContinue) {
       // Repeat and continue can't be set together, so deselect repeat mode
       ConfigurationManager.setProperty(CONF_STATE_CONTINUE, Boolean.toString(!bContinue));
       JajukJMenuBar.getInstance().jcbmiContinue.setSelected(false);
       CommandJPanel.getInstance().jbContinue.setBorder(BorderFactory.createRaisedBevelBorder());
     }
     boolean b = ConfigurationManager.getBoolean(CONF_STATE_REPEAT);
     ConfigurationManager.setProperty(CONF_STATE_REPEAT, Boolean.toString(!b));
     JajukJMenuBar.getInstance().jcbmiRepeat.setSelected(!b);
     if (!b == true) { // enabled button
       CommandJPanel.getInstance().jbRepeat.setBorder(BorderFactory.createLoweredBevelBorder());
       // set the forced repeat track to repeat over it even with others tracks in the fifo
       FIFO.getInstance().forceRepeat(FIFO.getInstance().getCurrentFile());
     } else { // disable repeat mode
       CommandJPanel.getInstance().jbRepeat.setBorder(BorderFactory.createRaisedBevelBorder());
       FIFO.getInstance().forceRepeat(null); // reset forced
     }
   } else if (e.getActionCommand().equals(EVENT_SHUFFLE_MODE_STATUS_CHANGED)) {
     boolean b = ConfigurationManager.getBoolean(CONF_STATE_SHUFFLE);
     ConfigurationManager.setProperty(CONF_STATE_SHUFFLE, Boolean.toString(!b));
     JajukJMenuBar.getInstance().jcbmiShuffle.setSelected(!b);
     if (!b == true) { // enabled button
       CommandJPanel.getInstance().jbRandom.setBorder(BorderFactory.createLoweredBevelBorder());
       FIFO.getInstance().shuffle(); // shuffle current selection
     } else {
       CommandJPanel.getInstance().jbRandom.setBorder(BorderFactory.createRaisedBevelBorder());
     }
   } else if (e.getActionCommand().equals(EVENT_CONTINUE_MODE_STATUS_CHANGED)) {
     boolean bRepeat = ConfigurationManager.getBoolean(CONF_STATE_REPEAT);
     if (bRepeat) {
       // Repeat and continue can't be set together, so deselect repeat mode
       ConfigurationManager.setProperty(CONF_STATE_REPEAT, Boolean.toString(!bRepeat));
       JajukJMenuBar.getInstance().jcbmiRepeat.setSelected(false);
       CommandJPanel.getInstance().jbRepeat.setBorder(BorderFactory.createRaisedBevelBorder());
     }
     boolean b = ConfigurationManager.getBoolean(CONF_STATE_CONTINUE);
     ConfigurationManager.setProperty(CONF_STATE_CONTINUE, Boolean.toString(!b));
     JajukJMenuBar.getInstance().jcbmiContinue.setSelected(!b);
     if (!b == true) { // enabled button
       CommandJPanel.getInstance().jbContinue.setBorder(BorderFactory.createLoweredBevelBorder());
     } else {
       CommandJPanel.getInstance().jbContinue.setBorder(BorderFactory.createRaisedBevelBorder());
     }
   } else if (e.getActionCommand().equals(EVENT_INTRO_MODE_STATUS_CHANGED)) {
     boolean b =
         Boolean.valueOf(ConfigurationManager.getProperty(CONF_STATE_INTRO)).booleanValue();
     ConfigurationManager.setProperty(CONF_STATE_INTRO, Boolean.toString(!b));
     JajukJMenuBar.getInstance().jcbmiIntro.setSelected(!b);
     if (!b == true) { // enabled button
       CommandJPanel.getInstance().jbIntro.setBorder(BorderFactory.createLoweredBevelBorder());
     } else {
       CommandJPanel.getInstance().jbIntro.setBorder(BorderFactory.createRaisedBevelBorder());
     }
   } else if (e.getActionCommand().equals(EVENT_VIEW_SHOW_STATUS_CHANGED_REQUEST)) {
     if (((JCheckBoxMenuItem) e.getSource()).isSelected()) { // show view request
       ViewManager.notify(
           EVENT_VIEW_SHOW_REQUEST,
           (IView) JajukJMenuBar.getInstance().hmCheckboxView.get(e.getSource()));
     } else {
       ViewManager.notify(
           EVENT_VIEW_CLOSE_REQUEST,
           (IView) JajukJMenuBar.getInstance().hmCheckboxView.get(e.getSource()));
     }
   } else if (EVENT_HELP_REQUIRED.equals(e.getActionCommand())) {
     PerspectiveManager.setCurrentPerspective(PERSPECTIVE_NAME_HELP);
   }
 }
Exemplo n.º 5
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == jbCancel) {
     dispose(); // close window
   } else if (e.getSource() == jbFileSelection) {
     JajukFileChooser jfc = new JajukFileChooser(new JajukFileFilter(true, false));
     jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     jfc.setDialogTitle(Messages.getString("FirstTimeWizard.5")); // $NON-NLS-1$
     jfc.setMultiSelectionEnabled(false);
     int returnVal = jfc.showOpenDialog(this);
     if (returnVal == JFileChooser.APPROVE_OPTION) {
       fDir = jfc.getSelectedFile();
       // check device availibility
       String sCode =
           DeviceManager.getInstance()
               .checkDeviceAvailablity(
                   fDir.getName(), 0, fDir.getAbsolutePath(), fDir.getAbsolutePath());
       if (!sCode.equals("0")) { // $NON-NLS-1$
         Messages.showErrorMessage(sCode);
         jbOk.setEnabled(false);
         return;
       }
       jtfFileSelected.setText(fDir.getAbsolutePath());
       jbOk.setEnabled(true);
       jbOk.grabFocus();
     }
   } else if (e.getSource() == jbOk) {
     /*Set perspective to display. We differentiate first connection or not because
     during first connection, perspectives are not yet initialized, so we just tell it whish
     perspective to use at startup*/
     if (ConfigurationManager.getBoolean(CONF_FIRST_CON)) {
       if (jcbHelp.isSelected()) {
         // set parameter perspective
         Main.setDefaultPerspective(PERSPECTIVE_NAME_HELP);
       } else {
         // set physical perspective
         Main.setDefaultPerspective(PERSPECTIVE_NAME_PHYSICAL);
       }
     } else {
       // go to help perspective if required
       if (jcbHelp.isSelected()) {
         // set parameter perspective
         PerspectiveManager.setCurrentPerspective(PERSPECTIVE_NAME_HELP);
       }
     }
     // Set auto cover property
     ConfigurationManager.setProperty(
         CONF_COVERS_AUTO_COVER, Boolean.toString(jcbAutoCover.isSelected()));
     // Create a directory device
     Device device =
         DeviceManager.getInstance().registerDevice(fDir.getName(), 0, fDir.getAbsolutePath());
     device.setProperty(XML_DEVICE_MOUNT_POINT, fDir.getAbsolutePath());
     device.setProperty(XML_DEVICE_AUTO_MOUNT, true);
     // as we don't know type of device, no auto-refresh (can cause network bandwith use for
     // network drive)
     device.setProperty(XML_DEVICE_AUTO_REFRESH, 0d);
     try {
       device.refresh(true);
     } catch (Exception e2) {
       Log.error("112", device.getName(), e2); // $NON-NLS-1$
       Messages.showErrorMessage("112", device.getName()); // $NON-NLS-1$
     }
     // exit
     dispose();
   }
 }