/** @return ItemManager associated with selected element in combo box */ ItemManager getItemManager() { ItemManager im = null; switch (jcbItemChoice.getSelectedIndex()) { case 0: im = TrackManager.getInstance(); break; case 1: im = FileManager.getInstance(); break; case 2: im = StyleManager.getInstance(); break; case 3: im = AuthorManager.getInstance(); break; case 4: im = AlbumManager.getInstance(); break; case 5: im = DeviceManager.getInstance(); break; case 6: im = DirectoryManager.getInstance(); break; case 7: im = PlaylistFileManager.getInstance(); break; case 8: im = YearManager.getInstance(); break; } return im; }
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(); } }