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

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

work on the GUI of the installer

File size: 3.0 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;
20import java.awt.event.KeyAdapter;
21import java.awt.event.KeyEvent;
22import java.awt.Dimension;
23import java.awt.Insets;
24
25import java.awt.FlowLayout;
26import java.awt.GridLayout;
27import java.awt.BorderLayout;
28import javax.swing.JPanel;
29
30import org.tp23.antinstaller.input.OutputField;
31import org.tp23.antinstaller.input.UnvalidatedTextInput;
32import org.tp23.gui.GBCF;
33
34public class UnvalidatedTextInputRenderer
35 extends SwingOutputFieldRenderer {
36
37 protected UnvalidatedTextInput inputField;
38
39 protected AILabel fieldLabel = new AILabel();
40 protected AITextfield jTextField = new AITextfield();
41
42 public UnvalidatedTextInputRenderer() {
43 }
44
45 public void initComponent(JPanel parent){
46 try {
47 jbInit();
48 }
49 catch(Exception e) {
50 ctx.log(e.getMessage());
51 if(ctx.getInstaller().isVerbose()) {
52 ctx.log(e);
53 }
54
55 }
56 }
57
58 public void setOutputField(OutputField inputField) {
59 this.inputField=(UnvalidatedTextInput)inputField;
60 this.inputField.setValue(this.inputField.getDefaultValue());
61 }
62 public void updateInputField(){
63 inputField.setValue(jTextField.getText());
64 }
65 public void updateDefaultValue(){
66 if(!inputField.isEditted())jTextField.setText(inputField.getDefaultValue());
67 }
68
69 private void jbInit() throws Exception {
70 fieldLabel.setText(inputField.getDisplayText());
71 fieldLabel.setMinimumSize( new Dimension( SizeConstants.LABEL_WIDTH, 0) );
72
73 jTextField.setText(inputField.getDefaultValue());
74 jTextField.addActionListener(new ActionListener() {
75 public void actionPerformed(ActionEvent e) {
76 updateInputField();
77 }
78 });
79 jTextField.addKeyListener(new KeyAdapter() {
80 public void keyTyped(KeyEvent e) {
81 if (e.getKeyChar() != '\t') {
82 inputField.setEditted(true);
83 }
84 }
85 });
86
87 }
88 public int addSelf(JPanel content,GBCF cf, int row,boolean overflow) {
89 JPanel p;
90
91 //p = new JPanel(new FlowLayout(FlowLayout.LEFT));
92 BorderLayout l = new BorderLayout();
93 p = new JPanel(l);
94 p.add( fieldLabel, BorderLayout.WEST );
95 p.add( jTextField, BorderLayout.CENTER );
96 content.add(p);
97
98 p = new JPanel();
99 p.setMinimumSize( new Dimension(0,1) );
100 content.add(p);
101
102
103 if(overflow){
104 jTextField.setOverflow(SizeConstants.OVERFLOW_FIELD_SIZE);
105 }
106 return ++row;
107 }
108
109 /**
110 * renderError
111 */
112 public void renderError() {
113 }
114}
Note: See TracBrowser for help on using the repository browser.