Example #1
0
  /**
   * @param primaryFileFilter this optional filter is immutable and supersedes any possible
   *     SearchConstraints.
   * @param constraints this optional set of constraints is used to fine-tune what the primary
   *     FileFilter accepts.
   */
  public FileList(FileFilter primaryFileFilter, SearchConstraints<File> constraints) {
    this.fileFilter = primaryFileFilter == null ? ACCEPT_ALL_FILTER : primaryFileFilter;
    setSearchConstraints(constraints);

    constrainedList.addListDataListener(
        new ListDataListener() {

          @Override
          public void intervalAdded(ListDataEvent e) {
            contentsChanged(e);
          }

          @Override
          public void intervalRemoved(ListDataEvent e) {
            contentsChanged(e);
          }

          @Override
          public void contentsChanged(ListDataEvent e) {
            SwingUtilities.invokeLater(updateContentsRunnable);
          }
        });

    setLayout(new GridBagLayout());
  }
Example #2
0
 public synchronized boolean setSearchConstraints(SearchConstraints<File> constraints) {
   if (this.searchConstraints == null && constraints == null) return false;
   if (this.searchConstraints != null
       && constraints != null
       && this.searchConstraints.equals(constraints)) return false;
   this.searchConstraints = constraints;
   constrainedList.refresh(false);
   return true;
 }
Example #3
0
  protected synchronized void updateFileListComponents() {
    throbber.setVisible(!finishedSearch);
    removeAll();
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = getColumnCount() - 1;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.EAST;
    add(throbber, c);

    c.gridx = 0;
    c.weightx = 1;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.BOTH;
    if (constrainedList.getSize() == 0) {
      if (finishedSearch) {
        add(emptyLabel, c);
      } else {
        add(searchingLabel, c);
      }
    }

    for (int a = 0; a < constrainedList.getSize(); a++) {
      File file = constrainedList.getElementAt(a);
      JComponent jc = componentCache.get(file);
      if (jc == null) {
        jc = createComponent(file);
        jc.putClientProperty(KEY_FILE, file);
        componentCache.put(file, jc);
      }

      add(jc, c);
      c.gridx = (c.gridx + 1) % getColumnCount();
      if (c.gridx == 0) c.gridy++;
    }
    c.gridy++;
    c.weighty = 1;
    add(fluff, c);

    revalidate();
    repaint();
  }
Example #4
0
 /**
  * Remove a ListDataListener.
  *
  * @param listListener
  * @see #addListDataListener(ListDataListener)
  */
 public void removeListDataListener(ListDataListener listListener) {
   constrainedList.removeListDataListener(listListener);
 }
Example #5
0
 /**
  * Add a ListDataListener to be notified when the visible files change.
  *
  * @param listListener
  * @see #removeListDataListener(ListDataListener)
  */
 public void addListDataListener(ListDataListener listListener) {
   constrainedList.addListDataListener(listListener);
 }