Revision 38552
branches/v2_0_0_prep/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/DefaultDataTransformWizard.java | ||
---|---|---|
71 | 71 |
} |
72 | 72 |
|
73 | 73 |
private void initialize() { |
74 |
|
|
74 | 75 |
getWizardComponents().getFinishButton().setEnabled(false); |
76 |
getWizardComponents().getBackButton().setEnabled(false); |
|
77 |
|
|
75 | 78 |
getWindowInfo().setTitle( |
76 | 79 |
PluginServices.getText(this, "transform_wizard")); |
77 | 80 |
addDataTransformWizardPanel(selectTransformWizardPanel); |
branches/v2_0_0_prep/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/components/FeatureTypeAttributesCombo.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.daltransform.swing.impl.components; |
29 | 29 |
|
30 |
import java.util.ArrayList; |
|
31 |
|
|
30 | 32 |
import javax.swing.DefaultComboBoxModel; |
31 | 33 |
import javax.swing.JComboBox; |
32 | 34 |
|
... | ... | |
52 | 54 |
this.setModel(new DefaultComboBoxModel()); |
53 | 55 |
} |
54 | 56 |
|
55 |
public void addFeatureAttrubutes(FeatureStore featureStore) throws DataException{ |
|
56 |
addFeatureAttributes(featureStore.getDefaultFeatureType()); |
|
57 |
/** |
|
58 |
* Removes all items then adds atts |
|
59 |
* |
|
60 |
* @param featureStore |
|
61 |
* @return the number of items added (equals total item count) |
|
62 |
* |
|
63 |
* @throws DataException |
|
64 |
*/ |
|
65 |
public int addFeatureAttrubutes(FeatureStore featureStore) throws DataException{ |
|
66 |
return addFeatureAttributes(featureStore.getDefaultFeatureType()); |
|
57 | 67 |
} |
58 | 68 |
|
59 |
public void addFeatureAttributes(FeatureType featureType){ |
|
69 |
/** |
|
70 |
* Removes all items then adds atts |
|
71 |
* |
|
72 |
* @param featureType |
|
73 |
* @return the number of items added (equals total item count) |
|
74 |
*/ |
|
75 |
public int addFeatureAttributes(FeatureType featureType){ |
|
60 | 76 |
removeAllItems(); |
61 | 77 |
FeatureAttributeDescriptor[] descriptors = featureType.getAttributeDescriptors(); |
62 | 78 |
for (int i=0 ; i<descriptors.length ; i++){ |
63 | 79 |
addFeatureAttributeDescriptor(descriptors[i]); |
64 | 80 |
} |
81 |
return descriptors.length; |
|
65 | 82 |
} |
66 | 83 |
|
67 |
public void addFeatureAttributeDescriptor(FeatureAttributeDescriptor featureAttributeDescriptor){ |
|
84 |
|
|
85 |
/** |
|
86 |
* Removes all items then adds atts whose type is |
|
87 |
* contained by list |
|
88 |
* |
|
89 |
* @param featureType |
|
90 |
* @param type |
|
91 |
* @return the number of items added (equals total item count) |
|
92 |
*/ |
|
93 |
public int addFeatureAttributes( |
|
94 |
FeatureType featureType, |
|
95 |
ArrayList<Integer> types){ |
|
96 |
|
|
97 |
removeAllItems(); |
|
98 |
|
|
99 |
int count = 0; |
|
100 |
FeatureAttributeDescriptor[] descriptors = featureType.getAttributeDescriptors(); |
|
101 |
for (int i=0 ; i<descriptors.length ; i++){ |
|
102 |
if (isIn(descriptors[i].getType(), types)) { |
|
103 |
addFeatureAttributeDescriptor(descriptors[i]); |
|
104 |
count++; |
|
105 |
} |
|
106 |
} |
|
107 |
return count; |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* @param type |
|
112 |
* @param types |
|
113 |
* @return |
|
114 |
*/ |
|
115 |
private boolean isIn(int t, ArrayList<Integer> list) { |
|
116 |
|
|
117 |
int len = list.size(); |
|
118 |
for (int i=0; i<len; i++) { |
|
119 |
if (list.get(i).intValue() == t) { |
|
120 |
return true; |
|
121 |
} |
|
122 |
} |
|
123 |
return false; |
|
124 |
} |
|
125 |
|
|
126 |
public void addFeatureAttributeDescriptor(FeatureAttributeDescriptor featureAttributeDescriptor){ |
|
68 | 127 |
((DefaultComboBoxModel)getModel()).addElement(new FeatureTypeAttributeWrapper(featureAttributeDescriptor)); |
69 | 128 |
} |
70 | 129 |
|
71 | 130 |
public FeatureAttributeDescriptor getSelectedFeatureAttributeDescriptor(){ |
72 | 131 |
return ((FeatureTypeAttributeWrapper)getSelectedItem()).getFeatureAttributeDescriptor(); |
73 | 132 |
} |
133 |
|
|
134 |
|
|
74 | 135 |
} |
75 | 136 |
|
branches/v2_0_0_prep/extensions/extDalTransformJoin/src/org/gvsig/app/join/daltransform/SelectParametersWizardPanel.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.app.join.daltransform; |
29 | 29 |
|
30 |
import java.awt.event.ActionEvent; |
|
31 |
import java.awt.event.ActionListener; |
|
32 |
import java.util.ArrayList; |
|
33 |
|
|
34 |
import javax.swing.JOptionPane; |
|
35 |
|
|
36 |
import org.slf4j.Logger; |
|
37 |
import org.slf4j.LoggerFactory; |
|
38 |
|
|
30 | 39 |
import org.gvsig.andami.PluginServices; |
40 |
import org.gvsig.app.ApplicationLocator; |
|
41 |
import org.gvsig.app.join.utils.TransformUtils; |
|
31 | 42 |
import org.gvsig.daltransform.swing.DataTransformWizardPanel; |
32 | 43 |
import org.gvsig.daltransform.swing.impl.AbstractDataTransformWizardPanel; |
33 | 44 |
import org.gvsig.daltransform.swing.impl.components.FeatureTypeAttributesCombo; |
34 | 45 |
import org.gvsig.daltransform.swing.impl.components.FeatureTypeAttributesList; |
35 | 46 |
import org.gvsig.fmap.dal.exception.DataException; |
47 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
36 | 48 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
49 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
50 |
import org.gvsig.i18n.Messages; |
|
37 | 51 |
|
38 | 52 |
|
39 | 53 |
/** |
40 | 54 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
41 | 55 |
*/ |
42 |
public class SelectParametersWizardPanel extends AbstractDataTransformWizardPanel implements DataTransformWizardPanel{ |
|
56 |
public class SelectParametersWizardPanel extends AbstractDataTransformWizardPanel |
|
57 |
implements DataTransformWizardPanel, ActionListener{ |
|
58 |
|
|
59 |
private static Logger logger = |
|
60 |
LoggerFactory.getLogger(SelectParametersWizardPanel.class); |
|
61 |
|
|
43 | 62 |
private javax.swing.JLabel attributesLabel; |
44 | 63 |
private FeatureTypeAttributesList attributesList; |
45 | 64 |
private javax.swing.JScrollPane attributesScroll; |
46 | 65 |
private FeatureTypeAttributesCombo key1Combo; |
47 | 66 |
private javax.swing.JLabel key1Label; |
48 |
private FeatureTypeAttributesCombo key2Combo; |
|
67 |
private FeatureTypeAttributesCombo key2_Combo;
|
|
49 | 68 |
private javax.swing.JLabel key2Label; |
50 | 69 |
private javax.swing.JLabel prefix1Label; |
51 | 70 |
private javax.swing.JTextField prefix1Text; |
52 | 71 |
private javax.swing.JLabel prefix2Label; |
53 | 72 |
private javax.swing.JTextField prefix2Text; |
73 |
|
|
74 |
private FeatureStore secondFeatStore = null; |
|
54 | 75 |
|
55 | 76 |
/** |
56 | 77 |
* @param featureTransformWizardModel |
... | ... | |
73 | 94 |
java.awt.GridBagConstraints gridBagConstraints; |
74 | 95 |
|
75 | 96 |
prefix2Text = new javax.swing.JTextField(); |
76 |
key2Combo = new FeatureTypeAttributesCombo(); |
|
97 |
key2_Combo = new FeatureTypeAttributesCombo();
|
|
77 | 98 |
prefix1Text = new javax.swing.JTextField(); |
78 | 99 |
key1Label = new javax.swing.JLabel(); |
100 |
|
|
79 | 101 |
key1Combo = new FeatureTypeAttributesCombo(); |
102 |
// listen to changes in first combo |
|
103 |
// we'll update second combo leaving |
|
104 |
// fields of same type |
|
105 |
key1Combo.addActionListener(this); |
|
106 |
|
|
80 | 107 |
key2Label = new javax.swing.JLabel(); |
81 | 108 |
prefix1Label = new javax.swing.JLabel(); |
82 | 109 |
prefix2Label = new javax.swing.JLabel(); |
... | ... | |
99 | 126 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
100 | 127 |
gridBagConstraints.weightx = 1.0; |
101 | 128 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2); |
102 |
add(key2Combo, gridBagConstraints); |
|
129 |
add(key2_Combo, gridBagConstraints);
|
|
103 | 130 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
104 | 131 |
gridBagConstraints.gridx = 0; |
105 | 132 |
gridBagConstraints.gridy = 5; |
... | ... | |
179 | 206 |
* @return |
180 | 207 |
*/ |
181 | 208 |
public String getkeyAtrr2() { |
182 |
return key2Combo.getSelectedFeatureAttributeDescriptor().getName(); |
|
209 |
return key2_Combo.getSelectedFeatureAttributeDescriptor().getName();
|
|
183 | 210 |
} |
184 | 211 |
|
185 | 212 |
/** |
... | ... | |
208 | 235 |
* @throws DataException |
209 | 236 |
*/ |
210 | 237 |
public void updateFeatureStores(FeatureStore selectedFeatureStore) throws DataException { |
238 |
secondFeatStore = selectedFeatureStore; |
|
211 | 239 |
key1Combo.addFeatureAttributes(getFeatureStore().getDefaultFeatureType()); |
212 |
key2Combo.addFeatureAttributes(selectedFeatureStore.getDefaultFeatureType()); |
|
213 | 240 |
attributesList.addFeatureAttributes(selectedFeatureStore.getDefaultFeatureType()); |
241 |
|
|
242 |
if (key1Combo.getItemCount() == 0) { |
|
243 |
|
|
244 |
String _msg = |
|
245 |
Messages.getText("_First_table_has_no_fields"); |
|
246 |
String _tit = Messages.getText("_Join"); |
|
247 |
|
|
248 |
JOptionPane.showMessageDialog( |
|
249 |
this, _msg, _tit, |
|
250 |
JOptionPane.ERROR_MESSAGE); |
|
251 |
|
|
252 |
getDataTransformWizard().setApplicable(false); |
|
253 |
} else { |
|
254 |
key1Combo.setSelectedIndex(0); |
|
255 |
} |
|
214 | 256 |
} |
257 |
|
|
258 |
|
|
259 |
/** |
|
260 |
* Listen to changes in first combo box (key1) |
|
261 |
*/ |
|
262 |
public void actionPerformed(ActionEvent e) { |
|
263 |
|
|
264 |
Object src = e.getSource(); |
|
265 |
if (src == key1Combo |
|
266 |
&& key1Combo != null |
|
267 |
&& key2_Combo != null |
|
268 |
&& secondFeatStore != null) { |
|
269 |
|
|
270 |
FeatureAttributeDescriptor att = |
|
271 |
key1Combo.getSelectedFeatureAttributeDescriptor(); |
|
272 |
if (att != null) { |
|
273 |
|
|
274 |
int the_type = att.getType(); |
|
275 |
key2_Combo.removeAllItems(); |
|
276 |
FeatureType ft = null; |
|
277 |
|
|
278 |
try { |
|
279 |
ft = secondFeatStore.getDefaultFeatureType(); |
|
280 |
} catch (DataException de) { |
|
281 |
logger.info("While getting feat type: " + de.getMessage()); |
|
282 |
getDataTransformWizard().setApplicable(false); |
|
283 |
ApplicationLocator.getManager().message( |
|
284 |
Messages.getText("_Error_getting_attributes"), |
|
285 |
JOptionPane.ERROR_MESSAGE); |
|
286 |
return; |
|
287 |
} |
|
288 |
|
|
289 |
ArrayList<Integer> comparable_types = |
|
290 |
TransformUtils.getComparableDataTypes(ft, the_type); |
|
291 |
|
|
292 |
if (key2_Combo.addFeatureAttributes(ft, comparable_types) == 0) { |
|
293 |
getDataTransformWizard().setApplicable(false); |
|
294 |
|
|
295 |
String _msg = |
|
296 |
Messages.getText("_No_compatible_field_in_second_table"); |
|
297 |
String _tit = Messages.getText("_Join"); |
|
298 |
|
|
299 |
JOptionPane.showMessageDialog( |
|
300 |
this, _msg, _tit, |
|
301 |
JOptionPane.ERROR_MESSAGE); |
|
302 |
} else { |
|
303 |
getDataTransformWizard().setApplicable(true); |
|
304 |
// JOptionPane.showMessageDialog(this, "(2) OK !!"); |
|
305 |
} |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
} |
|
215 | 310 |
} |
216 | 311 |
|
branches/v2_0_0_prep/extensions/extDalTransformJoin/src/org/gvsig/app/join/utils/TransformUtils.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.app.join.utils; |
|
24 |
|
|
25 |
import java.util.ArrayList; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DataTypes; |
|
28 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
29 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* {@link DataTypes}-related utility methods |
|
34 |
* |
|
35 |
* @author jldominguez |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class TransformUtils { |
|
39 |
|
|
40 |
public static boolean isNumericType(int t) { |
|
41 |
return (t == DataTypes.DOUBLE |
|
42 |
|| t == DataTypes.FLOAT |
|
43 |
|| t == DataTypes.INT |
|
44 |
|| t == DataTypes.LONG |
|
45 |
|| t == DataTypes.BYTE); |
|
46 |
} |
|
47 |
|
|
48 |
public static boolean comparableTypes(int a, int b) { |
|
49 |
|
|
50 |
if (a == b) { |
|
51 |
return true; |
|
52 |
} else { |
|
53 |
return isNumericType(a) && isNumericType(b); |
|
54 |
} |
|
55 |
|
|
56 |
} |
|
57 |
/** |
|
58 |
* @param ft |
|
59 |
* @param the_type |
|
60 |
* @return |
|
61 |
*/ |
|
62 |
public static ArrayList<Integer> getComparableDataTypes( |
|
63 |
FeatureType ft, |
|
64 |
int the_type) { |
|
65 |
|
|
66 |
ArrayList<Integer> resp = new ArrayList<Integer>(); |
|
67 |
|
|
68 |
FeatureAttributeDescriptor[] atts = ft.getAttributeDescriptors(); |
|
69 |
int len = atts.length; |
|
70 |
for (int i=0; i<len; i++) { |
|
71 |
if (comparableTypes(the_type, atts[i].getType())) { |
|
72 |
resp.add(atts[i].getType()); |
|
73 |
} |
|
74 |
} |
|
75 |
return resp; |
|
76 |
} |
|
77 |
|
|
78 |
} |
branches/v2_0_0_prep/extensions/extDalTransformJoin/resources/org/gvsig/app/join/i18n/text.properties | ||
---|---|---|
5 | 5 |
join_first_prefix=Escriba el prefijo de la primera tabla |
6 | 6 |
join_second_prefix=Escriba el prefijo de la segunda tabla |
7 | 7 |
join_select_attributes=Selecciona los atributos a unir |
8 |
_Unable_to_refresh_table_contents=No se ha podido actualizar la tabla |
|
8 |
_Unable_to_refresh_table_contents=No se ha podido actualizar la tabla |
|
9 |
_First_table_has_no_fields=La primera tabla no tiene campos |
|
10 |
_Join=Uni?n de tablas |
|
11 |
_Error_getting_attributes=Error al obtener campos |
|
12 |
_No_compatible_field_in_second_table=No hay campos compatibles en la segunda tabla |
branches/v2_0_0_prep/extensions/extDalTransformJoin/resources/org/gvsig/app/join/i18n/text_en.properties | ||
---|---|---|
6 | 6 |
join_second_prefix=Type a prefix for the second table |
7 | 7 |
join_select_attributes=Select the attributes to join |
8 | 8 |
_Unable_to_refresh_table_contents=Unable to refresh table contents |
9 |
_First_table_has_no_fields=First table has no fields |
|
10 |
_Join=Join |
|
11 |
_Error_getting_attributes=Error getting attributes |
|
12 |
_No_compatible_field_in_second_table=No compatible fields in second table |
Also available in: Unified diff