KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ui > logicalview > ejb > action > GoToSourceActionGroup


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.action;
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23 import javax.swing.Action JavaDoc;
24 import org.netbeans.api.java.classpath.ClassPath;
25 import org.netbeans.modules.j2ee.dd.api.ejb.EntityAndSession;
26 import org.openide.util.HelpCtx;
27 import org.openide.util.NbBundle;
28
29 /**
30  * Group holding source navigation actions for Session and Entity EJBs
31  *
32  * @author Martin Adamek
33  */

34 public class GoToSourceActionGroup extends EJBActionGroup {
35     
36     public String JavaDoc getName() {
37         return NbBundle.getMessage(GoToSourceActionGroup.class, "LBL_GoToSourceGroup");
38     }
39
40     protected Action JavaDoc[] grouped() {
41         EntityAndSession ejb = getEjb();
42         ClassPath classPath = getClassPath();
43         List JavaDoc<Action JavaDoc> actions = new ArrayList JavaDoc<Action JavaDoc>();
44         actions.add(new GoToSourceAction(classPath, ejb.getEjbClass(),
45                 NbBundle.getMessage(GoToSourceActionGroup.class, "LBL_GoTo_BeanImplementation")));
46         if (ejb.getRemote() != null) {
47             actions.add(new GoToSourceAction(classPath, ejb.getRemote(),
48                 NbBundle.getMessage(GoToSourceActionGroup.class, "LBL_GoTo_RemoteInterface")));
49         }
50         if (ejb.getLocal() != null) {
51             actions.add(new GoToSourceAction(classPath, ejb.getLocal(),
52                 NbBundle.getMessage(GoToSourceActionGroup.class, "LBL_GoTo_LocalInterface")));
53         }
54         if (ejb.getHome() != null) {
55             actions.add(new GoToSourceAction(classPath, ejb.getHome(),
56                 NbBundle.getMessage(GoToSourceActionGroup.class, "LBL_GoTo_RemoteHomeInterface")));
57         }
58         if (ejb.getLocalHome() != null) {
59             actions.add(new GoToSourceAction(classPath, ejb.getLocalHome(),
60                 NbBundle.getMessage(GoToSourceActionGroup.class, "LBL_GoTo_LocalHomeInterface")));
61         }
62         return actions.toArray(new Action JavaDoc[actions.size()]);
63     }
64
65     public HelpCtx getHelpCtx() {
66         return HelpCtx.DEFAULT_HELP;
67     }
68     
69     // private helpers =========================================================
70

71     private ClassPath getClassPath() {
72         //TODO: RETOUCHE
73
return null;
74 // TypeElement jc = Utils.getJavaClassFromNode(getActivatedNodes()[0]);
75
// FileObject fo = JavaModel.getFileObject(jc.getResource());
76
// return ClassPath.getClassPath(fo, ClassPath.SOURCE);
77
}
78     
79     private EntityAndSession getEjb() {
80         //TODO: RETOUCHE
81
// try {
82
// JavaClass jc = JMIUtils.getJavaClassFromNode(getActivatedNodes()[0]);
83
// EjbJar ejbJar = DDProvider.getDefault().getMergedDDRoot(getApiEjbJar(jc).getMetadataUnit());
84
// Ejb[] ejbs = ejbJar.getEnterpriseBeans().getEjbs();
85
// for (int i = 0; i < ejbs.length; i++) {
86
// if (jc.getName().equals(ejbs[i].getEjbClass())) {
87
// return (EntityAndSession) ejbs[i];
88
// }
89
// }
90
// } catch (IOException ioe) {
91
// // do nothing
92
// }
93
return null;
94     }
95
96     //TODO: RETOUCHE
97
// private org.netbeans.modules.j2ee.api.ejbjar.EjbJar getApiEjbJar(TypeElement jc) {
98
// return null;
99
// FileObject fo = JavaModel.getFileObject(jc.getResource());
100
// return org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(fo);
101
// }
102

103 }
104
Popular Tags