KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > ui > actions > ViewActions


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.debugger.ui.actions;
22
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import javax.swing.Action JavaDoc;
26 import javax.swing.AbstractAction JavaDoc;
27
28 import org.netbeans.modules.debugger.ui.Utils;
29 import org.netbeans.modules.debugger.ui.views.View;
30
31 import org.openide.util.NbBundle;
32 import org.openide.windows.Mode;
33 import org.openide.windows.TopComponent;
34 import org.openide.windows.WindowManager;
35
36
37 /**
38  * Opens View TopComponent.
39  *
40  * @author Jan Jancura, Martin Entlicher
41  */

42 public class ViewActions extends AbstractAction JavaDoc {
43     
44     private String JavaDoc viewName;
45
46     private ViewActions (String JavaDoc viewName) {
47         this.viewName = viewName;
48     }
49
50     public Object JavaDoc getValue(String JavaDoc key) {
51         if (key == Action.NAME) {
52             return NbBundle.getMessage (ViewActions.class, (String JavaDoc) super.getValue(key));
53         }
54         Object JavaDoc value = super.getValue(key);
55         if (key == Action.SMALL_ICON) {
56             if (value instanceof String JavaDoc) {
57                 value = Utils.getIcon ((String JavaDoc) value);
58             }
59         }
60         return value;
61     }
62     
63     public void actionPerformed (ActionEvent JavaDoc evt) {
64         openComponent (viewName, true);
65     }
66     
67     static TopComponent openComponent (String JavaDoc viewName, boolean activate) {
68         TopComponent view = WindowManager.getDefault().findTopComponent(viewName);
69         if (view == null) {
70             throw new IllegalArgumentException JavaDoc(viewName);
71         }
72         view.open();
73         if (activate) {
74             view.requestActive();
75         }
76         return view;
77     }
78     
79     
80     /**
81      * Creates an action that opens Breakpoints TopComponent.
82      */

83     public static Action JavaDoc createBreakpointsViewAction () {
84         ViewActions action = new ViewActions("breakpointsView");
85         action.putValue (Action.NAME, "CTL_BreakpointsAction");
86         action.putValue (Action.SMALL_ICON,
87                 "org/netbeans/modules/debugger/resources/breakpointsView/Breakpoint" // NOI18N
88
);
89         return action;
90     }
91
92     /**
93      * Creates an action that opens Call Stack TopComponent.
94      */

95     public static Action JavaDoc createCallStackViewAction () {
96         ViewActions action = new ViewActions("callstackView");
97         action.putValue (Action.NAME, "CTL_CallStackAction");
98         action.putValue (Action.SMALL_ICON,
99                 "org/netbeans/modules/debugger/resources/callStackView/NonCurrentFrame" // NOI18N
100
);
101         return action;
102     }
103
104     /**
105      * Creates an action that opens Local Variables TopComponent.
106      */

107     public static Action JavaDoc createLocalsViewAction() {
108         ViewActions action = new ViewActions("localsView");
109         action.putValue (Action.NAME, "CTL_LocalVariablesAction");
110         action.putValue (Action.SMALL_ICON,
111                 "org/netbeans/modules/debugger/resources/localsView/LocalVariable" // NOI18N
112
);
113         return action;
114     }
115
116     /**
117      * Creates an action that opens Sessions TopComponent.
118      */

119     public static Action JavaDoc createSessionsViewAction () {
120         ViewActions action = new ViewActions("sessionsView");
121         action.putValue (Action.NAME, "CTL_SessionsAction");
122         action.putValue (Action.SMALL_ICON,
123                 "org/netbeans/modules/debugger/resources/sessionsView/Session" // NOI18N
124
);
125         return action;
126     }
127
128     /**
129      * Creates an action that opens Threads TopComponent.
130      */

131     public static Action JavaDoc createThreadsViewAction () {
132         ViewActions action = new ViewActions("threadsView");
133         action.putValue (Action.NAME, "CTL_ThreadsAction");
134         action.putValue (Action.SMALL_ICON,
135                 "org/netbeans/modules/debugger/resources/threadsView/ThreadGroup" // NOI18N
136
);
137         return action;
138     }
139     
140     
141     /**
142      * Creates an action that opens Watches TopComponent.
143      */

144     public static Action JavaDoc createWatchesViewAction() {
145         ViewActions action = new ViewActions("watchesView");
146         action.putValue (Action.NAME, "CTL_WatchesAction");
147         action.putValue (Action.SMALL_ICON,
148                 "org/netbeans/modules/debugger/resources/watchesView/Watch" // NOI18N
149
);
150         return action;
151     }
152
153 }
154
155
Popular Tags