protected void deleteCurrent() {
      int num_logs_deleted = 0;
      Set<Group> groups_changed = new HashSet<>();

      for (TreePath tp : display.logTree.getSelectionPaths()) {
        if (tp.getPathCount() == 3) {
          Group group = (Group) tp.getPath()[1];
          LogReference reference = (LogReference) tp.getLastPathComponent();

          Debug.warn("deleting {%s} from {%s}", reference, group);
          group.remove(reference);

          ++num_logs_deleted;
          groups_changed.add(group);
        } else {
          Debug.warn("cannot delete {%s}", tp.getLastPathComponent());
        }
      }

      for (Group group : groups_changed) {
        TreeModelEvent removeEvent = new TreeModelEvent(this, new Object[] {this, group});

        for (TreeModelListener listener : listeners) listener.treeStructureChanged(removeEvent);
      }

      ToolMessage.displayAndPrint("deleted %d logs", num_logs_deleted);
    }
  /**
   * Notifies all registered TreeModelListeners of a change.
   *
   * @param event The TreeModelEvent to notify the listeners with.
   * @param action The action that is being reported.
   */
  private void notifyTreeModelListeners(TreeModelEvent tme, int action) {
    if (treeModelListeners != null) {
      TreeModelListener o;
      Iterator iterator;

      // Notify each listener.
      iterator = treeModelListeners.values().iterator();
      while (iterator.hasNext()) {
        o = ((TreeModelListener) ((WeakReference) iterator.next()).get());
        switch (action) {
          case NODES_CHANGED:
            ((TreeModelListener) o).treeNodesChanged(tme);
            break;
          case NODES_INSERTED:
            ((TreeModelListener) o).treeNodesInserted(tme);
            break;
          case NODES_REMOVED:
            ((TreeModelListener) o).treeNodesRemoved(tme);
            break;
          case STRUCTURE_CHANGED:
            ((TreeModelListener) o).treeStructureChanged(tme);
        }
      }
    }
  }
 public final void update() {
   this.list = swf.getAS3Packs();
   TreeModelEvent event = new TreeModelEvent(this, new TreePath(root));
   for (TreeModelListener listener : listeners) {
     listener.treeStructureChanged(event);
   }
 }
Example #4
0
 private void fireStructureChangedEvent(TreeModelEvent e) {
   TreeModelListener[] listeners =
       listenerList.toArray(new TreeModelListener[listenerList.size()]);
   for (TreeModelListener listener : listeners) {
     listener.treeStructureChanged(e);
   }
 }
 private void fireTreeStructureChanged(final Object oldRoot) {
   treeModelListeners.size();
   final TreeModelEvent e = new TreeModelEvent(this, new Object[] {oldRoot});
   for (final TreeModelListener tml : treeModelListeners) {
     tml.treeStructureChanged(e);
   }
 }
  /**
   * Hides nodes from the tree that do not match <code>text</code>.
   *
   * @param text search text
   */
  public void filterByText(String text) {
    text = normalize(text);
    if (text == null || text.length() == 0) {
      visibleNodes = null;
    } else {
      visibleNodes = new HashSet<Object>();
      String[] keywords = text.split(" ");
      for (int i = 0; i < keywords.length; i++) {
        SortedMap<String, List<Object>> nodeListByKey = getMatches(text);
        if (i == 0) {
          for (List<Object> nodes : nodeListByKey.values()) {
            visibleNodes.addAll(nodes);
          }
        } else {
          Set<Object> allNew = new HashSet<Object>();
          for (List<Object> nodes : nodeListByKey.values()) {
            allNew.addAll(nodes);
          }
          visibleNodes.retainAll(allNew);
        }
      }
      ensureParentsVisible();
    }

    TreeModelEvent event = new TreeModelEvent(this, new Object[] {model.getRoot()});
    for (TreeModelListener listener : listeners) {
      listener.treeStructureChanged(event);
    }
  }
    protected void treeReSorted() {
      Debug.event("LogModel tree resorted");

      TreeModelEvent tme = new TreeModelEvent(this, new Object[] {this});
      for (TreeModelListener l : listeners) {
        l.treeStructureChanged(tme);
      }
    }
 public void fireTreeStructureChanged(TreePath path) {
   TreeModelEvent event = new TreeModelEvent(this, path);
   synchronized (listeners) {
     for (TreeModelListener listener : listeners) {
       listener.treeStructureChanged(event);
     }
   }
 }
    protected void showReferenceAdded(LogReference reference) {
      Debug.event("LogModel reference added");

      TreeModelEvent tme = new TreeModelEvent(this, new Object[] {this, reference.container});
      for (TreeModelListener l : listeners) {
        l.treeStructureChanged(tme);
      }
    }
    public void treeStructureChanged(TreeModelEvent event) {
      if (!isVisible(event.getTreePath().getLastPathComponent())) {
        return;
      }

      for (TreeModelListener listener : listeners) {
        listener.treeStructureChanged(event);
      }
    }
    protected void showGroupAdded(Group group) {
      // TreeModelEvent tme = new TreeModelEvent(this, new Object[]{root},
      // new int[]{AllGroups.allGroups.indexOf(group)},
      // new Object[]{group});
      Debug.event("LogModel group added");

      TreeModelEvent changed = new TreeModelEvent(this, new Object[] {this});
      for (TreeModelListener listener : listeners) listener.treeStructureChanged(changed);
    }
Example #12
0
  /**
   * Send an event to the listeners instructing that the largescale structure of nodes has changed.
   *
   * @param evt The event to be sent
   */
  private void fireTreeStructureChanged(TreeModelEvent evt) {
    Iterator itr = listeners.iterator();
    TreeModelListener l;

    while (itr.hasNext()) {
      l = (TreeModelListener) itr.next();
      try {
        l.treeStructureChanged(evt);
      } catch (Exception e) {
        I18nManager intl_mgr = I18nManager.getManager();
        String msg = intl_mgr.getString(STRUCTURE_CHANGE_ERR_PROP) + l;

        errorReporter.errorReport(msg, e);
      }
    }
  }
 @Override
 public void folderRefreshed(Folder folder) {
   TreeModelEvent e = makeChangeEvent(folder);
   final RepositoryTreeUtil treeUtil = new RepositoryTreeUtil();
   if (parentTree != null) {
     treeUtil.saveExpansionState(parentTree);
   }
   for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
     l.treeStructureChanged(e);
   }
   treeUtil.locateExpandedEntries();
   if (parentTree != null) {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             treeUtil.restoreExpansionState(parentTree);
           }
         });
   }
 }
  private void fireStructureChanged(TreeModelEvent e) {
    for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {

      l.treeStructureChanged(e);
    }
  }
Example #15
0
 public void signalStructureChanged() {
   list.clear();
   world.populate(list);
   final TreeModelEvent e = new TreeModelEvent(this, new Object[] {root});
   for (final TreeModelListener l : listeners) l.treeStructureChanged(e);
 }
 public void reload() {
   TreeModelEvent event = new TreeModelEvent(this, new Object[] {model.getRoot()});
   for (TreeModelListener listener : listeners) {
     listener.treeStructureChanged(event);
   }
 }
 /**
  * Notify listeners that the structure of expanded node has changed.
  *
  * @param expandedPath path to expanded node
  * @param source source of this expansion event.
  */
 public void fireStructureChange(Object source, TreePath expandedPath) {
   TreeModelListener[] listeners = getTreeModelListeners();
   for (TreeModelListener listener : listeners) {
     listener.treeStructureChanged(new TreeModelEvent(source, expandedPath));
   }
 }
 /**
  * Notifies the tree that the children of given node have been changed.
  *
  * @param tree
  * @param node
  */
 public void nodeChildrenChanged(AbstractTree tree, TreeNode node) {
   TreeModelEvent event = new TreeModelEvent(this, pathFromNode(tree, node));
   for (TreeModelListener l : listeners) {
     l.treeStructureChanged(event);
   }
 }
 private void fireDataChanged() {
   TreeModelEvent event = new TreeModelEvent(this, (TreePath) null);
   for (TreeModelListener treeModelListener : treeModelListeners) {
     treeModelListener.treeStructureChanged(event);
   }
 }