KickJava   Java API By Example, From Geeks To Geeks.

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


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.openide.ErrorManager;
20 import org.openide.nodes.Children;
21
22 /**
23  * List of children of a containing node.
24  * Remember to document what your permitted keys are!
25  *
26  *
27  * @author Greg Hinkle (ghinkle@users.sourceforge.net), January 2002
28  * @version $Revision: 480 $($Author: ghinkl $ / $Date: 2004-10-05 01:17:41 -0400 (Tue, 05 Oct 2004) $)
29  */

30 public class ConnectionNodeChildren extends Children.Array {
31
32     private ConnectionNode connectionNode;
33
34
35     public void setConnectionNode(ConnectionNode node) {
36         this.connectionNode = node;
37     }
38
39     protected void addNotify() {
40         super.addNotify();
41         
42         Thread JavaDoc connector = new Thread JavaDoc(new Runnable JavaDoc() {
43             public void run() {
44                 exposeDomains();
45             }
46         }, "Mc4j Connection Thread");
47
48         connector.start();
49     }
50     
51     protected void exposeDomains() {
52         if (this.connectionNode.isConnected()) {
53             this.connectionNode.refresh();
54         } else {
55             try {
56                 this.connectionNode.connect();
57             } catch (Exception JavaDoc e) {
58                 ErrorManager.getDefault().notify(e);
59             }
60         }
61     }
62 }
63
Popular Tags