KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > DefaultRADAction


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.form;
21
22 import org.openide.nodes.*;
23 import org.openide.util.HelpCtx;
24 import org.openide.util.actions.CookieAction;
25
26 /** This action installs new bean into the system.
27  *
28  * @author Ian Formanek
29  */

30
31 public class DefaultRADAction extends CookieAction {
32
33     /** Human presentable name of the action. This should be
34      * presented as an item in a menu.
35      * @return the name of the action
36      */

37     public String JavaDoc getName() {
38         return "DefaultRADAction"; // NOI18N
39
}
40
41     /** Get a help context for the action.
42      * @return the help context for this action
43      */

44     public HelpCtx getHelpCtx() {
45         return new HelpCtx(DefaultRADAction.class);
46     }
47
48     /** @return the mode of action. Possible values are disjunctions of MODE_XXX
49      * constants. */

50     protected int mode() {
51         return MODE_EXACTLY_ONE;
52     }
53
54     /** Creates new set of classes that are tested by the cookie.
55      *
56      * @return list of classes the that the cookie tests
57      */

58     protected Class JavaDoc[] cookieClasses() {
59         return new Class JavaDoc[] { RADComponentCookie.class };
60     }
61
62     protected boolean asynchronous() {
63         return false;
64     }
65
66     /** Test for enablement based on the cookies of selected nodes.
67      * Generally subclasses should not override this except for strange
68      * purposes, and then only calling the super method and adding a check.
69      * Just use {@link #cookieClasses} and {@link #mode} to specify
70      * the enablement logic.
71      * @param activatedNodes the set of activated nodes
72      * @return <code>true</code> to enable
73      */

74 // protected boolean enable(Node[] activatedNodes) {
75
// if (activatedNodes.length == 0)
76
// return false;
77
//
78
// RADComponentCookie radCookie = (RADComponentCookie)
79
// activatedNodes[0].getCookie(RADComponentCookie.class);
80
// if (radCookie == null)
81
// return false;
82
//
83
// RADComponent comp = radCookie.getRADComponent();
84
// return comp.hasDefaultEvent();
85
// }
86

87     /**
88      * Standard perform action extended by actually activated nodes.
89      *
90      * @param activatedNodes gives array of actually activated nodes.
91      */

92     protected void performAction(Node[] activatedNodes) {
93         if (activatedNodes.length == 0)
94             return;
95
96         RADComponentCookie radCookie = (RADComponentCookie)
97             activatedNodes[0].getCookie(RADComponentCookie.class);
98         if (radCookie == null)
99             return;
100
101 // RADComponent comp = radCookie.getRADComponent();
102
// if (comp.hasDefaultEvent())
103
// comp.attachDefaultEvent();
104
radCookie.getRADComponent().attachDefaultEvent();
105     }
106 }
107
Popular Tags