Search in sources :

Example 46 with DefaultMutableTreeNode

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;
}
Also used : StringDict(processing.data.StringDict) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) IOException(java.io.IOException) File(java.io.File) Point(java.awt.Point)

Example 47 with DefaultMutableTreeNode

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);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 48 with DefaultMutableTreeNode

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));
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Component(org.sonar.scanner.protocol.output.ScannerReport.Component)

Example 49 with DefaultMutableTreeNode

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);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Component(org.sonar.scanner.protocol.output.ScannerReport.Component)

Example 50 with DefaultMutableTreeNode

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);
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ComboBoxModel(javax.swing.ComboBoxModel)

Aggregations

DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)692 TreePath (javax.swing.tree.TreePath)185 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)98 ArrayList (java.util.ArrayList)51 Nullable (org.jetbrains.annotations.Nullable)50 TreeNode (javax.swing.tree.TreeNode)42 Test (org.junit.Test)39 JTree (javax.swing.JTree)38 NotNull (org.jetbrains.annotations.NotNull)32 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 JScrollPane (javax.swing.JScrollPane)25 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)23 TreeSelectionListener (javax.swing.event.TreeSelectionListener)23 Module (com.intellij.openapi.module.Module)20 File (java.io.File)20 Tree (com.intellij.ui.treeStructure.Tree)19 Enumeration (java.util.Enumeration)19 MouseEvent (java.awt.event.MouseEvent)18 IOException (java.io.IOException)17 MProduct (org.compiere.model.MProduct)17