KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > loaderswitcher > ChangeTypeAction


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.loaderswitcher;
21
22 import org.openide.nodes.Node;
23 import org.openide.loaders.DataObject;
24 import org.openide.util.HelpCtx;
25 import org.openide.util.actions.CookieAction;
26 import org.openide.util.NbBundle;
27
28 /**
29 * Changes the type of a DataObject using a user dialog.
30 * @author Jaroslav Tulach
31 */

32 public class ChangeTypeAction extends CookieAction {
33     /** generated Serialized Version UID */
34     static final long serialVersionUID = 1352346576761226839L;
35
36     protected boolean surviveFocusChange () {
37         return false;
38     }
39
40     protected boolean asynchronous() {
41         return false;
42     }
43
44     /* Human presentable name of the action. This should be
45     * presented as an item in a menu.
46     * @return the name of the action
47     */

48     public String JavaDoc getName () {
49         return org.openide.util.NbBundle.getMessage(ChangeTypeAction.class, "Change_object_type");
50     }
51
52     /* Help context where to find more about the action.
53     * @return the help context for this action
54     */

55     public HelpCtx getHelpCtx () {
56         return new HelpCtx (ChangeTypeAction.class);
57     }
58
59     /* The resource string to our icon.
60     * @return the icon resource string
61     */

62     protected String JavaDoc iconResource () {
63         return "org/netbeans/modules/loaderswitcher/ChangeTypeAction.gif"; // NOI18N
64
}
65
66     /* @return the mode of action. */
67     protected int mode() {
68         return MODE_EXACTLY_ONE;
69     }
70
71     /* Creates a set of classes that are tested by this cookie.
72     * Here only HtmlDataObject class is tested.
73     *
74     * @return list of classes the that this cookie tests
75     */

76     protected Class JavaDoc[] cookieClasses () {
77         return new Class JavaDoc[] { org.openide.loaders.DataObject.class };
78     }
79
80     /* Actually performs the action.
81     * Calls edit on all activated nodes which supports
82     * HtmlDataObject cookie.
83     */

84     protected void performAction (final Node[] activatedNodes) {
85         for (int i = 0; i < activatedNodes.length; i++) {
86             DataObject es = (DataObject)activatedNodes[i].getCookie(DataObject.class);
87             if (es != null) {
88                 ObjectType.convert (es);
89             }
90         }
91     }
92 }
93
Popular Tags