use of javax.swing.tree.TreeModel in project processing by processing.
the class ExamplesFrame method expandTree.
void expandTree(JTree tree, Object object, String[] items, DefaultMutableTreeNode[] nodes, int index) {
// if (object == null) {
// object = model.getRoot();
// }
TreeModel model = tree.getModel();
if (index == 0) {
nodes[0] = (DefaultMutableTreeNode) model.getRoot();
expandTree(tree, nodes[0], items, nodes, 1);
} else if (index < items.length) {
// String item = items[0];
// TreeModel model = object.getModel();
// System.out.println(object.getClass().getName());
DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
int count = model.getChildCount(node);
// System.out.println("child count is " + count);
for (int i = 0; i < count; i++) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode) model.getChild(node, i);
if (items[index].equals(child.getUserObject())) {
nodes[index] = child;
expandTree(tree, child, items, nodes, index + 1);
}
}
} else {
// last one
// PApplet.println(nodes);
tree.expandPath(new TreePath(nodes));
}
}
use of javax.swing.tree.TreeModel in project gephi by gephi.
the class ReportPanel method fillIssues.
private void fillIssues(Report report) {
final List<Issue> issues = new ArrayList<>();
Iterator<Issue> itr = report.getIssues(ISSUES_LIMIT);
while (itr.hasNext()) {
issues.add(itr.next());
}
if (issues.isEmpty()) {
JLabel label = new JLabel(NbBundle.getMessage(getClass(), "ReportPanel.noIssues"));
label.setHorizontalAlignment(SwingConstants.CENTER);
tab1ScrollPane.setViewportView(label);
} else {
//Busy label
final BusyUtils.BusyLabel busyLabel = BusyUtils.createCenteredBusyLabel(tab1ScrollPane, "Retrieving issues...", issuesOutline);
//Thread
Thread thread = new Thread(fillingThreads, new Runnable() {
@Override
public void run() {
busyLabel.setBusy(true);
final TreeModel treeMdl = new IssueTreeModel(issues);
final OutlineModel mdl = DefaultOutlineModel.createOutlineModel(treeMdl, new IssueRowModel(), true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
issuesOutline.setRootVisible(false);
issuesOutline.setRenderDataProvider(new IssueRenderer());
issuesOutline.setModel(mdl);
busyLabel.setBusy(false);
}
});
}
}, "Report Panel Issues Outline");
if (NbPreferences.forModule(ReportPanel.class).getBoolean(SHOW_ISSUES, true)) {
thread.start();
}
}
}
use of javax.swing.tree.TreeModel in project pcgen by PCGen.
the class NotesView method initTree.
//Initialization methods
private void initTree() {
dataDir.listFiles();
root = new NotesTreeNode(dataDir.getName(), dataDir, notesTree);
TreeModel model = new DefaultTreeModel(root);
notesTree.setModel(model);
notesTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent evt) {
notesTreeActionPerformed();
}
});
notesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
notesTree.setEditable(true);
model.addTreeModelListener(new TreeModelListener() {
@Override
public void treeNodesChanged(TreeModelEvent e) {
notesTreeNodesChanged();
}
@Override
public void treeNodesInserted(TreeModelEvent e) {
// TODO: Method does nothing?
}
@Override
public void treeNodesRemoved(TreeModelEvent e) {
// TODO: Method does nothing?
}
@Override
public void treeStructureChanged(TreeModelEvent e) {
// TODO: Method does nothing?
}
});
}
use of javax.swing.tree.TreeModel in project intellij-community by JetBrains.
the class MavenArtifactSearchPanel method doSearch.
private void doSearch(String searchText) {
MavenSearcher searcher = myClassMode ? new MavenClassSearcher() : new MavenArtifactSearcher(USE_LUCENE_INDEXES);
List<MavenArtifactSearchResult> result = searcher.search(myProject, searchText, MAX_RESULT);
resortUsingDependencyVersionMap(result);
final TreeModel model = new MyTreeModel(result);
SwingUtilities.invokeLater(() -> {
if (!myDialog.isVisible())
return;
myResultList.getEmptyText().setText("No results");
myResultList.setModel(model);
myResultList.setSelectionRow(0);
myResultList.setPaintBusy(false);
});
}
use of javax.swing.tree.TreeModel in project zaproxy by zaproxy.
the class JCheckBoxTreeUnitTest method shouldSetATreeModelWithUndefinedRoot.
@Test
public void shouldSetATreeModelWithUndefinedRoot() {
// Given
TreeModel treeModel = new DefaultTreeModel(null);
JCheckBoxTree checkBoxTree = new JCheckBoxTree();
// When
checkBoxTree.setModel(treeModel);
// Then
assertThat(checkBoxTree.getModel(), is(equalTo(treeModel)));
}
Aggregations