Revision 34903
branches/v2_0_0_prep/extensions/extDalTransformJoin/src/org/gvsig/app/join/JoinToolExtension.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.app.join; |
29 | 29 |
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.Iterator; |
|
32 |
import java.util.List; |
|
30 |
import java.awt.Component; |
|
33 | 31 |
|
34 |
import org.gvsig.andami.messages.NotificationManager; |
|
32 |
import javax.swing.JOptionPane; |
|
33 |
|
|
34 |
import org.gvsig.andami.PluginServices; |
|
35 |
import org.gvsig.app.daltransform.DataTransformLocator; |
|
36 |
import org.gvsig.app.daltransform.gui.DataTransformWizard; |
|
35 | 37 |
import org.gvsig.app.extension.TableOperations; |
36 |
import org.gvsig.app.join.dal.feature.JoinTransform; |
|
37 |
import org.gvsig.app.project.Project; |
|
38 |
import org.gvsig.app.project.ProjectManager; |
|
39 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
40 |
import org.gvsig.app.project.documents.table.TableManager; |
|
41 |
import org.gvsig.fmap.dal.exception.DataException; |
|
42 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
43 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
44 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
45 |
import org.gvsig.project.document.table.gui.JoinWizardController; |
|
38 |
import org.gvsig.app.join.daltransform.JoinTransformGui; |
|
46 | 39 |
|
47 | 40 |
|
48 | 41 |
/** |
49 | 42 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
50 | 43 |
*/ |
51 | 44 |
public class JoinToolExtension extends TableOperations { |
52 |
// private FeatureStore featureStore = null; |
|
53 | 45 |
|
54 | 46 |
/** |
55 | 47 |
* @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String) |
56 | 48 |
*/ |
57 | 49 |
public void execute(String actionCommand) { |
58 |
// ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
|
59 |
// org.gvsig.app.project.Project project=pe.getProject(); |
|
60 |
Project project = ProjectManager.getInstance().getCurrentProject(); |
|
61 |
TableDocument[] pts = project.getDocuments(TableManager.TYPENAME) |
|
62 |
.toArray(new TableDocument[0]); |
|
63 |
|
|
64 |
JoinWizardController wizardController = new JoinWizardController(this); |
|
65 |
wizardController.runWizard(pts); |
|
66 |
} |
|
67 |
|
|
68 |
@SuppressWarnings("unchecked") |
|
69 |
public void execJoin(TableDocument sourceProjectTable, |
|
70 |
String field1, String prefix1, |
|
71 |
TableDocument targetProjectTable, String field2, |
|
72 |
String prefix2) { |
|
73 |
|
|
74 |
FeatureStore fs1 = sourceProjectTable.getStore(); |
|
75 |
|
|
76 |
FeatureStore fs2 = targetProjectTable.getStore(); |
|
77 |
|
|
78 |
if (fs1 == fs2) { |
|
79 |
NotificationManager |
|
80 |
.addInfo("no_es_posible_aplicar_join_sobre_la_misma_fuente"); |
|
81 |
} |
|
82 |
|
|
83 |
try { |
|
84 |
// DataManager dm = DALLocator.getDataManager(); |
|
85 |
JoinTransform jt = new JoinTransform(); |
|
86 |
List<String> fields = new ArrayList<String>(); |
|
87 |
Iterator<FeatureAttributeDescriptor> iterator2 = fs2.getDefaultFeatureType().iterator(); |
|
88 |
while (iterator2.hasNext()) { |
|
89 |
FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator2 |
|
90 |
.next(); |
|
91 |
String name = descriptor.getName(); |
|
92 |
if (!name.equals(field2)) { |
|
93 |
fields.add(name); |
|
94 |
} |
|
95 |
} |
|
96 |
jt.initialize(fs1, fs2, field1, field2, prefix1, prefix2, fields |
|
97 |
.toArray(new String[0])); |
|
98 |
fs1.getTransforms().add(jt); |
|
99 |
// featureStore=fs1; |
|
100 |
|
|
101 |
} catch (ReadException e) { |
|
102 |
NotificationManager.addError("Error leyendo del driver", e); |
|
103 |
} catch (DataException e) { |
|
104 |
NotificationManager.addError(e); |
|
105 |
} |
|
106 |
|
|
107 |
} |
|
50 |
try { |
|
51 |
DataTransformWizard dataTransformWizard = DataTransformLocator.getDataTransformManager().createWizard(); |
|
52 |
dataTransformWizard.setDataTransformGui(new JoinTransformGui()); |
|
53 |
PluginServices.getMDIManager().addWindow(dataTransformWizard.getWindow()); |
|
54 |
} catch (Exception e) { |
|
55 |
JOptionPane.showInternalMessageDialog((Component)PluginServices.getMDIManager(), |
|
56 |
PluginServices.getText(this, "transform_create_wizard_exception"), |
|
57 |
PluginServices.getText(this, "feature_transform"), |
|
58 |
JOptionPane.ERROR_MESSAGE); |
|
59 |
} |
|
60 |
} |
|
108 | 61 |
|
109 |
|
|
110 | 62 |
} |
Also available in: Unified diff