/** * Mount the device. * * @param bManual set whether mount is manual or auto * @return whether the device has been mounted. If user is asked for mounting but cancel, this * method returns false. * @throws JajukException if device cannot be mounted due to technical reason. */ public boolean mount(final boolean bManual) throws JajukException { if (bMounted) { // Device already mounted throw new JajukException(111); } // Check if we can mount the device. boolean readyToMount = checkDevice(); // Effective mounting if available. if (readyToMount) { bMounted = true; } else if (pathExists() && isVoid() && bManual) { // If the device is void and in manual mode, leave a chance to the user to // force it final int answer = Messages.getChoice( "[" + getName() + "] " + Messages.getString("Confirmation_void_refresh"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); // leave if user doesn't confirm to mount the void device if (answer != JOptionPane.YES_OPTION) { return false; } else { bMounted = true; } } else { throw new JajukException(11, "\"" + getName() + "\" at URL : " + getUrl()); } // notify views to refresh if needed ObservationManager.notify(new JajukEvent(JajukEvents.DEVICE_MOUNT)); return bMounted; }
/** * Synchronizing asynchronously. * * @param bAsynchronous : set asynchronous or synchronous mode */ public void synchronize(final boolean bAsynchronous) { // Check a source device is defined if (StringUtils.isBlank((String) getValue(Const.XML_DEVICE_SYNCHRO_SOURCE))) { Messages.showErrorMessage(171); return; } final Device device = this; if (!device.isMounted()) { try { device.mount(true); } catch (final Exception e) { Log.error(11, getName(), e); // mount failed Messages.showErrorMessage(11, getName()); return; } } if (bAsynchronous) { final Thread t = new Thread("Device Synchronize Thread") { @Override public void run() { synchronizeCommand(); } }; t.setPriority(Thread.MIN_PRIORITY); t.start(); } else { synchronizeCommand(); } }
RepeatModeAction() { super( Messages.getString("JajukJMenuBar.10"), IconLoader.getIcon(JajukIcons.REPEAT), "ctrl T", true, false); setShortDescription(Messages.getString("CommandJPanel.1")); }
/** Instantiates a new paste action. */ PasteAction() { super( Messages.getString("ActionMove.0"), IconLoader.getIcon(JajukIcons.PASTE), "ctrl V", true, false); setShortDescription(Messages.getString("ActionMove.0")); }
/** Instantiates a new mute action. */ MuteAction() { super( Messages.getString("JajukWindow.2"), IconLoader.getIcon(JajukIcons.VOLUME_LEVEL1), "F8", true, true); setShortDescription(Messages.getString("JajukWindow.19")); }
/** Instantiates a new copy action. */ CopyAction() { super( Messages.getString("FilesTreeView.3"), IconLoader.getIcon(JajukIcons.COPY), "ctrl C", true, false); setShortDescription(Messages.getString("FilesTreeView.3")); }
/** * Gets the nothing found panel. * * @return a panel with text explaining why no item has been found */ JPanel getNothingFoundPanel() { JPanel out = new JPanel(new MigLayout("ins 5", "grow")); JEditorPane jteNothing = new JEditorPane("text/html", Messages.getString("SuggestionView.7")); jteNothing.setBorder(null); jteNothing.setEditable(false); jteNothing.setOpaque(false); jteNothing.setToolTipText(Messages.getString("SuggestionView.7")); out.add(jteNothing, "center,grow"); return out; }
/* (non-Javadoc) * @see org.jajuk.ui.actions.JajukAction#perform(java.awt.event.ActionEvent) */ @Override public void perform(ActionEvent evt) { final JEditorPane text = new JEditorPane("text/html", getTraces()); text.setEditable(false); text.setMargin(new Insets(10, 10, 10, 10)); text.setOpaque(true); text.setBackground(Color.WHITE); text.setForeground(Color.DARK_GRAY); text.setFont(FontManager.getInstance().getFont(JajukFont.BOLD)); final JDialog dialog = new JDialog(JajukMainWindow.getInstance(), Messages.getString("DebugLogAction.0"), false); JButton jbCopy = new JButton( Messages.getString("DebugLogAction.2"), IconLoader.getIcon(JajukIcons.COPY_TO_CLIPBOARD)); jbCopy.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { StringSelection data = new StringSelection(text.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(data, data); } }); JButton jbRefresh = new JButton(Messages.getString("DebugLogAction.1"), IconLoader.getIcon(JajukIcons.REFRESH)); jbRefresh.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Refresh traces text.setText(getTraces()); } }); JButton jbClose = new JButton(Messages.getString("Close"), IconLoader.getIcon(JajukIcons.CLOSE)); jbClose.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); dialog.setLayout(new MigLayout("insets 10", "[grow]")); JScrollPane panel = new JScrollPane(text); UtilGUI.setEscapeKeyboardAction(dialog, panel); dialog.add(panel, "grow,wrap"); dialog.add(jbCopy, "split 3,right,sg button"); dialog.add(jbRefresh, "split 3,right,sg button"); dialog.add(jbClose, "right,sg button"); dialog.setPreferredSize(new Dimension(800, 600)); dialog.pack(); dialog.setLocationRelativeTo(JajukMainWindow.getInstance()); dialog.setVisible(true); }
/** * Return label for a type. * * @param type * @return label for a type */ public static String getTypeLabel(Type type) { if (type == Type.DIRECTORY) { return Messages.getString("Device_type.directory"); } else if (type == Type.FILES_CD) { return Messages.getString("Device_type.file_cd"); } else if (type == Type.EXTDD) { return Messages.getString("Device_type.extdd"); } else if (type == Type.PLAYER) { return Messages.getString("Device_type.player"); } else if (type == Type.NETWORK_DRIVE) { return Messages.getString("Device_type.network_drive"); } else { return null; } }
/** * Return the result panel for local albums. * * @param type * @return the local suggestions panel */ JScrollPane getLocalSuggestionsPanel(SuggestionType type) { FlowScrollPanel out = new FlowScrollPanel(); out.setLayout(new FlowLayout(FlowLayout.LEFT)); JScrollPane jsp = new JScrollPane( out, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jsp.setBorder(null); out.setScroller(jsp); List<Album> albums = null; if (type == SuggestionType.BEST_OF) { albums = albumsPrefered; } else if (type == SuggestionType.NEWEST) { albums = albumsNewest; } else if (type == SuggestionType.RARE) { albums = albumsRare; } if (albums != null && albums.size() > 0) { for (Album album : albums) { LocalAlbumThumbnail thumb = new LocalAlbumThumbnail(album, 100, false); thumb.populate(); thumb.getIcon().addMouseListener(new ThumbMouseListener()); out.add(thumb); } } else { out.add(UtilGUI.getCentredPanel(new JLabel(Messages.getString("WikipediaView.3")))); } return jsp; }
/** * Unmount the device with ejection. * * @param bEjection set whether the device must be ejected * @param bUIRefresh set whether the UI should be refreshed */ public void unmount(final boolean bEjection, final boolean bUIRefresh) { // look to see if the device is already mounted if (!bMounted) { Messages.showErrorMessage(125); // already unmounted return; } // ask fifo if it doens't use any track from this device if (!QueueModel.canUnmount(this)) { Messages.showErrorMessage(121); return; } bMounted = false; if (bUIRefresh) { ObservationManager.notify(new JajukEvent(JajukEvents.DEVICE_UNMOUNT)); } }
/** * Prepare manual refresh. * * @param bAsk ask user to perform deep or fast refresh * @return the user choice (deep or fast) * @throws JajukException if user canceled, device cannot be refreshed or device already * refreshing */ int prepareRefresh(final boolean bAsk) throws JajukException { if (bAsk) { final Object[] possibleValues = { Messages.getString("FilesTreeView.60"), // fast Messages.getString("FilesTreeView.61"), // deep Messages.getString("Cancel") }; // cancel try { SwingUtilities.invokeAndWait( new Runnable() { @Override public void run() { choice = JOptionPane.showOptionDialog( JajukMainWindow.getInstance(), Messages.getString("FilesTreeView.59"), Messages.getString("Option"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, possibleValues, possibleValues[0]); } }); } catch (Exception e) { Log.error(e); choice = Device.OPTION_REFRESH_CANCEL; } if (choice == Device.OPTION_REFRESH_CANCEL) { // Cancel return choice; } } // JajukException are not trapped, will be thrown to the caller final Device device = this; if (!device.isMounted()) { // Leave if user canceled device mounting if (!device.mount(true)) { return Device.OPTION_REFRESH_CANCEL; } } if (bAlreadyRefreshing) { throw new JajukException(107); } return choice; }
/** * Change a playlist name * * @param plfOld * @param sNewName * @return new playlist */ public Playlist changePlaylistFileName(Playlist plfOld, String sNewName) throws JajukException { synchronized (PlaylistManager.getInstance().getLock()) { // check given name is different if (plfOld.getName().equals(sNewName)) { return plfOld; } // check if this file still exists if (!plfOld.getFio().exists()) { throw new JajukException(135); } java.io.File ioNew = new java.io.File( plfOld.getFio().getParentFile().getAbsolutePath() + java.io.File.separator + sNewName); // recalculate file ID plfOld.getDirectory(); String sNewId = PlaylistManager.createID(sNewName, plfOld.getDirectory()); // create a new playlist (with own fio and sAbs) Playlist plfNew = new Playlist(sNewId, sNewName, plfOld.getDirectory()); plfNew.setProperties(plfOld.getProperties()); // transfert all // properties // (inc id and // name) plfNew.setProperty(XML_ID, sNewId); // reset new id and name plfNew.setProperty(XML_NAME, sNewName); // reset new id and name // check file name and extension if (plfNew.getName().lastIndexOf('.') != plfNew.getName().indexOf('.') // just // one // '.' || !(Util.getExtension(ioNew).equals(EXT_PLAYLIST))) { // check // extension Messages.showErrorMessage(134); throw new JajukException(134); } // check if future file exists (under windows, file.exists // return true even with different case so we test file name is // different) if (!ioNew.getName().equalsIgnoreCase(plfOld.getName()) && ioNew.exists()) { throw new JajukException(134); } // try to rename file on disk try { plfOld.getFio().renameTo(ioNew); } catch (Exception e) { throw new JajukException(134); } // OK, remove old file and register this new file hmItems.remove(plfOld.getID()); if (!hmItems.containsKey(sNewId)) { hmItems.put(sNewId, plfNew); } // change directory reference plfNew.getDirectory().changePlaylistFile(plfOld, plfNew); return plfNew; } }
/** * Manual refresh, displays a dialog. * * @param bAsk ask for refreshing type (deep or fast ?) * @param bAfterMove is this refresh done after a device location change ? * @param forcedDeep : override bAsk and force a deep refresh * @param dirsToRefresh : only refresh specified dirs, or all of them if null */ public void manualRefresh( final boolean bAsk, final boolean bAfterMove, final boolean forcedDeep, List<Directory> dirsToRefresh) { int i = 0; try { i = prepareRefresh(bAsk); if (i == OPTION_REFRESH_CANCEL) { return; } bAlreadyRefreshing = true; } catch (JajukException je) { Messages.showErrorMessage(je.getCode()); Log.debug(je); return; } try { reporter = new ManualDeviceRefreshReporter(this); reporter.startup(); // clean old files up (takes a while) if (!bAfterMove) { cleanRemovedFiles(dirsToRefresh); } reporter.cleanupDone(); // Actual refresh refreshCommand(((i == Device.OPTION_REFRESH_DEEP) || forcedDeep), true, dirsToRefresh); // cleanup logical items org.jajuk.base.Collection.cleanupLogical(); // if it is a move, clean old files *after* the refresh if (bAfterMove) { cleanRemovedFiles(dirsToRefresh); } // notify views to refresh ObservationManager.notify(new JajukEvent(JajukEvents.DEVICE_REFRESH)); // Commit collection at each refresh (can be useful if // application // is closed brutally with control-C or shutdown and that // exit hook has no time to perform commit). // But don't commit when any device is refreshing to avoid collisions. if (!DeviceManager.getInstance().isAnyDeviceRefreshing()) { try { org.jajuk.base.Collection.commit(SessionService.getConfFileByPath(Const.FILE_COLLECTION)); } catch (final IOException e) { Log.error(e); } } } finally { // Do not let current reporter as a manual reporter because it would fail // in NPE with auto-refresh reporter = null; // Make sure to unlock refreshing bAlreadyRefreshing = false; } }
/** Instantiates a new ambience wizard. */ public AmbienceWizard() { super( new Wizard.Builder( Messages.getString("DigitalDJWizard.56"), AmbienceScreen.class, JajukMainWindow.getInstance()) .hSize(600) .vSize(500) .locale(LocaleManager.getLocale()) .icon(IconLoader.getIcon(JajukIcons.AMBIENCE))); }
/** * Constructor * * @param lsl */ public SearchBox(ListSelectionListener lsl) { this.lsl = lsl; timer.start(); addKeyListener(this); setToolTipText(Messages.getString("SearchBox.0")); setBorder(BorderFactory.createEtchedBorder()); setFont(FontManager.getInstance().getFont(JajukFont.SEARCHBOX)); Color mediumGray = new Color(172, 172, 172); setForeground(mediumGray); setBorder(BorderFactory.createLineBorder(Color.BLUE)); }
/** * Change a playlist name. * * @param plfOld DOCUMENT_ME * @param sNewName DOCUMENT_ME * @return new playlist * @throws JajukException the jajuk exception */ public synchronized Playlist changePlaylistFileName(Playlist plfOld, String sNewName) throws JajukException { // check given name is different if (plfOld.getName().equals(sNewName)) { return plfOld; } // check if this file still exists if (!plfOld.getFIO().exists()) { throw new JajukException(135); } java.io.File ioNew = new java.io.File( plfOld.getFIO().getParentFile().getAbsolutePath() + java.io.File.separator + sNewName); // recalculate file ID plfOld.getDirectory(); String sNewId = PlaylistManager.createID(sNewName, plfOld.getDirectory()); // create a new playlist (with own fio and sAbs) Playlist plfNew = new Playlist(sNewId, sNewName, plfOld.getDirectory()); // Transfer all properties (id and name) // We use a shallow copy of properties to avoid any properties share between // two items plfNew.setProperties(plfOld.getShallowProperties()); plfNew.setProperty(Const.XML_ID, sNewId); // reset new id and name plfNew.setProperty(Const.XML_NAME, sNewName); // reset new id and name // check file name and extension if (plfNew.getName().lastIndexOf('.') != plfNew.getName().indexOf('.') // just // one // '.' || !(UtilSystem.getExtension(ioNew).equals(Const.EXT_PLAYLIST))) { // check // extension Messages.showErrorMessage(134); throw new JajukException(134); } // check if future file exists (under windows, file.exists // return true even with different case so we test file name is // different) if (!ioNew.getName().equalsIgnoreCase(plfOld.getName()) && ioNew.exists()) { throw new JajukException(134); } // try to rename file on disk try { boolean result = plfOld.getFIO().renameTo(ioNew); if (!result) { throw new IOException(); } } catch (Exception e) { throw new JajukException(134, e); } // OK, remove old file and register this new file removeItem(plfOld); registerItem(plfNew); return plfNew; }
@Override public void finish() { for (final Ambience ambience : AmbienceWizard.ambiences) { AmbienceManager.getInstance().registerAmbience(ambience); } // commit it to avoid it is lost before the app close AmbienceManager.getInstance().commit(); // Refresh UI ObservationManager.notify(new JajukEvent(JajukEvents.AMBIENCES_CHANGE)); InformationJPanel.getInstance() .setMessage(Messages.getString("Success"), InformationJPanel.MessageType.INFORMATIVE); }
/** Populate ambiences combo */ void populateAmbiences() { ambiencesCombo.removeActionListener(ambienceListener); ItemListener[] il = ambiencesCombo.getItemListeners(); for (int i = 0; i < il.length; i++) { ambiencesCombo.removeItemListener(il[i]); } ambiencesCombo.removeAllItems(); ambiencesCombo.addItem( new JLabel( Messages.getString("CommandJPanel.19"), IconLoader.ICON_CONFIGURATION, SwingConstants.LEFT)); ambiencesCombo.addItem( new JLabel( "<html><i>" + Messages.getString("DigitalDJWizard.64") + "</i></html>", IconLoader.ICON_STYLE, SwingConstants.LEFT)); // Add available ambiences for (final Ambience ambience : AmbienceManager.getInstance().getAmbiences()) { ambiencesCombo.addItem( new JLabel(ambience.getName(), IconLoader.ICON_STYLE, SwingConstants.LEFT)); } // Select right item 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 { // or "any" ambience ambiencesCombo.setSelectedIndex(1); } ambiencesCombo.addActionListener(ambienceListener); }
/** * Constructor with specified file filter * * @param jfilter filter to use */ public JajukFileChooser(JajukFileFilter jfilter) { setDialogTitle(Messages.getString("JajukFileChooser.0")); this.filter = jfilter; for (int i = 0; i < jfilter.getFilters().length; i++) { addChoosableFileFilter(jfilter.getFilters()[i]); } setMultiSelectionEnabled(true); // don't hide hidden files setFileHidingEnabled(false); setAcceptAllFileFilterUsed(false); // Use default directory to store documents (My Documents under Windows // for ie) setCurrentDirectory(FileSystemView.getFileSystemView().getDefaultDirectory()); }
/* * (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)); } }
/** * Delete a playlist. * * @param plf DOCUMENT_ME */ public synchronized void removePlaylistFile(Playlist plf) { String sFileToDelete = plf.getDirectory().getFio().getAbsoluteFile().toString() + java.io.File.separatorChar + plf.getName(); java.io.File fileToDelete = new java.io.File(sFileToDelete); if (fileToDelete.exists()) { if (!fileToDelete.delete()) { Log.warn("Could not delete file: " + fileToDelete.toString()); } // check that file has been really deleted (sometimes, we get no // exception) if (fileToDelete.exists()) { Log.error("131", new JajukException(131)); Messages.showErrorMessage(131); return; } } // remove playlist removeItem(plf); }
/** Populate DJs */ private void populateDJs() { try { ddbDDJ.setToolTipText( "<html>" + Messages.getString("CommandJPanel.18") + "<p><b>" + DigitalDJManager.getCurrentDJ() + "</b></html>"); popupDDJ.removeAll(); JMenuItem jmiNew = new JMenuItem(ActionManager.getAction(CONFIGURE_DJS)); popupDDJ.add(jmiNew); Iterator<DigitalDJ> it = DigitalDJManager.getInstance().getDJs().iterator(); while (it.hasNext()) { final DigitalDJ dj = it.next(); JCheckBoxMenuItem jmi = new JCheckBoxMenuItem(dj.getName(), IconLoader.ICON_DIGITAL_DJ_16x16); jmi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { ConfigurationManager.setProperty(CONF_DEFAULT_DJ, dj.getID()); DigitalDJManager.setCurrentDJ(dj); // force to reselect the item populateDJs(); // update action tooltip on main button with right item ActionBase action = ActionManager.getAction(JajukAction.DJ); action.setShortDescription( "<html>" + Messages.getString("CommandJPanel.18") + "<p><b>" + dj.getName() + "</b></p></html>"); } }); popupDDJ.add(jmi); jmi.setSelected(ConfigurationManager.getProperty(CONF_DEFAULT_DJ).equals(dj.getID())); } } catch (Exception e) { Log.error(e); } }
/* * (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); } }
/** * Update global functions tooltip after a change in ambiences or an ambience selection using the * ambience selector */ private void updateTooltips() { // Selected 'Any" ambience if (ambiencesCombo.getSelectedIndex() == 1) { ActionBase action = ActionManager.getAction(JajukAction.NOVELTIES); action.setShortDescription(Messages.getString("JajukWindow.31")); action = ActionManager.getAction(JajukAction.BEST_OF); action.setShortDescription(Messages.getString("JajukWindow.24")); action = ActionManager.getAction(JajukAction.SHUFFLE_GLOBAL); action.setShortDescription(Messages.getString("JajukWindow.23")); } else { // Selected an ambience Ambience ambience = AmbienceManager.getInstance() .getAmbienceByName(((JLabel) ambiencesCombo.getSelectedItem()).getText()); ActionBase action = ActionManager.getAction(JajukAction.NOVELTIES); action.setShortDescription( "<html>" + Messages.getString("JajukWindow.31") + "<p><b>" + ambience.getName() + "</b></p></html>"); action = ActionManager.getAction(JajukAction.SHUFFLE_GLOBAL); action.setShortDescription( "<html>" + Messages.getString("JajukWindow.23") + "<p><b>" + ambience.getName() + "</b></p></html>"); action = ActionManager.getAction(JajukAction.BEST_OF); action.setShortDescription( "<html>" + Messages.getString("JajukWindow.24") + "<p><b>" + ambience.getName() + "</b></p></html>"); } }
CDDBSelectionAction() { super(Messages.getString("TracksTreeView.34"), IconLoader.getIcon(JajukIcons.CDDB), true); setShortDescription(Messages.getString("TracksTreeView.34")); }
public void initUI() { // Search double[][] sizeSearch = new double[][] {{3, TableLayout.PREFERRED, 3, 100}, {25}}; JPanel jpSearch = new JPanel(new TableLayout(sizeSearch)); sbSearch = new SearchBox(CommandJPanel.this); JLabel jlSearch = new JLabel(IconLoader.ICON_SEARCH); jlSearch.setToolTipText(Messages.getString("CommandJPanel.23")); // Clear search text when clicking on the search icon jlSearch.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { sbSearch.setText(""); } }); jpSearch.add(jlSearch, "1,0"); jpSearch.add(sbSearch, "3,0"); // History JPanel jpHistory = new JPanel(); jcbHistory = new SteppedComboBox(); JLabel jlHistory = new JLabel(IconLoader.ICON_HISTORY); jlHistory.setToolTipText(Messages.getString("CommandJPanel.0")); // - Increase rating button ActionBase actionIncRate = ActionManager.getAction(JajukAction.INC_RATE); actionIncRate.setName(null); final JPopupMenu jpmIncRating = new JPopupMenu(); for (int i = 1; i <= 10; i++) { final int j = i; JMenuItem jmi = new JMenuItem("+" + i); if (ConfigurationManager.getInt(CONF_INC_RATING) == i) { jmi.setFont(FontManager.getInstance().getFont(JajukFont.BOLD)); } // Store selected value jmi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ConfigurationManager.setProperty(CONF_INC_RATING, "" + j); } }); jpmIncRating.add(jmi); } jbIncRate = new DropDownButton(IconLoader.ICON_INC_RATING) { private static final long serialVersionUID = 1L; @Override protected JPopupMenu getPopupMenu() { return jpmIncRating; } }; jbIncRate.setAction(actionIncRate); // we use a combo box model to make sure we get good performances after // rebuilding the entire model like after a refresh jcbHistory.setModel(new DefaultComboBoxModel(History.getInstance().getHistory())); // None selection because if we start in stop mode, a selection of the // first item will not launch the track because the selected item is // still the same and no action event is thrown (Java >= 1.6) jcbHistory.setSelectedItem(null); int iWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2); // size of popup jcbHistory.setPopupWidth(iWidth); // size of the combo itself, keep it! as text can be very long jcbHistory.setPreferredSize(new Dimension(250, 25)); jcbHistory.setMinimumSize(new Dimension(0, 25)); jcbHistory.setToolTipText(Messages.getString("CommandJPanel.0")); jcbHistory.addActionListener(CommandJPanel.this); JToolBar jtbIncRate = new JToolBar(); jtbIncRate.setFloatable(false); jbIncRate.addToToolBar(jtbIncRate); double[][] sizeHistory = new double[][] { {3, TableLayout.PREFERRED, 3, TableLayout.FILL, 10, TableLayout.PREFERRED}, {25} }; jpHistory.setLayout(new TableLayout(sizeHistory)); jpHistory.add(jlHistory, "1,0"); jpHistory.add(jcbHistory, "3,0"); jpHistory.add(jtbIncRate, "5,0"); // Mode toolbar // we need an inner toolbar to apply size properly JToolBar jtbModes = new JToolBar(); jtbModes.setBorder(null); // make it not floatable as this behavior is managed by vldocking jtbModes.setFloatable(false); jtbModes.setRollover(true); jbRepeat = new JajukToggleButton(ActionManager.getAction(JajukAction.REPEAT_MODE_STATUS_CHANGE)); jbRepeat.setSelected(ConfigurationManager.getBoolean(CONF_STATE_REPEAT)); jbRandom = new JajukToggleButton(ActionManager.getAction(JajukAction.SHUFFLE_MODE_STATUS_CHANGED)); jbRandom.setSelected(ConfigurationManager.getBoolean(CONF_STATE_SHUFFLE)); jbContinue = new JajukToggleButton(ActionManager.getAction(JajukAction.CONTINUE_MODE_STATUS_CHANGED)); jbContinue.setSelected(ConfigurationManager.getBoolean(CONF_STATE_CONTINUE)); jbIntro = new JajukToggleButton(ActionManager.getAction(JajukAction.INTRO_MODE_STATUS_CHANGED)); jbIntro.setSelected(ConfigurationManager.getBoolean(CONF_STATE_INTRO)); jtbModes.add(jbRepeat); jtbModes.addSeparator(); jtbModes.add(jbRandom); jtbModes.addSeparator(); jtbModes.add(jbContinue); jtbModes.addSeparator(); jtbModes.add(jbIntro); // Volume jpVolume = new JPanel(); ActionUtil.installKeystrokes( jpVolume, ActionManager.getAction(JajukAction.DECREASE_VOLUME), ActionManager.getAction(JajukAction.INCREASE_VOLUME)); jpVolume.setLayout(new BoxLayout(jpVolume, BoxLayout.X_AXIS)); int iVolume = (int) (100 * ConfigurationManager.getFloat(CONF_VOLUME)); if (iVolume > 100) { // can occur in some undefined cases iVolume = 100; } jsVolume = new JSlider(0, 100, iVolume); jpVolume.add(jsVolume); jpVolume.add(Box.createHorizontalStrut(5)); jpVolume.add(jbMute); jsVolume.setToolTipText(Messages.getString("CommandJPanel.14")); jsVolume.addChangeListener(CommandJPanel.this); jsVolume.addMouseWheelListener(CommandJPanel.this); // Special functions toolbar // Ambience combo ambiencesCombo = new SteppedComboBox(); iWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 4); ambiencesCombo.setPopupWidth(iWidth); ambiencesCombo.setFont(FontManager.getInstance().getFont(JajukFont.BOLD_L)); // size of the combo itself ambiencesCombo.setRenderer( new BasicComboBoxRenderer() { private static final long serialVersionUID = -6943363556191659895L; public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); JLabel jl = (JLabel) value; setIcon(jl.getIcon()); setText(jl.getText()); return this; } }); ambiencesCombo.setToolTipText(Messages.getString("DigitalDJWizard.66")); populateAmbiences(); ambienceListener = new AmbienceListener(); ambiencesCombo.addActionListener(ambienceListener); jtbSpecial = new JToolBar(); jtbSpecial.setBorder(null); jtbSpecial.setRollover(true); jtbSpecial.setFloatable(false); ddbGlobalRandom = new DropDownButton(IconLoader.ICON_SHUFFLE_GLOBAL) { private static final long serialVersionUID = 1L; @Override protected JPopupMenu getPopupMenu() { return popupGlobalRandom; } }; ddbGlobalRandom.setAction(ActionManager.getAction(JajukAction.SHUFFLE_GLOBAL)); popupGlobalRandom = new JPopupMenu(); // Global shuffle jmiShuffleModeSong = new JRadioButtonMenuItem(Messages.getString("CommandJPanel.20")); jmiShuffleModeSong.addActionListener(this); // album / album jmiShuffleModeAlbum = new JRadioButtonMenuItem(Messages.getString("CommandJPanel.21")); jmiShuffleModeAlbum.addActionListener(this); // Shuffle album / album jmiShuffleModeAlbum2 = new JRadioButtonMenuItem(Messages.getString("CommandJPanel.22")); jmiShuffleModeAlbum2.addActionListener(this); if (ConfigurationManager.getProperty(CONF_GLOBAL_RANDOM_MODE).equals(MODE_TRACK)) { jmiShuffleModeSong.setSelected(true); } else if (ConfigurationManager.getProperty(CONF_GLOBAL_RANDOM_MODE).equals(MODE_ALBUM2)) { jmiShuffleModeAlbum2.setSelected(true); } else { jmiShuffleModeAlbum.setSelected(true); } ButtonGroup bgGlobalRandom = new ButtonGroup(); bgGlobalRandom.add(jmiShuffleModeSong); bgGlobalRandom.add(jmiShuffleModeAlbum); bgGlobalRandom.add(jmiShuffleModeAlbum2); popupGlobalRandom.add(jmiShuffleModeSong); popupGlobalRandom.add(jmiShuffleModeAlbum); popupGlobalRandom.add(jmiShuffleModeAlbum2); ddbGlobalRandom.setText(""); // no text visible jbBestof = new JajukButton(ActionManager.getAction(JajukAction.BEST_OF)); ddbNovelties = new DropDownButton(IconLoader.ICON_NOVELTIES) { private static final long serialVersionUID = 1L; @Override protected JPopupMenu getPopupMenu() { return popupNovelties; } }; ddbNovelties.setAction(ActionManager.getAction(JajukAction.NOVELTIES)); popupNovelties = new JPopupMenu(); jmiNoveltiesModeSong = new JRadioButtonMenuItem(Messages.getString("CommandJPanel.20")); jmiNoveltiesModeSong.addActionListener(this); jmiNoveltiesModeAlbum = new JRadioButtonMenuItem(Messages.getString("CommandJPanel.22")); jmiNoveltiesModeAlbum.addActionListener(this); if (ConfigurationManager.getProperty(CONF_NOVELTIES_MODE).equals(MODE_TRACK)) { jmiNoveltiesModeSong.setSelected(true); } else { jmiNoveltiesModeAlbum.setSelected(true); } ButtonGroup bgNovelties = new ButtonGroup(); bgNovelties.add(jmiNoveltiesModeSong); bgNovelties.add(jmiNoveltiesModeAlbum); popupNovelties.add(jmiNoveltiesModeSong); popupNovelties.add(jmiNoveltiesModeAlbum); ddbNovelties.setText(""); // no text visible jbNorm = new JajukButton(ActionManager.getAction(FINISH_ALBUM)); popupDDJ = new JPopupMenu(); ddbDDJ = new DropDownButton(IconLoader.ICON_DIGITAL_DJ) { private static final long serialVersionUID = 1L; @Override protected JPopupMenu getPopupMenu() { return popupDDJ; } }; ddbDDJ.setAction(ActionManager.getAction(JajukAction.DJ)); populateDJs(); // no text visible ddbDDJ.setText(""); popupWebRadio = new XJPopupMenu(Main.getWindow()); ddbWebRadio = new DropDownButton(IconLoader.ICON_WEBRADIO) { private static final long serialVersionUID = 1L; @Override protected JPopupMenu getPopupMenu() { return popupWebRadio; } }; ddbWebRadio.setAction(ActionManager.getAction(JajukAction.WEB_RADIO)); populateWebRadios(); // no text ddbWebRadio.setText(""); ddbDDJ.addToToolBar(jtbSpecial); ddbNovelties.addToToolBar(jtbSpecial); ddbGlobalRandom.addToToolBar(jtbSpecial); jtbSpecial.add(jbBestof); jtbSpecial.add(jbNorm); // Radio tool bar JToolBar jtbWebRadio = new JToolBar(); jtbWebRadio.setBorder(null); jtbWebRadio.setRollover(true); jtbWebRadio.setFloatable(false); ddbWebRadio.addToToolBar(jtbWebRadio); // Play toolbar JToolBar jtbPlay = new JToolBar(); jtbPlay.setBorder(null); jtbPlay.setFloatable(false); // add some space to get generic size jtbPlay.setRollover(true); ActionUtil.installKeystrokes( jtbPlay, ActionManager.getAction(NEXT_ALBUM), ActionManager.getAction(PREVIOUS_ALBUM)); jbPrevious = new JajukButton(ActionManager.getAction(PREVIOUS_TRACK)); jbNext = new JajukButton(ActionManager.getAction(NEXT_TRACK)); jbRew = new JPressButton(ActionManager.getAction(REWIND_TRACK)); jbPlayPause = new JajukButton(ActionManager.getAction(PLAY_PAUSE_TRACK)); jbStop = new JajukButton(ActionManager.getAction(STOP_TRACK)); jbFwd = new JPressButton(ActionManager.getAction(FAST_FORWARD_TRACK)); jtbPlay.add(jbPrevious); jtbPlay.add(jbRew); jtbPlay.add(jbPlayPause); jtbPlay.add(jbStop); jtbPlay.add(jbFwd); jtbPlay.add(jbNext); // Add items FormLayout layout = new FormLayout( // --columns "3dlu,fill:min(10dlu;p):grow(0.5), 3dlu, " + // ambience "left:p, 2dlu" + // smart toolbar ", min(0dlu;p):grow(0.04), 3dlu," + // glue " right:p, 10dlu, " + // search /modes "fill:p, 5dlu, " + // history/player "fill:min(60dlu;p):grow(0.2),3dlu", // volume/part of // history // --rows "2dlu, p, 2dlu, p, 2dlu"); // rows PanelBuilder builder = new PanelBuilder(layout); // , new // FormDebugPanel() ); CellConstraints cc = new CellConstraints(); // Add items builder.add(jtbWebRadio, cc.xyw(2, 2, 3)); // grid width = 3 builder.add(ambiencesCombo, cc.xy(2, 4)); builder.add(jtbSpecial, cc.xy(4, 4)); builder.add(jpSearch, cc.xyw(6, 2, 4)); builder.add(jpHistory, cc.xyw(10, 2, 4)); builder.add(jtbModes, cc.xy(8, 4)); builder.add(jtbPlay, cc.xy(10, 4)); builder.add(jpVolume, cc.xy(12, 4)); JPanel p = builder.getPanel(); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); add(p); // register to player events ObservationManager.register(CommandJPanel.this); // if a track is playing, display right state if (FIFO.getInstance().getCurrentFile() != null) { // update initial state update( new Event( EventSubject.EVENT_PLAYER_PLAY, ObservationManager.getDetailsLastOccurence(EventSubject.EVENT_PLAYER_PLAY))); // update the history bar update(new Event(EventSubject.EVENT_FILE_LAUNCHED)); // check if some track has been launched before the view has been // displayed update(new Event(EventSubject.EVENT_HEART_BEAT)); } // start timer timer.start(); }
/** Instantiates a new push selection action. */ PushSelectionAction() { super(Messages.getString("TracksTableView.8"), IconLoader.getIcon(JajukIcons.PUSH), true); setShortDescription(Messages.getString("TracksTableView.8")); }
SaveAsAction() { super( Messages.getString("PhysicalPlaylistRepositoryView.2"), IconLoader.getIcon(JajukIcons.SAVE_AS), true); }
/** * Display currently copied file to information panel. * * @param file */ private void showMessage(java.io.File file) { String message = Messages.getString("Device.45"); message += file.getAbsolutePath() + "]"; InformationJPanel.getInstance().setMessage(message, InformationJPanel.MessageType.INFORMATIVE); }