Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / toc / gui / ChangeName.java @ 13936

History | View | Annotate | Download (5.78 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toc.gui;
42

    
43

    
44
import java.awt.FlowLayout;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
47
import java.awt.event.KeyEvent;
48
import java.awt.event.KeyListener;
49

    
50
import javax.swing.JLabel;
51
import javax.swing.JPanel;
52
import javax.swing.JTextField;
53

    
54
import org.gvsig.gui.beans.AcceptCancelPanel;
55

    
56
import com.iver.andami.PluginServices;
57
import com.iver.andami.ui.mdiManager.IWindow;
58
import com.iver.andami.ui.mdiManager.WindowInfo;
59

    
60

    
61
/**
62
 * Di?logo para cambiar el nombre de una capa.
63
 *
64
 * @author Vicente Caballero Navarro
65
 */
66
public class ChangeName extends JPanel implements IWindow {
67
        private JPanel jContentPane = null;
68
        private JLabel lblName = null;
69
        private JTextField txtName = null;
70
        private String name;
71
        private JPanel jPanel = null;
72
        private AcceptCancelPanel jPanel1 = null;
73
        private boolean isAccepted=false;
74
        /**
75
         * This is the default constructor
76
         *
77
         * @param layout Referencia al Layout.
78
         * @param fframe Referencia al fframe de imagen.
79
         */
80
        public ChangeName(String n) {
81
                super();
82
                if (n==null){
83
                        name=PluginServices.getText(this, "agrupacion");
84
                }else{
85
                        name=n;
86
                }
87
                initialize();
88
        }
89

    
90
        /**
91
         * This method initializes this
92
         */
93
        private void initialize() {
94
                this.setLayout(null);
95
                this.add(getJContentPane(), null);
96
                this.setSize(381, 77);
97
        }
98

    
99
        /**
100
         * This method initializes jContentPane
101
         *
102
         * @return javax.swing.JPanel
103
         */
104
        private JPanel getJContentPane() {
105
                if (jContentPane == null) {
106
                        jContentPane = new JPanel();
107
                        jContentPane.setLayout(null);
108
                        jContentPane.setSize(385, 77);
109
                        jContentPane.setLocation(0, 0);
110
                        jContentPane.add(getJPanel(), null);
111
                        jContentPane.add(getJPanel1(), null);
112
                }
113

    
114
                return jContentPane;
115
        }
116

    
117
        /**
118
         * This method initializes lFichero
119
         *
120
         * @return javax.swing.JLabel
121
         */
122
        private JLabel getLblName() {
123
                if (lblName == null) {
124
                        lblName = new JLabel();
125
                        lblName.setSize(42, 20);
126
                        lblName.setText(PluginServices.getText(this, "nombre"));
127
                        lblName.setLocation(10, 9);
128
                }
129

    
130
                return lblName;
131
        }
132

    
133
        /**
134
         * This method initializes tFichero
135
         *
136
         * @return javax.swing.JTextField
137
         */
138
        private JTextField getTxtName() {
139
                if (txtName == null) {
140
                        txtName = new JTextField();
141
                        txtName.setBounds(62, 8, 280, 20);
142
                        txtName.setPreferredSize(new java.awt.Dimension(270, 20));
143
                        txtName.setText(name);
144
                        txtName.addKeyListener(new KeyListener(){
145

    
146
                                public void keyPressed(KeyEvent e) {
147
                                        if (e.getKeyCode() == KeyEvent.VK_ENTER){
148
                                                acceptAction();
149
                                        } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE){
150
                                                cancelAction();
151
                                        }
152

    
153
                                }
154

    
155
                                public void keyReleased(KeyEvent e) {
156
                                        // TODO Auto-generated method stub
157

    
158
                                }
159

    
160
                                public void keyTyped(KeyEvent e) {
161
                                        // TODO Auto-generated method stub
162

    
163
                                }
164

    
165
                        });
166
                }
167
                return txtName;
168
        }
169

    
170
        /**
171
         * Inserta el path al TFichero.
172
         *
173
         * @param val path del fichero.
174
         */
175
        public void setText(String val) {
176
                getTxtName().setText(val);
177
        }
178

    
179
        /* (non-Javadoc)
180
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
181
         */
182
        public WindowInfo getWindowInfo() {
183
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
184
                m_viewinfo.setTitle(PluginServices.getText(this,
185
                                "cambio_nombre"));
186
                return m_viewinfo;
187
        }
188
        public String getName(){
189
                return name;
190
        }
191

    
192
        /**
193
         * This method initializes jPanel
194
         *
195
         * @return javax.swing.JPanel
196
         */
197
        private JPanel getJPanel() {
198
                if (jPanel == null) {
199
                        jPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
200
                        jPanel.add(getLblName(), null);
201
                        jPanel.add(getTxtName(), null);
202

    
203
                        jPanel.setBounds(new java.awt.Rectangle(4,3,329,35));
204
                }
205
                return jPanel;
206
        }
207

    
208
        /**
209
         * This method initializes jPanel1
210
         *
211
         * @return javax.swing.JPanel
212
         */
213
        private AcceptCancelPanel getJPanel1() {
214
                if (jPanel1 == null) {
215
                        ActionListener okActionListener, cancelActionListener;
216
                        okActionListener = new java.awt.event.ActionListener() {
217
                                public void actionPerformed(java.awt.event.ActionEvent e) {
218
                                        acceptAction();
219
                                }
220
                        };
221
                        cancelActionListener = new java.awt.event.ActionListener() {
222
                                public void actionPerformed(java.awt.event.ActionEvent e) {
223
                                        cancelAction();
224
                                }
225
                        };
226
                        jPanel1 = new AcceptCancelPanel(okActionListener, cancelActionListener);
227
                        jPanel1.setBounds(new java.awt.Rectangle(3,39,374,35));
228
                }
229
                return jPanel1;
230
        }
231

    
232
        public boolean isAccepted() {
233
                return isAccepted;
234
        }
235

    
236
        protected void acceptAction(){
237
                name=getTxtName().getText();
238
                isAccepted=true;
239
                PluginServices.getMDIManager().closeWindow(ChangeName.this);
240

    
241
        }
242

    
243
        protected void cancelAction(){
244
                isAccepted=false;
245
                PluginServices.getMDIManager().closeWindow(ChangeName.this);
246

    
247
        }
248

    
249
}  //  @jve:decl-index=0:visual-constraint="10,10"
250