Search in sources :

Example 1 with ComplexObject

use of cl.utfsm.acs.types.ComplexObject in project ACS by ACS-Community.

the class ErrorTreeCellRenderer method refreshNodesTree.

private void refreshNodesTree() {
    DefaultTreeModel model = (DefaultTreeModel) nodesTree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    root.removeAllChildren();
    if (docSelected == null) {
        model.reload();
        return;
    }
    TreeMap<String, ComplexObject> nodes = docSelected.getNodes();
    for (ComplexObject node : nodes.values()) {
        root.add(new DefaultMutableTreeNode(node));
    }
    model.reload();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ComplexObject(cl.utfsm.acs.types.ComplexObject) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 2 with ComplexObject

use of cl.utfsm.acs.types.ComplexObject in project ACS by ACS-Community.

the class EbeDocument method save.

/** Save the data to the selected path 
         * @throws IOException 
         * @throws FileNotFoundException */
public void save() throws FileNotFoundException, IOException {
    Document docFile = new DocumentImpl();
    Element typeElement = docFile.createElement(EbeDocument.getClassType().name);
    fillAttributes(this, typeElement);
    for (ComplexObject node : nodes.values()) {
        Element nodeElement;
        if (node instanceof Error)
            nodeElement = docFile.createElement("ErrorCode");
        else
            nodeElement = docFile.createElement("Code");
        fillAttributes(node, nodeElement);
        if (node instanceof Error) {
            Error err = (Error) node;
            for (ComplexObject memb : err.getMembers().values()) {
                Element membElement = docFile.createElement("Member");
                fillAttributes(memb, membElement);
                nodeElement.appendChild(membElement);
            }
        }
        typeElement.appendChild(nodeElement);
    }
    docFile.appendChild(typeElement);
    saveXmlDocument(docFile, getPath());
}
Also used : ComplexObject(cl.utfsm.acs.types.ComplexObject) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) DocumentImpl(org.apache.xerces.dom.DocumentImpl)

Example 3 with ComplexObject

use of cl.utfsm.acs.types.ComplexObject in project ACS by ACS-Community.

the class ErrorTreeCellRenderer method getNewCompletionMenuItem.

/**
	 * This method initializes jMenuItem1	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
private JMenuItem getNewCompletionMenuItem() {
    if (newCompletionMenuItem == null) {
        newCompletionMenuItem = new JMenuItem();
        newCompletionMenuItem.setText("Completion");
        newCompletionMenuItem.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (docSelected.getNode("NewCompletion") != null) {
                    log("\t[ATENTION: 'NewCompletion' is not allowed as a valid completion name, please change it before adding new errors]");
                } else {
                    ComplexObject newObj = new Completion();
                    newObj.setValue("NewCompletion");
                    newObj.setAttributeValue("name", "NewCompletion");
                    docSelected.putNode(newObj);
                    complexSelected = newObj;
                    log("\t[New Completion Added ]");
                }
                refreshNodesTree();
                refreshNodeAttributesTable();
            }
        });
    }
    return newCompletionMenuItem;
}
Also used : ComplexObject(cl.utfsm.acs.types.ComplexObject) JMenuItem(javax.swing.JMenuItem)

Example 4 with ComplexObject

use of cl.utfsm.acs.types.ComplexObject in project ACS by ACS-Community.

the class ErrorTreeCellRenderer method getNewErrorMenuItem.

/**
	 * This method initializes jMenuItem	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
private JMenuItem getNewErrorMenuItem() {
    if (newErrorMenuItem == null) {
        newErrorMenuItem = new JMenuItem();
        newErrorMenuItem.setText("Error");
        newErrorMenuItem.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (docSelected.getNode("NewError") != null) {
                    log("\t[ATENTION: 'NewError' is not allowed as a valid error name, please change it before adding new errors]");
                } else {
                    ComplexObject newObj = new Error();
                    newObj.setValue("NewError");
                    newObj.setAttributeValue("name", "NewError");
                    docSelected.putNode(newObj);
                    complexSelected = newObj;
                    log("\t[New Error Added ]");
                }
                refreshNodesTree();
                refreshNodeAttributesTable();
            }
        });
    }
    return newErrorMenuItem;
}
Also used : ComplexObject(cl.utfsm.acs.types.ComplexObject) JMenuItem(javax.swing.JMenuItem)

Aggregations

ComplexObject (cl.utfsm.acs.types.ComplexObject)4 JMenuItem (javax.swing.JMenuItem)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 DocumentImpl (org.apache.xerces.dom.DocumentImpl)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1