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-2002 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.struts.nodes;

import org.netbeans.modules.struts.ChangableDocument;

import java.util.ResourceBundle;
import java.util.*;
import java.text.MessageFormat;
// JDOM
import org.jdom.*;

import org.openide.actions.*;
import org.openide.nodes.*;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.SystemAction;
import org.openide.util.datatransfer.NewType;

/** A node with some children.
 *
 * @author mk115033
 */
public class JDOMElementNode extends AbstractNode implements JDOMElementCookie {
    private static final String ACTION_CREATE="create";
    private static final String ACTION_DELETE="delete";
    private static final String NODE_ACTION="node";
    private static final String BOOLEAN_TYPE="Boolean";
    private static final String INTEGER_TYPE="Integer";
    private static final String STRING_TYPE="String";
    private Element structureElement,sourceElement;
    private ChangableDocument changableDocument;
    private List createActions,nodeActions;
    private boolean deleteAction;
    private ResourceBundle bundle;
    
    public JDOMElementNode(ChangableDocument changableDocument, Element node, Element element, ResourceBundle bundle,String nameFrom) {
        super(element!=null && element.hasChildren()?new ElementChildren(changableDocument,node,element,bundle):Children.LEAF);
        structureElement=node;
        sourceElement=element;
        this.bundle=bundle;
        this.changableDocument=changableDocument;
        //setIconBase("org/netbeans/modules/struts/nodes/ElementNodeIcon");
        setIconBase(node.getAttribute("icon-base").getValue());
        // Whatever is most relevant to a user:
        setDefaultAction(SystemAction.get(PropertiesAction.class));
        // Set FeatureDescriptor stuff:
        Attribute attrName = node.getAttribute("name");
        String name = attrName.getValue();
        if (nameFrom==null) {
            //setName(name);
            setDisplayName(bundle.getString("LBL_"+name));
            setShortDescription(bundle.getString("DESC_"+name));
        } else {
            //String nameForElement = getNameForElement(nameFrom);
            String[] nameForNode = getNameForNode(nameFrom);
            String mes = MessageFormat.format (bundle.getString("LBL_"+name),nameForNode);
                                //new Object [] {nameForElement});            
            //setName(mes);
            setDisplayName(mes);
            mes = MessageFormat.format (bundle.getString("DESC_"+name),nameForNode);
                                //new Object [] {nameForElement});
            setShortDescription(mes);
        }
        
        Element allActions = structureElement.getChild("node-actions");
        createActions = new ArrayList();
        nodeActions = new ArrayList();
        if (allActions!=null) {
            List actions = allActions.getChildren("action");
            for (int i=0;i0) actionsCount++;
        if (nodeActionsCount>0) actionsCount+=nodeActionsCount;
        SystemAction[] sysActions = new SystemAction[actionsCount];
        int i=0;
        sysActions[i++]=SystemAction.get(OpenLocalExplorerAction.class);
        if (createActionsCount>0) sysActions[i++]=SystemAction.get(NewAction.class);
        for (int j=0;j
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

 

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.