/** Create common UI for property wizards */
 void populate() {
   getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
   Util.setShuffleLocation(this, 400, 400);
   jlItemChoice = new JLabel(Messages.getString("CustomPropertyWizard.0"));
   jlName = new JLabel(Messages.getString("CustomPropertyWizard.1"));
   jcbItemChoice = new JComboBox();
   jcbItemChoice.addItem(Messages.getString("Item_Track"));
   jcbItemChoice.addItem(Messages.getString("Item_File"));
   jcbItemChoice.addItem(Messages.getString("Item_Style"));
   jcbItemChoice.addItem(Messages.getString("Item_Author"));
   jcbItemChoice.addItem(Messages.getString("Item_Album"));
   jcbItemChoice.addItem(Messages.getString("Item_Device"));
   jcbItemChoice.addItem(Messages.getString("Item_Directory"));
   jcbItemChoice.addItem(Messages.getString("Item_Playlist")); // playlist
   //
   jcbItemChoice.addItem(Messages.getString("Item_Year"));
   // file
   // actually
   //
   okp = new OKCancelPanel(this);
   okp.getOKButton().setEnabled(false);
   // In physical perspective, default item is file, otherwise, it is track
   if (PerspectiveManager.getCurrentPerspective().getClass().equals(FilesPerspective.class)) {
     jcbItemChoice.setSelectedIndex(1);
   } else {
     jcbItemChoice.setSelectedIndex(0);
   }
   jcbItemChoice.addItemListener(this);
   jpMain = new JPanel();
 }
 /*
  * (non-Javadoc)
  *
  * @see org.jajuk.ui.Observer#update(java.lang.String)
  */
 public void update(Event event) {
   EventSubject subject = event.getSubject();
   // Make a search after a stop period
   if (subject.equals(EventSubject.EVENT_FILE_LAUNCHED)
       || subject.equals(EventSubject.EVENT_PERPECTIVE_CHANGED)) {
     // Do not perform search if current perspective is not info for
     // perfs
     if (!(PerspectiveManager.getCurrentPerspective() instanceof InfoPerspective)) {
       return;
     }
     // If current state is stopped, reset page
     if (FIFO.getInstance().getCurrentFile() == null) {
       reset();
       return;
     }
     // Launch search
     launchSearch(false);
   }
   // Reset the page when stopping
   else if (subject.equals(EventSubject.EVENT_ZERO)) {
     reset();
   }
   // User changed current track tags, so we have to reload
   // new author wikipedia page
   else if (subject.equals(EventSubject.EVENT_AUTHOR_CHANGED)
       || subject.equals(EventSubject.EVENT_ALBUM_CHANGED)
       || subject.equals(EventSubject.EVENT_TRACK_CHANGED)) {
     update(new Event(EventSubject.EVENT_FILE_LAUNCHED));
   }
 }
Esempio n. 3
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);
   }
 }
 /**
  * [Perf].
  *
  * @return whether LastFM tabs are visible or not
  */
 private boolean isLastFMTabsVisible() {
   // Refresh artists only if user selected similar artists or albums tab
   return (tabs.getSelectedIndex() == 3 || tabs.getSelectedIndex() == 4)
       // Check this view perspective is visible
       && PerspectiveManager.getCurrentPerspective().equals(this.getPerspective());
 }
 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();
   }
 }