use of javax.swing.tree.DefaultMutableTreeNode in project processing by processing.
the class ExamplesFrame method buildContribTree.
protected DefaultMutableTreeNode buildContribTree() {
DefaultMutableTreeNode contribExamplesNode = new DefaultMutableTreeNode(Language.text("examples.contributed"));
try {
File[] subfolders = ContributionType.EXAMPLES.listCandidates(examplesContribFolder);
if (subfolders != null) {
for (File sub : subfolders) {
StringDict props = Contribution.loadProperties(sub, ContributionType.EXAMPLES);
if (props != null) {
if (ExamplesContribution.isCompatible(base, props)) {
DefaultMutableTreeNode subNode = new DefaultMutableTreeNode(props.get("name"));
if (base.addSketches(subNode, sub, true)) {
contribExamplesNode.add(subNode);
// TODO there has to be a simpler way of handling this along
// with addSketches() as well [fry 150811]
int exampleNodeNumber = -1;
// The contrib may have other items besides the examples folder
for (int i = 0; i < subNode.getChildCount(); i++) {
if (subNode.getChildAt(i).toString().equals("examples")) {
exampleNodeNumber = i;
}
}
if (exampleNodeNumber != -1) {
TreeNode exampleNode = subNode.getChildAt(exampleNodeNumber);
subNode.remove(exampleNodeNumber);
int count = exampleNode.getChildCount();
for (int j = 0; j < count; j++) {
subNode.add((DefaultMutableTreeNode) exampleNode.getChildAt(0));
}
}
// if (subNode.getChildCount() != 1) {
// System.err.println("more children than expected when one is enough");
// }
// TreeNode exampleNode = subNode.getChildAt(0);
// subNode.add((DefaultMutableTreeNode) exampleNode.getChildAt(0));
}
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
return contribExamplesNode;
}
use of javax.swing.tree.DefaultMutableTreeNode in project jreversepro by akkumar.
the class ClassEditPanel method createModel.
/**
* Creates the tree model of the GUI version.
*
* @param aParent
* Parent Frame
* @param aFileName
* Name of the File.
* @param aChildren
* Children nodes of the tree root.
**/
public void createModel(JFrame aParent, String aFileName, List<String> aChildren) {
mRoot.removeAllChildren();
DefaultMutableTreeNode ClassName = new DefaultMutableTreeNode(aFileName);
for (String str : aChildren) {
ClassName.add(new DefaultMutableTreeNode(str));
}
mRoot.add(ClassName);
SwingUtilities.updateComponentTreeUI(aParent);
mTreeFieldMethod.expandRow(1);
}
use of javax.swing.tree.DefaultMutableTreeNode in project sonarqube by SonarSource.
the class ScannerReportViewerApp method loadComponents.
private void loadComponents() {
int rootComponentRef = metadata.getRootComponentRef();
Component component = reader.readComponent(rootComponentRef);
DefaultMutableTreeNode project = createNode(component);
loadChildren(component, project);
getComponentTree().setModel(new DefaultTreeModel(project));
}
use of javax.swing.tree.DefaultMutableTreeNode in project sonarqube by SonarSource.
the class ScannerReportViewerApp method loadChildren.
private void loadChildren(Component parentComponent, DefaultMutableTreeNode parentNode) {
for (int ref : parentComponent.getChildRefList()) {
Component child = reader.readComponent(ref);
DefaultMutableTreeNode childNode = createNode(child);
parentNode.add(childNode);
loadChildren(child, childNode);
}
}
use of javax.swing.tree.DefaultMutableTreeNode in project qi4j-sdk by Qi4j.
the class EntityViewer method treePanelValueChanged.
/**
* Event Handler for TreePanel
*
* @param evt the Event
*/
public void treePanelValueChanged(TreeSelectionEvent evt) {
TreePath path = evt.getPath();
Object source = path.getLastPathComponent();
if (source == null) {
return;
}
DefaultMutableTreeNode node = (DefaultMutableTreeNode) source;
Object obj = node.getUserObject();
if (obj == null) {
return;
}
Class<?> clazz = obj.getClass();
if (EntityDetailDescriptor.class.isAssignableFrom(clazz)) {
EntityDetailDescriptor entityDesc = (EntityDetailDescriptor) obj;
Class entityType = first(entityDesc.descriptor().types());
// Update the selected item on the combo box, which in turn update the properties table
ComboBoxModel comboModel = entitiesCombo.getModel();
int index = -1;
for (int i = 0; i < comboModel.getSize(); i++) {
EntityDetailDescriptor entityDesc1 = (EntityDetailDescriptor) comboModel.getElementAt(i);
Class entityType1 = first(entityDesc1.descriptor().types());
if (entityType1.equals(entityType)) {
index = i;
break;
}
}
if (index >= 0) {
entitiesCombo.setSelectedIndex(index);
}
}
}
Aggregations