svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / vectorialdb / JPasswordDlg.java @ 40557
History | View | Annotate | Download (7.18 KB)
1 | 40557 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40557 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40557 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | 40557 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | 40435 | jjdelcerro | *
|
21 | 40557 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.geodb.vectorialdb; |
||
25 | |||
26 | import java.awt.event.KeyEvent; |
||
27 | |||
28 | import javax.swing.JButton; |
||
29 | import javax.swing.JEditorPane; |
||
30 | import javax.swing.JPanel; |
||
31 | import javax.swing.JPasswordField; |
||
32 | import javax.swing.JTextArea; |
||
33 | |||
34 | import org.gvsig.andami.PluginServices; |
||
35 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
36 | import org.gvsig.andami.ui.mdiManager.WindowInfo; |
||
37 | |||
38 | |||
39 | public class JPasswordDlg extends JPanel implements IWindow { |
||
40 | |||
41 | private JPanel jContentPane = null; |
||
42 | |||
43 | private JButton jButtonOK = null; |
||
44 | |||
45 | private JButton jButton1 = null; |
||
46 | |||
47 | private JPasswordField jPasswordField = null; |
||
48 | |||
49 | private String password = null; |
||
50 | |||
51 | private JEditorPane jEditorPane = null; |
||
52 | |||
53 | private JTextArea jLblMensaje = null; |
||
54 | |||
55 | // private WindowEventsHandler windowHandler = new WindowEventsHandler();
|
||
56 | |||
57 | /**
|
||
58 | * This is the default constructor
|
||
59 | */
|
||
60 | public JPasswordDlg() {
|
||
61 | super();
|
||
62 | initialize(); |
||
63 | } |
||
64 | |||
65 | // class WindowEventsHandler extends WindowAdapter
|
||
66 | // {
|
||
67 | //
|
||
68 | // /* (non-Javadoc)
|
||
69 | // * @see java.awt.event.WindowAdapter#windowActivated(java.awt.event.WindowEvent)
|
||
70 | // */
|
||
71 | // public void windowActivated(WindowEvent e) {
|
||
72 | // // TODO Auto-generated method stub
|
||
73 | // super.windowActivated(e);
|
||
74 | // jPasswordField.requestFocus();
|
||
75 | // }
|
||
76 | //
|
||
77 | // }
|
||
78 | /**
|
||
79 | * This method initializes this
|
||
80 | *
|
||
81 | * @return void
|
||
82 | */
|
||
83 | private void initialize() { |
||
84 | this.setSize(287, 172); |
||
85 | this.setLayout(null); |
||
86 | this.add(getJContentPane());
|
||
87 | // this.setModal(true);
|
||
88 | // this.setResizable(false);
|
||
89 | // this.setTitle("Enter Password");
|
||
90 | // this.setContentPane(getJContentPane());
|
||
91 | //
|
||
92 | // addWindowListener(windowHandler);
|
||
93 | } |
||
94 | /**
|
||
95 | * This method initializes jContentPane
|
||
96 | *
|
||
97 | * @return javax.swing.JPanel
|
||
98 | */
|
||
99 | private JPanel getJContentPane() { |
||
100 | if (jContentPane == null) { |
||
101 | jContentPane = new JPanel(); |
||
102 | jContentPane.setLayout(null);
|
||
103 | jContentPane.add(getJButton1(), null);
|
||
104 | jContentPane.add(getJButtonOK(), null);
|
||
105 | jContentPane.add(getJPasswordField(), null);
|
||
106 | jContentPane.add(getJLblMensaje(), null);
|
||
107 | jContentPane.setBounds(0,0,300,200); |
||
108 | } |
||
109 | return jContentPane;
|
||
110 | } |
||
111 | |||
112 | /**
|
||
113 | * This method initializes jButton
|
||
114 | *
|
||
115 | * @return javax.swing.JButton
|
||
116 | */
|
||
117 | private JButton getJButtonOK() { |
||
118 | if (jButtonOK == null) { |
||
119 | jButtonOK = new JButton(); |
||
120 | jButtonOK.setText("OK");
|
||
121 | jButtonOK.setPreferredSize(new java.awt.Dimension(65, 23)); |
||
122 | jButtonOK.setBounds(35, 110, 101, 22); |
||
123 | jButtonOK.addActionListener(new java.awt.event.ActionListener() {
|
||
124 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
125 | System.out.println("actionPerformed()"); // TODO |
||
126 | // Auto-generated
|
||
127 | // Event stub
|
||
128 | // actionPerformed()
|
||
129 | password = String.copyValueOf(getJPasswordField()
|
||
130 | .getPassword()); |
||
131 | PluginServices.getMDIManager().closeWindow(JPasswordDlg.this); |
||
132 | // dispose();
|
||
133 | } |
||
134 | }); |
||
135 | } |
||
136 | return jButtonOK;
|
||
137 | } |
||
138 | |||
139 | /**
|
||
140 | * This method initializes jButton1
|
||
141 | *
|
||
142 | * @return javax.swing.JButton
|
||
143 | */
|
||
144 | private JButton getJButton1() { |
||
145 | if (jButton1 == null) { |
||
146 | jButton1 = new JButton(); |
||
147 | jButton1.setText("Cancel");
|
||
148 | jButton1.setBounds(136, 110, 99, 22); |
||
149 | jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||
150 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
151 | password = null;
|
||
152 | PluginServices.getMDIManager().closeWindow(JPasswordDlg.this); |
||
153 | // dispose();
|
||
154 | } |
||
155 | }); |
||
156 | } |
||
157 | return jButton1;
|
||
158 | } |
||
159 | |||
160 | /**
|
||
161 | * This method initializes jPasswordField
|
||
162 | *
|
||
163 | * @return javax.swing.JPasswordField
|
||
164 | */
|
||
165 | private JPasswordField getJPasswordField() { |
||
166 | if (jPasswordField == null) { |
||
167 | jPasswordField = new JPasswordField(); |
||
168 | jPasswordField.setPreferredSize(new java.awt.Dimension(60, 22)); |
||
169 | jPasswordField.setBounds(65, 78, 145, 21); |
||
170 | jPasswordField.addKeyListener(new java.awt.event.KeyAdapter() {
|
||
171 | public void keyTyped(java.awt.event.KeyEvent e) { |
||
172 | if (e.getKeyChar() == KeyEvent.VK_ENTER) { |
||
173 | // System.out.println("INTRO");
|
||
174 | getJButtonOK().doClick(); |
||
175 | } |
||
176 | } |
||
177 | }); |
||
178 | } |
||
179 | return jPasswordField;
|
||
180 | } |
||
181 | |||
182 | /**
|
||
183 | * @return Returns the password.
|
||
184 | */
|
||
185 | public String getPassword() { |
||
186 | return password;
|
||
187 | } |
||
188 | |||
189 | public void setMessage(String str) { |
||
190 | getJLblMensaje().setText(str); |
||
191 | } |
||
192 | |||
193 | /**
|
||
194 | * This method initializes jTextArea
|
||
195 | *
|
||
196 | * @return javax.swing.JTextArea
|
||
197 | */
|
||
198 | private JTextArea getJLblMensaje() { |
||
199 | if (jLblMensaje == null) { |
||
200 | jLblMensaje = new JTextArea(); |
||
201 | jLblMensaje.setEditable(false);
|
||
202 | jLblMensaje.setForeground(java.awt.Color.black); |
||
203 | jLblMensaje.setBackground(java.awt.SystemColor.control); |
||
204 | jLblMensaje.setText("Mensaje");
|
||
205 | jLblMensaje.setLineWrap(true);
|
||
206 | jLblMensaje.setFont(new java.awt.Font("SansSerif", |
||
207 | java.awt.Font.PLAIN, 12));
|
||
208 | jLblMensaje.setPreferredSize(new java.awt.Dimension(270, 50)); |
||
209 | jLblMensaje.setBounds(9, 6, 266, 68); |
||
210 | jLblMensaje.setWrapStyleWord(true);
|
||
211 | } |
||
212 | return jLblMensaje;
|
||
213 | } |
||
214 | public WindowInfo getWindowInfo() {
|
||
215 | WindowInfo wi=new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
|
||
216 | wi.setTitle(PluginServices.getText(this,"enter_password")); |
||
217 | return wi;
|
||
218 | } |
||
219 | public Object getWindowProfile() { |
||
220 | // TODO Auto-generated method stub
|
||
221 | return WindowInfo.DIALOG_PROFILE;
|
||
222 | } |
||
223 | |||
224 | } // @jve:decl-index=0:visual-constraint="10,10" |