/** @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;
 }
Пример #2
0
 /** Perform a search when user stop to type in the search combo for 2 sec or pressed enter */
 private void search() {
   try {
     bNeedSearch = false;
     setEnabled(false); // no typing during search
     if (sTyped.length() >= MIN_CRITERIA_LENGTH) {
       // second test to get sure user didn't
       // typed before entering this method
       TreeSet<SearchResult> tsResu = TrackManager.getInstance().search(sTyped.toString());
       // Add web radio names
       tsResu.addAll(WebRadioManager.getInstance().search(sTyped.toString()));
       if (tsResu.size() > 0) {
         DefaultListModel model = new DefaultListModel();
         alResults = new ArrayList<SearchResult>();
         alResults.addAll(tsResu);
         for (SearchResult sr : tsResu) {
           model.addElement(sr);
         }
         jlist = new JList(model);
         jlist.setLayoutOrientation(JList.VERTICAL);
         jlist.setCellRenderer(new SearchListRenderer());
         PopupFactory factory = PopupFactory.getSharedInstance();
         JScrollPane jsp = new JScrollPane(jlist);
         int width = (int) ((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.7f);
         jsp.setMinimumSize(new Dimension(width, 250));
         jsp.setPreferredSize(new Dimension(width, 250));
         jsp.setMaximumSize(new Dimension(width, 250));
         jlist.setSelectionMode(0);
         jlist.addListSelectionListener(lsl);
         jsp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
         if (popup != null) {
           popup.hide();
         }
         // take upper-left point relative to the
         // textfield
         Point point = new Point(0, 0);
         // take absolute coordonates in the screen (popups works
         // only on absolute coordonates in opposition to swing
         // widgets)
         SwingUtilities.convertPointToScreen(point, this);
         popup =
             factory.getPopup(
                 this, jsp, (int) point.getX() + 500 - (width), (int) point.getY() - 250);
         popup.show();
       } else {
         if (popup != null) {
           popup.hide();
         }
       }
     }
     requestFocusInWindow();
   } catch (Exception e) {
     Log.error(e);
   } finally { // make sure to enable search box in all cases
     setEnabled(true);
   }
 }
 /**
  * Gets the track.
  *
  * @return the track
  */
 private Track getTrack() {
   return TrackManager.getInstance()
       .registerTrack(
           "name",
           getAlbum(),
           getGenre(),
           getArtist(),
           123,
           getYear(),
           1,
           JUnitHelpers.getType(),
           1);
 }