KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > connection > ReconnectAction


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;
18
19 import org.mc4j.console.IConnectionNode;
20 import org.mc4j.console.util.NodeUtil;
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  *
31  * @author Greg Hinkle (ghinkle@users.sourceforge.net), September 2002
32  * @version $Revision: 488 $($Author: ghinkl $ / $Date: 2004-10-13 00:57:58 -0400 (Wed, 13 Oct 2004) $)
33  */

34 public class ReconnectAction extends NodeAction {
35
36     public ReconnectAction() {
37         Image image =
38             NodeUtil.mergeIcons(
39                 "org/mc4j/console/connection/ConnectionNodeIcon.gif",
40                 "org/mc4j/console/connection/Connected.gif");
41         setIcon(new ImageIcon(image));
42     }
43
44     protected void performAction(Node[] nodes) {
45         IConnectionNode node = (IConnectionNode)nodes[0];
46         try {
47             node.connect();
48         } catch (Exception JavaDoc e) {
49             ErrorManager.getDefault().notify(e);
50         }
51     }
52
53     protected boolean enable(Node[] nodes) {
54         return ((nodes.length == 1) &&
55                 (nodes[0] instanceof IConnectionNode) &&
56                 (!((IConnectionNode)nodes[0]).isConnected()));
57     }
58
59     public String JavaDoc getName() {
60         return "Connect";
61     }
62
63     public HelpCtx getHelpCtx() {
64         return HelpCtx.DEFAULT_HELP;
65     }
66 }
67
Popular Tags