01: /*
02: * Copyright 2005 Paul Hinds, Mark Anderson
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.tp23.antinstaller.renderer.swing;
17:
18: import java.util.Enumeration;
19:
20: import javax.swing.JRadioButton;
21:
22: import org.tp23.antinstaller.input.TargetSelectInput;
23:
24: /**
25: *
26: * @author Paul Hinds, Mark Anderson
27: * @version $Id: TargetSelectInputRenderer.java,v 1.3 2006/08/04 17:13:24 anothermwilson Exp $
28: */
29: public class TargetSelectInputRenderer extends SelectInputRenderer {
30:
31: public TargetSelectInputRenderer() {
32: }
33:
34: public void updateInputField() {
35: Enumeration enumeration = optionGroup.getElements();
36: int targetIdx = ((TargetSelectInput) inputField).getIdx();
37: int i = 0;
38: for (; enumeration.hasMoreElements(); i++) {
39: JRadioButton o = (JRadioButton) enumeration.nextElement();
40: ctx.getCurrentPage().removeTarget(targetIdx);
41: if (o.isSelected()) {
42: String target = inputField.getOptions()[i].value;
43: ctx.getCurrentPage().addTarget(targetIdx, target);
44: inputField.setValue(target);
45: break;
46: }
47: }
48: if (i > inputField.getOptions().length) {
49: inputField.setValue(inputField.getDefaultValue());
50: }
51: }
52:
53: }
|