source: release-kits/lirk3/bin/ant-installer/src/org/tp23/antinstaller/renderer/swing/TargetInputRenderer.java@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 2.8 KB
Line 
1/*
2 * Copyright 2005 Paul Hinds
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 */
16package org.tp23.antinstaller.renderer.swing;
17
18import java.awt.event.ActionEvent;
19import java.awt.event.ActionListener;
20
21import javax.swing.JPanel;
22
23import org.tp23.antinstaller.input.InputField;
24import org.tp23.antinstaller.input.OutputField;
25import org.tp23.antinstaller.input.TargetInput;
26import org.tp23.gui.GBCF;
27
28public class TargetInputRenderer
29 extends SwingOutputFieldRenderer {
30
31 protected TargetInput outputField;
32
33 protected AILabel fieldLabel = new AILabel();
34 protected AICheckBox targetCheckBox = new AICheckBox();
35
36 public TargetInputRenderer() {
37 }
38 public void initComponent(JPanel parent){
39 try {
40 jbInit();
41 }
42 catch(Exception e) {
43 ctx.log(e.getMessage());
44 if(ctx.getInstaller().isVerbose()) {
45 ctx.log(e);
46 }
47
48 }
49 }
50
51
52
53 public void setOutputField(OutputField outputField) {
54 this.outputField = (TargetInput)outputField;
55 }
56 public void updateInputField(){
57 String target = outputField.getTarget();
58 int targetIdx = outputField.getIdx();
59 boolean selected = targetCheckBox.isSelected();
60 outputField.setInputResult(String.valueOf(selected));
61 if(selected && !ctx.getCurrentPage().getAllTargets().contains(target)){
62 ctx.getCurrentPage().addTarget(targetIdx, target);
63 }
64 else if(!selected && ctx.getCurrentPage().isTarget(target)){
65 ctx.getCurrentPage().removeTarget(targetIdx);
66 }
67 }
68 public void updateDefaultValue(){
69 if(!outputField.isEditted()){
70 targetCheckBox.setSelected(InputField.isTrue(outputField.getDefaultValue()));
71 }
72 }
73
74 private void jbInit() throws Exception {
75 fieldLabel.setText(outputField.getDisplayText());
76 targetCheckBox.setSelected(InputField.isTrue(outputField.getDefaultValue()));
77 if(InputField.isTrue(outputField.getForce())){
78 targetCheckBox.setEnabled(false);
79 }
80
81 targetCheckBox.addActionListener(new ActionListener() {
82 public void actionPerformed(ActionEvent e) {
83 updateInputField();
84 outputField.setEditted(true);
85 }
86 });
87 }
88 public int addSelf(JPanel content,GBCF cf, int row,boolean overflow) {
89 content.add(fieldLabel,cf.getCell(row, 0));
90 content.add(targetCheckBox,cf.getCell(row, 1));
91 if(overflow){
92 targetCheckBox.setOverflow(SizeConstants.OVERFLOW_FIELD_SIZE);
93 }
94 return ++row;
95 }
96
97
98
99 /**
100 * renderError
101 */
102 public void renderError() {
103 }
104}
Note: See TracBrowser for help on using the repository browser.