KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > serverconfig > cache > CacheSettings


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.serverconfig.cache;
20
21 import java.awt.*;
22 import java.awt.event.*;
23
24 import javax.swing.*;
25
26 /**
27  * Panel for setting an individual cache's settings.
28  *
29  * @author Matthew Large
30  * @version $Revision: 1.1 $
31  *
32  */

33 public class CacheSettings
34     extends JPanel
35     implements LayoutManager, KeyListener {
36
37     /**
38      * Cache size label.
39      */

40     private JLabel m_cacheSizeLabel = null;
41     
42     /**
43      * Cache size text field.
44      */

45     private JTextField m_cacheSizeTextField = null;
46     
47     /**
48      * true if the cache size has changed.
49      */

50     private boolean m_bcacheSizeChanged = false;
51
52     /**
53      * Cache configuration options panel that this settings object belongs to.
54      */

55     private CacheServerConfigOptions m_optionsPanel = null;
56     
57     /**
58      * Name of the cache object these settings apply to.
59      */

60     private String JavaDoc m_sObjectName = null;
61
62     /**
63      * Constructs a new cache settings object.
64      *
65      * @param sObjectName name of the cache object these settings apply to.
66      * @param optionsPanel cache configuration options panel that this settings object belongs to.
67      */

68     public CacheSettings(String JavaDoc sObjectName, CacheServerConfigOptions optionsPanel) {
69         super();
70         this.m_optionsPanel = optionsPanel;
71         this.m_sObjectName = sObjectName;
72         this.setup();
73     }
74     
75     /**
76      * Initialises this object.
77      *
78      */

79     private void setup() {
80         String JavaDoc fontName = "Dialog";
81         int fontSize = 11;
82         Font font = new Font(fontName, Font.PLAIN, fontSize);
83         
84         this.setLayout(this);
85         
86         this.m_cacheSizeLabel = new JLabel(this.m_sObjectName);
87         this.m_cacheSizeLabel.setFont(font);
88         this.add(m_cacheSizeLabel);
89         
90         this.m_cacheSizeTextField = new JTextField();
91         this.m_cacheSizeTextField.setFont(font);
92         this.m_cacheSizeTextField.addKeyListener(this);
93         this.add(this.m_cacheSizeTextField);
94     }
95
96     /* (non-Javadoc)
97      * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
98      */

99     public void keyReleased(KeyEvent ke) {
100         if(ke.getSource()==this.m_cacheSizeTextField) {
101             this.m_bcacheSizeChanged=true;
102         }
103         this.m_optionsPanel.fireChangesMade();
104     }
105     
106     /**
107      * Checks if the cache size option has changed.
108      *
109      * @return true if the cache size option has changed.
110      */

111     public boolean isCacheSizeChanged() {
112         return this.m_bcacheSizeChanged;
113     }
114     
115     /**
116      * Sets whether the cache size option value has changed.
117      *
118      * @param bcacheSizeChanged true to set that the cache size option has changed.
119      */

120     public void setCacheSizeChanged(boolean bcacheSizeChanged) {
121         this.m_bcacheSizeChanged = bcacheSizeChanged;
122     }
123     
124     /**
125      * Returns the cache size option value.
126      *
127      * @return the cache size option value.
128      */

129     public String JavaDoc getCacheSize() {
130         return this.m_cacheSizeTextField.getText();
131     }
132     
133     /**
134      * Sets the cache size option value.
135      *
136      * @param sCacheSize the cache size option value.
137      */

138     public void setCacheSize(String JavaDoc sCacheSize) {
139         this.m_cacheSizeTextField.setText(sCacheSize);
140     }
141     
142     /**
143      * Returns the name of the cache object these settings apply to.
144      *
145      * @return name of the cache object these settings apply to.
146      */

147     public String JavaDoc getObjectName() {
148         return this.m_sObjectName;
149     }
150
151     /* (non-Javadoc)
152      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
153      */

154     public void layoutContainer(Container arg0) {
155         this.m_cacheSizeLabel.setSize(150, 20);
156         this.m_cacheSizeLabel.setLocation(20, 0);
157         
158         this.m_cacheSizeTextField.setSize(150, 20);
159         this.m_cacheSizeTextField.setLocation(150, 5);
160     }
161
162     /* (non-Javadoc)
163      * @see java.awt.Component#getPreferredSize()
164      */

165     public Dimension getPreferredSize() {
166         return new Dimension(350,30);
167     }
168
169     /* (non-Javadoc)
170      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
171      */

172     public Dimension minimumLayoutSize(Container arg0) {
173         return this.getPreferredSize();
174     }
175
176     /* (non-Javadoc)
177      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
178      */

179     public Dimension preferredLayoutSize(Container arg0) {
180         return this.getPreferredSize();
181     }
182
183     /* (non-Javadoc)
184      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
185      */

186     public void removeLayoutComponent(Component arg0) {
187     }
188
189     /* (non-Javadoc)
190      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
191      */

192     public void addLayoutComponent(String JavaDoc arg0, Component arg1) {
193     }
194
195     /* (non-Javadoc)
196      * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
197      */

198     public void keyPressed(KeyEvent arg0) {
199     }
200
201     /* (non-Javadoc)
202      * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
203      */

204     public void keyTyped(KeyEvent arg0) {
205     }
206
207     /**
208      * @param arg0
209      */

210     private CacheSettings(boolean arg0) {
211         super(arg0);
212     }
213
214     /**
215      * @param arg0
216      */

217     private CacheSettings(LayoutManager arg0) {
218         super(arg0);
219     }
220
221     /**
222      * @param arg0
223      * @param arg1
224      */

225     private CacheSettings(LayoutManager arg0, boolean arg1) {
226         super(arg0, arg1);
227     }
228
229 }
230
Popular Tags