KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > connection > create > CreateMBeanAction


1 /*
2  * Copyright 2002-2004 Greg Hinkle
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.mc4j.console.connection.create;
18
19 import org.mc4j.console.connection.ConnectionNode;
20 import org.openide.DialogDisplayer;
21 import org.openide.ErrorManager;
22 import org.openide.nodes.Node;
23 import org.openide.util.HelpCtx;
24 import org.openide.util.actions.NodeAction;
25
26 import javax.swing.*;
27 import java.awt.*;
28
29 /**
30  * Action sensitive to the node selection that does something useful.
31  * Consider using a cookie action instead if you can define what the
32  * action is applicable to in terms of cookies.
33  *
34  * @author Greg Hinkle (ghinkle@users.sourceforge.net), January 2002
35  * @version $Revision: 570 $($Author: ghinkl $ / $Date: 2006-04-12 15:14:16 -0400 (Wed, 12 Apr 2006) $)
36  */

37 public class CreateMBeanAction extends NodeAction {
38
39
40     public void performAction(Node[] nodes) {
41         // do work based on the current node selection, e.g.:
42
ConnectionNode node = (ConnectionNode) nodes[0];
43
44         final CreateWizardDescriptor desc = new CreateWizardDescriptor(node.getEmsConnection());
45
46
47         final Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
48
49         // The following assumes the wizard descriptor is modal:
50
try {
51             SwingUtilities.invokeAndWait(new Runnable JavaDoc() {
52                 public void run() {
53                     dlg.show();
54                 }
55             });
56         } catch (Exception JavaDoc e) { // InterruptedException, InvocationTargetException
57
ErrorManager.getDefault().notify(e);
58             return;
59         }
60
61     }
62
63     protected boolean enable(Node[] nodes) {
64
65         return nodes.length == 1 && nodes[0] instanceof ConnectionNode;
66     }
67
68     public String JavaDoc getName() {
69         return "Create MBean";
70
71     }
72
73     protected String JavaDoc iconResource() {
74         return "org/mc4j/console/connection/ConnectActionIcon.gif";
75     }
76
77     public HelpCtx getHelpCtx() {
78         return HelpCtx.DEFAULT_HELP;
79         // If you will provide context help then use:
80
// return new HelpCtx(ConnectAction.class);
81
}
82
83 }
84
Popular Tags