Revision 45931 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableManager.java
TableManager.java | ||
---|---|---|
70 | 70 |
import org.gvsig.tools.persistence.PersistenceManager; |
71 | 71 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
72 | 72 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
73 |
import org.gvsig.tools.util.Invocable; |
|
73 | 74 |
import org.gvsig.tools.util.MappedIterator; |
74 | 75 |
import org.gvsig.tools.util.UnmodifiableBasicSet; |
75 | 76 |
|
... | ... | |
197 | 198 |
|
198 | 199 |
@Override |
199 | 200 |
public Iterator<? extends Document> createDocumentsByUser() { |
201 |
return this.createDocumentsByUser(null); |
|
202 |
} |
|
203 |
|
|
204 |
@Override |
|
205 |
public Iterator<? extends Document> createDocumentsByUser(Invocable whenDocumentsLoaded) { |
|
200 | 206 |
AddLayerDialog fopen = null; |
201 | 207 |
try { |
202 | 208 |
fopen = |
... | ... | |
212 | 218 |
} |
213 | 219 |
PluginServices.getMDIManager().addWindow(fopen); |
214 | 220 |
if (fopen.isAccepted()) { |
215 |
panel = (WizardPanel) fopen.getSelectedTab(); |
|
216 |
@SuppressWarnings("unchecked") |
|
217 |
List<TableDocument> docs = |
|
218 |
(List<TableDocument>) panel.executeWizard(); |
|
219 |
for (TableDocument doc : docs) { |
|
220 |
try { |
|
221 |
FeatureStore store = ((TableDocument)doc).getDataStore(); |
|
222 |
FeatureType type = store.getDefaultFeatureType(); |
|
223 |
if( ! type.supportReferences() ) { |
|
224 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
225 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
226 |
dialogs.messageDialog( |
|
227 |
"\""+ doc.getName() + "\"\n"+ |
|
228 |
i18n.getTranslation("_The_table_has_no_primary_key_or_OID") +"\n" + |
|
229 |
i18n.getTranslation("_Many_features_selection_deletion_modification_will_not_be_available_as_they_require_it_for_proper_operation"), |
|
230 |
null, |
|
231 |
i18n.getTranslation("_Warning"), |
|
232 |
JOptionPane.WARNING_MESSAGE, |
|
233 |
"TableDoNotSupportReferences" |
|
234 |
); |
|
235 |
} |
|
236 |
} catch (Exception ex) { |
|
237 |
|
|
238 |
} |
|
221 |
WizardPanel selectedPanel = (WizardPanel) fopen.getSelectedTab(); |
|
222 |
if( whenDocumentsLoaded==null ) { |
|
223 |
List<TableDocument> docs = (List) selectedPanel.executeWizard(); |
|
224 |
this.checkDocuments(docs); |
|
225 |
return docs.iterator(); |
|
239 | 226 |
} |
240 |
return docs.iterator(); |
|
227 |
Thread task = new Thread(() -> { |
|
228 |
List<TableDocument> docs = (List) selectedPanel.executeWizard(); |
|
229 |
checkDocuments(docs); |
|
230 |
whenDocumentsLoaded.call(docs.iterator()); |
|
231 |
}, "DocumentTableLoader"); |
|
232 |
task.start(); |
|
233 |
return Collections.EMPTY_LIST.iterator(); |
|
241 | 234 |
} |
242 | 235 |
} catch (Exception e) { |
243 | 236 |
NotificationManager.addError(e); |
... | ... | |
249 | 242 |
} |
250 | 243 |
return null; |
251 | 244 |
} |
245 |
|
|
246 |
private void checkDocuments(List<TableDocument> docs) { |
|
247 |
if( docs==null ) { |
|
248 |
return; |
|
249 |
} |
|
250 |
for (TableDocument doc : docs) { |
|
251 |
try { |
|
252 |
FeatureStore store = ((TableDocument)doc).getDataStore(); |
|
253 |
FeatureType type = store.getDefaultFeatureType(); |
|
254 |
if( ! type.supportReferences() ) { |
|
255 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
256 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
257 |
dialogs.messageDialog( |
|
258 |
"\""+ doc.getName() + "\"\n"+ |
|
259 |
i18n.getTranslation("_The_table_has_no_primary_key_or_OID") +"\n" + |
|
260 |
i18n.getTranslation("_Many_features_selection_deletion_modification_will_not_be_available_as_they_require_it_for_proper_operation"), |
|
261 |
null, |
|
262 |
i18n.getTranslation("_Warning"), |
|
263 |
JOptionPane.WARNING_MESSAGE, |
|
264 |
"TableDoNotSupportReferences" |
|
265 |
); |
|
266 |
} |
|
267 |
} catch (Exception ex) { |
|
252 | 268 |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
253 | 273 |
@Override |
254 | 274 |
public AbstractDocument createDocumentByUser() { |
255 | 275 |
return (AbstractDocument) createDocumentsByUser().next(); |
Also available in: Unified diff