source: release-kits/shared/ant-installer/src/org/tp23/antinstaller/renderer/swing/TargetInputRenderer.java@ 15311

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

deleting unneeded compiled classes

File size: 3.2 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 java.awt.BorderLayout;
22import java.awt.FlowLayout;
23import java.awt.Dimension;
24
25import javax.swing.JPanel;
26import javax.swing.JLabel;
27import javax.swing.JCheckBox;
28
29import org.tp23.antinstaller.input.InputField;
30import org.tp23.antinstaller.input.OutputField;
31import org.tp23.antinstaller.input.TargetInput;
32import org.tp23.gui.GBCF;
33
34public class TargetInputRenderer
35 extends SwingOutputFieldRenderer {
36
37 protected TargetInput outputField;
38
39 protected AILabel fieldLabel = new AILabel();
40 protected AIShortLabel sizeLabel = new AIShortLabel();
41 protected JCheckBox targetCheckBox = new JCheckBox();
42
43
44 public TargetInputRenderer() {
45 }
46 public void initComponent(JPanel parent){
47 try {
48 jbInit();
49 }
50 catch(Exception e) {
51 ctx.log(e.getMessage());
52 if(ctx.getInstaller().isVerbose()) {
53 ctx.log(e);
54 }
55
56 }
57 }
58
59
60
61 public void setOutputField(OutputField outputField) {
62 this.outputField = (TargetInput)outputField;
63 }
64 public void updateInputField(){
65 String target = outputField.getTarget();
66 int targetIdx = outputField.getIdx();
67 boolean selected = targetCheckBox.isSelected();
68 outputField.setInputResult(String.valueOf(selected));
69 if(selected && !ctx.getCurrentPage().getAllTargets().contains(target)){
70 ctx.getCurrentPage().addTarget(targetIdx, target);
71 }
72 else if(!selected && ctx.getCurrentPage().isTarget(target)){
73 ctx.getCurrentPage().removeTarget(targetIdx);
74 }
75 }
76 public void updateDefaultValue(){
77 if(!outputField.isEditted()){
78 targetCheckBox.setSelected(InputField.isTrue(outputField.getDefaultValue()));
79 }
80 }
81
82 private void jbInit() throws Exception {
83 fieldLabel.setText(outputField.getDisplayText());
84 sizeLabel.setText(outputField.getDiskRequirement());
85 sizeLabel.setMinimumSize( new Dimension( 80, 0 ) );
86 targetCheckBox.setSelected(InputField.isTrue(outputField.getDefaultValue()));
87 if(InputField.isTrue(outputField.getForce())){
88 targetCheckBox.setEnabled(false);
89 }
90
91 targetCheckBox.addActionListener(new ActionListener() {
92 public void actionPerformed(ActionEvent e) {
93 updateInputField();
94 outputField.setEditted(true);
95 }
96 });
97 }
98 public int addSelf(JPanel content,GBCF cf, int row,boolean overflow) {
99
100
101 JLabel hlp = new JLabel("help");
102 hlp.setToolTipText(outputField.getExplanatoryText());
103
104 JPanel p;
105
106 p = new JPanel(new FlowLayout(FlowLayout.LEFT));
107 p.add( fieldLabel );
108 p.add( sizeLabel );
109 p.add( targetCheckBox );
110 p.add( hlp );
111 content.add(p);
112
113 return ++row;
114 }
115
116
117
118 /**
119 * renderError
120 */
121 public void renderError() {
122 }
123}
Note: See TracBrowser for help on using the repository browser.