/** 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); }
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)); } }
/** * 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>"); } }