KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > httpserver > HttpServerNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.httpserver;
21
22 import javax.swing.Action JavaDoc;
23 import org.openide.actions.PropertiesAction;
24 import org.openide.filesystems.Repository;
25 import org.openide.loaders.DataObject;
26 import org.openide.loaders.DataObjectNotFoundException;
27 import org.openide.nodes.*;
28 import org.openide.util.actions.SystemAction;
29
30 /** Proxy to HTTP server that allows to start/stop it from Runtime tab.
31  *
32  * @author Radim Kubacki
33  */

34 public class HttpServerNode extends FilterNode {
35
36     public HttpServerNode() throws DataObjectNotFoundException {
37         this (HttpServerSettings.createViewNode());
38     }
39     
40     public HttpServerNode(Node original) {
41         super(original, Children.LEAF);
42     }
43     
44     public Node cloneNode() {
45         // Usually you will want to override this if you are subclassing.
46
// Otherwise a filter of a filter is created, which works but is not ideal.
47
return new HttpServerNode(getOriginal());
48     }
49     
50     /** Enhances original settings with Start and Stop action.
51      * @return system actions appropriate to the node
52      */

53     public Action JavaDoc[] getActions(boolean context) {
54         return new Action JavaDoc [] {
55             SystemAction.get(StartHttpServerAction.class),
56             SystemAction.get(StopHttpServerAction.class),
57             null,
58             SystemAction.get(PropertiesAction.class)
59         };
60     }
61     
62     /** Adds helpIDs to node */
63     public org.openide.nodes.Node.PropertySet[] getPropertySets () {
64         PropertySet[] ps = super.getPropertySets ();
65         for (int i = 0; i< ps.length; i++) {
66             if (Sheet.PROPERTIES.equals (ps[i].getName ())) {
67                 ps[i].setValue ("helpID", HttpServerNode.class.getName ()+"_properties"); // NOI18N
68
}
69             else if (Sheet.EXPERT.equals (ps[i].getName ())) {
70                 ps[i].setValue ("helpID", HttpServerNode.class.getName ()+"_expert"); // NOI18N
71
}
72         }
73         return ps;
74     }
75     
76 }
77
Popular Tags