Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / table / gui / TableProperties.java @ 7304

History | View | Annotate | Download (11.4 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.table.gui;
42

    
43

    
44
import java.awt.FlowLayout;
45

    
46
import javax.swing.JPanel;
47
import javax.swing.JTable;
48

    
49
import org.gvsig.gui.beans.AcceptCancelPanel;
50

    
51
import com.hardcode.gdbms.engine.data.driver.DriverException;
52
import com.iver.andami.PluginServices;
53
import com.iver.andami.ui.mdiManager.SingletonWindow;
54
import com.iver.andami.ui.mdiManager.WindowInfo;
55
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
56

    
57

    
58
/**
59
 * Dialogo de propiedades de la tabla
60
 *
61
 * @author Fernando Gonz?lez Cort?s
62
 */
63
public class TableProperties extends JPanel implements SingletonWindow {
64
    private javax.swing.JPanel jContentPane = null;
65
    private javax.swing.JLabel jLabel = null;
66
    private javax.swing.JTextField txtName = null;
67
    private javax.swing.JLabel jLabel1 = null;
68
    private javax.swing.JTextField txtDate = null;
69
    private javax.swing.JTextField txtOwner = null;
70
    private javax.swing.JLabel jLabel2 = null;
71
    private javax.swing.JLabel jLabel3 = null;
72
    private javax.swing.JScrollPane jScrollPane = null;
73
    private javax.swing.JTextArea txtComments = null;
74
    private javax.swing.JScrollPane jScrollPane1 = null;
75
    private javax.swing.JTable tabla = null;
76
    private ProjectTable table;
77
    private AcceptCancelPanel okCancelPanel = null;
78
    private javax.swing.JPanel jPanel = null;
79
    private javax.swing.JPanel jPanel1 = null;
80
    private javax.swing.JLabel jLabel4 = null;
81
    private WindowInfo m_viewinfo = null;
82
    /**
83
     * This is the default constructor
84
     *
85
     * @param f Frame padre del di?logo
86
     * @param t Tabla que se representa en el di?logo
87
     * @throws DriverException
88
     */
89
    public TableProperties(ProjectTable t) throws DriverException {
90
        table = t;
91

    
92
        initialize();
93
    }
94

    
95
    /**
96
     * This method initializes this
97
     * @throws DriverException
98
     */
99
    private void initialize() throws DriverException {
100

    
101
                java.awt.FlowLayout layFlowLayout7 = new java.awt.FlowLayout();
102
                layFlowLayout7.setHgap(0);                
103
        setLayout(layFlowLayout7);
104
                add(getJPanel(), null);
105
                add(getJPanel1(), null);
106
                add(getJLabel3(), null);
107
                add(getJScrollPane(), null);
108
                add(getJScrollPane1(), null);
109
                add(getOkCancelPanel(),null);
110
                //add(getBtnOk(), null);
111
                //add(getJLabel4(), null);
112
                //add(getBtnCancel(), null);
113

    
114
        txtName.setText(table.getName());
115
        txtDate.setText(table.getCreationDate());
116
        txtOwner.setText(table.getOwner());
117
        txtComments.setText(table.getComment());
118

    
119
        tabla.setModel(new TableModel(table));   
120
        
121
        // TODO: provisional hasta que revisemos lo del mapeado de campos.
122
        tabla.setVisible(false);
123
        tabla.getTableHeader().setVisible(false);
124
    }
125

    
126
    /**
127
     * This method initializes jLabel
128
     *
129
     * @return javax.swing.JLabel
130
     */
131
    private javax.swing.JLabel getJLabel() {
132
        if (jLabel == null) {
133
            jLabel = new javax.swing.JLabel();
134
            jLabel.setText(PluginServices.getText(this, "nombre") + ":");
135
        }
136

    
137
        return jLabel;
138
    }
139

    
140
    /**
141
     * This method initializes txtName
142
     *
143
     * @return javax.swing.JTextField
144
     */
145
    private javax.swing.JTextField getTxtName() {
146
        if (txtName == null) {
147
            txtName = new javax.swing.JTextField();
148
            txtName.setPreferredSize(new java.awt.Dimension(190, 20));
149
        }
150

    
151
        return txtName;
152
    }
153

    
154
    /**
155
     * This method initializes jLabel1
156
     *
157
     * @return javax.swing.JLabel
158
     */
159
    private javax.swing.JLabel getJLabel1() {
160
        if (jLabel1 == null) {
161
            jLabel1 = new javax.swing.JLabel();
162
            jLabel1.setText(PluginServices.getText(this, "creation_date") + ":");
163
        }
164

    
165
        return jLabel1;
166
    }
167

    
168
    /**
169
     * This method initializes txtDate
170
     *
171
     * @return javax.swing.JTextField
172
     */
173
    private javax.swing.JTextField getTxtDate() {
174
        if (txtDate == null) {
175
            txtDate = new javax.swing.JTextField();
176
            txtDate.setPreferredSize(new java.awt.Dimension(190, 20));
177
            txtDate.setEditable(false);
178
            txtDate.setBackground(java.awt.Color.white);
179
        }
180

    
181
        return txtDate;
182
    }
183

    
184
    /**
185
     * This method initializes txtOwner
186
     *
187
     * @return javax.swing.JTextField
188
     */
189
    private javax.swing.JTextField getTxtOwner() {
190
        if (txtOwner == null) {
191
            txtOwner = new javax.swing.JTextField();
192
            txtOwner.setPreferredSize(new java.awt.Dimension(190, 20));
193
        }
194

    
195
        return txtOwner;
196
    }
197

    
198
    /**
199
     * This method initializes jLabel2
200
     *
201
     * @return javax.swing.JLabel
202
     */
203
    private javax.swing.JLabel getJLabel2() {
204
        if (jLabel2 == null) {
205
            jLabel2 = new javax.swing.JLabel();
206
            jLabel2.setText(PluginServices.getText(this, "owner") + ":");
207
        }
208

    
209
        return jLabel2;
210
    }
211

    
212
    /**
213
     * This method initializes jLabel3
214
     *
215
     * @return javax.swing.JLabel
216
     */
217
    private javax.swing.JLabel getJLabel3() {
218
        if (jLabel3 == null) {
219
            jLabel3 = new javax.swing.JLabel();
220
            jLabel3.setText(PluginServices.getText(this, "comentarios") + ":");
221
            jLabel3.setPreferredSize(new java.awt.Dimension(320,16));            
222
        }
223

    
224
        return jLabel3;
225
    }
226

    
227
    /**
228
     * This method initializes jScrollPane
229
     *
230
     * @return javax.swing.JScrollPane
231
     */
232
    private javax.swing.JScrollPane getJScrollPane() {
233
        if (jScrollPane == null) {
234
            jScrollPane = new javax.swing.JScrollPane();
235
            jScrollPane.setViewportView(getTxtComments());
236
            jScrollPane.setPreferredSize(new java.awt.Dimension(320, 70));
237
        }
238

    
239
        return jScrollPane;
240
    }
241

    
242
    /**
243
     * This method initializes txtComments
244
     *
245
     * @return javax.swing.JTextArea
246
     */
247
    private javax.swing.JTextArea getTxtComments() {
248
        if (txtComments == null) {
249
            txtComments = new javax.swing.JTextArea();
250
        }
251

    
252
        return txtComments;
253
    }
254

    
255
    /**
256
     * This method initializes jTable
257
     *
258
     * @return javax.swing.JTable
259
     */
260
    private javax.swing.JTable getJTable() {
261
        if (tabla == null) {
262
            tabla = new javax.swing.JTable();
263
            tabla.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);            
264
        }
265

    
266
        return tabla;
267
    }
268

    
269
    /**
270
     * This method initializes jScrollPane1
271
     *
272
     * @return javax.swing.JScrollPane
273
     */
274
    private javax.swing.JScrollPane getJScrollPane1() {
275
        if (jScrollPane1 == null) {
276
            jScrollPane1 = new javax.swing.JScrollPane();
277
            jScrollPane1.setViewportView(getJTable());
278
            jScrollPane1.setPreferredSize(new java.awt.Dimension(320, 160));
279
        }
280

    
281
        return jScrollPane1;
282
    }
283
    
284
    private AcceptCancelPanel getOkCancelPanel() {
285
            if (okCancelPanel == null) {
286
                    okCancelPanel = new AcceptCancelPanel(
287
                                    new java.awt.event.ActionListener() {
288
                        public void actionPerformed(java.awt.event.ActionEvent e) {
289
                            table.setName(txtName.getText());
290
                            table.setCreationDate(txtDate.getText());
291
                            table.setOwner(txtOwner.getText());
292
                            table.setComment(txtComments.getText());
293

    
294
                            TableModel tm = (TableModel) getJTable().getModel();
295
                            table.setAliases(tm.getAliases());
296
                            table.setMapping(tm.getFieldMapping());
297
                            
298
                                                    PluginServices.getMDIManager().closeWindow(TableProperties.this);
299
                        }
300
                    }
301
                                    ,
302
                                    new java.awt.event.ActionListener() {
303
                        public void actionPerformed(java.awt.event.ActionEvent e) {
304
                                PluginServices.getMDIManager().closeWindow(TableProperties.this);
305
                        }
306
                    }                                                        
307
                    );
308
                    okCancelPanel.setPreferredSize(new java.awt.Dimension(339, 30));
309
            }
310
            return okCancelPanel;
311
    }
312

    
313

    
314
    /**
315
     * This method initializes jPanel
316
     *
317
     * @return javax.swing.JPanel
318
     */
319
    private javax.swing.JPanel getJPanel() {
320
        if (jPanel == null) {
321
            jPanel = new javax.swing.JPanel();
322

    
323
            java.awt.FlowLayout layFlowLayout9 = new java.awt.FlowLayout();
324
            layFlowLayout9.setAlignment(java.awt.FlowLayout.LEFT);
325
            layFlowLayout9.setVgap(9);
326
            jPanel.setLayout(layFlowLayout9);
327
            jPanel.add(getJLabel(), null);
328
            jPanel.add(getJLabel1(), null);
329
            jPanel.add(getJLabel2(), null);
330
            jPanel.setPreferredSize(new java.awt.Dimension(130, 80));
331
        }
332

    
333
        return jPanel;
334
    }
335

    
336
    /**
337
     * This method initializes jPanel1
338
     *
339
     * @return javax.swing.JPanel
340
     */
341
    private javax.swing.JPanel getJPanel1() {
342
        if (jPanel1 == null) {
343
            jPanel1 = new javax.swing.JPanel();
344

    
345
            java.awt.FlowLayout layFlowLayout8 = new java.awt.FlowLayout();
346
            layFlowLayout8.setAlignment(java.awt.FlowLayout.LEFT);
347
            jPanel1.setLayout(layFlowLayout8);
348
            jPanel1.add(getTxtName(), null);
349
            jPanel1.add(getTxtDate(), null);
350
            jPanel1.add(getTxtOwner(), null);
351
            jPanel1.setPreferredSize(new java.awt.Dimension(200, 80));
352
        }
353

    
354
        return jPanel1;
355
    }
356

    
357
    /**
358
     * This method initializes jLabel4
359
     *
360
     * @return javax.swing.JLabel
361
     */
362
    private javax.swing.JLabel getJLabel4() {
363
        if (jLabel4 == null) {
364
            jLabel4 = new javax.swing.JLabel();
365
            jLabel4.setText("");
366
            jLabel4.setPreferredSize(new java.awt.Dimension(30, 0));
367
        }
368

    
369
        return jLabel4;
370
    }
371

    
372
        /**
373
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
374
         */
375
        public WindowInfo getWindowInfo() {
376
                WindowInfo m_viewinfo=new WindowInfo();
377
                   m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_tabla"));
378
                m_viewinfo.setWidth(349);
379
                m_viewinfo.setHeight(375);
380

    
381
                return m_viewinfo;
382
        }
383

    
384
        /**
385
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
386
         */
387
        public void viewActivated() {
388
        }
389

    
390
    /**
391
     * @see com.iver.andami.ui.mdiManager.SingletonWindow#getWindowModel()
392
     */
393
    public Object getWindowModel() {
394
        return table;
395
    }
396
}
397

    
398

    
399
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"