Revision 37522 branches/v2_0_0_prep/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/SelectDataStoreWizardPanel.java
SelectDataStoreWizardPanel.java | ||
---|---|---|
40 | 40 |
import org.gvsig.app.project.documents.table.TableDocument; |
41 | 41 |
import org.gvsig.app.project.documents.table.TableManager; |
42 | 42 |
import org.gvsig.app.project.documents.view.gui.IView; |
43 |
import org.gvsig.daltransform.swing.DataTransformGui; |
|
43 | 44 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
44 | 45 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
45 | 46 |
import org.gvsig.fmap.mapcontext.layers.LayersIterator; |
... | ... | |
59 | 60 |
*/ |
60 | 61 |
public SelectDataStoreWizardPanel() { |
61 | 62 |
super(); |
62 |
initComponents(); |
|
63 |
addDataStores(); |
|
63 |
initComponents(); |
|
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
private void initComponents() { |
... | ... | |
97 | 97 |
* Adding the objects |
98 | 98 |
*/ |
99 | 99 |
private void addDataStores(){ |
100 |
//Add all the tables |
|
100 |
((DefaultListModel)dataStoreList.getModel()).removeAllElements(); |
|
101 |
DataTransformGui dataTransformGui = |
|
102 |
getDataTransformWizard().getDataTransformGui(); |
|
103 |
|
|
104 |
//Add all the tables |
|
101 | 105 |
List<Document> tables = ProjectManager.getInstance().getCurrentProject() |
102 | 106 |
.getDocuments(TableManager.TYPENAME); |
103 | 107 |
for (Document table : tables) { |
104 |
((DefaultListModel)dataStoreList.getModel()).addElement( |
|
105 |
new FeatureStoreCombo( |
|
106 |
table.getName(), |
|
107 |
((TableDocument)table).getStore(), |
|
108 |
false |
|
109 |
) |
|
110 |
); |
|
108 |
if (dataTransformGui.accept(((TableDocument)table).getStore())){ |
|
109 |
((DefaultListModel)dataStoreList.getModel()).addElement( |
|
110 |
new FeatureStoreCombo( |
|
111 |
table.getName(), |
|
112 |
((TableDocument)table).getStore(), |
|
113 |
false |
|
114 |
) |
|
115 |
); |
|
116 |
} |
|
111 | 117 |
} |
112 | 118 |
|
113 |
// ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
|
114 |
// ArrayList<ProjectDocument> tables = ext.getProject().getDocumentsByType(FeatureTableDocumentFactory.registerName); |
|
115 |
// for (int i=0 ; i<tables.size() ; i++){ |
|
116 |
// FeatureTableDocument table = (FeatureTableDocument)tables.get(i); |
|
117 |
// ((DefaultListModel)dataStoreList.getModel()).addElement( |
|
118 |
// new FeatureStoreCombo(table.getName(), |
|
119 |
// table.getStore(), |
|
120 |
// false)); |
|
121 |
// } |
|
122 | 119 |
//Add the layers from the current view |
123 | 120 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
124 | 121 |
if (window instanceof IView){ |
... | ... | |
128 | 125 |
while(it.hasNext()){ |
129 | 126 |
FLayer layer = it.nextLayer(); |
130 | 127 |
if (layer instanceof FLyrVect){ |
131 |
// try { |
|
132 |
FLyrVect layerVect = (FLyrVect)layer; |
|
133 |
FeatureStore featureStore = layerVect.getFeatureStore(); |
|
134 |
boolean found = false; |
|
135 |
for (int i=0 ; i<tables.size() ; i++){ |
|
136 |
TableDocument table = (TableDocument)tables.get(i); |
|
137 |
if (table.getStore().equals(featureStore)) { |
|
138 |
found = true; |
|
139 |
} |
|
140 |
} |
|
141 |
if (!found){ |
|
142 |
((DefaultListModel)dataStoreList.getModel()).addElement( |
|
143 |
new FeatureStoreCombo(layerVect.getName(), |
|
144 |
featureStore, |
|
145 |
true)); |
|
146 |
} |
|
147 |
// } catch (ReadException e) { |
|
148 |
// logger.error("It is not possible to read the FeatureStore", e); |
|
149 |
// } |
|
128 |
FLyrVect layerVect = (FLyrVect)layer; |
|
129 |
FeatureStore featureStore = layerVect.getFeatureStore(); |
|
130 |
boolean found = false; |
|
131 |
for (int i=0 ; i<tables.size() ; i++){ |
|
132 |
TableDocument table = (TableDocument)tables.get(i); |
|
133 |
if (table.getStore().equals(featureStore)) { |
|
134 |
found = true; |
|
135 |
} |
|
136 |
} |
|
137 |
if (!found){ |
|
138 |
if (dataTransformGui.accept(featureStore)){ |
|
139 |
((DefaultListModel)dataStoreList.getModel()).addElement( |
|
140 |
new FeatureStoreCombo(layerVect.getName(), |
|
141 |
featureStore, |
|
142 |
true)); |
|
143 |
} |
|
144 |
} |
|
150 | 145 |
} |
151 | 146 |
} |
152 | 147 |
} |
... | ... | |
233 | 228 |
* @see org.gvsig.app.daltransform.DataTransformWizard#updatePanel() |
234 | 229 |
*/ |
235 | 230 |
public void updatePanel() { |
236 |
if (dataStoreList.getSelectedIndex() == -1){ |
|
231 |
addDataStores(); |
|
232 |
if (dataStoreList.getSelectedIndex() == -1){ |
|
237 | 233 |
if (dataStoreList.getModel().getSize() > 0){ |
238 | 234 |
dataStoreList.setSelectedIndex(0); |
239 | 235 |
getDataTransformWizard().setApplicable(true); |
Also available in: Unified diff