コード例 #1
0
 /**
  * Test device accessibility.
  *
  * @return true if the device is available
  */
 public boolean test() {
   UtilGUI.waiting(); // waiting cursor
   boolean bOK = false;
   boolean bWasMounted = bMounted; // store mounted state of device before
   // mount test
   try {
     if (!bMounted) {
       mount(true);
     }
   } catch (final Exception e) {
     UtilGUI.stopWaiting();
     return false;
   }
   if (getLongValue(Const.XML_TYPE) != 5) { // not a remote device
     final File file = new File(sUrl);
     if (file.exists() && file.canRead()) { // see if the url exists
       // and is readable
       // check if this device was void
       boolean bVoid = true;
       for (org.jajuk.base.File f : FileManager.getInstance().getFiles()) {
         if (f.getDirectory().getDevice().equals(this)) {
           // at least one field in this device
           bVoid = false;
           break;
         }
       }
       if (!bVoid) { // if the device is not supposed to be void,
         // check if it is the case, if no, the device
         // must not be unix-mounted
         if (file.list().length > 0) {
           bOK = true;
         }
       } else { // device is void, OK we assume it is accessible
         bOK = true;
       }
     }
   } else {
     bOK = false; // TBI
   }
   // unmount the device if it was mounted only for the test
   if (!bWasMounted) {
     try {
       unmount(false, false);
     } catch (final Exception e1) {
       Log.error(e1);
     }
   }
   UtilGUI.stopWaiting();
   return bOK;
 }
コード例 #2
0
  /**
   * Invoked when an action occurs.
   *
   * @param evt
   */
  @Override
  public void perform(ActionEvent evt) {

    boolean b = Conf.getBoolean(Const.CONF_STATE_REPEAT);

    UtilGUI.setRepeatSingleGui(!b);
    QueueModel.setRepeatModeToAll(false);

    if (!b) { // enabled button
      // if FIFO is not void, repeat over current item
      StackItem item = QueueModel.getCurrentItem();
      if (item != null) {
        item.setRepeat(true);
      }
    } else { // disable repeat mode
      if (Conf.getBoolean(Const.CONF_DROP_PLAYED_TRACKS_FROM_QUEUE)) {
        // remove tracks before current position
        QueueModel.remove(0, QueueModel.getIndex() - 1);
        QueueModel.setIndex(0); // select first track
      }
    }
    // computes planned tracks
    QueueModel.computesPlanned(false);
    // Refresh Queue View
    ObservationManager.notify(new JajukEvent(JajukEvents.QUEUE_NEED_REFRESH));
  }
コード例 #3
0
 /*
  * (non-Javadoc)
  *
  * @see org.jajuk.ui.actions.JajukAction#perform(java.awt.event.ActionEvent)
  */
 @Override
 public void perform(ActionEvent evt) throws Exception {
   /*
    * If slimbar is visible, hide it and show the main window. Note that both main window and
    * slimbar can be displayed at the same time: If the slimbar is visible and user display main
    * window by right clicking on the tray, the main window is displayed, this is a normal behavior
    */
   WindowStateDecorator sdSlimbar = JajukSlimbar.getInstance().getWindowStateDecorator();
   WindowStateDecorator sdMainWindow = JajukMainWindow.getInstance().getWindowStateDecorator();
   if (sdSlimbar.isDisplayed()) {
     // close the previous window before displaying the other
     sdSlimbar.display(false);
     sdMainWindow.display(true);
     // Update the icon according to status
     setIcon(IconLoader.getIcon(JajukIcons.SLIM_WINDOW));
   } else {
     sdMainWindow.display(false);
     sdSlimbar.display(true);
     // Update the icon according to status
     setIcon(IconLoader.getIcon(JajukIcons.FULL_SCREEN));
   }
   // Store window-type displayed (useful for tray display/hide feature for ie.)
   UtilGUI.storeWindowSate();
   // Notify that slimbar visibility change (menu bar is interested in it)
   ObservationManager.notify(new JajukEvent(JajukEvents.SLIMBAR_VISIBILTY_CHANGED));
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
 /* (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);
 }
コード例 #6
0
  /*
   * (non-Javadoc)
   *
   * @see org.jajuk.ui.views.IView#populate()
   */
  @Override
  public void initUI() {
    tabs = new JTabbedPane();
    // Remove tab border, see
    // http://forum.java.sun.com/thread.jspa?threadID=260746&messageID=980405
    class MyTabbedPaneUI extends javax.swing.plaf.basic.BasicTabbedPaneUI {
      @Override
      protected Insets getContentBorderInsets(int tabPlacement) {
        return new Insets(0, 0, 0, 0);
      }

      @Override
      protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
        // nothing to do here...
      }
    }
    // Now use the new TabbedPaneUI
    tabs.setUI(new MyTabbedPaneUI());
    // Fill tabs with empty tabs
    tabs.addTab(
        Messages.getString("SuggestionView.1"),
        UtilGUI.getCentredPanel(new JLabel(Messages.getString("WikipediaView.3"))));
    tabs.addTab(
        Messages.getString("SuggestionView.2"),
        UtilGUI.getCentredPanel(new JLabel(Messages.getString("WikipediaView.3"))));
    tabs.addTab(
        Messages.getString("SuggestionView.5"),
        UtilGUI.getCentredPanel(new JLabel(Messages.getString("WikipediaView.3"))));
    tabs.addTab(
        Messages.getString("SuggestionView.3"), new JLabel(Messages.getString("SuggestionView.7")));
    tabs.addTab(
        Messages.getString("SuggestionView.4"), new JLabel(Messages.getString("SuggestionView.7")));
    // Refresh tabs on demand only, add changelisterner after tab creation to
    // avoid that the stored tab is overwrited at startup
    tabs.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent arg0) {
            refreshLastFMCollectionTabs();
            // store the selected tab
            Conf.setProperty(
                getClass().getName()
                    + "_"
                    + ((getPerspective() == null) ? "solo" : getPerspective().getID()),
                Integer.toString(tabs.getSelectedIndex()).toString());
          }
        });
    if (Conf.containsProperty(
        getClass().getName()
            + "_"
            + ((getPerspective() == null) ? "solo" : getPerspective().getID()))) {
      int index =
          Conf.getInt(
              getClass().getName()
                  + "_"
                  + ((getPerspective() == null) ? "solo" : getPerspective().getID()));
      if (index > 0 && index < tabs.getTabCount()) {
        tabs.setSelectedIndex(index);
      }
    }
    // Add panels
    refreshLocalCollectionTabs();
    // Add tabs
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    add(tabs);
    // Look for events
    ObservationManager.register(this);
  }