Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extDalTransformEventTheme / src / org / gvsig / app / eventtheme / daltransform / EventThemeTransformPanel.java @ 29791

History | View | Annotate | Download (6.4 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
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
* as published by the Free Software Foundation; either version 2
9
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.app.eventtheme.daltransform;
29

    
30
import java.awt.BorderLayout;
31
import java.awt.Insets;
32
import java.awt.event.ActionEvent;
33
import java.awt.event.ActionListener;
34

    
35
import javax.swing.JLabel;
36
import javax.swing.JPanel;
37
import javax.swing.JTextField;
38

    
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.app.daltransform.gui.components.impl.FeatureTypeCombo;
41
import org.gvsig.app.daltransform.gui.components.impl.NumericFeatureTypeAttributesCombo;
42
import org.gvsig.app.daltransform.gui.impl.AbstractDataTransformWizardPanel;
43

    
44

    
45
/**
46
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
47
 */
48
public class EventThemeTransformPanel extends AbstractDataTransformWizardPanel implements ActionListener {
49
        private JLabel nameLabel;
50
        private JTextField nameText;
51
        private NumericFeatureTypeAttributesCombo xCombo;
52
        private JLabel xLabel;
53
        private NumericFeatureTypeAttributesCombo yCombo;
54
        private JLabel yLabel;
55
        private FeatureTypeCombo featureTypeCombo;
56
        private JLabel featureTypeLabel;
57
        private JPanel northPanel = null;
58

    
59
        public EventThemeTransformPanel() {
60
                super();
61
                initComponents();
62
                initLabels();
63
                featureTypeCombo.addActionListener(this);
64
        }
65

    
66
        private void initLabels() {
67
                featureTypeLabel.setText(PluginServices.getText(this, "events_feature_type_field"));
68
                xLabel.setText(PluginServices.getText(this, "events_x_field"));
69
                yLabel.setText(PluginServices.getText(this, "events_y_field"));
70
                nameLabel.setText(PluginServices.getText(this, "events_geom_field"));
71
        }
72

    
73
        private void initComponents() {
74
                java.awt.GridBagConstraints gridBagConstraints;
75
                
76
                featureTypeCombo = new FeatureTypeCombo();
77
                featureTypeLabel = new javax.swing.JLabel();
78
                xLabel = new javax.swing.JLabel();
79
                xCombo = new NumericFeatureTypeAttributesCombo();
80
                yLabel = new javax.swing.JLabel();
81
                yCombo = new NumericFeatureTypeAttributesCombo();
82
                nameLabel = new javax.swing.JLabel();
83
                nameText = new javax.swing.JTextField();
84
                northPanel= new JPanel();
85

    
86
                setLayout(new BorderLayout());
87
                northPanel.setLayout(new java.awt.GridBagLayout());
88

    
89
//                gridBagConstraints = new java.awt.GridBagConstraints();
90
//                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
91
//                gridBagConstraints.insets = new Insets(5,2,2,2);
92
//                northPanel.add(featureTypeLabel, gridBagConstraints);
93
//
94
//                featureTypeCombo.setModel(new javax.swing.DefaultComboBoxModel());
95
//                gridBagConstraints = new java.awt.GridBagConstraints();
96
//                gridBagConstraints.gridx = 0;
97
//                gridBagConstraints.gridy = 1;
98
//                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
99
//                gridBagConstraints.weightx = 1.0;
100
//                gridBagConstraints.insets = new Insets(2,2,5,2);
101
//                northPanel.add(featureTypeCombo, gridBagConstraints);
102
                                
103
                gridBagConstraints = new java.awt.GridBagConstraints();
104
                gridBagConstraints.gridx = 0;
105
                gridBagConstraints.gridy = 0;
106
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
107
                gridBagConstraints.insets = new Insets(5,2,2,2);
108
                northPanel.add(xLabel, gridBagConstraints);
109

    
110
                xCombo.setModel(new javax.swing.DefaultComboBoxModel());
111
                gridBagConstraints = new java.awt.GridBagConstraints();
112
                gridBagConstraints.gridx = 0;
113
                gridBagConstraints.gridy = 1;
114
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
115
                gridBagConstraints.insets = new Insets(2,2,5,2);
116
                gridBagConstraints.weightx = 1.0;
117
                northPanel.add(xCombo, gridBagConstraints);
118

    
119
                gridBagConstraints = new java.awt.GridBagConstraints();
120
                gridBagConstraints.gridx = 0;
121
                gridBagConstraints.gridy = 2;
122
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
123
                gridBagConstraints.insets = new Insets(5,2,2,2);
124
                northPanel.add(yLabel, gridBagConstraints);
125

    
126
                yCombo.setModel(new javax.swing.DefaultComboBoxModel());
127
                gridBagConstraints = new java.awt.GridBagConstraints();
128
                gridBagConstraints.gridx = 0;
129
                gridBagConstraints.gridy = 3;
130
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
131
                gridBagConstraints.weightx = 1.0;
132
                gridBagConstraints.insets = new Insets(2,2,5,2);
133
                northPanel.add(yCombo, gridBagConstraints);
134

    
135
                gridBagConstraints = new java.awt.GridBagConstraints();
136
                gridBagConstraints.gridx = 0;
137
                gridBagConstraints.gridy = 4;
138
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
139
                gridBagConstraints.insets = new Insets(5,2,2,2);
140
                northPanel.add(nameLabel, gridBagConstraints);
141

    
142
                gridBagConstraints = new java.awt.GridBagConstraints();
143
                gridBagConstraints.gridx = 0;
144
                gridBagConstraints.gridy = 5;
145
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
146
                gridBagConstraints.weightx = 1.0;
147
                gridBagConstraints.insets = new Insets(2,2,5,2);
148
                northPanel.add(nameText, gridBagConstraints);
149
                
150
                add(northPanel, BorderLayout.NORTH);
151
        }        
152

    
153
        /* (non-Javadoc)
154
         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
155
         */
156
        public void actionPerformed(ActionEvent arg0) {
157
                Object obj = featureTypeCombo.getSelectedItem();
158
                if (obj != null){
159
                        xCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType());
160
                        yCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType());                        
161
                }
162
        }
163
        
164
        public String getGeometryName(){
165
                return nameText.getText();
166
        }
167
        
168
        public String getXName(){
169
                return xCombo.getSelectedFeatureAttributeDescriptor().getName();
170
        }
171
        
172
        public String getYName(){
173
                return yCombo.getSelectedFeatureAttributeDescriptor().getName();
174
        }
175
        
176
        /*
177
         * (non-Javadoc)
178
         * @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel()
179
         */
180
        public void updatePanel() {
181
                featureTypeCombo.addFeatureStore(getFeatureStore());
182
                actionPerformed(null);                        
183
        }
184
}