KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > gui > objects > ControllerObject


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.gui.objects;
26
27 import java.awt.Color JavaDoc;
28
29 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
30 import org.objectweb.cjdbc.console.gui.constants.GuiIcons;
31
32 /**
33  * This class defines a ControllerObject
34  *
35  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
36  * @version 1.0
37  */

38 public class ControllerObject extends AbstractGuiObject
39 {
40   private String JavaDoc state;
41
42   /**
43    * Creates a new <code>ControllerObject</code> object
44    *
45    * @param name the name of the controller
46    */

47   public ControllerObject(String JavaDoc name)
48   {
49     super();
50     setText(name);
51     setName(name);
52     setBackground(Color.white);
53   }
54
55   /**
56    * Get ip address of this controller
57    *
58    * @return ipAddress
59    */

60   public String JavaDoc getIpAdress()
61   {
62     return getName().substring(0, getName().indexOf(':'));
63   }
64
65   /**
66    * Get port of this controller
67    *
68    * @return port
69    */

70   public String JavaDoc getPort()
71   {
72     return getName().substring(getName().indexOf(':') + 1);
73   }
74
75   /**
76    * Get the state of the controller
77    *
78    * @return state of controller as defined in gui constants , null if unknown
79    */

80   public String JavaDoc getState()
81   {
82     return state;
83   }
84
85   /**
86    * Set state of controller and change its icon
87    *
88    * @param state string description of the state
89    */

90   public void setState(String JavaDoc state)
91   {
92     if (state.equals(GuiConstants.CONTROLLER_STATE_UP))
93     {
94       setIcon(GuiIcons.CONTROLLER_READY);
95       setEnabled(true);
96     }
97     else
98     {
99       setIcon(GuiIcons.CONTROLLER_DOWN);
100       //setEnabled(false);
101
}
102     this.state = state;
103   }
104 }
Popular Tags