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.httpserver;

import org.openide.actions.PropertiesAction;
import org.openide.filesystems.Repository;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.*;
import org.openide.util.actions.SystemAction;

/** Proxy to HTTP server that allows to start/stop it from Runtime tab.
 *
 * @author Radim Kubacki
 */
public class HttpServerNode extends FilterNode {
    
    public HttpServerNode() throws DataObjectNotFoundException {
        this (DataObject.find(
            Repository.getDefault().getDefaultFileSystem().findResource("Services/org-netbeans-modules-httpserver-HttpServerSettings.settings") // NOI18N
            ).getNodeDelegate()
        );
    }
    
    public HttpServerNode(Node original) {
        super(original, Children.LEAF);
    }
    
    public Node cloneNode() {
        // Usually you will want to override this if you are subclassing.
        // Otherwise a filter of a filter is created, which works but is not ideal.
        return new HttpServerNode(getOriginal());
    }
    
    /** Enhances original settings with Start and Stop action.
     * @return system actions appropriate to the node
     */
    public SystemAction[] getActions() {
        return new SystemAction [] {
            SystemAction.get(StartHttpServerAction.class),
            SystemAction.get(StopHttpServerAction.class),
            null,
            SystemAction.get(PropertiesAction.class)
        };
    }
    
    /** Adds helpIDs to node */
    public org.openide.nodes.Node.PropertySet[] getPropertySets () {
        PropertySet[] ps = super.getPropertySets ();
        for (int i = 0; i< ps.length; i++) {
            if (Sheet.PROPERTIES.equals (ps[i].getName ())) {
                ps[i].setValue ("helpID", HttpServerNode.class.getName ()+"_properties");   // NOI18N
            }
            else if (Sheet.EXPERT.equals (ps[i].getName ())) {
                ps[i].setValue ("helpID", HttpServerNode.class.getName ()+"_expert");   // NOI18N
            }
        }
        return ps;
    }
    
}
... 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.