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 | */
|
---|
16 | package org.tp23.antinstaller.renderer.swing;
|
---|
17 |
|
---|
18 | import java.awt.Color;
|
---|
19 | import java.awt.event.KeyAdapter;
|
---|
20 | import java.awt.event.KeyEvent;
|
---|
21 | import java.util.ResourceBundle;
|
---|
22 |
|
---|
23 | import javax.swing.JPanel;
|
---|
24 |
|
---|
25 | import org.tp23.antinstaller.renderer.MessageRenderer;
|
---|
26 | import org.tp23.gui.GBCF;
|
---|
27 |
|
---|
28 | public class PasswordTextInputRenderer extends ValidatedTextInputRenderer{
|
---|
29 |
|
---|
30 | public PasswordTextInputRenderer() {
|
---|
31 | this.jTextField = new AIPasswordField();
|
---|
32 | origFore = jTextField.getForeground(); // this is lazy there must be a way to shift this line of code to the superclass (is it worth it)
|
---|
33 | }
|
---|
34 |
|
---|
35 |
|
---|
36 | public void renderError() {
|
---|
37 | MessageRenderer mr = ctx.getMessageRenderer();
|
---|
38 | mr.printMessage( getErrorMessage() );
|
---|
39 | // fixed BUG:1295944 mr.printMessage("The password is not of the correct format\n\n e.g. "+inputField.getDefaultValue());
|
---|
40 | this.jTextField.requestFocus();
|
---|
41 | this.jTextField.setForeground(Color.red);
|
---|
42 | jTextField.addKeyListener(new KeyAdapter() {
|
---|
43 | public void keyTyped(KeyEvent e) {
|
---|
44 | if(e.getKeyChar() != '\t'){
|
---|
45 | inputField.setEditted(true);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | });
|
---|
49 | }
|
---|
50 | public int addSelf(JPanel content, GBCF cf, int row, boolean overflow) {
|
---|
51 | content.add(fieldLabel, cf.getCell(row, 0));
|
---|
52 | content.add(jTextField, cf.getCell(row, 1));
|
---|
53 | if(overflow){
|
---|
54 | ((AIPasswordField)jTextField).setOverflow(SizeConstants.OVERFLOW_FIELD_SIZE);
|
---|
55 | }
|
---|
56 | return ++row;
|
---|
57 | }
|
---|
58 | protected String getErrorMessage(){
|
---|
59 | return org.tp23.antinstaller.Installer.langPack.getString("notCorrectPasswordFormat") +
|
---|
60 | "\n\n e.g. " +
|
---|
61 | inputField.getDefaultValue();
|
---|
62 | }
|
---|
63 |
|
---|
64 | }
|
---|