Revision 26051
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/TableOperations.java | ||
---|---|---|
54 | 54 |
import com.iver.andami.messages.NotificationManager; |
55 | 55 |
import com.iver.andami.plugins.Extension; |
56 | 56 |
import com.iver.andami.ui.mdiManager.IWindow; |
57 |
import com.iver.cit.gvsig.exceptions.visitors.StartWriterVisitorException; |
|
57 | 58 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
59 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
|
58 | 60 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
59 | 61 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
60 | 62 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
... | ... | |
66 | 68 |
import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory; |
67 | 69 |
import com.iver.cit.gvsig.project.documents.table.TableSelectionModel; |
68 | 70 |
import com.iver.cit.gvsig.project.documents.table.gui.AndamiWizard; |
71 |
import com.iver.cit.gvsig.project.documents.table.gui.JoinWizardController; |
|
69 | 72 |
import com.iver.cit.gvsig.project.documents.table.gui.Table; |
70 | 73 |
import com.iver.utiles.swing.objectSelection.SelectionException; |
71 | 74 |
import com.iver.utiles.swing.wizard.WizardControl; |
... | ... | |
91 | 94 |
ProjectTable[] pts = (ProjectTable[]) project.getDocumentsByType(ProjectTableFactory.registerName) |
92 | 95 |
.toArray(new ProjectTable[0]); |
93 | 96 |
if ("JOIN".equals(actionCommand)) { |
94 |
try { |
|
95 |
final ObjectSelectionStep sourceTable = new ObjectSelectionStep(); |
|
96 |
sourceTable.setModel(new TableSelectionModel(pts, |
|
97 |
PluginServices.getText(this, "seleccione_tabla_origen"))); |
|
98 |
|
|
99 |
final ObjectSelectionStep targetTable = new ObjectSelectionStep(); |
|
100 |
targetTable.setModel(new TableSelectionModel(pts, |
|
101 |
PluginServices.getText(this, "seleccione_tabla_a_enlazar"))); |
|
102 |
|
|
103 |
final ObjectSelectionStep firstTableField = new ObjectSelectionStep(); |
|
104 |
final ObjectSelectionStep secondTableField = new ObjectSelectionStep(); |
|
105 |
final AndamiWizard wiz = new AndamiWizard(PluginServices.getText(this, "back"), PluginServices.getText(this, "next"), PluginServices.getText(this, "finish"), PluginServices.getText(this, "cancel")); |
|
106 |
wiz.setSize(new Dimension(450,200)); |
|
107 |
wiz.addStep(sourceTable); |
|
108 |
wiz.addStep(firstTableField); |
|
109 |
wiz.addStep(targetTable); |
|
110 |
wiz.addStep(secondTableField); |
|
111 |
|
|
112 |
wiz.addWizardListener(new WizardListener() { |
|
113 |
public void cancel(WizardEvent w) { |
|
114 |
PluginServices.getMDIManager().closeWindow(wiz); |
|
115 |
} |
|
116 |
|
|
117 |
public void finished(WizardEvent w) { |
|
118 |
PluginServices.getMDIManager().closeWindow(wiz); |
|
119 |
|
|
120 |
ProjectTable sourceProjectTable = (ProjectTable) sourceTable.getSelected(); |
|
121 |
SelectableDataSource sds=null; |
|
122 |
try { |
|
123 |
sds = sourceProjectTable.getModelo().getRecordset(); |
|
124 |
} catch (ReadDriverException e) { |
|
125 |
e.printStackTrace(); |
|
126 |
} |
|
127 |
String tableName1 = sds.getName(); |
|
128 |
|
|
129 |
ProjectTable targetProjectTable = (ProjectTable) targetTable.getSelected(); |
|
130 |
try { |
|
131 |
sds = targetProjectTable.getModelo().getRecordset(); |
|
132 |
} catch (ReadDriverException e) { |
|
133 |
e.printStackTrace(); |
|
134 |
} |
|
135 |
|
|
136 |
String tableName2 = sds.getName(); |
|
137 |
|
|
138 |
String field1 = (String) firstTableField.getSelected(); |
|
139 |
String field2 = (String) secondTableField.getSelected(); |
|
140 |
|
|
141 |
String sql = |
|
142 |
"custom com_iver_cit_gvsig_arcjoin tables '" + |
|
143 |
tableName1 + "', '" + tableName2 + "' values(" + |
|
144 |
field1 + ", " + field2 + ");"; |
|
145 |
System.out.println(sql); |
|
146 |
|
|
147 |
try { |
|
148 |
SelectableDataSource result = new SelectableDataSource(LayerFactory.getDataSourceFactory() |
|
149 |
.executeSQL(sql, |
|
150 |
DataSourceFactory.AUTOMATIC_OPENING)); |
|
151 |
ProjectTable projectTable = (ProjectTable) sourceTable.getSelected(); |
|
152 |
EditableAdapter auxea=new EditableAdapter(); |
|
153 |
auxea.setOriginalDataSource(result); |
|
154 |
projectTable.replaceDataSource(auxea); |
|
155 |
} catch (ParseException e) { |
|
156 |
throw new RuntimeException(e); |
|
157 |
} catch (DriverLoadException e) { |
|
158 |
NotificationManager.addError("Error con la carga de drivers", |
|
159 |
e); |
|
160 |
} catch (ReadDriverException e) { |
|
161 |
NotificationManager.addError("Error leyendo del driver", |
|
162 |
e); |
|
163 |
} catch (SemanticException e) { |
|
164 |
throw new RuntimeException(e); |
|
165 |
} catch (EvaluationException e) { |
|
166 |
NotificationManager.addError("Error de evaluaci?n de la expresi?n", |
|
167 |
e); |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
public void next(WizardEvent w) { |
|
172 |
WizardControl wiz = w.wizard; |
|
173 |
wiz.enableBack(true); |
|
174 |
wiz.enableNext(((ObjectSelectionStep) wiz.getCurrentStep()).getSelectedItem() != null); |
|
175 |
|
|
176 |
if (w.currentStep == 1) { |
|
177 |
ProjectTable pt = (ProjectTable) sourceTable.getSelected(); |
|
178 |
|
|
179 |
try { |
|
180 |
firstTableField.setModel(new FieldSelectionModel( |
|
181 |
pt.getModelo().getRecordset(), |
|
182 |
PluginServices.getText(this, "seleccione_campo_enlace"), |
|
183 |
-1)); |
|
184 |
} catch (SelectionException e) { |
|
185 |
NotificationManager.addError("Error obteniendo los campos de la tabla", |
|
186 |
e); |
|
187 |
} catch (ReadDriverException e) { |
|
188 |
NotificationManager.addError("Error obteniendo los campos de la tabla", |
|
189 |
e); |
|
190 |
} |
|
191 |
} else if (w.currentStep == 3) { |
|
192 |
try { |
|
193 |
//tabla |
|
194 |
ProjectTable pt = (ProjectTable) sourceTable.getSelected(); |
|
195 |
|
|
196 |
//?ndice del campo |
|
197 |
SelectableDataSource sds = pt.getModelo().getRecordset(); |
|
198 |
String fieldName = (String) firstTableField.getSelected(); |
|
199 |
int fieldIndex = sds.getFieldIndexByName(fieldName); |
|
200 |
int type = sds.getFieldType(fieldIndex); |
|
201 |
|
|
202 |
secondTableField.setModel(new FieldSelectionModel( |
|
203 |
((ProjectTable) targetTable.getSelected()).getModelo().getRecordset(), |
|
204 |
PluginServices.getText(this, "seleccione_campo_enlace"), |
|
205 |
type)); |
|
206 |
} catch (SelectionException e) { |
|
207 |
NotificationManager.addError("Error obteniendo los campos de la tabla", |
|
208 |
e); |
|
209 |
} catch (ReadDriverException e) { |
|
210 |
NotificationManager.addError("Error obteniendo los campos de la tabla", |
|
211 |
e); |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
public void back(WizardEvent w) { |
|
217 |
WizardControl wiz = w.wizard; |
|
218 |
wiz.enableBack(true); |
|
219 |
wiz.enableNext(((ObjectSelectionStep) wiz.getCurrentStep()).getSelectedItem() != null); |
|
220 |
} |
|
221 |
}); |
|
222 |
project.setModified(true); |
|
223 |
PluginServices.getMDIManager().addWindow(wiz); |
|
224 |
} catch (SelectionException e) { |
|
225 |
NotificationManager.addError("Error abriendo el asistente", e); |
|
226 |
} |
|
97 |
JoinWizardController wizardController = new JoinWizardController(this); |
|
98 |
wizardController.runWizard(pts); |
|
227 | 99 |
}else if ("LINK".equals(actionCommand)) { |
228 | 100 |
try { |
229 | 101 |
final ObjectSelectionStep sourceTable = new ObjectSelectionStep(); |
... | ... | |
522 | 394 |
return true; |
523 | 395 |
} |
524 | 396 |
|
397 |
public void execJoin(ProjectTable sourceProjectTable, String field1, String prefix1, |
|
398 |
ProjectTable targetProjectTable, String field2, String prefix2) { |
|
399 |
// get source table and source field |
|
400 |
SelectableDataSource sds=null; |
|
401 |
try { |
|
402 |
sds = sourceProjectTable.getModelo().getRecordset(); |
|
403 |
} catch (ReadDriverException e) { |
|
404 |
e.printStackTrace(); |
|
405 |
} |
|
406 |
String tableName1 = sds.getName(); |
|
407 |
// get target table and target field |
|
408 |
try { |
|
409 |
sds = targetProjectTable.getModelo().getRecordset(); |
|
410 |
} catch (ReadDriverException e) { |
|
411 |
e.printStackTrace(); |
|
412 |
} |
|
413 |
String tableName2 = sds.getName(); |
|
414 |
// compute the join |
|
415 |
String sql = |
|
416 |
"custom com_iver_cit_gvsig_arcjoin tables '" + |
|
417 |
tableName1 + "', '" + tableName2 + "' values(" + |
|
418 |
field1 + ", " + field2 + ");"; |
|
419 |
PluginServices.getLogger().debug(sql); |
|
525 | 420 |
|
421 |
try { |
|
422 |
SelectableDataSource result = new SelectableDataSource(LayerFactory.getDataSourceFactory() |
|
423 |
.executeSQL(sql, |
|
424 |
DataSourceFactory.AUTOMATIC_OPENING)); |
|
425 |
EditableAdapter auxea=new EditableAdapter(); |
|
426 |
auxea.setOriginalDataSource(result); |
|
427 |
renameFields(auxea, sourceProjectTable, sanitizeFieldName(prefix1), |
|
428 |
targetProjectTable, sanitizeFieldName(prefix2)); |
|
429 |
sourceProjectTable.replaceDataSource(auxea); |
|
430 |
} catch (ParseException e) { |
|
431 |
throw new RuntimeException(e); |
|
432 |
} catch (DriverLoadException e) { |
|
433 |
NotificationManager.addError(PluginServices.getText(this, "Error_loading_driver"), |
|
434 |
e); |
|
435 |
} catch (ReadDriverException e) { |
|
436 |
NotificationManager.addError(PluginServices.getText(this, "Error_reading_from_the_driver"), |
|
437 |
e); |
|
438 |
} catch (SemanticException e) { |
|
439 |
throw new RuntimeException(e); |
|
440 |
} catch (EvaluationException e) { |
|
441 |
NotificationManager.addError(PluginServices.getText(this, "Error_evaluationg_expression"), |
|
442 |
e); |
|
443 |
} |
|
444 |
} |
|
445 |
|
|
446 |
/** |
|
447 |
* Renames fields in a JOIN, so that fields from TABLE1 |
|
448 |
* become sourcePrefix.field1, sourcePrefix.field2, etc, and fields |
|
449 |
* from TABLE2 become targetPrefix.field1, targetPrefix.field2, etc. |
|
450 |
* @param eds |
|
451 |
* @param pt1 |
|
452 |
* @param pt1 |
|
453 |
*/ |
|
454 |
private void renameFields(EditableAdapter eds, |
|
455 |
ProjectTable pt1, String sourcePrefix, ProjectTable pt2, String targetPrefix) { |
|
456 |
try { |
|
457 |
SelectableDataSource sourceDS1 = pt1.getModelo().getRecordset(); |
|
458 |
SelectableDataSource sourceDS2 = pt2.getModelo().getRecordset(); |
|
459 |
SelectableDataSource joinDS = eds.getRecordset(); |
|
460 |
eds.startEdition(EditionEvent.ALPHANUMERIC); |
|
461 |
// rename fields from sourceDS1 |
|
462 |
for (int i=0; i<sourceDS1.getFieldCount(); i++) { |
|
463 |
String fieldName = sourceDS1.getFieldName(i); |
|
464 |
|
|
465 |
if (joinDS.getFieldIndexByName(fieldName)!=-1) { |
|
466 |
eds.renameField(fieldName, sourcePrefix+"_"+fieldName); |
|
467 |
} |
|
468 |
} |
|
469 |
// rename fields from sourceDS2 |
|
470 |
for (int i=0; i<sourceDS2.getFieldCount(); i++) { |
|
471 |
String fieldName = "link_"+sourceDS2.getFieldName(i); |
|
472 |
|
|
473 |
if (joinDS.getFieldIndexByName(fieldName)!=-1) { |
|
474 |
eds.renameField(fieldName, targetPrefix+"_"+sourceDS2.getFieldName(i)); |
|
475 |
} |
|
476 |
} |
|
477 |
} catch (ReadDriverException e) { |
|
478 |
//just log the error, it's not bad if fields couldn't be removed |
|
479 |
PluginServices.getLogger().error("Error renaming fields in a JOIN", e); |
|
480 |
} catch (StartWriterVisitorException e) { |
|
481 |
PluginServices.getLogger().error("Error renaming fields in a JOIN", e); |
|
482 |
} |
|
483 |
} |
|
484 |
|
|
485 |
/** |
|
486 |
* Ensure that field name only has 'safe' characters |
|
487 |
* (no spaces, special characters, etc). |
|
488 |
*/ |
|
489 |
public String sanitizeFieldName(String fieldName) { |
|
490 |
return fieldName.replaceAll("\\W", "_"); // replace any non-word character by an underscore |
|
491 |
} |
|
492 |
|
|
526 | 493 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/gui/JoinWizardController.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package com.iver.cit.gvsig.project.documents.table.gui; |
|
5 |
|
|
6 |
import java.awt.Dimension; |
|
7 |
import java.awt.event.ItemEvent; |
|
8 |
import java.awt.event.ItemListener; |
|
9 |
|
|
10 |
import javax.swing.ImageIcon; |
|
11 |
|
|
12 |
import jwizardcomponent.FinishAction; |
|
13 |
|
|
14 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
15 |
import com.iver.andami.PluginServices; |
|
16 |
import com.iver.andami.messages.NotificationManager; |
|
17 |
import com.iver.cit.gvsig.TableOperations; |
|
18 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
19 |
import com.iver.cit.gvsig.gui.simpleWizard.SimpleWizard; |
|
20 |
import com.iver.cit.gvsig.project.documents.table.FieldSelectionModel; |
|
21 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
|
22 |
|
|
23 |
public class JoinWizardController { |
|
24 |
private final TableOperations tableOperations; |
|
25 |
|
|
26 |
/** |
|
27 |
* @param tableOperations |
|
28 |
*/ |
|
29 |
public JoinWizardController(TableOperations tableOperations) { |
|
30 |
this.tableOperations = tableOperations; |
|
31 |
} |
|
32 |
|
|
33 |
|
|
34 |
public void runWizard(ProjectTable[] pts) { |
|
35 |
// create wizard |
|
36 |
ImageIcon logo = PluginServices.getIconTheme().get("table-join"); |
|
37 |
final SimpleWizard wizard = new SimpleWizard(logo); |
|
38 |
wizard.getWindowInfo().setTitle(PluginServices.getText(this, "Table_Join")); |
|
39 |
|
|
40 |
// create first step (source table) |
|
41 |
final TableWizardStep srcTableWzrd = new TableWizardStep(wizard.getWizardComponents(), "Title" ); |
|
42 |
srcTableWzrd.getHeaderLbl().setText(PluginServices.getText(this,"Source_table_options")); |
|
43 |
srcTableWzrd.getTableNameLbl().setText(PluginServices.getText(this,"Source_table_")); |
|
44 |
srcTableWzrd.getFieldNameLbl().setText(PluginServices.getText(this,"Field_to_use_for_JOIN_")); |
|
45 |
srcTableWzrd.getFieldPrefixLbl().setText(PluginServices.getText(this,"Field_prefix_")); |
|
46 |
srcTableWzrd.getTableNameCmb().addItemListener( |
|
47 |
new ItemListener() { |
|
48 |
|
|
49 |
public void itemStateChanged(ItemEvent e) { |
|
50 |
if (e.getStateChange()==e.SELECTED) { |
|
51 |
ProjectTable pt = (ProjectTable) srcTableWzrd.getTableNameCmb().getSelectedItem(); |
|
52 |
|
|
53 |
try { |
|
54 |
srcTableWzrd.setFieldModel(new FieldSelectionModel( |
|
55 |
pt.getModelo().getRecordset(), |
|
56 |
PluginServices.getText(this, "seleccione_campo_enlace"), |
|
57 |
-1)); |
|
58 |
srcTableWzrd.getFieldPrefixTxt().setText(tableOperations.sanitizeFieldName(pt.getName())); |
|
59 |
} catch (ReadDriverException e1) { |
|
60 |
NotificationManager.addError( |
|
61 |
PluginServices.getText(this, "Error_getting_table_fields"), |
|
62 |
e1); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
} |
|
67 |
} |
|
68 |
); |
|
69 |
for (int i=0; i<pts.length; i++) { |
|
70 |
srcTableWzrd.getTableNameCmb().addItem(pts[i]); |
|
71 |
} |
|
72 |
|
|
73 |
// create second step (target table) |
|
74 |
final TableWizardStep targTableWzrd = new TableWizardStep(wizard.getWizardComponents(), "Title" ); |
|
75 |
targTableWzrd.getHeaderLbl().setText(PluginServices.getText(this,"Target_table_options")); |
|
76 |
targTableWzrd.getTableNameLbl().setText(PluginServices.getText(this,"Target_table_")); |
|
77 |
targTableWzrd.getFieldNameLbl().setText(PluginServices.getText(this,"Field_to_use_for_JOIN_")); |
|
78 |
targTableWzrd.getFieldPrefixLbl().setText(PluginServices.getText(this,"Field_prefix_")); |
|
79 |
targTableWzrd.getTableNameCmb().addItemListener( |
|
80 |
new ItemListener() { |
|
81 |
|
|
82 |
public void itemStateChanged(ItemEvent e) { |
|
83 |
if (e.getStateChange()==e.SELECTED) { |
|
84 |
try { |
|
85 |
//tabla |
|
86 |
ProjectTable sourcePt = (ProjectTable) srcTableWzrd.getTableNameCmb().getSelectedItem(); |
|
87 |
ProjectTable targetPt = (ProjectTable) targTableWzrd.getTableNameCmb().getSelectedItem(); |
|
88 |
targTableWzrd.getFieldPrefixTxt().setText(tableOperations.sanitizeFieldName(targetPt.getName())); |
|
89 |
|
|
90 |
//?ndice del campo |
|
91 |
SelectableDataSource sds = sourcePt.getModelo().getRecordset(); |
|
92 |
String fieldName = (String) srcTableWzrd.getFieldNameCmb().getSelectedItem(); |
|
93 |
int fieldIndex = sds.getFieldIndexByName(fieldName); |
|
94 |
if (fieldIndex!=-1) { |
|
95 |
int type = sds.getFieldType(fieldIndex); |
|
96 |
targTableWzrd.setFieldModel(new FieldSelectionModel( |
|
97 |
targetPt.getModelo().getRecordset(), |
|
98 |
PluginServices.getText(this, "seleccione_campo_enlace"), |
|
99 |
type)); |
|
100 |
} |
|
101 |
else { |
|
102 |
NotificationManager.addError(PluginServices.getText(this, "Error_getting_table_fields") |
|
103 |
, new Exception()); |
|
104 |
} |
|
105 |
} catch (ReadDriverException e2) { |
|
106 |
NotificationManager.addError(PluginServices.getText(this, "Error_getting_table_fields"), |
|
107 |
e2); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
} |
|
112 |
} |
|
113 |
); |
|
114 |
for (int i=0; i<pts.length; i++) { |
|
115 |
targTableWzrd.getTableNameCmb().addItem(pts[i]); |
|
116 |
} |
|
117 |
|
|
118 |
// add steps and configure wizard |
|
119 |
wizard.getWizardComponents().addWizardPanel(srcTableWzrd); |
|
120 |
wizard.getWizardComponents().addWizardPanel(targTableWzrd); |
|
121 |
wizard.getWizardComponents().updateComponents(); |
|
122 |
wizard.setSize(new Dimension(450, 230)); |
|
123 |
wizard.getWizardComponents().setFinishAction(new FinishAction(wizard.getWizardComponents()) { |
|
124 |
public void performAction() { |
|
125 |
ProjectTable sourceProjectTable = (ProjectTable) srcTableWzrd.getTableNameCmb().getSelectedItem(); |
|
126 |
String field1 = (String) srcTableWzrd.getFieldNameCmb().getSelectedItem(); |
|
127 |
String prefix1 = srcTableWzrd.getFieldPrefixTxt().getText(); |
|
128 |
if (sourceProjectTable==null || field1==null || prefix1 == null) { |
|
129 |
NotificationManager.showMessageError( |
|
130 |
PluginServices.getText(this, "Join_parameters_are_incomplete"), new InvalidParameterException()); |
|
131 |
return; |
|
132 |
} |
|
133 |
ProjectTable targetProjectTable = (ProjectTable) targTableWzrd.getTableNameCmb().getSelectedItem(); |
|
134 |
String field2 = (String) targTableWzrd.getFieldNameCmb().getSelectedItem(); |
|
135 |
String prefix2 = targTableWzrd.getFieldPrefixTxt().getText(); |
|
136 |
if (targetProjectTable==null || field2==null || prefix2 == null) { |
|
137 |
NotificationManager.showMessageError( |
|
138 |
PluginServices.getText(this, "Join_parameters_are_incomplete"), new InvalidParameterException()); |
|
139 |
return; |
|
140 |
} |
|
141 |
tableOperations.execJoin(sourceProjectTable, field1, prefix1, targetProjectTable, field2, prefix2); |
|
142 |
|
|
143 |
PluginServices.getMDIManager().closeWindow(wizard); |
|
144 |
} |
|
145 |
} |
|
146 |
); |
|
147 |
|
|
148 |
// show the wizard |
|
149 |
PluginServices.getMDIManager().addWindow(wizard); |
|
150 |
} |
|
151 |
|
|
152 |
private class InvalidParameterException extends Exception { |
|
153 |
} |
|
154 |
} |
|
0 | 155 |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/gui/TableWizardStep.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package com.iver.cit.gvsig.project.documents.table.gui; |
|
5 |
|
|
6 |
import java.awt.Font; |
|
7 |
import java.awt.GridBagConstraints; |
|
8 |
import java.awt.GridBagLayout; |
|
9 |
import java.awt.Insets; |
|
10 |
|
|
11 |
import javax.swing.JLabel; |
|
12 |
import javax.swing.JTextField; |
|
13 |
|
|
14 |
import jwizardcomponent.JWizardComponents; |
|
15 |
import jwizardcomponent.JWizardPanel; |
|
16 |
|
|
17 |
import com.iver.andami.PluginServices; |
|
18 |
import com.iver.andami.messages.NotificationManager; |
|
19 |
import com.iver.utiles.swing.JComboBox; |
|
20 |
import com.iver.utiles.swing.objectSelection.ObjectSelectionModel; |
|
21 |
|
|
22 |
public class TableWizardStep extends JWizardPanel { |
|
23 |
private JLabel lbl_header = null; |
|
24 |
private static final long serialVersionUID = 1L; |
|
25 |
private JLabel tableNameLbl = null; |
|
26 |
private JComboBox tableNameCmb = null; |
|
27 |
private JLabel fieldNameLbl = null; |
|
28 |
private JComboBox fieldNameCmb = null; |
|
29 |
private JLabel fieldPrefixLbl = null; |
|
30 |
private JTextField fieldPrefixTxt = null; |
|
31 |
|
|
32 |
|
|
33 |
public TableWizardStep(JWizardComponents wizardComponents, String title) { |
|
34 |
super(wizardComponents, title); |
|
35 |
initialize(); |
|
36 |
} |
|
37 |
|
|
38 |
public void setTableModel(ObjectSelectionModel model) { |
|
39 |
getTableNameCmb().removeAllItems(); |
|
40 |
Object[] tableNames; |
|
41 |
try { |
|
42 |
tableNames = model.getObjects(); |
|
43 |
for (int i=0; i<tableNames.length; i++) { |
|
44 |
getTableNameCmb().addItem(tableNames[i]); |
|
45 |
} |
|
46 |
} catch (Exception e) { |
|
47 |
NotificationManager.addError(PluginServices.getText(this, "Error_getting_table_fields"), e); |
|
48 |
} |
|
49 |
} |
|
50 |
|
|
51 |
public void setFieldModel(ObjectSelectionModel model) { |
|
52 |
getFieldNameCmb().removeAllItems(); |
|
53 |
Object[] fieldNames; |
|
54 |
try { |
|
55 |
fieldNames = model.getObjects(); |
|
56 |
for (int i=0; i<fieldNames.length; i++) { |
|
57 |
getFieldNameCmb().addItem(fieldNames[i]); |
|
58 |
} |
|
59 |
} catch (Exception e) { |
|
60 |
NotificationManager.addError(PluginServices.getText(this, "Error_getting_table_fields"), e); |
|
61 |
} |
|
62 |
|
|
63 |
} |
|
64 |
|
|
65 |
private void initialize() { |
|
66 |
this.setLayout(new GridBagLayout()); |
|
67 |
|
|
68 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
69 |
constraints.gridx = 0; |
|
70 |
constraints.gridy = 0; |
|
71 |
constraints.gridwidth = 2; |
|
72 |
constraints.anchor = GridBagConstraints.NORTH; |
|
73 |
constraints.fill = GridBagConstraints.HORIZONTAL; |
|
74 |
constraints.weightx = 1.0; |
|
75 |
constraints.weighty = 0.0; |
|
76 |
constraints.insets = new Insets(4,10,8,4); |
|
77 |
this.add(getHeaderLbl(), constraints); |
|
78 |
|
|
79 |
constraints.gridx = 0; |
|
80 |
constraints.gridy = 1; |
|
81 |
constraints.gridwidth = 1; |
|
82 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
83 |
constraints.fill = GridBagConstraints.NONE; |
|
84 |
constraints.weightx = 0.0; |
|
85 |
constraints.weighty = 0.0; |
|
86 |
constraints.insets = new Insets(4,10,4,6); |
|
87 |
this.add(getTableNameLbl(), constraints); |
|
88 |
|
|
89 |
constraints.gridx = 1; |
|
90 |
constraints.gridy = 1; |
|
91 |
constraints.gridwidth = 1; |
|
92 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
93 |
constraints.fill = GridBagConstraints.HORIZONTAL; |
|
94 |
constraints.weightx = 0.5; |
|
95 |
constraints.weighty = 0.0; |
|
96 |
this.add(getTableNameCmb(), constraints); |
|
97 |
|
|
98 |
constraints.gridx = 0; |
|
99 |
constraints.gridy = 2; |
|
100 |
constraints.gridwidth = 1; |
|
101 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
102 |
constraints.fill = GridBagConstraints.NONE; |
|
103 |
constraints.weightx = 0.0; |
|
104 |
constraints.weighty = 0.0; |
|
105 |
constraints.insets = new Insets(4,10,4,6); |
|
106 |
this.add(getFieldNameLbl(), constraints); |
|
107 |
|
|
108 |
constraints.gridx = 1; |
|
109 |
constraints.gridy = 2; |
|
110 |
constraints.gridwidth = 1; |
|
111 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
112 |
constraints.fill = GridBagConstraints.HORIZONTAL; |
|
113 |
constraints.weightx = 0.5; |
|
114 |
constraints.weighty = 0.0; |
|
115 |
this.add(getFieldNameCmb(), constraints); |
|
116 |
|
|
117 |
constraints.gridx = 0; |
|
118 |
constraints.gridy = 3; |
|
119 |
constraints.gridwidth = 1; |
|
120 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
121 |
constraints.fill = GridBagConstraints.NONE; |
|
122 |
constraints.weightx = 0.0; |
|
123 |
constraints.weighty = 0.0; |
|
124 |
constraints.insets = new Insets(4,10,4,6); |
|
125 |
this.add(getFieldPrefixLbl(), constraints); |
|
126 |
|
|
127 |
constraints.gridx = 1; |
|
128 |
constraints.gridy = 3; |
|
129 |
constraints.gridwidth = 1; |
|
130 |
constraints.anchor = GridBagConstraints.NORTHWEST; |
|
131 |
constraints.fill = GridBagConstraints.HORIZONTAL; |
|
132 |
constraints.weightx = 0.5; |
|
133 |
constraints.weighty = 0.0; |
|
134 |
this.add(getFieldPrefixTxt(), constraints); |
|
135 |
} |
|
136 |
|
|
137 |
public JLabel getHeaderLbl() { |
|
138 |
if (lbl_header==null) { |
|
139 |
lbl_header = new JLabel(); |
|
140 |
Font font = lbl_header.getFont(); |
|
141 |
lbl_header.setFont(font.deriveFont(Font.BOLD)); |
|
142 |
} |
|
143 |
return lbl_header; |
|
144 |
} |
|
145 |
|
|
146 |
public JLabel getTableNameLbl() { |
|
147 |
if (tableNameLbl == null) { |
|
148 |
tableNameLbl = new JLabel(); |
|
149 |
} |
|
150 |
return tableNameLbl; |
|
151 |
} |
|
152 |
|
|
153 |
public JComboBox getTableNameCmb() { |
|
154 |
if (tableNameCmb == null) { |
|
155 |
tableNameCmb = new JComboBox(); |
|
156 |
} |
|
157 |
return tableNameCmb; |
|
158 |
} |
|
159 |
|
|
160 |
public JLabel getFieldNameLbl() { |
|
161 |
if (fieldNameLbl==null) { |
|
162 |
fieldNameLbl = new JLabel(); |
|
163 |
} |
|
164 |
return fieldNameLbl; |
|
165 |
} |
|
166 |
|
|
167 |
public JComboBox getFieldNameCmb() { |
|
168 |
if (fieldNameCmb==null) { |
|
169 |
fieldNameCmb = new JComboBox(); |
|
170 |
} |
|
171 |
return fieldNameCmb; |
|
172 |
} |
|
173 |
|
|
174 |
public JLabel getFieldPrefixLbl() { |
|
175 |
if (fieldPrefixLbl==null) { |
|
176 |
fieldPrefixLbl = new JLabel(); |
|
177 |
} |
|
178 |
return fieldPrefixLbl; |
|
179 |
} |
|
180 |
|
|
181 |
public JTextField getFieldPrefixTxt() { |
|
182 |
if (fieldPrefixTxt==null) { |
|
183 |
fieldPrefixTxt = new JTextField(); |
|
184 |
} |
|
185 |
return fieldPrefixTxt; |
|
186 |
} |
|
187 |
} |
|
0 | 188 |
trunk/applications/appgvSIG/config/text.properties | ||
---|---|---|
1085 | 1085 |
options.view.behavior.screen_refreshrate.full=<html><b>Total</b> (tiempo de respuesta real)</html> |
1086 | 1086 |
options.view.behavior.screen_refresh_rate.help=<html><b>Nota:</b> El refresco de pantalla permite mejorar la navegaci?n sobre el mapa gracias a la reducci?n del tiempo entre pintados de ?ste. Esto es especialmente interesante en tiempo de edicion. Sin embargo, este refresco es una tarea que incrementa el tiempo de procesado de la CPU (<15%). Por lo tanto, cuanto mayor sea el refresco de pantalla, m?s tiempo ser? necesario para dibujar el mapa.</html>. |
1087 | 1087 |
fixed_color=Color fijo |
1088 |
Table_Join=Uni?n de tablas |
|
1089 |
Source_table_options=Opciones de la tabla de origen |
|
1090 |
Target_table_options=Opciones de la tabla de destino |
|
1091 |
Source_table_=Tabla de origen: |
|
1092 |
Field_to_use_for_JOIN_=Campo a usar para la uni?n: |
|
1093 |
Field_prefix_=Prefijo de campo: |
|
1094 |
Error_getting_table_fields=Error obteniendo los campos de la tabla |
|
1095 |
Target_table_=Tabla destino: |
|
1096 |
Join_parameters_are_incomplete=Los par?metros del JOIN est?n incompletos |
|
1097 |
Error_loading_driver=Error en la carga del driver |
|
1098 |
Error_reading_from_the_driver=Error leyendo del driver |
|
1099 |
Error_evaluationg_expression=Error de evaluaci?n en la expresi?n |
trunk/applications/appgvSIG/config/text_en.properties | ||
---|---|---|
999 | 999 |
clear_selection=Clear selection |
1000 | 1000 |
distance_area=Measuring area units |
1001 | 1001 |
fixed_color=Fixed color |
1002 |
unidades_area=Area units |
|
1002 |
unidades_area=Area units |
|
1003 |
Table_Join=Table Join |
|
1004 |
Source_table_options=Source Table Options |
|
1005 |
Target_table_options=Target Table Options |
|
1006 |
Source_table_=Source table: |
|
1007 |
Field_to_use_for_JOIN_=Field to use for JOIN: |
|
1008 |
Field_prefix_=Field prefix: |
|
1009 |
Error_getting_table_fields=Error getting table fields |
|
1010 |
Target_table_=Target table: |
|
1011 |
Join_parameters_are_incomplete=JOIN parameters are incomplete |
|
1012 |
Error_loading_driver=Error loading the driver |
|
1013 |
Error_reading_from_the_driver=Error reading from the driver |
|
1014 |
Error_evaluationg_expression=Error evaluating expression |
Also available in: Unified diff