Revision 45931
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/ProjectManager.java | ||
---|---|---|
51 | 51 |
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable; |
52 | 52 |
import org.gvsig.tools.util.BaseListenerSupport; |
53 | 53 |
import org.gvsig.tools.util.BaseListenerSupport.NotificationListener; |
54 |
import org.gvsig.tools.util.Invocable; |
|
54 | 55 |
|
55 | 56 |
public class ProjectManager extends BaseWeakReferencingObservable { |
56 | 57 |
|
... | ... | |
193 | 194 |
return getDocumentManager(type).createDocumentsByUser(); |
194 | 195 |
} |
195 | 196 |
|
197 |
public Iterator<? extends Document> createDocumentsByUser(String type, Invocable whenDocumentsLoadeds) { |
|
198 |
logger.info("createDocumentsByUser('{}')", type); |
|
199 |
return getDocumentManager(type).createDocumentsByUser(whenDocumentsLoadeds); |
|
200 |
} |
|
201 |
|
|
196 | 202 |
public Project createProject() { |
197 | 203 |
return new DefaultProject(); |
198 | 204 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/AbstractDocumentManager.java | ||
---|---|---|
64 | 64 |
import org.gvsig.tools.persistence.PersistentState; |
65 | 65 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
66 | 66 |
import org.gvsig.tools.swing.api.Component; |
67 |
import org.gvsig.tools.util.Invocable; |
|
67 | 68 |
|
68 | 69 |
|
69 | 70 |
|
... | ... | |
125 | 126 |
return PluginServices.getText(this, "documento"); |
126 | 127 |
} |
127 | 128 |
|
129 |
@Override |
|
128 | 130 |
public AbstractDocument createDocumentByUser() { |
129 | 131 |
return createDocument(); |
130 | 132 |
} |
131 | 133 |
|
134 |
@Override |
|
132 | 135 |
public Iterator<? extends Document> createDocumentsByUser() { |
133 |
Set<AbstractDocument> doc = new HashSet<AbstractDocument>(1);
|
|
136 |
Set<AbstractDocument> doc = new HashSet<>(1); |
|
134 | 137 |
doc.add(createDocumentByUser()); |
135 | 138 |
return doc.iterator(); |
136 | 139 |
} |
137 | 140 |
|
141 |
@Override |
|
142 |
public Iterator<? extends Document> createDocumentsByUser(Invocable whenDocumentsLoaded) { |
|
143 |
Set<AbstractDocument> docs = new HashSet<>(1); |
|
144 |
docs.add(createDocumentByUser()); |
|
145 |
return docs.iterator(); |
|
146 |
} |
|
147 |
|
|
138 | 148 |
/** |
139 | 149 |
* @see ExtensionBuilder |
140 | 150 |
*/ |
151 |
@Override |
|
141 | 152 |
public Object create() { |
142 | 153 |
return this; |
143 | 154 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/gui/projectpanel/ProjectDocumentsPanelPage.java | ||
---|---|---|
47 | 47 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
48 | 48 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
49 | 49 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
50 |
import org.gvsig.tools.util.Invocable; |
|
50 | 51 |
import org.gvsig.utils.DefaultListModel; |
51 | 52 |
import org.slf4j.Logger; |
52 | 53 |
import org.slf4j.LoggerFactory; |
... | ... | |
356 | 357 |
private void doDocumentNew() { |
357 | 358 |
String documentsTypeName = this.currentDocumentType.getTypeName(); |
358 | 359 |
ProjectManager projectManager = ProjectManager.getInstance(); |
359 |
Iterator<? extends Document> documents = projectManager.createDocumentsByUser(documentsTypeName); |
|
360 |
Iterator<? extends Document> documents = projectManager.createDocumentsByUser(documentsTypeName, new Invocable() { |
|
361 |
@Override |
|
362 |
public Object call(Object... args) { |
|
363 |
Iterator<? extends Document> docs = (Iterator<? extends Document>) args[0]; |
|
364 |
addNewDocuments(docs); |
|
365 |
return null; |
|
366 |
} |
|
367 |
}); |
|
368 |
addNewDocuments(documents); |
|
369 |
} |
|
370 |
|
|
371 |
private void addNewDocuments(Iterator<? extends Document> documents) { |
|
360 | 372 |
while ( documents != null && documents.hasNext() ) { |
361 | 373 |
try { |
362 | 374 |
Document document = documents.next(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/DocumentManager.java | ||
---|---|---|
37 | 37 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
38 | 38 |
import org.gvsig.tools.observer.WeakReferencingObservable; |
39 | 39 |
import org.gvsig.tools.persistence.PersistenceFactory; |
40 |
import org.gvsig.tools.util.Invocable; |
|
40 | 41 |
|
41 | 42 |
public interface DocumentManager extends ExtensionBuilder, PersistenceFactory, WeakReferencingObservable, ExtendedPropertiesSupport { |
42 | 43 |
|
... | ... | |
94 | 95 |
*/ |
95 | 96 |
public Iterator<? extends Document> createDocumentsByUser(); |
96 | 97 |
|
98 |
public Iterator<? extends Document> createDocumentsByUser(Invocable whenDocumentsLoaded); |
|
99 |
|
|
97 | 100 |
/** |
98 | 101 |
* Returns the title of type of document. |
99 | 102 |
* |
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 | ||
---|---|---|
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