Example usage for javax.swing.event TreeModelListener treeStructureChanged

List of usage examples for javax.swing.event TreeModelListener treeStructureChanged

Introduction

In this page you can find the example usage for javax.swing.event TreeModelListener treeStructureChanged.

Prototype

void treeStructureChanged(TreeModelEvent e);

Source Link

Document

Invoked after the tree has drastically changed structure from a given node down.

Usage

From source file:CreatingTreeModel.java

public void fireTreeStructureChanged(TreeModelEvent e) {
    Enumeration listenerCount = listeners.elements();
    while (listenerCount.hasMoreElements()) {
        TreeModelListener listener = (TreeModelListener) listenerCount.nextElement();
        listener.treeStructureChanged(e);
    }//from   w ww. j  a v  a  2 s  . c  o m

}

From source file:gov.nij.er.ui.RawDataFilteredTreeModel.java

/**
 * Refresh the model to recognize new data, and notify any listeners
 *//*from   w w w .  j  a  v  a  2s . c o  m*/
public void updateModel() {
    LOG.debug("Updating model, isFiltered=" + isFiltered);
    for (TreeModelListener l : listeners) {
        l.treeStructureChanged(new TreeModelEvent(this, new Object[] { getRoot(), }));
    }
}

From source file:gov.nij.er.ui.RecordTreeModel.java

/**
 * Update the model with data and notify listeners
 *///from  ww  w  .  j  a va  2  s .co  m
public void updateModel() {
    root = new DefaultMutableTreeNode(ROOT_NODE_LABEL);
    if (records != null) {
        Collections.sort(records, recordSorter);
        for (RecordWrapper record : records) {

            DefaultMutableTreeNode node = new RecordTreeNode(record);
            root.add(node);
        }
        LOG.debug("Initializing tree model with new records");
        for (TreeModelListener l : listeners) {
            l.treeStructureChanged(new TreeModelEvent(this, new Object[] { root, }));
        }
    }
}

From source file:GenealogyExample.java

/**
 * The only event raised by this model is TreeStructureChanged with the root
 * as path, i.e. the whole tree has changed.
 *//*from   w ww.  j  a v a2s  .c om*/
protected void fireTreeStructureChanged(Person oldRoot) {
    int len = treeModelListeners.size();
    TreeModelEvent e = new TreeModelEvent(this, new Object[] { oldRoot });
    for (TreeModelListener tml : treeModelListeners) {
        tml.treeStructureChanged(e);
    }
}

From source file:com.haulmont.cuba.desktop.gui.data.TreeModelAdapter.java

public TreeModelAdapter(HierarchicalDatasource datasource, CaptionMode captionMode, String captionProperty,
        boolean autoRefresh) {

    this.datasource = datasource;
    this.captionMode = captionMode;

    setCaptionProperty(captionProperty);

    this.autoRefresh = autoRefresh;

    this.metadataTools = AppBeans.get(MetadataTools.NAME);

    collectionChangeListener = e -> {
        switch (e.getOperation()) {
        case CLEAR:
        case REFRESH:
        case ADD:
        case REMOVE:
            Object[] path = { getRoot() };
            for (TreeModelListener listener : treeModelListeners) {
                TreeModelEvent ev = new TreeModelEvent(this, path);
                listener.treeStructureChanged(ev);
            }/*ww  w  . jav  a 2s  .c  om*/
            break;

        case UPDATE:
            for (Object item : e.getItems()) {
                TreePath treePath = getTreePath(item);
                for (TreeModelListener listener : treeModelListeners) {
                    TreeModelEvent ev = new TreeModelEvent(this, treePath.getPath());
                    listener.treeNodesChanged(ev);
                }
            }
            break;
        }
    };
    //noinspection unchecked
    datasource.addCollectionChangeListener(
            new WeakCollectionChangeListener(datasource, collectionChangeListener));
}

From source file:com.igormaznitsa.mindmap.model.MindMap.java

private void fireModelChanged() {
    final Topic rootTopic = this.root;
    final TreeModelEvent evt = new TreeModelEvent(this,
            rootTopic == null ? (Topic[]) null : rootTopic.getPath());
    for (final TreeModelListener l : this.treeListeners) {
        l.treeStructureChanged(evt);
    }/*from   w  w w  .  j a  va  2s. com*/
}

From source file:gov.nij.er.ui.RawDataFilteredTreeModel.java

RawDataFilteredTreeModel(RecordTreeModel rawDataTreeModel) {
    this.rawDataTreeModel = rawDataTreeModel;
    rawDataTreeModel.addTreeModelListener(new TreeModelListener() {

        public void treeNodesChanged(TreeModelEvent e) {
            if (!isFiltered) {
                for (TreeModelListener l : listeners) {
                    l.treeNodesChanged(e);
                }//from   w  w w  .  ja  va2 s .  c  o m
            }
        }

        public void treeNodesInserted(TreeModelEvent e) {
            if (!isFiltered) {
                for (TreeModelListener l : listeners) {
                    l.treeNodesInserted(e);
                }
            }
        }

        public void treeNodesRemoved(TreeModelEvent e) {
            if (!isFiltered) {
                for (TreeModelListener l : listeners) {
                    l.treeNodesRemoved(e);
                }
            }
        }

        public void treeStructureChanged(TreeModelEvent e) {
            if (!isFiltered) {
                for (TreeModelListener l : listeners) {
                    l.treeStructureChanged(e);
                }
            }
        }
    });
    root = new DefaultMutableTreeNode(ROOT_NODE_LABEL);

}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModel.java

public void fireTreeDataChanged() {
    final TreeModelEvent event = new TreeModelEvent(this, new TreePath(root));
    final TreeModelListener[] modelListeners = listenerList.getListeners(TreeModelListener.class);
    for (int i = 0; i < modelListeners.length; i++) {
        final TreeModelListener modelListener = modelListeners[i];
        modelListener.treeStructureChanged(event);
    }/*w w  w.j av  a  2 s.  c o  m*/
}

From source file:org.photovault.swingui.PhotoFolderTreeModel.java

/**
   Sends a strucure changed event to all listeners of this object. Currently only this type of
   event is supported, in future also other types of tree model events should be considered.
*///from w  w w . j  a  va2  s.  c  om

protected void fireTreeModelEvent(TreeModelEvent e) {
    Iterator iter = treeModelListeners.iterator();
    final TreeModelEvent fe = e;
    while (iter.hasNext()) {
        final TreeModelListener l = (TreeModelListener) iter.next();
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                l.treeStructureChanged(fe);
            }
        });
        log.debug("Sending treeModelEvent");
    }
}