/** * Creates the TreeModel representing the document model structure * * @return TreeModel */ private TreeModel createTreeModel() { final DefaultMutableTreeNode root = new PatchedDefaultMutableTreeNode("DocumentTypeModel"); final List<Doctype> documentTypes = doctypeModel.getDoctypes(); final List<DefaultMutableTreeNode> nodes = wrapDoctypesInTreeNodes(documentTypes); for (DefaultMutableTreeNode node : nodes) { Doctype doctype = (Doctype) node.getUserObject(); if (doctype.getParent() == null) { root.add(node); } else { DefaultMutableTreeNode parent = findDoctypeTreeNodeByName(nodes, doctype.getParent().getName()); if (parent != null) { parent.add(node); } } } return new DefaultTreeModel(root); }
/** * Creates the TreeModel representing the properties of the doctype * * @return TreeModel */ private TreeModel createTreeModel() { final DefaultMutableTreeNode root = new PatchedDefaultMutableTreeNode("Properties"); root.add(createDoctypeWithPropertiesTreeNode(doctype)); Doctype parent = doctype.getParent(); while (parent != null) { root.add(createDoctypeWithPropertiesTreeNode(parent)); parent = parent.getParent(); } return new DefaultTreeModel(root); }
/** * Creates the TreeNode containing the properties for the given doctype and the doctype as root node * * @param doctype Doctype * @return TreeNode */ private DefaultMutableTreeNode createDoctypeWithPropertiesTreeNode(Doctype doctype) { final DefaultMutableTreeNode root = new PatchedDefaultMutableTreeNode(doctype); final List<DefaultMutableTreeNode> nodes = wrapDoctypesInTreeNodes(doctype.getProperties()); for (DefaultMutableTreeNode node : nodes) { root.add(node); } return root; }
/** * Creates a List with TreeNodes for each property in the given List * * @param properties List with properties * @return List with TreeNodes */ private List<DefaultMutableTreeNode> wrapDoctypesInTreeNodes(@NotNull List<Property> properties) { final List<DefaultMutableTreeNode> results = new ArrayList<DefaultMutableTreeNode>(properties.size()); for (Property property : properties) { results.add(new PatchedDefaultMutableTreeNode(property)); } return results; }
/** * Creates a List with TreeNodes for each document type in the given List * * @param doctypes List with doctypes * @return List with TreeNodes */ private List<DefaultMutableTreeNode> wrapDoctypesInTreeNodes(List<Doctype> doctypes) { final List<DefaultMutableTreeNode> results = new ArrayList<DefaultMutableTreeNode>(); if (doctypes != null) { for (Doctype doctype : doctypes) { results.add(new PatchedDefaultMutableTreeNode(doctype)); } } return results; }
protected final DefaultMutableTreeNode createChildNode(final NodeDescriptor childDescr) { return new PatchedDefaultMutableTreeNode(childDescr); }