Example usage for javax.swing.tree DefaultMutableTreeNode add

List of usage examples for javax.swing.tree DefaultMutableTreeNode add

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode add.

Prototype

public void add(MutableTreeNode newChild) 

Source Link

Document

Removes newChild from its parent and makes it a child of this node by adding it to the end of this node's child array.

Usage

From source file:de.erdesignerng.visual.common.OutlineComponent.java

private void buildSubjectAreasChildren(Model aModel, DefaultMutableTreeNode aParent, List<SubjectArea> aList) {
    DefaultMutableTreeNode theSANode = new DefaultMutableTreeNode(TreeGroupingElement.SUBJECTAREAS);
    aList.stream().filter(theArea -> isVisible(theArea)).forEach(theArea -> {
        DefaultMutableTreeNode theAreaNode = new DefaultMutableTreeNode(theArea);
        theSANode.add(theAreaNode);

        registerUserObject(theArea, theAreaNode);

        List<Table> theSATables = new ArrayList<>();
        theSATables.addAll(theArea.getTables());
        Collections.sort(theSATables, new BeanComparator("name"));
        buildTablesChildren(aModel, theAreaNode, theSATables);

        List<View> theSAViews = new ArrayList<>();
        theSAViews.addAll(theArea.getViews());
        Collections.sort(theSAViews, new BeanComparator("name"));
        buildViewsChildren(aModel, theAreaNode, theSAViews);

    });/*from   ww  w.  ja  v  a 2s .  c o  m*/
    aParent.add(theSANode);
}

From source file:de.erdesignerng.visual.common.OutlineComponent.java

private void buildDomainsChildren(Model aModel, DefaultMutableTreeNode aParent, List<Domain> aDomainList) {
    DefaultMutableTreeNode theDomainsNode = new DefaultMutableTreeNode(TreeGroupingElement.DOMAINS);
    aDomainList.stream().filter(theDomain -> isVisible(theDomain)).forEach(theDomain -> {
        DefaultMutableTreeNode theDomainNode = new DefaultMutableTreeNode(theDomain);
        theDomainsNode.add(theDomainNode);

        registerUserObject(theDomain, theDomainNode);

        updateDomainTreeNode(aModel, theDomain, theDomainNode);
    });//from w ww .  jav a 2s.  co m
    aParent.add(theDomainsNode);
}

From source file:org.jfree.chart.demo.SuperDemo.java

private TreeModel createTreeModel() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("JFreeChart");
    defaultmutabletreenode.add(createAreaChartsNode());
    defaultmutabletreenode.add(createBarChartsNode());
    defaultmutabletreenode.add(createCombinedAxisChartsNode());
    defaultmutabletreenode.add(createFinancialChartsNode());
    defaultmutabletreenode.add(createGanttChartsNode());
    defaultmutabletreenode.add(createLineChartsNode());
    defaultmutabletreenode.add(createMeterChartsNode());
    defaultmutabletreenode.add(createMultipleAxisChartsNode());
    defaultmutabletreenode.add(createOverlaidChartsNode());
    defaultmutabletreenode.add(createPieChartsNode());
    defaultmutabletreenode.add(createStatisticalChartsNode());
    defaultmutabletreenode.add(createTimeSeriesChartsNode());
    defaultmutabletreenode.add(createXYChartsNode());
    defaultmutabletreenode.add(createMiscellaneousChartsNode());
    defaultmutabletreenode.add(createExperimentalNode());
    return new DefaultTreeModel(defaultmutabletreenode);
}

From source file:de.erdesignerng.visual.common.OutlineComponent.java

private void updateTableTreeNode(Model aModel, Table aTable, DefaultMutableTreeNode aTableNode) {

    aTableNode.removeAllChildren();//from  w ww.  j a  va2 s .c o  m

    aTable.getAttributes().stream().filter(theAttribute -> isVisible(theAttribute)).forEach(theAttribute -> {
        DefaultMutableTreeNode theAttributeNode = new DefaultMutableTreeNode(theAttribute);
        aTableNode.add(theAttributeNode);

        registerUserObject(theAttribute, theAttributeNode);
    });

    aTable.getIndexes().stream().filter(theIndex -> isVisible(theIndex)).forEach(theIndex -> {
        createIndexTreeNode(aTableNode, theIndex);
    });

    aModel.getRelations().getForeignKeysFor(aTable).stream().filter(theRelation -> isVisible(theRelation))
            .forEach(theRelation -> {
                createRelationTreeNode(aTableNode, theRelation);
            });

    Set<Table> theAlreadyKnown = new HashSet<>();
    aModel.getRelations().getExportedKeysFor(aTable).stream().filter(
            theRelation -> isVisible(theRelation) && !theAlreadyKnown.contains(theRelation.getImportingTable()))
            .forEach(theRelation -> {
                UsedBy theUsedBy = new UsedBy();
                theUsedBy.ref = theRelation.getImportingTable();
                DefaultMutableTreeNode theUsedByNode = new DefaultMutableTreeNode(theUsedBy);
                aTableNode.add(theUsedByNode);

                theAlreadyKnown.add(theRelation.getImportingTable());
            });
}

From source file:de.erdesignerng.visual.common.OutlineComponent.java

private void buildCustomTypesChildren(Model aModel, DefaultMutableTreeNode aParent,
        List<CustomType> aCustomTypesList) {
    DefaultMutableTreeNode theCustomTypesNode = new DefaultMutableTreeNode(TreeGroupingElement.CUSTOMTYPES);
    aCustomTypesList.stream().filter(theCustomType -> isVisible(theCustomType)).forEach(theCustomType -> {
        DefaultMutableTreeNode theCustomTypeNode = new DefaultMutableTreeNode(theCustomType);
        theCustomTypesNode.add(theCustomTypeNode);

        registerUserObject(theCustomType, theCustomTypeNode);

        updateCustomTypeTreeNode(aModel, theCustomType, theCustomTypeNode);
    });//w w  w  . j  ava  2  s  . c  o  m
    aParent.add(theCustomTypesNode);
}

From source file:SAXTreeValidator.java

/**
 * <p>/*from   w w  w  . ja  va 2  s .c om*/
 *   This reports the occurrence of an actual element. It includes
 *     the element's attributes, with the exception of XML vocabulary
 *     specific attributes, such as
 *     <code>xmlns:[namespace prefix]</code> and
 *     <code>xsi:schemaLocation</code>.
 * </p>
 *
 * @param namespaceURI <code>String</code> namespace URI this element
 *               is associated with, or an empty <code>String</code>
 * @param localName <code>String</code> name of element (with no
 *               namespace prefix, if one is present)
 * @param qName <code>String</code> XML 1.0 version of element name:
 *                [namespace prefix]:[localName]
 * @param atts <code>Attributes</code> list for this element
 * @throws <code>SAXException</code> when things go wrong
 */
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
        throws SAXException {

    DefaultMutableTreeNode element = new DefaultMutableTreeNode("Element: " + localName);
    current.add(element);
    current = element;

    // Determine namespace
    if (namespaceURI.length() > 0) {
        String prefix = (String) namespaceMappings.get(namespaceURI);
        if (prefix.equals("")) {
            prefix = "[None]";
        }
        DefaultMutableTreeNode namespace = new DefaultMutableTreeNode(
                "Namespace: prefix = '" + prefix + "', URI = '" + namespaceURI + "'");
        current.add(namespace);
    }

    // Process attributes
    for (int i = 0; i < atts.getLength(); i++) {
        DefaultMutableTreeNode attribute = new DefaultMutableTreeNode(
                "Attribute (name = '" + atts.getLocalName(i) + "', value = '" + atts.getValue(i) + "')");
        String attURI = atts.getURI(i);
        if (attURI.length() > 0) {
            String attPrefix = (String) namespaceMappings.get(namespaceURI);
            if (attPrefix.equals("")) {
                attPrefix = "[None]";
            }
            DefaultMutableTreeNode attNamespace = new DefaultMutableTreeNode(
                    "Namespace: prefix = '" + attPrefix + "', URI = '" + attURI + "'");
            attribute.add(attNamespace);
        }
        current.add(attribute);
    }
}

From source file:de.erdesignerng.visual.common.OutlineComponent.java

private void buildIndexChildren(DefaultMutableTreeNode aParentNode, List<Index> aIndexList) {
    DefaultMutableTreeNode theIndexesNode = new DefaultMutableTreeNode(TreeGroupingElement.INDEXES);
    aIndexList.stream().filter(theIndex -> isVisible(theIndex)).forEach(theIndex -> {
        createIndexTreeNode(theIndexesNode, theIndex);
    });/*from   w  w  w  . j  a va2 s .co  m*/
    aParentNode.add(theIndexesNode);
}

From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java

/**
 * Setting of the each plug-in which is in the tree view.
 * @param top - default top tree node/*from  ww w  . ja  va2  s  .  c  om*/
 */
private void createPluginNodes(DefaultMutableTreeNode top) {
    DefaultMutableTreeNode phase = null;
    DefaultMutableTreeNode type = null;

    phase = new DefaultMutableTreeNode("Phase1 Plug-in. Plain Text Processing");
    type = new DefaultMutableTreeNode("Supplement Plugin");
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("InformalSentenceFilter", PluginInfo.PHASE1, PluginInfo.SUPPLEMENT)));
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("SentenceSegmentor", PluginInfo.PHASE1, PluginInfo.SUPPLEMENT)));
    phase.add(type);
    top.add(phase);

    phase = new DefaultMutableTreeNode("Phase2 Plug-in. Morphological Analysis");
    type = new DefaultMutableTreeNode("Major Plug-in");
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("ChartMorphAnalyzer", PluginInfo.PHASE2, PluginInfo.MAJOR)));
    phase.add(type);
    type = new DefaultMutableTreeNode("Supplement Plug-in");
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("UnknownMorphProcessor", PluginInfo.PHASE2, PluginInfo.SUPPLEMENT)));
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("SimpleMAResult09", PluginInfo.PHASE2, PluginInfo.SUPPLEMENT)));
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("SimpleMAResult22", PluginInfo.PHASE2, PluginInfo.SUPPLEMENT)));

    phase.add(type);
    top.add(phase);

    phase = new DefaultMutableTreeNode("Phase3 Plug-in. Part Of Speech Tagging");
    type = new DefaultMutableTreeNode("Major Plug-in");
    type.add(new DefaultMutableTreeNode(new PluginInfo("HmmPosTagger", PluginInfo.PHASE3, PluginInfo.MAJOR)));
    phase.add(type);
    type = new DefaultMutableTreeNode("Supplement Plug-in");
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("NounExtractor", PluginInfo.PHASE3, PluginInfo.SUPPLEMENT)));
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("SimplePOSResult09", PluginInfo.PHASE3, PluginInfo.SUPPLEMENT)));
    type.add(new DefaultMutableTreeNode(
            new PluginInfo("SimplePOSResult22", PluginInfo.PHASE3, PluginInfo.SUPPLEMENT)));
    phase.add(type);
    top.add(phase);
}

From source file:br.upe.ecomp.dosa.view.mainwindow.MainWindowActions.java

private void createNodes() {
    DefaultMutableTreeNode root = new ExtendedTreeNode(algorithm, TreeNodeTypeEnum.ALGORITHM);
    DefaultMutableTreeNode problemNode = new ExtendedTreeNode("Problem", TreeNodeTypeEnum.PROBLEM);
    DefaultMutableTreeNode stopConditionNode = new ExtendedTreeNode("Stop conditions",
            TreeNodeTypeEnum.STOP_CONDITION);
    DefaultMutableTreeNode meassurementNode = new ExtendedTreeNode("Meassurements",
            TreeNodeTypeEnum.MEASSUREMENT);

    addProblem(problemNode, algorithm);//w ww  .  ja  v  a2 s.  c  o  m
    addStopCondition(stopConditionNode, algorithm);
    addMeasurement(meassurementNode, algorithm);

    root.add(problemNode);
    root.add(stopConditionNode);
    root.add(meassurementNode);
    TreeModel model = new DefaultTreeModel(root);
    tree.setModel(model);
}

From source file:de.erdesignerng.visual.common.OutlineComponent.java

private void buildRelationChildren(DefaultMutableTreeNode aParentNode, List<Relation> aRelationList) {
    DefaultMutableTreeNode theRelationsNode = new DefaultMutableTreeNode(TreeGroupingElement.RELATIONS);
    aRelationList.stream().filter(theRelation -> isVisible(theRelation)).forEach(theRelation -> {
        createRelationTreeNode(theRelationsNode, theRelation);
    });//  w  w w .  ja va  2s  . c  o m
    aParentNode.add(theRelationsNode);
}