001: /*
002: * Copyright (c) 2004 JETA Software, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without modification,
005: * are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of JETA Software nor the names of its contributors may
015: * be used to endorse or promote products derived from this software without
016: * specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
021: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022: * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
023: * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
025: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
026: * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: */
029:
030: package com.jeta.open.support;
031:
032: import javax.swing.AbstractButton;
033: import javax.swing.JCheckBox;
034: import javax.swing.JComboBox;
035: import javax.swing.JLabel;
036: import javax.swing.JList;
037: import javax.swing.JPanel;
038: import javax.swing.JProgressBar;
039: import javax.swing.JRadioButton;
040: import javax.swing.JSpinner;
041: import javax.swing.JTabbedPane;
042: import javax.swing.JTable;
043: import javax.swing.JTextField;
044: import javax.swing.JTree;
045: import javax.swing.text.JTextComponent;
046:
047: /**
048: * Interface that defines common methods for working with SwingComponents in a
049: * Container.
050: *
051: * @author Jeff Tassin
052: */
053: public interface SwingComponentSupport extends ComponentFinder {
054: /**
055: * Enables/Disables the component associated with the commandid
056: *
057: * @param commandId
058: * the id of the command whose button to enable/disable
059: * @param bEnable
060: * true/false to enable/disable
061: */
062: public void enableComponent(String commandId, boolean bEnable);
063:
064: /**
065: * Returns the selected state of the AbstractButton that has the given name.
066: * If a component is found with the given name and that component is not an
067: * AbstractButton, then false is returned.
068: *
069: * @return the selected state of the named AbstractButton.
070: */
071: public boolean getBoolean(String compName);
072:
073: /**
074: * Returns the button that is contained in this panel and has the given
075: * name. If the component is not found nor is an AbstractButton, null is
076: * returned.
077: *
078: * @return the named AbstractButton
079: */
080: public AbstractButton getButton(String compName);
081:
082: /**
083: * Returns the JCheckBox that is contained in this panel and has the given
084: * name. If the component is not found nor is a JCheckBox, null is returned.
085: *
086: * @return the named JCheckBox
087: */
088: public JCheckBox getCheckBox(String compName);
089:
090: /**
091: * Returns the JComboBox that is contained in this panel and has the given
092: * name. If the component is not found nor is a JComboBox, null is returned.
093: *
094: * @return the named JComboBox
095: */
096: public JComboBox getComboBox(String compName);
097:
098: /**
099: * Locates the JTextField that has the given component name. The text in the
100: * field is converted to an integer and returned. If the text cannot be
101: * converted to an integer or the component is not a JTextField, the
102: * defaultValue is returned.
103: *
104: * @param compName
105: * the JTextField to find.
106: * @param defaultValue
107: * the value to return if the component is not a JTextField or
108: * the text in the field is not an integer.
109: * @return the text converted to an integer.
110: */
111: public int getInteger(String compName, int defaultValue);
112:
113: /**
114: * Returns the JLabel that is contained in this panel and has the given
115: * name. If the component is not found nor is a JLabel, null is returned.
116: *
117: * @return the named JLabel.
118: */
119: public JLabel getLabel(String compName);
120:
121: /**
122: * Returns the JList that is contained in this panel and has the given name.
123: * If the component is not found nor is a JList, null is returned.
124: *
125: * @return the named JList
126: */
127: public JList getList(String compName);
128:
129: /**
130: * Returns the JPanel that is contained in this panel and has the given
131: * name. If the component is not found nor is a JPanel, null is returned.
132: *
133: * @return the named JPanel
134: */
135: public JPanel getPanel(String compName);
136:
137: /**
138: * Returns JProgressBar that is contained in this panel and has the given
139: * name. If the component is not found nor is a JProgressBar, null is
140: * returned.
141: *
142: * @return the named JProgressBar.
143: */
144: public JProgressBar getProgressBar(String compName);
145:
146: /**
147: * Returns the JRadioButton that is contained in this panel and has the
148: * given name. If the component is not found nor is a JRadioButton, null is
149: * returned.
150: *
151: * @return the named JRadioButton
152: */
153: public JRadioButton getRadioButton(String compName);
154:
155: /**
156: * Returns the selected item from the JList or JComboBox that has the given
157: * name. If a list or combo is not found with the name, null is returned.
158: *
159: * @return the selected item from the named JList or JComboBox.
160: */
161: public Object getSelectedItem(String compName);
162:
163: /**
164: * Returns JSpinner that is contained in this panel and has the given name.
165: * If the component is not found nor is a JSpinner, null is returned.
166: *
167: * @return the named JSpinner
168: */
169: public JSpinner getSpinner(String compName);
170:
171: /**
172: * Returns the JTable that is contained in this panel and has the given
173: * name. If the component is not found nor is a JTable, null is returned.
174: *
175: * @return the named JTable
176: */
177: public JTable getTable(String compName);
178:
179: /**
180: * Returns the JTabbedPane that is contained in this panel and has the given
181: * name. If the component is not found nor is a JTabbedPane, null is
182: * returned.
183: *
184: * @return the named JTabbedPane
185: */
186: public JTabbedPane getTabbedPane(String compName);
187:
188: /**
189: * Returns the JTextComponent that is contained in this panel and has the
190: * given name. If the component is not found nor is a JTextComponent, null
191: * is returned.
192: *
193: * @return the named JTextComponent
194: */
195: public JTextComponent getTextComponent(String compName);
196:
197: /**
198: * Returns the JTextField that is contained in this panel and has the given
199: * name. If the component is not found nor is a JTextField, null is
200: * returned.
201: *
202: * @return the named JTextField
203: */
204: public JTextField getTextField(String compName);
205:
206: /**
207: * Returns the text property from a Component. If a component is not found
208: * with the given name or a component does not have a text property, then
209: * null is returned.
210: *
211: * @return the text property.
212: */
213: public String getText(String compName);
214:
215: /**
216: * Returns the JTree that is contained in this panel and has the given name.
217: * If the component is not found nor is a JTree, null is returned.
218: *
219: * @return the named JTree
220: */
221: public JTree getTree(String compName);
222:
223: /**
224: * Return the selected state of the AbstractButton that has the given name.
225: * If a component is found with the given name and that component is not an
226: * AbstractButton, then false is returned.
227: *
228: * @see SwingCompnentSupport#getBoolean
229: */
230: public boolean isSelected(String compName);
231:
232: /**
233: * Shows/Hides the component with the given name.
234: *
235: * @param compName
236: * the name of the component to enable/disable
237: * @param bVisible
238: * show/hide the component/disable
239: */
240: public void setVisible(String compName, boolean bVisible);
241:
242: /**
243: * Sets the selected attribute for the AbstractButton with the given name.
244: * If a component is found with the given name and that component is not an
245: * AbstractButton, this call is ignored.
246: *
247: * @param compName
248: * the name of the AbstractButton whose selected attribute to
249: * set.
250: * @param sel
251: * the selected attribute to set
252: */
253: public void setSelected(String compName, boolean sel);
254:
255: /**
256: * Sets the selected item in a JComboBox that has the given name. If a combo
257: * is not found with the name, no action is performed.
258: */
259: public void setSelectedItem(String compName, Object value);
260:
261: /**
262: * Sets text property for the Component with the given name. If no component
263: * is found or the Component does not have a text property, then this method
264: * is a no op.
265: *
266: * @param compName
267: * the name of the JTextComponent whose text to set
268: * @param txt
269: * the text to set
270: */
271: public void setText(String compName, String txt);
272:
273: }
|