Revision 4245
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.25/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Fri Jul 30 00:29:52 CEST 2021 |
|
2 |
buildNumber=32 |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.25/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.25/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 org.gvsig.vcsgis.app.addlayer.WizardVCSGisVectorial; |
|
25 |
import org.gvsig.vcsgis.app.addlayer.WizardVCSGisTabular; |
|
26 |
import java.util.Map; |
|
27 |
import javax.swing.JOptionPane; |
|
28 |
import org.gvsig.andami.IconThemeHelper; |
|
29 |
import org.gvsig.andami.PluginsLocator; |
|
30 |
import org.gvsig.andami.plugins.Extension; |
|
31 |
import org.gvsig.app.ApplicationLocator; |
|
32 |
import org.gvsig.app.extension.AddLayer; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
34 |
import org.gvsig.tools.ToolsLocator; |
|
35 |
import org.gvsig.tools.dynobject.DynObject; |
|
36 |
import org.gvsig.tools.i18n.I18nManager; |
|
37 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
38 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
39 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
40 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
41 |
import org.gvsig.vcsgis.app.VCSGisDialogsHelper.VCSGisDialogInfo; |
|
42 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
43 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
44 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
45 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
46 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceDescriptor; |
|
47 |
import org.gvsig.vcsgis.swing.VCSGisJAddToWorkspace; |
|
48 |
import org.gvsig.vcsgis.swing.VCSGisJCheckout; |
|
49 |
import org.gvsig.vcsgis.swing.VCSGisJCheckoutDataModel; |
|
50 |
import org.gvsig.vcsgis.swing.VCSGisJCreateResourceTable; |
|
51 |
import org.gvsig.vcsgis.swing.VCSGisJExport; |
|
52 |
import org.gvsig.vcsgis.swing.VCSGisJImportHistory; |
|
53 |
import org.gvsig.vcsgis.swing.VCSGisJInitServer; |
|
54 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
|
55 |
import org.gvsig.vcsgis.swing.VCSGisJLogout; |
|
56 |
import org.gvsig.vcsgis.swing.VCSGisJShowServerTableForm; |
|
57 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
|
58 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
|
59 |
|
|
60 |
/** |
|
61 |
* |
|
62 |
* @author gvSIG Team |
|
63 |
*/ |
|
64 |
public class VCSGisExtension extends Extension { |
|
65 |
|
|
66 |
private VCSGisDialogsHelper dialogsHelper; |
|
67 |
|
|
68 |
@Override |
|
69 |
public void initialize() { |
|
70 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-init-server", this); |
|
71 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-init-workspace", this); |
|
72 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-add-to-workspace", this); |
|
73 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-export", this); |
|
74 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-checkout", this); |
|
75 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-showchanges", this); |
|
76 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-register-workspace", this); |
|
77 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-show-revisions", this); |
|
78 |
IconThemeHelper.registerIcon("action", "tools-vcsgis-checkout-datamodel", this); |
|
79 |
|
|
80 |
this.dialogsHelper = new VCSGisDialogsHelper(); |
|
81 |
// ToolsLocator.getDisposableManager().setStackLimit(200); |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public void postInitialize() { |
|
86 |
super.postInitialize(); |
|
87 |
VCSGisManager manager = VCSGisLocator.getVCSGisManager(); |
|
88 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
89 |
swingManager.setDefaultServices(new VCSGisSwingServicesImpl()); |
|
90 |
|
|
91 |
DynObject pluginProperties = this.getPlugin().getPluginProperties(); |
|
92 |
Map<String, VCSGisWorkspaceDescriptor> workspaces = (Map) pluginProperties.getDynValue("workspaces"); |
|
93 |
manager.restoreWorkspaces(workspaces); |
|
94 |
|
|
95 |
PluginsLocator.getPluginsManager().addShutdownTask( |
|
96 |
"VCSGisSave", |
|
97 |
() -> { |
|
98 |
VCSGisManager manager1 = VCSGisLocator.getVCSGisManager(); |
|
99 |
DynObject pluginProperties1 = getPlugin().getPluginProperties(); |
|
100 |
pluginProperties1.setDynValue("workspaces", manager1.getWorkspaces()); |
|
101 |
}, |
|
102 |
false, |
|
103 |
100 |
|
104 |
); |
|
105 |
|
|
106 |
ApplicationLocator.getManager().registerAddTableWizard( |
|
107 |
"VCSGis", |
|
108 |
"VCSGis", |
|
109 |
WizardVCSGisTabular.class |
|
110 |
); |
|
111 |
AddLayer.addWizard(WizardVCSGisVectorial.class); |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public void execute(String actionCommand) { |
|
117 |
|
|
118 |
switch (actionCommand) { |
|
119 |
case "tools-vcsgis-showchanges": |
|
120 |
this.showChangesDialog(); |
|
121 |
break; |
|
122 |
|
|
123 |
case "tools-vcsgis-init-server": |
|
124 |
showInitializaRepositoryDialog(); |
|
125 |
break; |
|
126 |
case "tools-vcsgis-init-workspace": |
|
127 |
showInitWorkspaceDialog(); |
|
128 |
break; |
|
129 |
case "tools-vcsgis-add-to-workspace": |
|
130 |
showAddToWorkspaceDialog(); |
|
131 |
break; |
|
132 |
case "tools-vcsgis-checkout": |
|
133 |
showCheckoutDialog(); |
|
134 |
break; |
|
135 |
case "tools-vcsgis-export": |
|
136 |
showExportDialog(); |
|
137 |
break; |
|
138 |
case "tools-vcsgis-register-workspace": |
|
139 |
showRegisterWorkspaceDialog(); |
|
140 |
break; |
|
141 |
case "tools-vcsgis-show_server-entities": |
|
142 |
showServerEntitiesDialog(); |
|
143 |
break; |
|
144 |
case "tools-vcsgis-show_server-hooks": |
|
145 |
showServerHooksDialog(); |
|
146 |
break; |
|
147 |
case "tools-vcsgis-show-revisions": |
|
148 |
showHistory(); |
|
149 |
break; |
|
150 |
case "tools-vcsgis-import-history": |
|
151 |
showImportHistoryDialog(); |
|
152 |
break; |
|
153 |
case "tools-vcsgis-create-resource-table": |
|
154 |
showCreateResourceTableDialog(); |
|
155 |
break; |
|
156 |
case "tools-vcsgis-logout": |
|
157 |
showLogoutDialog(); |
|
158 |
break; |
|
159 |
case "tools-vcsgis-checkout-datamodel": |
|
160 |
showCheckoutDataModelDialog(); |
|
161 |
break; |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
public boolean isEnabled() { |
|
167 |
return true; |
|
168 |
} |
|
169 |
|
|
170 |
@Override |
|
171 |
public boolean isVisible() { |
|
172 |
return true; |
|
173 |
} |
|
174 |
|
|
175 |
// private void cleanHighligthed() { |
|
176 |
// VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
177 |
// swingManager.getDefaultServices().cleanHighligthed(); |
|
178 |
// } |
|
179 |
// |
|
180 |
|
|
181 |
private void showAddToWorkspaceDialog() { |
|
182 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
183 |
|
|
184 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
185 |
"AddToWorkingCopy", |
|
186 |
swingManager.createAddToWorkspacePanel(), |
|
187 |
"_VCS_Add_to_workingcopy", |
|
188 |
"_VCS_Add_to_workingcopy", |
|
189 |
"_VCS_Add_to_workingcopy", |
|
190 |
() -> { |
|
191 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
192 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
193 |
VCSGisJAddToWorkspace addToWorkspacePanel = (VCSGisJAddToWorkspace) this.dialogsHelper.getDialog("AddToWorkingCopy").getPanel(); |
|
194 |
int r = addToWorkspacePanel.add(); |
|
195 |
if (r != 0) { |
|
196 |
FeatureStore featureStore = addToWorkspacePanel.getFeatureStore(); |
|
197 |
String targetName = addToWorkspacePanel.getTabletName(); |
|
198 |
VCSGisWorkspace workspace = addToWorkspacePanel.getWorkspace(); |
|
199 |
dialogsManager.messageDialog( |
|
200 |
i18n.getTranslation( |
|
201 |
"_Cant_add_{0}_as_{1}_in_{2}", |
|
202 |
new String[]{ |
|
203 |
featureStore.getName(), |
|
204 |
targetName, |
|
205 |
workspace.getLabel() |
|
206 |
} |
|
207 |
) + "\n" + workspace.getErrorMessage(r), |
|
208 |
i18n.getTranslation("_VCS_Add_to_workingcopy"), |
|
209 |
JOptionPane.WARNING_MESSAGE |
|
210 |
); |
|
211 |
} |
|
212 |
} |
|
213 |
); |
|
214 |
dialog.show(); |
|
215 |
} |
|
216 |
|
|
217 |
private void showImportHistoryDialog() { |
|
218 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
219 |
|
|
220 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
221 |
"ImportHistory", |
|
222 |
swingManager.createImportHistoryPanel(), |
|
223 |
"_VCS_Import_history", |
|
224 |
"_VCS_Import_history", |
|
225 |
"_VCS_Import_history", |
|
226 |
() -> { |
|
227 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
228 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
229 |
VCSGisJImportHistory importHistoryPanel = (VCSGisJImportHistory) this.dialogsHelper.getDialog("ImportHistory").getPanel(); |
|
230 |
int r = importHistoryPanel.importHistory(); |
|
231 |
if (r != 0) { |
|
232 |
FeatureStore featureStore = importHistoryPanel.getFeatureStore(); |
|
233 |
String targetName = importHistoryPanel.getTabletName(); |
|
234 |
VCSGisWorkspace workspace = importHistoryPanel.getWorkspace(); |
|
235 |
dialogsManager.messageDialog( |
|
236 |
i18n.getTranslation( |
|
237 |
"_Cant_add_{0}_as_{1}_in_{2}", |
|
238 |
new String[]{ |
|
239 |
featureStore.getName(), |
|
240 |
targetName, |
|
241 |
workspace.getLabel() |
|
242 |
} |
|
243 |
) + "\n" + workspace.getErrorMessage(r), |
|
244 |
i18n.getTranslation("_VCS_Import_history"), |
|
245 |
JOptionPane.WARNING_MESSAGE |
|
246 |
); |
|
247 |
} |
|
248 |
} |
|
249 |
); |
|
250 |
dialog.show(); |
|
251 |
} |
|
252 |
|
|
253 |
private void showInitWorkspaceDialog() { |
|
254 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
255 |
|
|
256 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
257 |
"InitializeWorkingCopy", |
|
258 |
swingManager.createInitWorkspacePanel(), |
|
259 |
"_VCS_Initialize_workingcopy", |
|
260 |
"_VCS_Initialize_workingcopy", |
|
261 |
"_VCS_Initialize_workingcopy", |
|
262 |
() -> { |
|
263 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
264 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
265 |
VCSGisJInitWorkspace panelInitWorkspace = (VCSGisJInitWorkspace) this.dialogsHelper.getDialog("InitializeWorkingCopy").getPanel(); |
|
266 |
int r = panelInitWorkspace.initializeWorkspace(); |
|
267 |
if (r != 0) { |
|
268 |
dialogsManager.messageDialog( |
|
269 |
i18n.getTranslation( |
|
270 |
"_Cant_initialize_workingcopy_{0}", |
|
271 |
new String[]{panelInitWorkspace.getWorkspaceName()} |
|
272 |
), |
|
273 |
i18n.getTranslation("_VCS_Initialize_workingcopy"), |
|
274 |
JOptionPane.WARNING_MESSAGE |
|
275 |
); |
|
276 |
} |
|
277 |
} |
|
278 |
); |
|
279 |
dialog.setAutoclose(true); |
|
280 |
dialog.show(); |
|
281 |
} |
|
282 |
|
|
283 |
private void showInitializaRepositoryDialog() { |
|
284 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
285 |
|
|
286 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
287 |
"InitializeRepository", |
|
288 |
swingManager.createInitRepositoryPanel(), |
|
289 |
"_VCS_Initialize_repository", |
|
290 |
"_VCS_Initialize_repository", |
|
291 |
"_VCS_Initialize_repository", |
|
292 |
() -> { |
|
293 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
294 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
295 |
VCSGisJInitServer panel = (VCSGisJInitServer) this.dialogsHelper.getDialog("InitializeRepository").getPanel(); |
|
296 |
int r = panel.initialize(); |
|
297 |
if (r != 0) { |
|
298 |
dialogsManager.messageDialog( |
|
299 |
i18n.getTranslation( |
|
300 |
"_Cant_initialize_server_{0}", |
|
301 |
new String[]{panel.getConnectionLabel()} |
|
302 |
), |
|
303 |
i18n.getTranslation("_VCS_Initialize_repository"), |
|
304 |
JOptionPane.WARNING_MESSAGE |
|
305 |
); |
|
306 |
} |
|
307 |
} |
|
308 |
); |
|
309 |
dialog.setAutoclose(true); |
|
310 |
dialog.show(); |
|
311 |
} |
|
312 |
|
|
313 |
private void showCheckoutDialog() { |
|
314 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
315 |
|
|
316 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
317 |
"Checkout", |
|
318 |
swingManager.createCheckoutPanel(), |
|
319 |
"_VCS_Checkout", |
|
320 |
"_VCS_Checkout", |
|
321 |
"_VCS_Checkout", |
|
322 |
() -> { |
|
323 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
324 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
325 |
VCSGisJCheckout checkoutPanel = (VCSGisJCheckout) this.dialogsHelper.getDialog("Checkout").getPanel(); |
|
326 |
int r = checkoutPanel.checkout(); |
|
327 |
if (r != 0) { |
|
328 |
VCSGisEntity entity = checkoutPanel.getTable(); |
|
329 |
dialogsManager.messageDialog( |
|
330 |
i18n.getTranslation( |
|
331 |
"_Failed_checkout_of_{0}", |
|
332 |
new String[]{entity.toString()} |
|
333 |
), |
|
334 |
i18n.getTranslation("_Checkout"), |
|
335 |
JOptionPane.WARNING_MESSAGE |
|
336 |
); |
|
337 |
} |
|
338 |
} |
|
339 |
); |
|
340 |
dialog.show(); |
|
341 |
} |
|
342 |
|
|
343 |
private void showExportDialog() { |
|
344 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
345 |
|
|
346 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
347 |
"Export", |
|
348 |
swingManager.createExportPanel(), |
|
349 |
"_VCS_Export", |
|
350 |
"_Export_to_a_local_table_a_table_of_the_repository", |
|
351 |
"_VCS_Export", |
|
352 |
() -> { |
|
353 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
354 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
355 |
VCSGisJExport exportPanel = (VCSGisJExport) this.dialogsHelper.getDialog("Export").getPanel(); |
|
356 |
int r = exportPanel.export(); |
|
357 |
if (r != 0) { |
|
358 |
VCSGisEntity entity = exportPanel.getTable(); |
|
359 |
dialogsManager.messageDialog( |
|
360 |
i18n.getTranslation( |
|
361 |
"_Failed_export_of_{0}", |
|
362 |
new String[]{entity.toString()} |
|
363 |
), |
|
364 |
i18n.getTranslation("_VCSGis_Export"), |
|
365 |
JOptionPane.WARNING_MESSAGE |
|
366 |
); |
|
367 |
} |
|
368 |
} |
|
369 |
); |
|
370 |
dialog.show(); |
|
371 |
} |
|
372 |
|
|
373 |
private void showChangesDialog() { |
|
374 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
375 |
|
|
376 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
377 |
"Changes", |
|
378 |
swingManager.createChangesPanel(), |
|
379 |
"_VCS_Changes" |
|
380 |
); |
|
381 |
dialog.show(); |
|
382 |
} |
|
383 |
|
|
384 |
private void showHistory() { |
|
385 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
386 |
|
|
387 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
388 |
"Revisions", |
|
389 |
swingManager.createRevisionsPanel(), |
|
390 |
"_VCS_Revisions" |
|
391 |
); |
|
392 |
dialog.show(); |
|
393 |
} |
|
394 |
|
|
395 |
private void showRegisterWorkspaceDialog() { |
|
396 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
397 |
|
|
398 |
final VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
399 |
"RegisterWorkingCopies", |
|
400 |
swingManager.createRegisterWorkspacePanel(), |
|
401 |
"_VCS_Register_workingcopy" |
|
402 |
); |
|
403 |
dialog.show(); |
|
404 |
} |
|
405 |
|
|
406 |
private void showServerEntitiesDialog() { |
|
407 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
408 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
409 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
410 |
|
|
411 |
final VCSGisJShowServerTableForm panel = swingManager.createShowTableServerFormPanel("VCSGIS_ENTITIES"); |
|
412 |
winManager.showWindow( |
|
413 |
panel.asJComponent(), |
|
414 |
i18nManager.getTranslation("_VCS_Server_entities"), |
|
415 |
WindowManager.MODE.WINDOW |
|
416 |
); |
|
417 |
} |
|
418 |
|
|
419 |
private void showServerHooksDialog() { |
|
420 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
421 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
422 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
423 |
|
|
424 |
final VCSGisJShowServerTableForm panel = swingManager.createShowTableServerFormPanel("VCSGIS_HOOKS"); |
|
425 |
winManager.showWindow( |
|
426 |
panel.asJComponent(), |
|
427 |
i18nManager.getTranslation("_VCS_Server_hooks"), |
|
428 |
WindowManager.MODE.WINDOW |
|
429 |
); |
|
430 |
} |
|
431 |
|
|
432 |
private void showCreateResourceTableDialog() { |
|
433 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
434 |
|
|
435 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
436 |
"CreateResourceTable", |
|
437 |
swingManager.createResourceTablePanel(), |
|
438 |
"_VCS_Create_resource_table", |
|
439 |
"_Create_resource_table_parameters", |
|
440 |
"_VCS_Create_resource_table", |
|
441 |
() -> { |
|
442 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
443 |
VCSGisJCreateResourceTable panel = (VCSGisJCreateResourceTable) this.dialogsHelper.getDialog("CreateResourceTable").getPanel(); |
|
444 |
panel.createResourceTable(); |
|
445 |
} |
|
446 |
); |
|
447 |
dialog.setAutoclose(true); |
|
448 |
dialog.show(); |
|
449 |
} |
|
450 |
|
|
451 |
private void showLogoutDialog() { |
|
452 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
453 |
|
|
454 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
455 |
"Logout", |
|
456 |
swingManager.createLogoutPanel(), |
|
457 |
"_VCS_Logout", |
|
458 |
"_Logout_the_current_user_from_a_VCSGis_working_copy", |
|
459 |
"_VCS_Logout", |
|
460 |
() -> { |
|
461 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
462 |
VCSGisJLogout panel = (VCSGisJLogout) this.dialogsHelper.getDialog("Logout").getPanel(); |
|
463 |
panel.logout(); |
|
464 |
} |
|
465 |
); |
|
466 |
dialog.setAutoclose(true); |
|
467 |
dialog.show(); |
|
468 |
} |
|
469 |
|
|
470 |
private void showCheckoutDataModelDialog() { |
|
471 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
472 |
|
|
473 |
VCSGisDialogInfo dialog = this.dialogsHelper.getOrCreateDialog( |
|
474 |
"ConnectDataModel", |
|
475 |
swingManager.createCheckoutDataModelPanel(), |
|
476 |
"_VCS_Connect_to_datamodel", |
|
477 |
"_VCS_Connect_to_datamodel", |
|
478 |
"_VCS_Connect_to_datamodel", |
|
479 |
() -> { |
|
480 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
481 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
482 |
VCSGisJCheckoutDataModel checkoutDataModelPanel = (VCSGisJCheckoutDataModel) this.dialogsHelper.getDialog("ConnectDataModel").getPanel(); |
|
483 |
int r = checkoutDataModelPanel.connectToModel(); |
|
484 |
if (r != 0) { |
|
485 |
String dataModel = checkoutDataModelPanel.getDataModel(); |
|
486 |
dialogsManager.messageDialog( |
|
487 |
i18n.getTranslation( |
|
488 |
"_Failed_connect_to_{0}", |
|
489 |
new String[]{dataModel} |
|
490 |
), |
|
491 |
i18n.getTranslation("_VCS_Connect_to_datamodel"), |
|
492 |
JOptionPane.WARNING_MESSAGE |
|
493 |
); |
|
494 |
} |
|
495 |
} |
|
496 |
); |
|
497 |
dialog.show(); |
|
498 |
} |
|
499 |
|
|
500 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.25/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 javax.swing.event.TreeModelListener; |
|
9 |
import javax.swing.tree.TreeModel; |
|
10 |
import javax.swing.tree.TreePath; |
|
11 |
import org.gvsig.app.ApplicationLocator; |
|
12 |
import org.gvsig.fmap.dal.DataStore; |
|
13 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
14 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
|
15 |
import org.gvsig.fmap.mapcontext.layers.vectorial.VectorLayer; |
|
16 |
import org.gvsig.fmap.mapcontrol.LayersTreeModel; |
|
17 |
import org.gvsig.tools.evaluator.Evaluator; |
|
18 |
import org.gvsig.tools.evaluator.EvaluatorData; |
|
19 |
import org.gvsig.tools.evaluator.EvaluatorException; |
|
20 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
|
21 |
import org.gvsig.tools.swing.api.ListElement; |
|
22 |
|
|
23 |
|
|
24 |
/** |
|
25 |
* |
|
26 |
* @author fdiaz |
|
27 |
*/ |
|
28 |
public class FeatureStoresTreeModel implements TreeModel { |
|
29 |
|
|
30 |
private final LayersTreeModel delegated; |
|
31 |
private final ListElement<Object> root; |
|
32 |
|
|
33 |
public FeatureStoresTreeModel() { |
|
34 |
this.delegated = (LayersTreeModel) ApplicationLocator.getApplicationManager().createProjectLayersTreeModel(); |
|
35 |
this.delegated.setFilter(new Evaluator() { |
|
36 |
@Override |
|
37 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
38 |
FLayer layer = (FLayer) data.getDataValue("layer"); |
|
39 |
return (layer instanceof VectorLayer); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public String getName() { |
|
44 |
return "VectorialLayersFilter"; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public String getDescription() { |
|
49 |
return null; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public String getSQL() { |
|
54 |
return null; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public EvaluatorFieldsInfo getFieldsInfo() { |
|
59 |
return null; |
|
60 |
} |
|
61 |
}); |
|
62 |
this.root = new ListElement<>("Project", this.delegated.getRoot()); |
|
63 |
} |
|
64 |
|
|
65 |
private Object getNode(Object value) { |
|
66 |
if( value instanceof ListElement ) { |
|
67 |
return ((ListElement) value).getValue(); |
|
68 |
} |
|
69 |
return value; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public Object getRoot() { |
|
74 |
return this.root; |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public Object getChild(Object parent, int index) { |
|
79 |
parent = this.getNode(parent); |
|
80 |
Object x = this.delegated.getChild(parent, index); |
|
81 |
if( x instanceof VectorLayer ) { |
|
82 |
SingleLayer layer = (SingleLayer)x; |
|
83 |
DataStore store = (DataStore) layer.getDataStore(); |
|
84 |
return store; |
|
85 |
} |
|
86 |
return x; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public int getChildCount(Object parent) { |
|
91 |
parent = this.getNode(parent); |
|
92 |
return this.delegated.getChildCount(parent); |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
public boolean isLeaf(Object node) { |
|
97 |
node = this.getNode(node); |
|
98 |
return this.delegated.isLeaf(node); |
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public void valueForPathChanged(TreePath path, Object newValue) { |
|
103 |
this.delegated.valueForPathChanged(path, newValue); |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public int getIndexOfChild(Object parent, Object child) { |
|
108 |
parent = this.getNode(parent); |
|
109 |
return this.delegated.getIndexOfChild(parent, child); |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public void addTreeModelListener(TreeModelListener l) { |
|
114 |
this.delegated.addTreeModelListener(l); |
|
115 |
} |
|
116 |
|
|
117 |
@Override |
|
118 |
public void removeTreeModelListener(TreeModelListener l) { |
|
119 |
this.delegated.removeTreeModelListener(l); |
|
120 |
} |
|
121 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.25/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.swing.ComboBoxModel; |
|
17 |
import javax.swing.DefaultComboBoxModel; |
|
18 |
import javax.swing.DefaultListModel; |
|
19 |
import javax.swing.ListModel; |
|
20 |
import javax.swing.tree.TreeModel; |
|
21 |
import org.apache.commons.lang3.StringUtils; |
|
22 |
import org.gvsig.andami.PluginsLocator; |
|
23 |
import org.gvsig.app.ApplicationLocator; |
|
24 |
import org.gvsig.app.ApplicationManager; |
|
25 |
import org.gvsig.app.project.Project; |
|
26 |
import org.gvsig.app.project.ProjectManager; |
|
27 |
import org.gvsig.app.project.documents.Document; |
|
28 |
import org.gvsig.app.project.documents.DocumentManager; |
|
29 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
30 |
import org.gvsig.app.project.documents.table.TableManager; |
|
31 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
32 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
33 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
34 |
import org.gvsig.fmap.dal.exception.DataException; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
36 |
import org.gvsig.fmap.geom.Geometry; |
|
37 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
|
38 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
39 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
|
40 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
41 |
import org.gvsig.fmap.geom.primitive.Point; |
|
42 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
43 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
44 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
45 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
46 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
47 |
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer; |
|
48 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
49 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2; |
|
50 |
import org.gvsig.tools.ToolsLocator; |
|
51 |
import org.gvsig.tools.i18n.I18nManager; |
|
52 |
import org.gvsig.tools.util.LabeledValue; |
|
53 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
54 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
55 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
56 |
import org.gvsig.vcsgis.lib.VCSGisRuntimeException; |
|
57 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
58 |
import org.gvsig.vcsgis.swing.VCSGisSwingServices; |
|
59 |
import org.slf4j.LoggerFactory; |
|
60 |
|
|
61 |
/** |
|
62 |
* |
|
63 |
* @author gvSIG Team |
|
64 |
*/ |
|
65 |
@SuppressWarnings("UseSpecificCatch") |
|
66 |
public class VCSGisSwingServicesImpl implements VCSGisSwingServices { |
|
67 |
|
|
68 |
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(VCSGisSwingServicesImpl.class); |
|
69 |
|
|
70 |
private Map<Integer,ISymbol> highlightedPolygonSymbols; |
|
71 |
private Map<Integer,ISymbol> highlightedLineSymbols; |
|
72 |
private Map<Integer,ISymbol> highlightedPointSymbols; |
|
73 |
|
|
74 |
|
|
75 |
@Override |
|
76 |
public TreeModel getFeatureStoresTreeModel() { |
|
77 |
return new FeatureStoresTreeModel(); |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public ListModel getFeatureStoresListModel() { |
|
82 |
DefaultListModel<FeatureStore> model = new DefaultListModel(); |
|
83 |
|
|
84 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
85 |
Project project = appManager.getCurrentProject(); |
|
86 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
87 |
for (Document document : tables) { |
|
88 |
TableDocument table = (TableDocument) document; |
|
89 |
model.addElement(table.getFeatureStore()); |
|
90 |
} |
|
91 |
|
|
92 |
return model; |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
public void addTableToProject(VCSGisWorkspace ws, FeatureStore store) { |
|
97 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
98 |
|
|
99 |
DocumentManager tableManager = appManager.getProjectManager().getDocumentManager( |
|
100 |
TableManager.TYPENAME |
|
101 |
); |
|
102 |
|
|
103 |
Project project = appManager.getCurrentProject(); |
|
104 |
TableDocument tableDoc = (TableDocument) tableManager.createDocument(); |
|
105 |
|
|
106 |
tableDoc.setName(store.getName()); |
|
107 |
tableDoc.setStore(store); |
|
108 |
project.addDocument(tableDoc); |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public ComboBoxModel getViewDocumentsComboBoxModel() { |
|
113 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
114 |
DefaultComboBoxModel<LabeledValue> model = new DefaultComboBoxModel(); |
|
115 |
model.addElement(new LabeledValueImpl(i18n.getTranslation("_Select_a_view"), null)); |
|
116 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
117 |
Project project = appManager.getCurrentProject(); |
|
118 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
119 |
for (Document document : views) { |
|
120 |
ViewDocument view = (ViewDocument) document; |
|
121 |
model.addElement(new LabeledValueImpl(view.getName(), view)); |
|
122 |
} |
|
123 |
return model; |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public void addLayerToView(FeatureStore store, LabeledValue labeledView) { |
|
128 |
addLayerToView(store, labeledView, null); |
|
129 |
} |
|
130 |
|
|
131 |
@Override |
|
132 |
public void addLayerToView(FeatureStore store, LabeledValue labeledView, String name) { |
|
133 |
if (labeledView.getValue() == null){ |
|
134 |
return; |
|
135 |
} |
|
136 |
ViewDocument view = (ViewDocument) labeledView.getValue(); |
|
137 |
addLayerToView(store, view, name); |
|
138 |
} |
|
139 |
|
|
140 |
|
|
141 |
private void addLayerToView(FeatureStore store, ViewDocument view, String name) { |
|
142 |
try { |
|
143 |
String layerName = name; |
|
144 |
if(StringUtils.isBlank(layerName)){ |
|
145 |
layerName = store.getName(); |
|
146 |
} |
|
147 |
FLayer layer = MapContextLocator.getMapContextManager().createLayer(layerName, store); |
|
148 |
view.getMapContext().getLayers().add(layer); |
|
149 |
} catch (Exception ex) { |
|
150 |
VCSGisManager manager = VCSGisLocator.getManager(); |
|
151 |
throw new VCSGisRuntimeException( |
|
152 |
VCSGisManager.ERR_CANT_ADD_LAYER, |
|
153 |
manager.getErrorMessage(VCSGisManager.ERR_CANT_ADD_LAYER), |
|
154 |
ex); |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
@Override |
|
159 |
public void highlight(int mode, Geometry geom) { |
|
160 |
highlight(mode, geom, null); |
|
161 |
} |
|
162 |
|
|
163 |
@Override |
|
164 |
public void highlight(int mode, Geometry geom, FeatureStore store) { |
|
165 |
if (this.highlightedPointSymbols == null) { |
|
166 |
this.highlightedPointSymbols = new HashMap<>(); |
|
167 |
this.highlightedLineSymbols = new HashMap<>(); |
|
168 |
this.highlightedPolygonSymbols = new HashMap<>(); |
|
169 |
try { |
|
170 |
File pluginfolder = PluginsLocator.getManager().getPlugin(this).getPluginDirectory(); |
|
171 |
File folder = new File(pluginfolder, "symbols"); |
|
172 |
ISymbol[] symbols = MapContextLocator.getSymbolManager().loadSymbols(folder); |
|
173 |
for (ISymbol symbol : symbols) { |
|
174 |
if (symbol instanceof ISymbol_v2) { |
|
175 |
String symbolid = ((ISymbol_v2) symbol).getID(); |
|
176 |
switch(symbolid) { |
|
177 |
case "vcsgis-repository-polygon": |
|
178 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
179 |
break; |
|
180 |
case "vcsgis-repository-line": |
|
181 |
this.highlightedLineSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
182 |
break; |
|
183 |
case "vcsgis-repository-point": |
|
184 |
this.highlightedPointSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
185 |
break; |
|
186 |
|
|
187 |
case "vcsgis-workspace-polygon": |
|
188 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
189 |
break; |
|
190 |
case "vcsgis-workspace-line": |
|
191 |
this.highlightedLineSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
192 |
break; |
|
193 |
case "vcsgis-workspace-point": |
|
194 |
this.highlightedPointSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
195 |
break; |
|
196 |
|
|
197 |
case "vcsgis-workspace-previous-polygon": |
|
198 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
199 |
break; |
|
200 |
case "vcsgis-workspace-previous-line": |
|
201 |
this.highlightedLineSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
202 |
break; |
|
203 |
case "vcsgis-workspace-previous-point": |
|
204 |
this.highlightedPointSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
205 |
break; |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
} catch (Exception ex) { |
|
210 |
} |
|
211 |
} |
|
212 |
List<ViewDocument> viewList = null; |
|
213 |
if(store == null){ |
|
214 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
215 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
216 |
viewList = new ArrayList<>(); |
|
217 |
viewList.add(viewdoc); |
|
218 |
} else { |
|
219 |
viewList = getViewDocumentsHavingAStore(store); |
|
220 |
} |
|
221 |
for (ViewDocument viewDoc : viewList) { |
|
222 |
MapContext mapContext = viewDoc.getMapContext(); |
|
223 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
224 |
if (geom != null) { |
|
225 |
ISymbol symbol = null; |
|
226 |
if (geom instanceof Point || geom instanceof MultiPoint) { |
|
227 |
symbol = this.highlightedPointSymbols.get(mode); |
|
228 |
} else if (geom instanceof Curve || geom instanceof MultiCurve) { |
|
229 |
symbol = this.highlightedLineSymbols.get(mode); |
|
230 |
} else if (geom instanceof Surface || geom instanceof MultiSurface) { |
|
231 |
symbol = this.highlightedPolygonSymbols.get(mode); |
|
232 |
} |
|
233 |
if (symbol != null) { |
|
234 |
int symbolid = gl.getSymbolId(symbol); |
|
235 |
if (symbolid < 0) { |
|
236 |
gl.addSymbol(symbol); |
|
237 |
symbolid = gl.getSymbolId(symbol); |
|
238 |
} |
|
239 |
gl.addGraphic("vcsgis-highlighted", geom, symbolid); |
|
240 |
} |
|
241 |
} |
|
242 |
mapContext.invalidate(); |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
@Override |
|
247 |
public void centerActiveViewToGeometry(Geometry geometry) { |
|
248 |
if(geometry != null){ |
|
249 |
IView view = getActiveView(); |
|
250 |
if(view != null){ |
|
251 |
ViewDocument viewDocument = view.getViewDocument(); |
|
252 |
viewDocument.center(geometry.getEnvelope()); |
|
253 |
} |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
@Override |
|
258 |
public void centerViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) { |
|
259 |
if(geometry != null){ |
|
260 |
List<ViewDocument> views = getViewDocumentsHavingAStore(store); |
|
261 |
for (ViewDocument view : views) { |
|
262 |
if(view != null){ |
|
263 |
view.center(geometry.getEnvelope()); |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
} |
|
268 |
|
|
269 |
@Override |
|
270 |
public void zoomActiveViewToGeometry(Geometry geometry) { |
|
271 |
if(geometry != null){ |
|
272 |
IView view = getActiveView(); |
|
273 |
if(view != null){ |
|
274 |
ViewDocument viewDocument = view.getViewDocument(); |
|
275 |
viewDocument.getMapContext().getViewPort().setEnvelope(geometry.getEnvelope()); |
|
276 |
} |
|
277 |
} |
|
278 |
} |
|
279 |
|
|
280 |
@Override |
|
281 |
public void zoomViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) { |
|
282 |
if(geometry != null){ |
|
283 |
List<ViewDocument> views = getViewDocumentsHavingAStore(store); |
|
284 |
for (ViewDocument view : views) { |
|
285 |
if(view != null){ |
|
286 |
view.getMapContext().getViewPort().setEnvelope(geometry.getEnvelope()); |
|
287 |
} |
|
288 |
} |
|
289 |
} |
|
290 |
} |
|
291 |
|
|
292 |
private IView getActiveView() { |
|
293 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
294 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
295 |
return view; |
|
296 |
} |
|
297 |
|
|
298 |
@Override |
|
299 |
public void cleanHighligthed() { |
|
300 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
301 |
ProjectManager projectManager = application.getProjectManager(); |
|
302 |
Project project = projectManager.getCurrentProject(); |
|
303 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
304 |
for (Document doc : views) { |
|
305 |
ViewDocument viewdoc = (ViewDocument)doc; |
|
306 |
MapContext mapContext = viewdoc.getMapContext(); |
|
307 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
308 |
//FIXME: Refrescar el mapContext solo cuando se ha borrado el graphics |
|
309 |
if(gl.removeGraphics("vcsgis-highlighted")) { |
|
310 |
mapContext.invalidate(); |
|
311 |
} |
|
312 |
} |
|
313 |
} |
|
314 |
|
|
315 |
@Override |
|
316 |
public void cleanActiveViewHighligthed() { |
|
317 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
318 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
319 |
if(viewdoc != null){ |
|
320 |
MapContext mapContext = viewdoc.getMapContext(); |
|
321 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
322 |
gl.removeGraphics("vcsgis-highlighted"); |
|
323 |
mapContext.invalidate(); |
|
324 |
} |
|
325 |
} |
|
326 |
|
|
327 |
@Override |
|
328 |
public void refreshDocument(FeatureStore store){ |
|
329 |
if(store == null){ |
|
330 |
return; |
|
331 |
} |
|
332 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
333 |
ProjectManager projectManager = application.getProjectManager(); |
|
334 |
Project project = projectManager.getCurrentProject(); |
|
335 |
|
|
336 |
String storeFullName = store.getFullName(); |
|
337 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
338 |
for (Document doc : views) { |
|
339 |
ViewDocument view = (ViewDocument)doc; |
|
340 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
341 |
FLayer layer = it.next(); |
|
342 |
if(layer instanceof FLyrVect){ |
|
343 |
if( StringUtils.equals(((FLyrVect) layer).getFeatureStore().getFullName(), storeFullName)){ |
|
344 |
view.getMapContext().invalidate(); |
|
345 |
break; |
|
346 |
} |
|
347 |
} |
|
348 |
} |
|
349 |
} |
|
350 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
351 |
for (Document doc : tables) { |
|
352 |
TableDocument table = (TableDocument)doc; |
|
353 |
FeatureStore featureStore = table.getStore(); |
|
354 |
if( StringUtils.equals(featureStore.getFullName(), storeFullName)){ |
|
355 |
try { |
|
356 |
featureStore.refresh(); |
|
357 |
} catch (DataException e) { |
|
358 |
LOGGER.warn("Error refreshing table", e); |
|
359 |
} |
|
360 |
} |
|
361 |
} |
|
362 |
} |
|
363 |
|
|
364 |
@Override |
|
365 |
public void refreshDocument(Set<FeatureStore> stores){ |
|
366 |
if(stores == null || stores.isEmpty()){ |
|
367 |
return; |
|
368 |
} |
|
369 |
|
|
370 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
371 |
ProjectManager projectManager = application.getProjectManager(); |
|
372 |
Project project = projectManager.getCurrentProject(); |
|
373 |
|
|
374 |
Set<ViewDocument> viewsToRefresh = new HashSet<>(); |
|
375 |
for (FeatureStore store : stores) { |
|
376 |
String storeFullName = store.getFullName(); |
|
377 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
378 |
for (Document doc : views) { |
|
379 |
ViewDocument view = (ViewDocument)doc; |
|
380 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
381 |
FLayer layer = it.next(); |
|
382 |
if(layer instanceof FLyrVect){ |
|
383 |
if( StringUtils.equals(((FLyrVect) layer).getFeatureStore().getFullName(), storeFullName)){ |
|
384 |
viewsToRefresh.add(view); |
|
385 |
break; |
|
386 |
} |
|
387 |
} |
|
388 |
} |
|
389 |
} |
|
390 |
|
|
391 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
392 |
for (Document doc : tables) { |
|
393 |
TableDocument table = (TableDocument)doc; |
|
394 |
FeatureStore featureStore = table.getStore(); |
|
395 |
if( StringUtils.equals(featureStore.getFullName(), storeFullName)){ |
|
396 |
try { |
|
397 |
featureStore.refresh(); |
|
398 |
} catch (DataException e) { |
|
399 |
LOGGER.warn("Error refreshing table", e); |
|
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
} |
|
404 |
|
|
405 |
for (ViewDocument viewDocument : viewsToRefresh) { |
|
406 |
viewDocument.getMapContext().invalidate(); |
|
407 |
} |
|
408 |
|
|
409 |
} |
|
410 |
|
|
411 |
|
|
412 |
public List<ViewDocument> getViewDocumentsHavingAStore(FeatureStore store){ |
|
413 |
if(store == null){ |
|
414 |
return null; |
|
415 |
} |
|
416 |
List<ViewDocument> viewList = new ArrayList<>(); |
|
417 |
|
|
418 |
String storeFullName = store.getFullName(); |
|
419 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
420 |
ProjectManager projectManager = application.getProjectManager(); |
|
421 |
Project project = projectManager.getCurrentProject(); |
|
422 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
423 |
for (Document doc : views) { |
|
424 |
ViewDocument view = (ViewDocument) doc; |
|
425 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
426 |
FLayer layer = it.next(); |
|
427 |
if (layer instanceof FLyrVect) { |
|
428 |
if (StringUtils.equals( |
|
429 |
((FLyrVect) layer).getFeatureStore().getFullName(), |
|
430 |
store.getFullName() |
|
431 |
)) { |
|
432 |
viewList.add(view); |
|
433 |
break; |
|
434 |
} |
|
435 |
} |
|
436 |
} |
|
437 |
} |
|
438 |
return viewList; |
|
439 |
} |
|
440 |
|
|
441 |
@Override |
|
442 |
public void addLayerToActiveView(FeatureStore store, String name) { |
|
443 |
if(store != null && StringUtils.isNotBlank(name)){ |
|
444 |
IView view = getActiveView(); |
|
445 |
if(view != null){ |
|
446 |
ViewDocument viewDocument = view.getViewDocument(); |
|
447 |
this.addLayerToView(store, viewDocument, name); |
|
448 |
} |
|
449 |
} |
|
450 |
} |
|
451 |
|
|
452 |
@Override |
|
453 |
public boolean isThereAnyActiveView() { |
|
454 |
return this.getActiveView() != null; |
|
455 |
} |
|
456 |
|
|
457 |
@Override |
|
458 |
public void addTableToProject(VCSGisWorkspace ws, FeatureStore store, String tableName) { |
|
459 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
460 |
|
|
461 |
DocumentManager tableManager = appManager.getProjectManager().getDocumentManager( |
|
462 |
TableManager.TYPENAME |
|
463 |
); |
|
464 |
|
|
465 |
Project project = appManager.getCurrentProject(); |
|
466 |
TableDocument tableDoc = (TableDocument) tableManager.createDocument(); |
|
467 |
|
|
468 |
tableDoc.setName(tableName); |
|
469 |
tableDoc.setStore(store); |
|
470 |
project.addDocument(tableDoc); |
|
471 |
} |
|
472 |
|
|
473 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.25/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/VCSGisDialogsHelper.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 |
|
|
23 |
package org.gvsig.vcsgis.app; |
|
24 |
|
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ComponentAdapter; |
|
27 |
import java.awt.event.ComponentEvent; |
|
28 |
import java.util.HashMap; |
|
29 |
import java.util.Map; |
|
30 |
import javax.swing.SwingUtilities; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
32 |
import org.gvsig.tools.i18n.I18nManager; |
|
33 |
import org.gvsig.tools.swing.api.Component; |
|
34 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
35 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
36 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
37 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
38 |
import org.gvsig.vcsgis.swing.VCSGisPanel; |
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 |
/** |
|
43 |
* |
|
44 |
* @author gvSIG Team |
|
45 |
*/ |
|
46 |
public class VCSGisDialogsHelper { |
|
47 |
private static final Logger LOGGER = LoggerFactory.getLogger(VCSGisDialogsHelper.class); |
|
48 |
|
|
49 |
public static class VCSGisDialogInfo { |
|
50 |
|
|
51 |
private VCSGisPanel panel; |
|
52 |
private final String name; |
|
53 |
private final String title; |
|
54 |
private String header; |
|
55 |
private String okLabel; |
|
56 |
private boolean closed; |
|
57 |
private Runnable action; |
|
58 |
private Dialog dialog; |
|
59 |
private boolean autoclose; |
|
60 |
|
|
61 |
public VCSGisDialogInfo(String name, VCSGisPanel thePanel, String title) { |
|
62 |
this.name = name; |
|
63 |
this.panel = thePanel; |
|
64 |
this.title = title; |
|
65 |
this.closed = true; |
|
66 |
this.autoclose = false; |
|
67 |
|
|
68 |
this.panel.asJComponent().addComponentListener(new ComponentAdapter() { |
|
69 |
@Override |
|
70 |
public void componentHidden(ComponentEvent e) { |
|
71 |
closed = true; |
|
72 |
} |
|
73 |
}); |
|
74 |
} |
|
75 |
|
|
76 |
public VCSGisDialogInfo(String name, VCSGisPanel thePanel, String title, String header, String okLabel) { |
|
77 |
this(name, thePanel, title); |
|
78 |
this.header = header; |
|
79 |
this.okLabel = okLabel; |
|
80 |
} |
|
81 |
|
|
82 |
private void performDialogAction() { |
|
83 |
action.run(); |
|
84 |
} |
|
85 |
|
|
86 |
public void setAction(Runnable action) { |
|
87 |
this.action = action; |
|
88 |
} |
|
89 |
|
|
90 |
public Component getPanel() { |
|
91 |
return this.panel; |
|
92 |
} |
|
93 |
|
|
94 |
public boolean isClosed() { |
|
95 |
return this.closed; |
|
96 |
} |
|
97 |
|
|
98 |
public String getName() { |
|
99 |
return this.name; |
|
100 |
} |
|
101 |
|
|
102 |
public void setAutoclose(boolean autoclose) { |
|
103 |
this.autoclose = autoclose; |
|
104 |
} |
|
105 |
|
|
106 |
private Dialog createDialog() { |
|
107 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
108 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
109 |
|
|
110 |
Dialog theDialog = winManager.createDialog( |
|
111 |
this.panel.asJComponent(), |
|
112 |
i18n.getTranslation(title), |
|
113 |
i18n.getTranslation(header), |
|
114 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
115 |
); |
|
116 |
theDialog.setAutoclose(false); |
|
117 |
|
|
118 |
this.panel.setDialog(theDialog); |
|
119 |
theDialog.setButtonLabel( |
|
120 |
WindowManager_v2.BUTTON_OK, |
|
121 |
i18n.getTranslation(okLabel) |
|
122 |
); |
|
123 |
theDialog.setButtonLabel( |
|
124 |
WindowManager_v2.BUTTON_CANCEL, |
|
125 |
i18n.getTranslation("_Close") |
|
126 |
); |
|
127 |
if (this.panel.isProcessing()) { |
|
128 |
theDialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false); |
|
129 |
} |
|
130 |
theDialog.addActionListener((ActionEvent e) -> { |
|
131 |
switch (theDialog.getAction()) { |
|
132 |
case WindowManager_v2.BUTTON_OK: |
|
133 |
Thread task = new Thread(() -> { |
|
134 |
if(this.autoclose){ |
|
135 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false); |
|
136 |
} |
|
137 |
performDialogAction(); |
|
138 |
if(this.autoclose){ |
|
139 |
close(); |
|
140 |
} |
|
141 |
}, "VCSGis" + name); |
|
142 |
task.start(); |
|
143 |
break; |
|
144 |
case WindowManager_v2.BUTTON_CANCEL: |
|
145 |
close(); |
|
146 |
break; |
|
147 |
} |
|
148 |
}); |
|
149 |
return theDialog; |
|
150 |
} |
|
151 |
|
|
152 |
public void show() { |
|
153 |
if (!this.closed) { |
|
154 |
return; |
|
155 |
} |
|
156 |
this.closed = false; |
|
157 |
if( this.action==null ) { |
|
158 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
159 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
160 |
winManager.showWindow( |
|
161 |
this.panel.asJComponent(), |
|
162 |
i18n.getTranslation(this.title), |
|
163 |
WindowManager.MODE.WINDOW |
|
164 |
); |
|
165 |
} else { |
|
166 |
this.dialog = this.createDialog(); |
|
167 |
this.dialog.show(WindowManager.MODE.WINDOW); |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
private void close() { |
|
172 |
if (this.closed || this.dialog == null) { |
|
173 |
this.panel = null; |
|
174 |
this.dialog = null; |
|
175 |
return; |
|
176 |
} |
|
177 |
if(!SwingUtilities.isEventDispatchThread()){ |
|
178 |
SwingUtilities.invokeLater(this::close); |
|
179 |
return; |
|
180 |
} |
|
181 |
this.dialog.asJComponent().setVisible(false); |
|
182 |
this.panel = null; |
|
183 |
this.dialog = null; |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
private Map<String, VCSGisDialogInfo> dialogsInfo; |
|
188 |
|
|
189 |
public VCSGisDialogInfo getDialog(String name) { |
|
190 |
if (this.dialogsInfo == null) { |
|
191 |
return null; |
|
192 |
} |
|
193 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
194 |
return info; |
|
195 |
} |
|
196 |
|
|
197 |
public VCSGisDialogInfo getOrCreateDialog(String name, VCSGisPanel panel, String title, String header, String okLabel, Runnable action) { |
|
198 |
if (this.dialogsInfo == null) { |
|
199 |
this.dialogsInfo = new HashMap<>(); |
|
200 |
} |
|
201 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
202 |
if (info == null || info.isClosed() ) { |
|
203 |
info = new VCSGisDialogInfo(name, panel, title, header, okLabel); |
|
204 |
info.setAction(action); |
|
205 |
this.dialogsInfo.put(name, info); |
|
206 |
} |
|
207 |
return info; |
|
208 |
} |
|
209 |
|
|
210 |
public VCSGisDialogInfo getOrCreateDialog(String name, VCSGisPanel panel, String title) { |
|
211 |
if (this.dialogsInfo == null) { |
|
212 |
this.dialogsInfo = new HashMap<>(); |
|
213 |
} |
|
214 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
215 |
if (info == null || info.isClosed()) { |
|
216 |
info = new VCSGisDialogInfo(name, panel, title); |
|
217 |
this.dialogsInfo.put(name, info); |
|
218 |
} |
|
219 |
return info; |
|
220 |
} |
|
221 |
|
|
222 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.25/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/WizardVCSGisVectorial.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.addlayer; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Arrays; |
|
6 |
import java.util.Collection; |
|
7 |
import java.util.Iterator; |
|
8 |
import java.util.LinkedHashMap; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 |
import javax.swing.SwingUtilities; |
|
12 |
import org.apache.commons.codec.binary.Hex; |
|
13 |
import org.apache.commons.collections4.CollectionUtils; |
|
14 |
import org.apache.commons.lang3.StringUtils; |
|
15 |
import org.gvsig.andami.PluginServices; |
|
16 |
import org.gvsig.andami.PluginsLocator; |
|
17 |
import org.gvsig.andami.PluginsManager; |
|
18 |
import org.gvsig.fmap.dal.DALLocator; |
|
19 |
import org.gvsig.fmap.dal.DataManager; |
|
20 |
import org.gvsig.fmap.dal.DataStore; |
|
21 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
22 |
import org.gvsig.fmap.dal.exception.DataException; |
|
23 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
24 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
25 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
26 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
|
27 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
|
28 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
29 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
31 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
32 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
33 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
35 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
36 |
import org.gvsig.geodb.ExtDB_Spatial; |
|
37 |
import org.gvsig.geodb.TableInfo; |
|
38 |
import org.gvsig.geodb.vectorialdb.visibility.LayerScaleVisibility; |
|
39 |
import org.gvsig.geodb.vectorialdb.visibility.VisibilityScaleSelector; |
|
40 |
import org.gvsig.tools.ToolsLocator; |
|
41 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
42 |
import org.gvsig.tools.dynobject.DynObject; |
|
43 |
import org.gvsig.tools.i18n.I18nManager; |
|
44 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
45 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
46 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
47 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
48 |
import org.gvsig.tools.util.IsEmpty; |
|
49 |
import static org.gvsig.vcsgis.app.addlayer.AbstractWizardVCSGis.LOGGER; |
|
50 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
51 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
52 |
|
|
53 |
/** |
|
54 |
* |
|
55 |
* @author gvSIG Team |
|
56 |
*/ |
|
57 |
@SuppressWarnings("UseSpecificCatch") |
|
58 |
public class WizardVCSGisVectorial extends AbstractWizardVCSGis { |
|
59 |
|
|
60 |
public static final int NUMBER_OF_FEATURES_TO_ASK_FOR_VISIBILITY_SCALE = 10000; |
|
61 |
public static final String LAYERS_SCALE_VISIBILITY_PARAMETER="layersScaleVisibility"; |
|
62 |
|
|
63 |
private static class LayersTwoLevelsTree implements Iterable<FLayer>, IsEmpty { |
|
64 |
|
|
65 |
private final VCSGisWorkspace workspace; |
|
66 |
private Map<String, FLayer> treelayers; |
|
67 |
private List<FLayer> layers; |
|
68 |
private MapContext mapContext; |
|
69 |
|
|
70 |
public LayersTwoLevelsTree(VCSGisWorkspace workspace, MapContext mapContext) { |
|
71 |
this.workspace = workspace; |
|
72 |
this.treelayers = new LinkedHashMap<>(); |
|
73 |
this.layers = new ArrayList<>(); |
|
74 |
this.mapContext = mapContext; |
|
75 |
} |
|
76 |
|
|
77 |
public void add(String tableName, FLayer layer) { |
|
78 |
layer.setVisible(true); |
|
79 |
layers.add(layer); |
|
80 |
VCSGisWorkspaceEntity entity = this.workspace.getWorkspaceEntityByName(tableName); |
|
81 |
if( entity==null ) { |
|
82 |
treelayers.put(layer.getName(), layer); |
|
83 |
return; |
|
84 |
} |
|
85 |
List<String> categories = entity.getCategoriesAsList(); |
|
86 |
if( CollectionUtils.isEmpty(categories) ) { |
|
87 |
treelayers.put(layer.getName(), layer); |
|
88 |
return; |
|
89 |
} |
|
90 |
String groupName = categories.get(0); |
|
91 |
FLayers group = (FLayers) treelayers.get("$$"+groupName); |
|
92 |
if( group==null ) { |
|
93 |
group = new FLayers(); |
Also available in: Unified diff