KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ui > logicalview > ejb > entity > CMPFieldsNode


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.j2ee.ejbcore.ui.logicalview.ejb.entity;
21
22 import javax.swing.Action JavaDoc;
23 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar;
24 import org.openide.actions.*;
25 import org.openide.cookies.OpenCookie;
26 import org.openide.loaders.DataObject;
27 import org.openide.nodes.*;
28 import org.openide.util.actions.SystemAction;
29 import org.netbeans.modules.j2ee.dd.api.ejb.Entity;
30 import org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.AddCmpFieldAction;
31 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.EntityMethodController;
32 import org.netbeans.modules.j2ee.common.DDEditorNavigator;
33 import org.openide.ErrorManager;
34 import org.openide.filesystems.FileObject;
35 import org.openide.loaders.DataObjectNotFoundException;
36 import org.openide.util.lookup.AbstractLookup;
37 import org.openide.util.lookup.InstanceContent;
38
39
40 /**
41  *
42  * @author Martin Adamek
43  */

44 public class CMPFieldsNode extends AbstractNode implements OpenCookie {
45     private final EntityMethodController controller;
46     private final EjbJar ejbJar;
47     private final FileObject ddFile;
48     private Entity entity;
49
50     public CMPFieldsNode(EntityMethodController controller, Entity model, EjbJar jar, FileObject ddFile) {
51         this(new InstanceContent(), controller, model, jar, ddFile);
52     }
53     
54     private CMPFieldsNode(InstanceContent content, EntityMethodController controller, Entity model, EjbJar jar, FileObject ddFile) {
55         super(new CMFieldChildren(controller, model, jar, ddFile), new AbstractLookup(content));
56         entity = model;
57         this.controller = controller;
58         this.ejbJar = jar;
59         this.ddFile = ddFile;
60         content.add(this);
61         //TODO: RETOUCHE
62
// JavaClass jc = controller.getBeanClass();
63
// if (jc != null)
64
// content.add(jc);
65
}
66     
67     public Action JavaDoc[] getActions(boolean context) {
68         return new SystemAction[] {
69             SystemAction.get(AddCmpFieldAction.class)
70         };
71     }
72     
73     public Action JavaDoc getPreferredAction() {
74         return SystemAction.get(OpenAction.class);
75     }
76     
77     public void open() {
78         try {
79             DataObject ddFileDO = DataObject.find(ddFile);
80             Object JavaDoc cookie = ddFileDO.getCookie(DDEditorNavigator.class);
81             if (cookie != null) {
82                 ((DDEditorNavigator) cookie).showElement(entity.getCmpField());
83             }
84         } catch (DataObjectNotFoundException donf) {
85             ErrorManager.getDefault().notify(donf);
86         }
87     }
88 }
89
Popular Tags