alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */
package org.netbeans.modules.xml.tree.nodes;

import java.io.*;
import java.awt.*;
import java.awt.datatransfer.*;
import java.util.*;
import java.beans.*;

import org.openide.*;
import org.openide.actions.*;
import org.openide.util.actions.*;
import org.openide.nodes.*;
import org.openide.loaders.DataNode;
import org.openide.explorer.propertysheet.editors.*;
import org.openide.util.datatransfer.*;

import org.netbeans.tax.*;
import org.netbeans.tax.io.*;
import org.netbeans.modules.xml.core.*;
import org.netbeans.modules.xml.tree.lib.GuiUtil;
import org.netbeans.modules.xml.tree.children.*;
import org.netbeans.modules.xml.tree.nodes.*;
import org.netbeans.modules.xml.tree.settings.*;
import org.netbeans.modules.xml.core.settings.*;

import org.netbeans.modules.xml.core.actions.CollectXMLAction;
import org.netbeans.modules.xml.core.actions.XMLUpdateDocumentAction;

/**
 *
 * @author  Libor Kramolis
 * @version 0.1
 */
public class XMLDataNode extends AbstractDataNode {

    /** */
    private static final String XML_SET = "xml"; // NOI18N


    //
    // init
    //

    /** Default constructor, constructs node */
    public XMLDataNode (XMLDataObject dataObject) {
        super (dataObject);

        setIconBase ("org/netbeans/modules/xml/core/resources/xmlObject"); // NOI18N
    }

    /** Look first at XML module wide default action. */
    public SystemAction getDefaultAction() {
        CoreSettings settings  = CoreSettings.getDefault();
        SystemAction actions[] = getActions();
        SystemAction system    = SystemAction.get (EditAction.class);
        
        return settings.getDefaultAction (actions, system);
    }
    
    protected SystemAction[] createActions() {
        return new SystemAction[] {
            SystemAction.get (EditAction.class),
            SystemAction.get (OpenAction.class),
            SystemAction.get (ViewAction.class),
            SystemAction.get (FileSystemAction.class),
            null,
            SystemAction.get (XMLUpdateDocumentAction.class),
            SystemAction.get (CollectXMLAction.class),
            null,
            SystemAction.get (CutAction.class),
            SystemAction.get (CopyAction.class),
            SystemAction.get (PasteAction.class),
            null,
            SystemAction.get (DeleteAction.class),
            SystemAction.get (RenameAction.class),
            null,
            SystemAction.get (SaveAsTemplateAction.class),
            null,
            SystemAction.get (NewAction.class),
            null,
            SystemAction.get (ToolsAction.class),
            SystemAction.get (PropertiesAction.class)
        };
    }
    //
    // itself
    //

    /**
     */
    public final XMLDataObject getXMLDataObject () {
        return (XMLDataObject)getDataObject();
    }
    

    /**
     */
    public final TreeDocument getTreeDocument () {
        return (TreeDocument)getTreeObject();
    }

    /**
     */
    public final void setDocumentType (TreeDocumentType documentType) {
        if ( getRootNode() != null ) {
            ((DocumentNode)getRootNode()).setDocumentType (documentType);
        }
    }

    /**
     */
    public final void setDocumentElement (TreeElement element) {
        if ( getRootNode() != null ) {
            ((DocumentNode)getRootNode()).setDocumentElement (element);
        }
    }

    //
    // from AbstractDataNode
    //

    /**
     */
    protected final AbstractRootNode createRootNode (TreeDocumentRoot documentRoot) {
        try {
            return new DocumentNode ((TreeDocument)documentRoot);
        } catch (Exception exc) {
            return null;
        }
    }

    /**
     */
    protected final String getNodeDescription () {
        return (Util.THIS.getString ("PROP_DocumentNode_description"));
    }

    
    //
    // Sheet
    //

    /** Creates new XML sheet set from TreeDocumentRoot properties. */
    protected final Sheet.Set createXMLSheetSet () {
        Sheet.Set xmlSet = super.createXMLSheetSet();

        xmlSet.setName (XML_SET);
        xmlSet.setDisplayName (Util.THIS.getString ("PROP_xmlSetName"));
        xmlSet.setShortDescription (Util.THIS.getString ("HINT_xmlSetName"));

        return xmlSet;
    }


    //
    // class DataNodeCreatorImpl
    //

    /**
     *
     */
    public static class DataNodeCreatorImpl implements XMLDataObject.DataNodeCreator {

        /**
         */
        public DataNode createDataNode (XMLDataObject xmlDO) {
            if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("--> XMLDataNode::DataNodeCreatorImpl.createDataNode: xmlDO = " + xmlDO); // NOI18N

            return new XMLDataNode (xmlDO);
        }

    } // end of class DataNodeCreatorImpl

}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.