Revision 7703
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.88/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG |
|
2 |
Association. This program is free software; you can redistribute it and/or modify |
|
3 |
it under the terms of the GNU General Public License as published by the Free Software |
|
4 |
Foundation; either version 3 of the License, or (at your option) any later version. |
|
5 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
6 |
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
7 |
PURPOSE. See the GNU General Public License for more details. You should have received |
|
8 |
a copy of the GNU General Public License along with this program; if not, write to |
|
9 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
|
10 |
USA. For any additional information, do not hesitate to contact us at info AT gvsig.com, |
|
11 |
or visit our website www.gvsig.com. --> |
|
12 |
<assembly> |
|
13 |
<id>gvsig-plugin-package</id> |
|
14 |
<formats> |
|
15 |
<format>zip</format> |
|
16 |
</formats> |
|
17 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
18 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
19 |
<files> |
|
20 |
<file> |
|
21 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
22 |
<outputDirectory>lib</outputDirectory> |
|
23 |
</file> |
|
24 |
<file> |
|
25 |
<source>target/package.info</source> |
|
26 |
</file> |
|
27 |
</files> |
|
28 |
|
|
29 |
<fileSets> |
|
30 |
<fileSet> |
|
31 |
<directory>src/main/resources-plugin</directory> |
|
32 |
<outputDirectory>.</outputDirectory> |
|
33 |
</fileSet> |
|
34 |
</fileSets> |
|
35 |
|
|
36 |
|
|
37 |
<dependencySets> |
|
38 |
<dependencySet> |
|
39 |
<useProjectArtifact>false</useProjectArtifact> |
|
40 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
41 |
<outputDirectory>lib</outputDirectory> |
|
42 |
<includes> |
|
43 |
<include>org.gvsig:org.gvsig.vcsgis.lib.api</include> |
|
44 |
<include>org.gvsig:org.gvsig.vcsgis.lib.impl</include> |
|
45 |
<include>org.gvsig:org.gvsig.vcsgis.swing.api</include> |
|
46 |
<include>org.gvsig:org.gvsig.vcsgis.swing.impl</include> |
|
47 |
<include>javax.servlet:javax.servlet-api</include> |
|
48 |
|
|
49 |
</includes> |
|
50 |
</dependencySet> |
|
51 |
</dependencySets> |
|
52 |
|
|
53 |
</assembly> |
|
54 |
|
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.88/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/VCSGisExtension.java | ||
---|---|---|
1 |
/* |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2020 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
18 |
* |
|
19 |
* For any additional information, do not hesitate to contact us |
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
21 |
*/ |
|
22 |
package org.gvsig.vcsgis.app; |
|
23 |
|
|
24 |
import java.sql.Timestamp; |
|
25 |
import java.util.ArrayList; |
|
26 |
import java.util.EventListener; |
|
27 |
import java.util.List; |
|
28 |
import java.util.Map; |
|
29 |
import java.util.Objects; |
|
30 |
import javax.swing.JOptionPane; |
|
31 |
import org.gvsig.andami.IconThemeHelper; |
|
32 |
import org.gvsig.andami.PluginsLocator; |
|
33 |
import org.gvsig.andami.plugins.Extension; |
|
34 |
import org.gvsig.andami.preferences.IPreference; |
|
35 |
import org.gvsig.andami.preferences.IPreferenceExtension; |
|
36 |
import org.gvsig.app.ApplicationLocator; |
|
37 |
import org.gvsig.app.ApplicationManager; |
|
38 |
import org.gvsig.app.extension.AddLayer; |
|
39 |
import org.gvsig.app.project.ProjectManager.ProjectEvent; |
|
40 |
import static org.gvsig.app.project.ProjectNotification.AFTER_LOAD_FROM_FILE; |
|
41 |
import static org.gvsig.app.project.ProjectNotification.BEFORE_SAVE_TO_FILE; |
|
42 |
import org.gvsig.fmap.dal.EditingNotificationManager; |
|
43 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
44 |
import org.gvsig.tools.ToolsLocator; |
|
45 |
import org.gvsig.tools.arguments.Arguments; |
|
46 |
import org.gvsig.tools.dynobject.DynObject; |
|
47 |
import org.gvsig.tools.i18n.I18nManager; |
|
48 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
49 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
50 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
51 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
52 |
import org.gvsig.vcsgis.app.VCSGisDialogsHelper.VCSGisDialogInfo; |
|
53 |
import org.gvsig.vcsgis.app.addlayer.WizardVCSGisTabular; |
|
54 |
import org.gvsig.vcsgis.app.addlayer.WizardVCSGisVectorial; |
|
55 |
import org.gvsig.vcsgis.app.preferencespages.VCSGisPage; |
|
56 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
57 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
58 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
59 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
|
60 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_USER_CANCELLED; |
|
61 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
62 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceDescriptor; |
|
63 |
import org.gvsig.vcsgis.swing.VCSGisJAddToWorkspace; |
|
64 |
import org.gvsig.vcsgis.swing.VCSGisJCheckout; |
|
65 |
import org.gvsig.vcsgis.swing.VCSGisJCheckoutDataModel; |
|
66 |
import org.gvsig.vcsgis.swing.VCSGisJCreateResourceTable; |
|
67 |
import org.gvsig.vcsgis.swing.VCSGisJDownloadWorkingcopy; |
|
68 |
import org.gvsig.vcsgis.swing.VCSGisJExport; |
|
69 |
import org.gvsig.vcsgis.swing.VCSGisJBackupHistory; |
|
70 |
import org.gvsig.vcsgis.swing.VCSGisJImportHistory; |
|
71 |
import org.gvsig.vcsgis.swing.VCSGisJInitServer; |
|
72 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
|
73 |
import org.gvsig.vcsgis.swing.VCSGisJLogout; |
|
74 |
import org.gvsig.vcsgis.swing.VCSGisJPrepareWorkingcopy; |
|
75 |
import org.gvsig.vcsgis.swing.VCSGisJRestoreHistory; |
|
76 |
import org.gvsig.vcsgis.swing.VCSGisJShowServerTableForm; |
|
77 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
|
78 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
|
79 |
|
|
80 |
/** |
|
81 |
* |
|
82 |
* @author gvSIG Team |
|
83 |
*/ |
|
84 |
public class VCSGisExtension extends Extension implements IPreferenceExtension { |
|
85 |
|
|
86 |
private VCSGisDialogsHelper dialogsHelper; |
|
87 |
|
|
88 |
@Override |
|
89 |
public void initialize() { |
|
90 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-init-server", this); |
|
91 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-init-workspace", this); |
|
92 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-add-to-workspace", this); |
|
93 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-export", this); |
|
94 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-checkout", this); |
|
95 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-showchanges", this); |
|
96 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-register-workspace", this); |
|
97 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-show-revisions", this); |
|
98 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-checkout-datamodel", this); |
|
99 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-download-workingcopy", this); |
|
100 |
|
|
101 |
this.dialogsHelper = new VCSGisDialogsHelper(); |
|
102 |
// ToolsLocator.getDisposableManager().setStackLimit(200); |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public void postInitialize() { |
|
107 |
super.postInitialize(); |
|
108 |
|
|
109 |
IconThemeHelper.registerIcon("preferences", "vcsgis-preferences", this); |
|
110 |
|
|
111 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
112 |
VCSGisManager manager = VCSGisLocator.getVCSGisManager(); |
|
113 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
114 |
swingManager.setDefaultServices(new VCSGisSwingServicesImpl()); |
|
115 |
|
|
116 |
DynObject pluginProperties = this.getPlugin().getPluginProperties(); |
|
117 |
Map<String, VCSGisWorkspaceDescriptor> workspaces = (Map) pluginProperties.getDynValue("workspaces"); |
|
118 |
manager.restoreWorkspaces(workspaces); |
|
119 |
swingManager.setEmptyEffectiveDateAllowed((boolean)pluginProperties.getDynValue("EmptyEffectiveDateAllowedInCommitPanel")); |
|
120 |
swingManager.setCurrentDateAsEffectiveDateByDefault((boolean)pluginProperties.getDynValue("CurrentDateAsEffectiveDateByDefaultInCommitPanel")); |
|
121 |
swingManager.setRepositoryEntityFeatureTypeEditorMode((int)pluginProperties.getDynValue("RepositoryEntityFeatureTypeEditorMode")); |
|
122 |
|
|
123 |
PluginsLocator.getPluginsManager().addShutdownTask( |
|
124 |
"VCSGisSave", |
|
125 |
() -> { |
|
126 |
DynObject pluginProps = getPlugin().getPluginProperties(); |
|
127 |
pluginProps.setDynValue("workspaces", manager.getWorkspaces()); |
|
128 |
pluginProps.setDynValue("EmptyEffectiveDateAllowedInCommitPanel", swingManager.isEmptyEffectiveDateAllowed()); |
|
129 |
pluginProps.setDynValue("CurrentDateAsEffectiveDateByDefaultInCommitPanel", swingManager.useCurrentDateAsEffectiveDateByDefault()); |
|
130 |
pluginProps.setDynValue("RepositoryEntityFeatureTypeEditorMode", swingManager.getRepositoryEntityFeatureTypeEditorMode()); |
|
131 |
}, |
|
132 |
false, |
|
133 |
100 |
|
134 |
); |
|
135 |
|
|
136 |
ApplicationLocator.getManager().registerAddTableWizard( |
|
137 |
"VCSGis", |
|
138 |
"VCSGis", |
|
139 |
WizardVCSGisTabular.class |
|
140 |
); |
|
141 |
AddLayer.addWizard(WizardVCSGisVectorial.class); |
|
142 |
|
|
143 |
application.getProjectManager().addProjectListener((EventListener e) -> { |
|
144 |
if( e instanceof ProjectEvent ) { |
|
145 |
ProjectEvent pe = (ProjectEvent)e; |
|
146 |
switch(pe.getId()) { |
|
147 |
case AFTER_LOAD_FROM_FILE: |
|
148 |
VCSGisSwingServicesImpl services = (VCSGisSwingServicesImpl) VCSGisSwingLocator.getVCSGisSwingManager().getDefaultServices(); |
|
149 |
services.projectLoaded(pe.getProject()); |
|
150 |
break; |
|
151 |
case BEFORE_SAVE_TO_FILE: |
|
152 |
break; |
|
153 |
} |
|
154 |
} |
|
155 |
}); |
|
156 |
|
|
157 |
EditingNotificationManager editingNotificationManager = DALSwingLocator.getEditingNotificationManager(); |
|
158 |
editingNotificationManager.addObserver(new EditingNotificationObserver()); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public void execute(String actionCommand) { |
|
163 |
this.execute(actionCommand, null); |
|
164 |
} |
|
165 |
|
|
166 |
@Override |
|
167 |
public void execute(String actionCommand, Object[] args) { |
|
168 |
Arguments arguments = Arguments.create(args); |
|
169 |
switch (actionCommand) { |
|
170 |
case "tools-vcsgis-showchanges": |
|
171 |
this.showChangesDialog( |
|
172 |
(VCSGisWorkspace) arguments.get("workspace", VCSGisWorkspace.class, null), |
|
173 |
arguments.getListOf("tablenames", String.class), |
|
174 |
(Timestamp) arguments.get("efectivedate", Timestamp.class, null), |
|
175 |
(String) arguments.get("comment", String.class, null) |
|
176 |
); |
|
177 |
break; |
|
178 |
|
|
179 |
case "tools-vcsgis-init-server": |
|
180 |
showInitializaRepositoryDialog(); |
|
181 |
break; |
|
182 |
case "tools-vcsgis-init-workspace": |
|
183 |
showInitWorkspaceDialog(); |
|
184 |
break; |
|
185 |
case "tools-vcsgis-add-to-workspace": |
|
186 |
showAddToWorkspaceDialog(); |
|
187 |
break; |
|
188 |
case "tools-vcsgis-checkout": |
|
189 |
showCheckoutDialog( |
|
190 |
(VCSGisWorkspace) arguments.get("workspace", VCSGisWorkspace.class, null), |
|
191 |
arguments.getListOf("tablenames", String.class), |
|
192 |
(Boolean) arguments.get("overwrite", Boolean.class, null) |
|
193 |
); |
|
194 |
break; |
|
195 |
|
|
196 |
case "tools-vcsgis-export": |
|
197 |
showExportDialog(); |
|
198 |
break; |
|
199 |
case "tools-vcsgis-register-workspace": |
|
200 |
showRegistrationWorkspaceDialog(); |
|
201 |
break; |
|
202 |
case "tools-vcsgis-show_server-entities": |
|
203 |
showServerEntitiesDialog(); |
|
204 |
break; |
|
205 |
case "tools-vcsgis-show_server-hooks": |
|
206 |
showServerHooksDialog(); |
|
207 |
break; |
|
208 |
case "tools-vcsgis-show-revisions": |
|
209 |
showHistory(); |
|
210 |
break; |
|
211 |
case "tools-vcsgis-import-history": |
|
212 |
showImportHistoryDialog(); |
|
213 |
break; |
|
214 |
case "tools-vcsgis-create-resource-table": |
|
215 |
showCreateResourceTableDialog(); |
|
216 |
break; |
|
217 |
case "tools-vcsgis-logout": |
|
218 |
showLogoutDialog(); |
|
219 |
break; |
|
220 |
case "tools-vcsgis-checkout-datamodel": |
|
221 |
showCheckoutDataModelDialog( |
|
222 |
(VCSGisWorkspace) arguments.get("workspace", VCSGisWorkspace.class, null), |
|
223 |
(String) arguments.get("model", String.class, null) |
|
224 |
); |
|
225 |
break; |
|
226 |
case "tools-vcsgis-download-workingcopy": |
|
227 |
showDownloadWorkingcopyDialog(); |
|
228 |
break; |
|
229 |
case "tools-vcsgis-prepare-workingcopy": |
|
230 |
showPrepareWorkingcopyDialog(); |
|
231 |
break; |
|
232 |
case "tools-vcsgis-backup-history": |
|
233 |
showBackupHistoryDialog(); |
|
234 |
break; |
|
235 |
case "tools-vcsgis-restore-history": |
|
236 |
showRestoreHistoryDialog(); |
|
237 |
break; |
|
238 |
case "tools-vcsgis-registrationeditingstores": |
|
239 |
showRegistrationOfEditingStoresDialog(); |
|
240 |
break; |
|
241 |
case "tools-vcsgis-repositoryentityfeaturetypeeditor": |
|
242 |
showRepositoryEntityFeatureTypeEditorImplDialog(); |
|
243 |
break; |
|
244 |
} |
|
245 |
} |
|
246 |
|
|
247 |
@Override |
|
248 |
public boolean isEnabled() { |
|
249 |
return true; |
|
250 |
} |
|
251 |
|
|
252 |
@Override |
|
253 |
public boolean isVisible() { |
|
254 |
return true; |
|
255 |
} |
|
256 |
|
|
257 |
// private void cleanHighligthed() { |
|
258 |
// VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
259 |
// swingManager.getDefaultServices().cleanHighligthed(); |
|
260 |
// } |
|
261 |
// |
|
262 |
|
|
263 |
private void showAddToWorkspaceDialog() { |
|
264 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
265 |
|
|
266 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
267 |
"AddToWorkingCopy", |
|
268 |
swingManager.createAddToWorkspacePanel(), |
|
269 |
"_VCS_Add_to_workingcopy", |
|
270 |
"_VCS_Add_to_workingcopy", |
|
271 |
"_VCS_Add_to_workingcopy", |
|
272 |
() -> { |
|
273 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
274 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
275 |
VCSGisJAddToWorkspace addToWorkspacePanel = (VCSGisJAddToWorkspace) this.dialogsHelper.getDialog("AddToWorkingCopy").getPanel(); |
|
276 |
int r = addToWorkspacePanel.add(); |
|
277 |
if (r != 0) { |
|
278 |
dialogsManager.messageDialog( |
|
279 |
addToWorkspacePanel.getLastErrorMessage(), |
|
280 |
i18n.getTranslation("_VCS_Add_to_workingcopy"), |
|
281 |
JOptionPane.WARNING_MESSAGE |
|
282 |
); |
|
283 |
} |
|
284 |
} |
|
285 |
); |
|
286 |
dialog.show(); |
|
287 |
} |
|
288 |
|
|
289 |
private void showImportHistoryDialog() { |
|
290 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
291 |
|
|
292 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
293 |
"ImportHistory", |
|
294 |
swingManager.createImportHistoryPanel(), |
|
295 |
"_VCS_Import_history", |
|
296 |
"_VCS_Import_history", |
|
297 |
"_VCS_Import_history", |
|
298 |
() -> { |
|
299 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
300 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
301 |
VCSGisJImportHistory importHistoryPanel = (VCSGisJImportHistory) this.dialogsHelper.getDialog("ImportHistory").getPanel(); |
|
302 |
int r = importHistoryPanel.importHistory(); |
|
303 |
if (r != 0) { |
|
304 |
// FeatureStore featureStore = importHistoryPanel.getFeatureStore(); |
|
305 |
// String targetName = importHistoryPanel.getTabletName(); |
|
306 |
VCSGisWorkspace workspace = importHistoryPanel.getWorkspace(); |
|
307 |
String errmsg = workspace.getErrorMessage(r); |
|
308 |
if( errmsg==null ) { |
|
309 |
errmsg = ""; |
|
310 |
} |
|
311 |
dialogsManager.messageDialog( |
|
312 |
i18n.getTranslation("_Cant_import_history") |
|
313 |
+ "\n" |
|
314 |
+ errmsg |
|
315 |
+ "\n" |
|
316 |
+ i18n.getTranslation("_see_error_log_for_more_information") |
|
317 |
+ "\n" |
|
318 |
+ "("+ Objects.toString(importHistoryPanel.getLastLogFile()) + ")" |
|
319 |
, |
|
320 |
i18n.getTranslation("_VCS_Import_history"), |
|
321 |
JOptionPane.WARNING_MESSAGE |
|
322 |
); |
|
323 |
} |
|
324 |
} |
|
325 |
); |
|
326 |
dialog.show(); |
|
327 |
} |
|
328 |
|
|
329 |
private void showInitWorkspaceDialog() { |
|
330 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
331 |
|
|
332 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
333 |
"InitializeWorkingCopy", |
|
334 |
swingManager.createInitWorkspacePanel(), |
|
335 |
"_VCS_Initialize_workingcopy", |
|
336 |
"_VCS_Initialize_workingcopy", |
|
337 |
"_VCS_Initialize_workingcopy", |
|
338 |
() -> { |
|
339 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
340 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
341 |
VCSGisJInitWorkspace panelInitWorkspace = (VCSGisJInitWorkspace) this.dialogsHelper.getDialog("InitializeWorkingCopy").getPanel(); |
|
342 |
int r = panelInitWorkspace.initializeWorkspace(); |
|
343 |
if (r != 0) { |
|
344 |
dialogsManager.messageDialog( |
|
345 |
i18n.getTranslation( |
|
346 |
"_Cant_initialize_workingcopy_{0}", |
|
347 |
new String[]{panelInitWorkspace.getWorkspaceName()} |
|
348 |
), |
|
349 |
i18n.getTranslation("_VCS_Initialize_workingcopy"), |
|
350 |
JOptionPane.WARNING_MESSAGE |
|
351 |
); |
|
352 |
} |
|
353 |
} |
|
354 |
); |
|
355 |
dialog.setAutoclose(true); |
|
356 |
dialog.show(); |
|
357 |
} |
|
358 |
|
|
359 |
private void showInitializaRepositoryDialog() { |
|
360 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
361 |
|
|
362 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
363 |
"InitializeRepository", |
|
364 |
swingManager.createInitRepositoryPanel(), |
|
365 |
"_VCS_Initialize_repository", |
|
366 |
"_VCS_Initialize_repository", |
|
367 |
"_VCS_Initialize_repository", |
|
368 |
() -> { |
|
369 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
370 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
371 |
VCSGisJInitServer panel = (VCSGisJInitServer) this.dialogsHelper.getDialog("InitializeRepository").getPanel(); |
|
372 |
int r = panel.initialize(); |
|
373 |
if (r != 0) { |
|
374 |
dialogsManager.messageDialog( |
|
375 |
i18n.getTranslation( |
|
376 |
"_Cant_initialize_server_{0}", |
|
377 |
new String[]{panel.getConnectionLabel()} |
|
378 |
), |
|
379 |
i18n.getTranslation("_VCS_Initialize_repository"), |
|
380 |
JOptionPane.WARNING_MESSAGE |
|
381 |
); |
|
382 |
} |
|
383 |
} |
|
384 |
); |
|
385 |
dialog.setAutoclose(true); |
|
386 |
dialog.show(); |
|
387 |
} |
|
388 |
|
|
389 |
private void showCheckoutDialog(VCSGisWorkspace workspace, List<String> tableNames,Boolean overwrite) { |
|
390 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
391 |
|
|
392 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
393 |
"Checkout", |
|
394 |
swingManager.createCheckoutPanel(workspace,tableNames, overwrite), |
|
395 |
"_VCS_Checkout", |
|
396 |
"_VCS_Checkout", |
|
397 |
"_VCS_Checkout", |
|
398 |
() -> { |
|
399 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
400 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
401 |
VCSGisJCheckout checkoutPanel = (VCSGisJCheckout) this.dialogsHelper.getDialog("Checkout").getPanel(); |
|
402 |
int r = checkoutPanel.checkout(); |
|
403 |
if (r != 0) { |
|
404 |
VCSGisEntity entity = checkoutPanel.getTable(); |
|
405 |
dialogsManager.messageDialog( |
|
406 |
i18n.getTranslation( |
|
407 |
"_Failed_checkout_of_{0}", |
|
408 |
new String[]{entity.toString()} |
|
409 |
), |
|
410 |
i18n.getTranslation("_VCS_Checkout"), |
|
411 |
JOptionPane.WARNING_MESSAGE |
|
412 |
); |
|
413 |
} |
|
414 |
} |
|
415 |
); |
|
416 |
dialog.show(); |
|
417 |
} |
|
418 |
|
|
419 |
private void showExportDialog() { |
|
420 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
421 |
|
|
422 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
423 |
"Export", |
|
424 |
swingManager.createExportPanel(), |
|
425 |
"_VCS_Export", |
|
426 |
"_Export_to_a_local_table_a_table_of_the_repository", |
|
427 |
"_VCS_Export", |
|
428 |
() -> { |
|
429 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
430 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
431 |
VCSGisJExport exportPanel = (VCSGisJExport) this.dialogsHelper.getDialog("Export").getPanel(); |
|
432 |
int r = exportPanel.export(); |
|
433 |
if (r != 0) { |
|
434 |
VCSGisEntity entity = exportPanel.getTable(); |
|
435 |
dialogsManager.messageDialog( |
|
436 |
i18n.getTranslation( |
|
437 |
"_Failed_export_of_{0}", |
|
438 |
new String[]{entity.toString()} |
|
439 |
), |
|
440 |
i18n.getTranslation("_VCSGis_Export"), |
|
441 |
JOptionPane.WARNING_MESSAGE |
|
442 |
); |
|
443 |
} |
|
444 |
} |
|
445 |
); |
|
446 |
dialog.show(); |
|
447 |
} |
|
448 |
|
|
449 |
private void showChangesDialog(VCSGisWorkspace workspace, List<String> tableNames, Timestamp efectivedate, String comment) { |
|
450 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
451 |
|
|
452 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
453 |
"Changes", |
|
454 |
swingManager.createChangesPanel(workspace,tableNames, efectivedate, comment), |
|
455 |
"_VCS_Changes" |
|
456 |
); |
|
457 |
dialog.show(); |
|
458 |
} |
|
459 |
|
|
460 |
private void showHistory() { |
|
461 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
462 |
|
|
463 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
464 |
"Revisions", |
|
465 |
swingManager.createRevisionsPanel(), |
|
466 |
"_VCS_Revisions" |
|
467 |
); |
|
468 |
dialog.show(); |
|
469 |
} |
|
470 |
|
|
471 |
private void showRegistrationWorkspaceDialog() { |
|
472 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
473 |
|
|
474 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
475 |
"RegisterWorkingCopies", |
|
476 |
swingManager.createRegisterWorkspacePanel(), |
|
477 |
"_VCS_Registration_workingcopies" |
|
478 |
); |
|
479 |
dialog.show(); |
|
480 |
} |
|
481 |
|
|
482 |
|
|
483 |
private void showRegistrationOfEditingStoresDialog() { |
|
484 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
485 |
|
|
486 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
487 |
"RegistrationOfEditingStores", |
|
488 |
swingManager.createRegistrationOfEditingStoresPanel(), |
|
489 |
"_VCS_Registration_of_editing_stores" |
|
490 |
); |
|
491 |
dialog.show(); |
|
492 |
} |
|
493 |
|
|
494 |
private void showServerEntitiesDialog() { |
|
495 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
496 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
497 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
498 |
|
|
499 |
final VCSGisJShowServerTableForm panel = swingManager.createShowTableServerFormPanel("VCSGIS_ENTITIES"); |
|
500 |
winManager.showWindow( |
|
501 |
panel.asJComponent(), |
|
502 |
i18nManager.getTranslation("_VCS_Server_entities"), |
|
503 |
WindowManager.MODE.WINDOW |
|
504 |
); |
|
505 |
} |
|
506 |
|
|
507 |
private void showServerHooksDialog() { |
|
508 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
509 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
510 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
511 |
|
|
512 |
final VCSGisJShowServerTableForm panel = swingManager.createShowTableServerFormPanel("VCSGIS_HOOKS"); |
|
513 |
winManager.showWindow( |
|
514 |
panel.asJComponent(), |
|
515 |
i18nManager.getTranslation("_VCS_Server_hooks"), |
|
516 |
WindowManager.MODE.WINDOW |
|
517 |
); |
|
518 |
} |
|
519 |
|
|
520 |
private void showCreateResourceTableDialog() { |
|
521 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
522 |
|
|
523 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
524 |
"CreateResourceTable", |
|
525 |
swingManager.createResourceTablePanel(), |
|
526 |
"_VCS_Create_resource_table", |
|
527 |
"_Create_resource_table_parameters", |
|
528 |
"_VCS_Create_resource_table", |
|
529 |
() -> { |
|
530 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
531 |
VCSGisJCreateResourceTable panel = (VCSGisJCreateResourceTable) this.dialogsHelper.getDialog("CreateResourceTable").getPanel(); |
|
532 |
panel.createResourceTable(); |
|
533 |
} |
|
534 |
); |
|
535 |
dialog.setAutoclose(true); |
|
536 |
dialog.show(); |
|
537 |
} |
|
538 |
|
|
539 |
private void showLogoutDialog() { |
|
540 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
541 |
|
|
542 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
543 |
"Logout", |
|
544 |
swingManager.createLogoutPanel(), |
|
545 |
"_VCS_Logout", |
|
546 |
"_Logout_the_current_user_from_a_VCSGis_working_copy", |
|
547 |
"_VCS_Logout", |
|
548 |
() -> { |
|
549 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
550 |
VCSGisJLogout panel = (VCSGisJLogout) this.dialogsHelper.getDialog("Logout").getPanel(); |
|
551 |
panel.logout(); |
|
552 |
} |
|
553 |
); |
|
554 |
dialog.setAutoclose(true); |
|
555 |
dialog.show(); |
|
556 |
} |
|
557 |
|
|
558 |
private void showCheckoutDataModelDialog(VCSGisWorkspace workspace, String model) { |
|
559 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
560 |
|
|
561 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
562 |
"ConnectDataModel", |
|
563 |
swingManager.createCheckoutDataModelPanel(workspace, model), |
|
564 |
"_VCS_Connect_to_datamodel", |
|
565 |
"_VCS_Connect_to_datamodel", |
|
566 |
"_VCS_Connect_to_datamodel", |
|
567 |
() -> { |
|
568 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
569 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
570 |
VCSGisJCheckoutDataModel checkoutDataModelPanel = (VCSGisJCheckoutDataModel) this.dialogsHelper.getDialog("ConnectDataModel").getPanel(); |
|
571 |
int r = checkoutDataModelPanel.connectToModel(); |
|
572 |
if ( !(r == ERR_OK || r==ERR_USER_CANCELLED) ) { |
|
573 |
String dataModel = checkoutDataModelPanel.getDataModel(); |
|
574 |
dialogsManager.messageDialog( |
|
575 |
i18n.getTranslation( |
|
576 |
"_Failed_connect_to_{0}", |
|
577 |
new String[]{dataModel} |
|
578 |
), |
|
579 |
i18n.getTranslation("_VCS_Connect_to_datamodel"), |
|
580 |
JOptionPane.WARNING_MESSAGE |
|
581 |
); |
|
582 |
} |
|
583 |
} |
|
584 |
); |
|
585 |
dialog.show(); |
|
586 |
} |
|
587 |
|
|
588 |
private void showDownloadWorkingcopyDialog() { |
|
589 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
590 |
|
|
591 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog("DownloadWorkingcopy", |
|
592 |
swingManager.createDownloadWorkingcopyPanel(), |
|
593 |
"_VCS_Download_workingcopy", |
|
594 |
"_VCS_Download_workingcopy", |
|
595 |
"_VCS_Download_workingcopy", |
|
596 |
() -> { |
|
597 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
598 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
599 |
VCSGisJDownloadWorkingcopy downloadWorkingcopyPanel = (VCSGisJDownloadWorkingcopy) this.dialogsHelper.getDialog("DownloadWorkingcopy").getPanel(); |
|
600 |
int r = downloadWorkingcopyPanel.download(false); |
|
601 |
if (r != 0) { |
|
602 |
dialogsManager.messageDialog( |
|
603 |
i18n.getTranslation( |
|
604 |
"_Failed_dowloading_working_copy" |
|
605 |
), |
|
606 |
i18n.getTranslation("_VCS_Download_working_copy"), |
|
607 |
JOptionPane.WARNING_MESSAGE |
|
608 |
); |
|
609 |
} |
|
610 |
} |
|
611 |
); |
|
612 |
dialog.show(); |
|
613 |
} |
|
614 |
|
|
615 |
private void showPrepareWorkingcopyDialog() { |
|
616 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
617 |
|
|
618 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog("PrepareWorkingcopy", |
|
619 |
swingManager.createPrepareWorkingcopyPanel(), |
|
620 |
"_VCS_Prepare_workingcopy", |
|
621 |
"_VCS_Prepare_workingcopy", |
|
622 |
"_VCS_Prepare_workingcopy", |
|
623 |
() -> { |
|
624 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
625 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
626 |
VCSGisJPrepareWorkingcopy prepareWorkingcopyPanel = (VCSGisJPrepareWorkingcopy) this.dialogsHelper.getDialog("PrepareWorkingcopy").getPanel(); |
|
627 |
int r = prepareWorkingcopyPanel.prepare(); |
|
628 |
if (r != 0) { |
|
629 |
dialogsManager.messageDialog( |
|
630 |
i18n.getTranslation( |
|
631 |
"_Failed_prepare_working_copy" |
|
632 |
), |
|
633 |
i18n.getTranslation("_VCS_Prepare_working_copy"), |
|
634 |
JOptionPane.WARNING_MESSAGE |
|
635 |
); |
|
636 |
} |
|
637 |
} |
|
638 |
); |
|
639 |
dialog.setAutoclose(true); |
|
640 |
dialog.show(); |
|
641 |
} |
|
642 |
|
|
643 |
private void showBackupHistoryDialog() { |
|
644 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
645 |
|
|
646 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog("BackupHistory", |
|
647 |
swingManager.createBackupHistoryPanel(), |
|
648 |
"_VCS_Backup_history", |
|
649 |
"_VCS_Backup_history", |
|
650 |
"_VCS_Backup_history", |
|
651 |
() -> { |
|
652 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
653 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
654 |
VCSGisJBackupHistory backupHistoryPanel = (VCSGisJBackupHistory) this.dialogsHelper.getDialog("BackupHistory").getPanel(); |
|
655 |
int r = backupHistoryPanel.backupHistory(); |
|
656 |
if (r != 0) { |
|
657 |
dialogsManager.messageDialog( |
|
658 |
i18n.getTranslation( |
|
659 |
"_Failed_doing_backup_history" |
|
660 |
), |
|
661 |
i18n.getTranslation("_VCS_Backup_history"), |
|
662 |
JOptionPane.WARNING_MESSAGE |
|
663 |
); |
|
664 |
} |
|
665 |
} |
|
666 |
); |
|
667 |
dialog.show(); |
|
668 |
} |
|
669 |
|
|
670 |
private void showRestoreHistoryDialog() { |
|
671 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
672 |
|
|
673 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog("RestoreHistory", |
|
674 |
swingManager.createRestoreHistoryPanel(), |
|
675 |
"_VCS_Restore_history", |
|
676 |
"_VCS_Restore_history", |
|
677 |
"_VCS_Restore_history", |
|
678 |
() -> { |
|
679 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
680 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
681 |
VCSGisJRestoreHistory restoreHistoryPanel = (VCSGisJRestoreHistory) this.dialogsHelper.getDialog("RestoreHistory").getPanel(); |
|
682 |
int r = restoreHistoryPanel.restoreHistory(); |
|
683 |
if (r != 0) { |
|
684 |
dialogsManager.messageDialog( |
|
685 |
i18n.getTranslation( |
|
686 |
"_Failed_restoring_history" |
|
687 |
), |
|
688 |
i18n.getTranslation("_VCS_Restore_history"), |
|
689 |
JOptionPane.WARNING_MESSAGE |
|
690 |
); |
|
691 |
} |
|
692 |
} |
|
693 |
); |
|
694 |
dialog.show(); |
|
695 |
} |
|
696 |
|
|
697 |
private void showRepositoryEntityFeatureTypeEditorImplDialog() { |
|
698 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
699 |
|
|
700 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
701 |
"RepositoryEntityFeatureTypeEditor", |
|
702 |
swingManager.createRepositoryEntityFeatureTypeEditor(), |
|
703 |
"_VCS_Repository_entity_feature_type_editor" |
|
704 |
); |
|
705 |
dialog.show(); |
|
706 |
} |
|
707 |
|
|
708 |
@Override |
|
709 |
public IPreference[] getPreferencesPages() { |
|
710 |
List<IPreference> prefs = new ArrayList<>(); |
|
711 |
prefs.add(new VCSGisPage()); |
|
712 |
|
|
713 |
return prefs.toArray(new IPreference[prefs.size()]); |
|
714 |
} |
|
715 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.88/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/FeatureStoresTreeModel.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.vcsgis.app; |
|
7 |
|
|
8 |
import java.util.HashMap; |
|
9 |
import java.util.Map; |
|
10 |
import javax.swing.Icon; |
|
11 |
import javax.swing.ImageIcon; |
|
12 |
import javax.swing.event.TreeModelListener; |
|
13 |
import javax.swing.tree.TreeModel; |
|
14 |
import javax.swing.tree.TreePath; |
|
15 |
import org.gvsig.app.ApplicationLocator; |
|
16 |
import org.gvsig.fmap.dal.DataStore; |
|
17 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
18 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
19 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
20 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
|
21 |
import org.gvsig.fmap.mapcontext.layers.vectorial.VectorLayer; |
|
22 |
import org.gvsig.fmap.mapcontrol.LayersTreeModel; |
|
23 |
import org.gvsig.tools.evaluator.Evaluator; |
|
24 |
import org.gvsig.tools.evaluator.EvaluatorData; |
|
25 |
import org.gvsig.tools.evaluator.EvaluatorException; |
|
26 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
|
27 |
import org.gvsig.tools.swing.api.IconGetter; |
|
28 |
import org.gvsig.tools.swing.api.ListElement; |
|
29 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
* @author fdiaz |
|
35 |
*/ |
|
36 |
public class FeatureStoresTreeModel implements TreeModel, IconGetter { |
|
37 |
|
|
38 |
private final LayersTreeModel delegated; |
|
39 |
private final ListElement<Object> root; |
|
40 |
private final Map<Object,Icon> icons; |
|
41 |
|
|
42 |
public FeatureStoresTreeModel() { |
|
43 |
this.delegated = (LayersTreeModel) ApplicationLocator.getApplicationManager().createProjectLayersTreeModel(); |
|
44 |
this.icons = new HashMap<>(); |
|
45 |
this.delegated.setFilter(new Evaluator() { |
|
46 |
@Override |
|
47 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
48 |
FLayer layer = (FLayer) data.getDataValue("layer"); |
|
49 |
return (layer instanceof VectorLayer); |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public String getName() { |
|
54 |
return "VectorialLayersFilter"; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public String getDescription() { |
|
59 |
return null; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public String getSQL() { |
|
64 |
return null; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public EvaluatorFieldsInfo getFieldsInfo() { |
|
69 |
return null; |
|
70 |
} |
|
71 |
}); |
|
72 |
this.root = new ListElement<>("Project", this.delegated.getRoot()); |
|
73 |
} |
|
74 |
|
|
75 |
private Object getNode(Object value) { |
|
76 |
if( value instanceof ListElement ) { |
|
77 |
return ((ListElement) value).getValue(); |
|
78 |
} |
|
79 |
return value; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public Object getRoot() { |
|
84 |
return this.root; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public Object getChild(Object parent, int index) { |
|
89 |
parent = this.getNode(parent); |
|
90 |
Object x = this.delegated.getChild(parent, index); |
|
91 |
if( x instanceof VectorLayer ) { |
|
92 |
SingleLayer layer = (SingleLayer)x; |
|
93 |
DataStore store = (DataStore) layer.getDataStore(); |
|
94 |
return store; |
|
95 |
} |
|
96 |
return x; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public int getChildCount(Object parent) { |
|
101 |
parent = this.getNode(parent); |
|
102 |
return this.delegated.getChildCount(parent); |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public boolean isLeaf(Object node) { |
|
107 |
node = this.getNode(node); |
|
108 |
return this.delegated.isLeaf(node); |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public void valueForPathChanged(TreePath path, Object newValue) { |
|
113 |
this.delegated.valueForPathChanged(path, newValue); |
|
114 |
} |
|
115 |
|
|
116 |
@Override |
|
117 |
public int getIndexOfChild(Object parent, Object child) { |
|
118 |
parent = this.getNode(parent); |
|
119 |
return this.delegated.getIndexOfChild(parent, child); |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public void addTreeModelListener(TreeModelListener l) { |
|
124 |
this.delegated.addTreeModelListener(l); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public void removeTreeModelListener(TreeModelListener l) { |
|
129 |
this.delegated.removeTreeModelListener(l); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public Icon getIcon(Object item) { |
|
134 |
if( !this.icons.containsKey(item) ) { |
|
135 |
String iconName; |
|
136 |
if( item instanceof DataStore ) { |
|
137 |
iconName = MapContextLocator.getMapContextManager().getIconLayer((DataStore)item); |
|
138 |
} else if( item instanceof FLayers ) { |
|
139 |
FLayers layers = (FLayers) item; |
|
140 |
if( layers.getParentLayer()!=null && layers.getParentLayer().getParentLayer()==null ) { |
|
141 |
iconName = "view-navigation-zoom-all"; |
|
142 |
} else { |
|
143 |
iconName = "layer-icon-group"; |
|
144 |
} |
|
145 |
} else if( item == root ) { |
|
146 |
iconName = "common-folder-open"; |
|
147 |
} else { |
|
148 |
iconName = "common-leaf"; |
|
149 |
} |
|
150 |
ImageIcon icon = ToolsSwingLocator.getIconThemeManager().getCurrent().get(iconName); |
|
151 |
this.icons.put(item, icon); |
|
152 |
} |
|
153 |
return this.icons.get(item); |
|
154 |
} |
|
155 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.88/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/VCSGisSwingServicesImpl.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.vcsgis.app; |
|
7 |
|
|
8 |
import java.io.File; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.HashMap; |
|
11 |
import java.util.HashSet; |
|
12 |
import java.util.Iterator; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Map; |
|
15 |
import java.util.Set; |
|
16 |
import javax.json.JsonArray; |
|
17 |
import javax.json.JsonObject; |
|
18 |
import javax.json.JsonValue; |
|
19 |
import javax.swing.ComboBoxModel; |
|
20 |
import javax.swing.DefaultComboBoxModel; |
|
21 |
import javax.swing.DefaultListModel; |
|
22 |
import javax.swing.Icon; |
|
23 |
import javax.swing.ListModel; |
|
24 |
import javax.swing.tree.TreeModel; |
|
25 |
import org.apache.commons.lang3.StringUtils; |
|
26 |
import org.gvsig.andami.PluginsLocator; |
|
27 |
import org.gvsig.app.ApplicationLocator; |
|
28 |
import org.gvsig.app.ApplicationManager; |
|
29 |
import org.gvsig.app.project.Project; |
|
30 |
import org.gvsig.app.project.ProjectManager; |
|
31 |
import org.gvsig.app.project.documents.Document; |
|
32 |
import org.gvsig.app.project.documents.DocumentManager; |
|
33 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
34 |
import org.gvsig.app.project.documents.table.TableManager; |
|
35 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
36 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
37 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
38 |
import org.gvsig.fmap.dal.DALLocator; |
|
39 |
import org.gvsig.fmap.dal.DataManager; |
|
40 |
import org.gvsig.fmap.dal.exception.DataException; |
|
41 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
42 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
|
43 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
44 |
import org.gvsig.fmap.geom.Geometry; |
|
45 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
|
46 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
47 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
|
48 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
49 |
import org.gvsig.fmap.geom.primitive.Point; |
|
50 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
51 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
52 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
53 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
54 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
55 |
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer; |
|
56 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
57 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2; |
|
58 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
59 |
import org.gvsig.json.Json; |
|
60 |
import org.gvsig.json.JsonArrayBuilder; |
|
61 |
import org.gvsig.json.JsonObjectBuilder; |
|
62 |
import org.gvsig.tools.ToolsLocator; |
|
63 |
import org.gvsig.tools.i18n.I18nManager; |
|
64 |
import org.gvsig.tools.util.LabeledValue; |
|
65 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
66 |
import org.gvsig.vcsgis.app.addlayer.LayersWithGroup; |
|
67 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
68 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
69 |
import org.gvsig.vcsgis.lib.VCSGisRuntimeException; |
|
70 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
71 |
import org.gvsig.vcsgis.swing.VCSGisSwingServices; |
|
72 |
import org.slf4j.LoggerFactory; |
|
73 |
|
|
74 |
/** |
|
75 |
* |
|
76 |
* @author gvSIG Team |
|
77 |
*/ |
|
78 |
@SuppressWarnings("UseSpecificCatch") |
|
79 |
public class VCSGisSwingServicesImpl implements VCSGisSwingServices { |
|
80 |
|
|
81 |
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(VCSGisSwingServicesImpl.class); |
|
82 |
|
|
83 |
private static final String VCSGISMODELS_PROJECT_PROPERTY = "VCSGisModels"; |
|
84 |
|
|
85 |
private Map<Integer,ISymbol> highlightedPolygonSymbols; |
|
86 |
private Map<Integer,ISymbol> highlightedLineSymbols; |
|
87 |
private Map<Integer,ISymbol> highlightedPointSymbols; |
|
88 |
|
|
89 |
@Override |
|
90 |
public TreeModel getFeatureStoresTreeModel() { |
|
91 |
return new FeatureStoresTreeModel(); |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
public ListModel getFeatureStoresListModel() { |
|
96 |
DefaultListModel<FeatureStore> model = new DefaultListModel(); |
|
97 |
|
|
98 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
99 |
Project project = appManager.getCurrentProject(); |
|
100 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
101 |
for (Document document : tables) { |
|
102 |
TableDocument table = (TableDocument) document; |
|
103 |
FeatureStore tableStore = table.getFeatureStore(); |
|
104 |
if( tableStore!=null ) { |
|
105 |
model.addElement(tableStore); |
|
106 |
} |
|
107 |
} |
|
108 |
return model; |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public void addTableToProject(VCSGisWorkspace ws, FeatureStore store) { |
|
113 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
114 |
|
|
115 |
DocumentManager tableManager = appManager.getProjectManager().getDocumentManager( |
|
116 |
TableManager.TYPENAME |
|
117 |
); |
|
118 |
|
|
119 |
Project project = appManager.getCurrentProject(); |
|
120 |
TableDocument tableDoc = (TableDocument) tableManager.createDocument(); |
|
121 |
|
|
122 |
tableDoc.setName(store.getName()); |
|
123 |
tableDoc.setStore(store); |
|
124 |
project.addDocument(tableDoc); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public ComboBoxModel getViewDocumentsComboBoxModel() { |
|
129 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
130 |
DefaultComboBoxModel<LabeledValue> model = new DefaultComboBoxModel(); |
|
131 |
model.addElement(new LabeledValueImpl(i18n.getTranslation("_Select_a_view"), null)); |
|
132 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
133 |
Project project = appManager.getCurrentProject(); |
|
134 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
135 |
for (Document document : views) { |
|
136 |
ViewDocument view = (ViewDocument) document; |
|
137 |
model.addElement(new LabeledValueImpl(view.getName(), view)); |
|
138 |
} |
|
139 |
return model; |
|
140 |
} |
|
141 |
|
|
142 |
// @Override |
|
143 |
// public void addLayerToView(FeatureStore store, LabeledValue labeledView) { |
|
144 |
// addLayerToView(store, labeledView, null, null, false); |
|
145 |
// } |
|
146 |
// |
|
147 |
@Override |
|
148 |
public void addLayerToView(FeatureStore store, LabeledValue labeledView, String groupName, String name, boolean replaceLayerIfExists) { |
|
149 |
ViewDocument view; |
|
150 |
if( labeledView == null ) { |
|
151 |
view = null; |
|
152 |
} else if (labeledView.getValue() == null){ |
|
153 |
view = null; |
|
154 |
} else { |
|
155 |
view = (ViewDocument) labeledView.getValue(); |
|
156 |
} |
|
157 |
addLayerToView(store, view, groupName, name, replaceLayerIfExists); |
|
158 |
} |
|
159 |
|
|
160 |
|
|
161 |
private void addLayerToView(FeatureStore store, ViewDocument view, String groupName, String name, boolean replaceLayerIfExists) { |
|
162 |
try { |
|
163 |
if( store == null ) { |
|
164 |
return; |
|
165 |
} |
|
166 |
if( view==null ) { |
|
167 |
IView viewWin = getActiveView(); |
|
168 |
if(viewWin == null){ |
|
169 |
return; |
|
170 |
} |
|
171 |
view = viewWin.getViewDocument(); |
|
172 |
} |
|
173 |
String layerName = name; |
|
174 |
if(StringUtils.isBlank(layerName)){ |
|
175 |
layerName = store.getName(); |
|
176 |
} |
|
177 |
FLayer layer = MapContextLocator.getMapContextManager().createLayer(layerName, store); |
|
178 |
LayersWithGroup helper = new LayersWithGroup(view.getMapContext()); |
|
179 |
helper.add(groupName, name, layer); |
|
180 |
helper.updateMapContext(true, replaceLayerIfExists); |
|
181 |
} catch (Exception ex) { |
|
182 |
VCSGisManager manager = VCSGisLocator.getManager(); |
|
183 |
throw new VCSGisRuntimeException( |
|
184 |
VCSGisManager.ERR_CANT_ADD_LAYER, |
|
185 |
manager.getErrorMessage(VCSGisManager.ERR_CANT_ADD_LAYER), |
|
186 |
ex); |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
@Override |
|
191 |
public void highlight(int mode, Geometry geom) { |
|
192 |
highlight(mode, geom, null); |
|
193 |
} |
|
194 |
|
|
195 |
@Override |
|
196 |
public void highlight(int mode, Geometry geom, FeatureStore store) { |
|
197 |
if (this.highlightedPointSymbols == null) { |
|
198 |
this.highlightedPointSymbols = new HashMap<>(); |
|
199 |
this.highlightedLineSymbols = new HashMap<>(); |
|
200 |
this.highlightedPolygonSymbols = new HashMap<>(); |
|
201 |
try { |
|
202 |
File pluginfolder = PluginsLocator.getManager().getPlugin(this).getPluginDirectory(); |
|
203 |
File folder = new File(pluginfolder, "symbols"); |
|
204 |
ISymbol[] symbols = MapContextLocator.getSymbolManager().loadSymbols(folder); |
|
205 |
for (ISymbol symbol : symbols) { |
|
206 |
if (symbol instanceof ISymbol_v2) { |
|
207 |
String symbolid = ((ISymbol_v2) symbol).getID(); |
|
208 |
switch(symbolid) { |
|
209 |
case "vcsgis-repository-polygon": |
|
210 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
211 |
break; |
|
212 |
case "vcsgis-repository-line": |
|
213 |
this.highlightedLineSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
214 |
break; |
|
215 |
case "vcsgis-repository-point": |
|
216 |
this.highlightedPointSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
217 |
break; |
|
218 |
|
|
219 |
case "vcsgis-workspace-polygon": |
|
220 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
221 |
break; |
|
222 |
case "vcsgis-workspace-line": |
|
223 |
this.highlightedLineSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
224 |
break; |
|
225 |
case "vcsgis-workspace-point": |
|
226 |
this.highlightedPointSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
227 |
break; |
|
228 |
|
|
229 |
case "vcsgis-workspace-previous-polygon": |
|
230 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
231 |
break; |
|
232 |
case "vcsgis-workspace-previous-line": |
|
233 |
this.highlightedLineSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
234 |
break; |
|
235 |
case "vcsgis-workspace-previous-point": |
|
236 |
this.highlightedPointSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
237 |
break; |
|
238 |
} |
|
239 |
} |
|
240 |
} |
|
241 |
} catch (Exception ex) { |
|
242 |
} |
|
243 |
} |
|
244 |
List<ViewDocument> viewList; |
|
245 |
if(store == null){ |
|
246 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
247 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
248 |
viewList = new ArrayList<>(); |
|
249 |
viewList.add(viewdoc); |
|
250 |
} else { |
|
251 |
viewList = getViewDocumentsHavingAStore(store); |
|
252 |
} |
|
253 |
for (ViewDocument viewDoc : viewList) { |
|
254 |
MapContext mapContext = viewDoc.getMapContext(); |
|
255 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
256 |
if (geom != null) { |
|
257 |
ISymbol symbol = null; |
|
258 |
if (geom instanceof Point || geom instanceof MultiPoint) { |
|
259 |
symbol = this.highlightedPointSymbols.get(mode); |
|
260 |
} else if (geom instanceof Curve || geom instanceof MultiCurve) { |
|
261 |
symbol = this.highlightedLineSymbols.get(mode); |
|
262 |
} else if (geom instanceof Surface || geom instanceof MultiSurface) { |
|
263 |
symbol = this.highlightedPolygonSymbols.get(mode); |
|
264 |
} |
|
265 |
if (symbol != null) { |
|
266 |
int symbolid = gl.getSymbolId(symbol); |
|
267 |
if (symbolid < 0) { |
|
268 |
gl.addSymbol(symbol); |
|
269 |
symbolid = gl.getSymbolId(symbol); |
|
270 |
} |
|
271 |
gl.addGraphic("vcsgis-highlighted", geom, symbolid); |
|
272 |
} |
|
273 |
} |
|
274 |
mapContext.invalidate(); |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
@Override |
|
279 |
public void centerActiveViewToGeometry(Geometry geometry) { |
|
280 |
if(geometry != null){ |
|
281 |
IView view = getActiveView(); |
|
282 |
if(view != null){ |
|
283 |
ViewDocument viewDocument = view.getViewDocument(); |
|
284 |
viewDocument.center(geometry.getEnvelope()); |
|
285 |
} |
|
286 |
} |
|
287 |
} |
|
288 |
|
|
289 |
@Override |
|
290 |
public void centerViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) { |
|
291 |
if(geometry != null){ |
|
292 |
List<ViewDocument> views = getViewDocumentsHavingAStore(store); |
|
293 |
for (ViewDocument view : views) { |
|
294 |
if(view != null){ |
|
295 |
view.center(geometry.getEnvelope()); |
|
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
@Override |
|
302 |
public void zoomActiveViewToGeometry(Geometry geometry) { |
|
303 |
if(geometry != null){ |
|
304 |
IView view = getActiveView(); |
|
305 |
if(view != null){ |
|
306 |
ViewDocument viewDocument = view.getViewDocument(); |
|
307 |
viewDocument.getMapContext().getViewPort().setEnvelope(geometry.getEnvelope()); |
|
308 |
} |
|
309 |
} |
|
310 |
} |
|
311 |
|
|
312 |
@Override |
|
313 |
public void zoomViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) { |
|
314 |
if(geometry != null){ |
|
315 |
List<ViewDocument> views = getViewDocumentsHavingAStore(store); |
|
316 |
for (ViewDocument view : views) { |
|
317 |
if(view != null){ |
|
318 |
view.getMapContext().getViewPort().setEnvelope(geometry.getEnvelope()); |
|
319 |
} |
|
320 |
} |
|
321 |
} |
|
322 |
} |
|
323 |
|
|
324 |
private IView getActiveView() { |
|
325 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
326 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
327 |
return view; |
|
328 |
} |
|
329 |
|
|
330 |
@Override |
|
331 |
public void cleanHighligthed() { |
|
332 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
333 |
ProjectManager projectManager = application.getProjectManager(); |
|
334 |
Project project = projectManager.getCurrentProject(); |
|
335 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
336 |
for (Document doc : views) { |
|
337 |
ViewDocument viewdoc = (ViewDocument)doc; |
|
338 |
MapContext mapContext = viewdoc.getMapContext(); |
|
339 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
340 |
//FIXME: Refrescar el mapContext solo cuando se ha borrado el graphics |
|
341 |
if(gl.removeGraphics("vcsgis-highlighted")) { |
|
342 |
mapContext.invalidate(); |
|
343 |
} |
|
344 |
} |
|
345 |
} |
|
346 |
|
|
347 |
@Override |
|
348 |
public void cleanActiveViewHighligthed() { |
|
349 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
350 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
351 |
if(viewdoc != null){ |
|
352 |
MapContext mapContext = viewdoc.getMapContext(); |
|
353 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
354 |
gl.removeGraphics("vcsgis-highlighted"); |
|
355 |
mapContext.invalidate(); |
|
356 |
} |
|
357 |
} |
|
358 |
|
|
359 |
@Override |
|
360 |
public void refreshDocuments() { |
|
361 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
362 |
ProjectManager projectManager = application.getProjectManager(); |
|
363 |
Project project = projectManager.getCurrentProject(); |
|
364 |
|
|
365 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
366 |
for (Document doc : views) { |
|
367 |
doc.refresh(); |
|
368 |
} |
|
369 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
370 |
for (Document doc : tables) { |
|
371 |
doc.refresh(); |
|
372 |
} |
|
373 |
} |
|
374 |
|
|
375 |
@Override |
|
376 |
public void refreshDocument(FeatureStore store){ |
|
377 |
if(store == null){ |
|
378 |
return; |
|
379 |
} |
|
380 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
381 |
ProjectManager projectManager = application.getProjectManager(); |
|
382 |
Project project = projectManager.getCurrentProject(); |
|
383 |
|
|
384 |
String storeFullName = store.getFullName(); |
|
385 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
386 |
for (Document doc : views) { |
|
387 |
ViewDocument view = (ViewDocument)doc; |
|
388 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
389 |
FLayer layer = it.next(); |
|
390 |
if(layer instanceof FLyrVect){ |
|
391 |
FeatureStore layerStore = ((FLyrVect) layer).getFeatureStore(); |
|
392 |
if( layerStore!=null && StringUtils.equals(layerStore.getFullName(), storeFullName)){ |
|
393 |
view.getMapContext().invalidate(); |
|
394 |
break; |
|
395 |
} |
|
396 |
} |
|
397 |
} |
|
398 |
} |
|
399 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
400 |
for (Document doc : tables) { |
|
401 |
TableDocument table = (TableDocument)doc; |
|
402 |
FeatureStore featureStore = table.getStore(); |
|
403 |
if( StringUtils.equals(featureStore.getFullName(), storeFullName)){ |
|
404 |
try { |
|
405 |
featureStore.refresh(); |
|
406 |
} catch (DataException e) { |
|
407 |
LOGGER.warn("Error refreshing table", e); |
|
408 |
} |
|
409 |
} |
|
410 |
} |
|
411 |
} |
|
412 |
|
|
413 |
@Override |
|
414 |
public void refreshDocument(Set<FeatureStore> stores){ |
|
415 |
if(stores == null || stores.isEmpty()){ |
|
416 |
return; |
|
417 |
} |
|
418 |
|
|
419 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
420 |
ProjectManager projectManager = application.getProjectManager(); |
|
421 |
Project project = projectManager.getCurrentProject(); |
|
422 |
|
|
423 |
Set<ViewDocument> viewsToRefresh = new HashSet<>(); |
|
424 |
for (FeatureStore store : stores) { |
|
425 |
String storeFullName = store.getFullName(); |
|
426 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
427 |
for (Document doc : views) { |
|
428 |
ViewDocument view = (ViewDocument)doc; |
|
429 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
430 |
FLayer layer = it.next(); |
|
431 |
if(layer instanceof FLyrVect){ |
|
432 |
FeatureStore layerStore = ((FLyrVect) layer).getFeatureStore(); |
|
433 |
if( layerStore!=null && StringUtils.equals(layerStore.getFullName(), storeFullName)){ |
|
434 |
viewsToRefresh.add(view); |
|
435 |
break; |
|
436 |
} |
|
437 |
} |
|
438 |
} |
|
439 |
} |
|
440 |
|
|
441 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
442 |
for (Document doc : tables) { |
|
443 |
TableDocument table = (TableDocument)doc; |
|
444 |
FeatureStore featureStore = table.getStore(); |
|
445 |
if( StringUtils.equals(featureStore.getFullName(), storeFullName)){ |
|
446 |
try { |
|
447 |
featureStore.refresh(); |
|
448 |
} catch (DataException e) { |
|
449 |
LOGGER.warn("Error refreshing table", e); |
|
450 |
} |
|
451 |
} |
|
452 |
} |
|
453 |
} |
|
454 |
|
|
455 |
for (ViewDocument viewDocument : viewsToRefresh) { |
|
456 |
viewDocument.getMapContext().invalidate(); |
|
457 |
} |
|
458 |
|
|
459 |
} |
|
460 |
|
|
461 |
|
|
462 |
public List<ViewDocument> getViewDocumentsHavingAStore(FeatureStore store){ |
|
463 |
if(store == null){ |
|
464 |
return null; |
|
465 |
} |
|
466 |
List<ViewDocument> viewList = new ArrayList<>(); |
|
467 |
|
|
468 |
String storeFullName = store.getFullName(); |
|
469 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
470 |
ProjectManager projectManager = application.getProjectManager(); |
|
471 |
Project project = projectManager.getCurrentProject(); |
|
472 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
473 |
for (Document doc : views) { |
|
474 |
ViewDocument view = (ViewDocument) doc; |
|
475 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
476 |
FLayer layer = it.next(); |
|
477 |
if (layer instanceof FLyrVect) { |
|
478 |
FeatureStore layerStore = ((FLyrVect) layer).getFeatureStore(); |
|
479 |
if ( layerStore!=null && StringUtils.equals(layerStore.getFullName(),store.getFullName() )) { |
|
480 |
viewList.add(view); |
|
481 |
break; |
|
482 |
} |
|
483 |
} |
|
484 |
} |
|
485 |
} |
|
486 |
return viewList; |
|
487 |
} |
|
488 |
|
|
489 |
// @Override |
|
490 |
// public void addLayerToActiveView(FeatureStore store, String name) { |
|
491 |
// if(store != null && StringUtils.isNotBlank(name)){ |
|
492 |
// IView view = getActiveView(); |
|
493 |
// if(view != null){ |
|
494 |
// ViewDocument viewDocument = view.getViewDocument(); |
|
495 |
// this.addLayerToView(store, viewDocument, null, name, false); |
|
496 |
// } |
|
497 |
// } |
|
498 |
// } |
|
499 |
// |
|
500 |
@Override |
|
501 |
public boolean isThereAnyActiveView() { |
|
502 |
return this.getActiveView() != null; |
|
503 |
} |
|
504 |
|
|
505 |
@Override |
|
506 |
public void addTableToProject(VCSGisWorkspace ws, FeatureStore store, String tableName) { |
|
507 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
508 |
|
|
509 |
DocumentManager tableManager = appManager.getProjectManager().getDocumentManager( |
|
510 |
TableManager.TYPENAME |
|
511 |
); |
|
512 |
|
|
513 |
Project project = appManager.getCurrentProject(); |
|
514 |
TableDocument tableDoc = (TableDocument) tableManager.createDocument(); |
|
515 |
|
|
516 |
tableDoc.setName(tableName); |
|
517 |
tableDoc.setStore(store); |
|
518 |
project.addDocument(tableDoc); |
|
519 |
} |
|
520 |
|
|
521 |
@Override |
|
522 |
public Icon getFeatureStoresTreeModelIcon(TreeModel model, Object obj) { |
|
523 |
if( model instanceof FeatureStoresTreeModel ) { |
|
524 |
return ((FeatureStoresTreeModel)model).getIcon(obj); |
|
525 |
} |
|
526 |
return null; |
|
527 |
} |
|
528 |
|
|
529 |
@Override |
|
530 |
public void connectedToModel(VCSGisWorkspace workspace, String model) { |
|
531 |
String previousProjectModelInfo = null; |
|
532 |
try { |
|
533 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
534 |
Project project = application.getCurrentProject(); |
|
535 |
|
|
536 |
Map<String,JsonObject> models = new HashMap<>(); |
|
537 |
previousProjectModelInfo = (String) project.getProperty(VCSGISMODELS_PROJECT_PROPERTY); |
|
538 |
if( previousProjectModelInfo != null ) { |
|
539 |
JsonArray array = Json.createArray(previousProjectModelInfo); |
|
540 |
for (JsonValue value : array) { |
|
541 |
JsonObject item = (JsonObject) value; |
|
542 |
String modelName = item.getString("model", null); |
|
543 |
JDBCServerExplorerParameters wsparameters = (JDBCServerExplorerParameters) Json.toObject(item.getJsonObject("parameters")); |
|
544 |
String url = wsparameters.getUrl(); |
|
545 |
String key = modelName; //+ "("+ url + ")"; |
|
546 |
models.put(key, item); |
|
547 |
} |
|
548 |
} |
|
549 |
JDBCServerExplorerParameters parameters = workspace.getExplorerParameters(); |
|
550 |
String url = parameters.getUrl(); |
|
551 |
String key = model;// + "("+ url + ")"; |
|
552 |
JsonObjectBuilder item = Json.createObjectBuilder(); |
|
553 |
item.add("model", model); |
|
554 |
item.add("parameters", parameters); |
|
555 |
models.put(key, item.build()); |
|
556 |
JsonArrayBuilder array = Json.createArrayBuilder(); |
Also available in: Unified diff