KickJava   Java API By Example, From Geeks To Geeks.

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


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
21 package org.netbeans.modules.form;
22
23 import javax.swing.Action JavaDoc;
24 import org.netbeans.api.java.loaders.JavaDataSupport;
25 import org.openide.nodes.AbstractNode;
26 import org.openide.nodes.FilterNode;
27 import org.openide.nodes.Node;
28
29 import org.openide.util.actions.SystemAction;
30
31 /** The DataNode for Forms.
32  *
33  * @author Ian Formanek
34  * @version 1.00, Jul 21, 1998
35  */

36 public class FormDataNode extends FilterNode {
37     /** generated Serialized Version UID */
38     // static final long serialVersionUID = 1795549004166402392L;
39

40     /** Icon base for form data objects. */
41     private static final String JavaDoc FORM_ICON_BASE = "org/netbeans/modules/form/resources/form.gif"; // NOI18N
42

43     /** Constructs a new FormDataObject for specified primary file */
44     public FormDataNode(FormDataObject fdo) {
45         this(JavaDataSupport.createJavaNode(fdo.getPrimaryFile()));
46     }
47     
48     private FormDataNode(Node orig) {
49         super(orig);
50         ((AbstractNode) orig).setIconBaseWithExtension(FORM_ICON_BASE);
51     }
52     
53     @Override JavaDoc
54     public Action JavaDoc getPreferredAction() {
55         // issue 56351
56
return new javax.swing.AbstractAction JavaDoc() {
57             public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
58                 FormEditorSupport supp = getCookie(FormEditorSupport.class);
59                 supp.openFormEditor(false);
60             }
61         };
62     }
63     
64     @Override JavaDoc
65     public Action JavaDoc[] getActions(boolean context) {
66         Action JavaDoc[] javaActions = super.getActions(context);
67         Action JavaDoc[] formActions = new Action JavaDoc[javaActions.length+2];
68         formActions[0] = javaActions[0]; // OpenAction
69
formActions[1] = SystemAction.get(org.openide.actions.EditAction.class);
70         formActions[2] = null;
71         System.arraycopy(javaActions, 1, formActions, 3, javaActions.length-1);
72         return formActions;
73     }
74
75 }
76
Popular Tags