Revision 7761
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.89/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.vcsgis.app</artifactId> |
|
6 |
<version>1.0.89</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.vcsgis.app.mainplugin</artifactId> |
|
9 |
<packaging>jar</packaging> |
|
10 |
<name>${project.artifactId}</name> |
|
11 |
<properties> |
|
12 |
<!-- Package info property values --> |
|
13 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
14 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
15 |
<gvsig.package.info.name>vcsgis</gvsig.package.info.name> |
|
16 |
<gvsig.package.info.description>Provides tools for Version Control System (VCS) for GIS.</gvsig.package.info.description> |
|
17 |
<gvsig.package.info.categories /> |
|
18 |
<gvsig.package.info.javaVM>j1_8</gvsig.package.info.javaVM> |
|
19 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-vcsgis/pool</gvsig.package.info.poolURL> |
|
20 |
</properties> |
|
21 |
|
|
22 |
<dependencies> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.andami</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.vcsgis.swing.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.vcsgis.lib.api</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.vcsgis.lib.impl</artifactId> |
|
41 |
<scope>runtime</scope> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.vcsgis.swing.impl</artifactId> |
|
46 |
<scope>runtime</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
<dependency> |
|
54 |
<groupId>org.gvsig</groupId> |
|
55 |
<artifactId>org.gvsig.app.document.table.app.mainplugin</artifactId> |
|
56 |
<scope>compile</scope> |
|
57 |
</dependency> |
|
58 |
<dependency> |
|
59 |
<groupId>org.apache.httpcomponents</groupId> |
|
60 |
<artifactId>httpclient</artifactId> |
|
61 |
<scope>runtime</scope> |
|
62 |
</dependency> |
|
63 |
<dependency> |
|
64 |
<groupId>org.gvsig</groupId> |
|
65 |
<artifactId>org.gvsig.geodb.app.mainplugin</artifactId> |
|
66 |
<scope>compile</scope> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>javax.servlet</groupId> |
|
70 |
<artifactId>javax.servlet-api</artifactId> |
|
71 |
<version>3.1.0</version> |
|
72 |
<scope>compile</scope> |
|
73 |
</dependency> |
|
74 |
|
|
75 |
</dependencies> |
|
76 |
|
|
77 |
<build> |
|
78 |
<plugins> |
|
79 |
|
|
80 |
<plugin> |
|
81 |
<groupId>org.apache.maven.plugins</groupId> |
|
82 |
<artifactId>maven-surefire-plugin</artifactId> |
|
83 |
<configuration> |
|
84 |
<systemPropertyVariables> |
|
85 |
<user.language>es</user.language> |
|
86 |
<user.region>ES</user.region> |
|
87 |
</systemPropertyVariables> |
|
88 |
<!-- Skip test execution ? --> |
|
89 |
<skipTests>true</skipTests> |
|
90 |
<!-- Ignore test execution failure ? --> |
|
91 |
<testFailureIgnore>false</testFailureIgnore> |
|
92 |
</configuration> |
|
93 |
</plugin> |
|
94 |
|
|
95 |
<!-- Skip test compilation ? --> |
|
96 |
<plugin> |
|
97 |
<groupId>org.apache.maven.plugins</groupId> |
|
98 |
<artifactId>maven-compiler-plugin</artifactId> |
|
99 |
<executions> |
|
100 |
<execution> |
|
101 |
<id>default-testCompile</id> |
|
102 |
<phase>process-test-sources</phase> |
|
103 |
<goals> |
|
104 |
<goal>testCompile</goal> |
|
105 |
</goals> |
|
106 |
<configuration> |
|
107 |
<skip>false</skip> |
|
108 |
</configuration> |
|
109 |
</execution> |
|
110 |
</executions> |
|
111 |
</plugin> |
|
112 |
|
|
113 |
</plugins> |
|
114 |
</build> |
|
115 |
|
|
116 |
</project> |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.89/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Mon Dec 12 00:06:45 CET 2022 |
|
2 |
buildNumber=99 |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.89/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.89/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/VCSGisTableInfo.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.addlayer; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.DALLocator; |
|
4 |
import org.gvsig.fmap.dal.DataManager; |
|
5 |
import org.gvsig.fmap.dal.StoresRepository; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
8 |
import org.gvsig.fmap.geom.Geometry; |
|
9 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
10 |
import org.gvsig.geodb.TableInfo; |
|
11 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
12 |
|
|
13 |
/** |
|
14 |
* |
|
15 |
* @author jjdelcerro |
|
16 |
*/ |
|
17 |
public class VCSGisTableInfo extends TableInfo { |
|
18 |
|
|
19 |
private VCSGisEntity entity; |
|
20 |
|
|
21 |
public VCSGisTableInfo(VCSGisEntity entity, JDBCStoreParameters parameters, boolean requireGeometry, boolean isView) { |
|
22 |
super(entity.getEntityName(), parameters, requireGeometry, isView); |
|
23 |
this.entity = entity; |
|
24 |
} |
|
25 |
|
|
26 |
public VCSGisEntity getEntity() { |
|
27 |
return this.entity; |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
protected void fetchFromStore() { |
|
32 |
if (this.featureType != null) { |
|
33 |
return; |
|
34 |
} |
|
35 |
try { |
|
36 |
this.featureType = entity.getFeatureType(); |
|
37 |
this.table = this.featureType.getTags().getString("Layer.name", this.table); |
|
38 |
FeatureAttributeDescriptor attr = this.featureType.getDefaultGeometryAttribute(); |
|
39 |
if (attr != null) { |
|
40 |
GeometryType geomType = attr.getGeomType(); |
|
41 |
if (geomType != null) { |
|
42 |
if (this.getGeometryType() == Geometry.TYPES.UNKNOWN) { |
|
43 |
this.setGeometryType(geomType.getType()); |
|
44 |
} |
|
45 |
if (this.getGeometrySubtype() == Geometry.SUBTYPES.UNKNOWN) { |
|
46 |
this.setGeometrySubtype(geomType.getSubType()); |
|
47 |
} |
|
48 |
} |
|
49 |
if (this.getProjection() == null) { |
|
50 |
this.setProjection(attr.getSRS()); |
|
51 |
} |
|
52 |
} |
|
53 |
if (this.readOnly == null) { |
|
54 |
this.readOnly = false; //!store.allowWrite(); |
|
55 |
} |
|
56 |
|
|
57 |
// this force calculate some required values of tableinfo |
|
58 |
this.getGeomFieldComboModel(); |
|
59 |
this.getIdFieldComboModel(); |
|
60 |
|
|
61 |
} catch (Exception ex) { |
|
62 |
LOGGER.trace("Can't get feature type.", ex); // To allow set break points |
|
63 |
} finally { |
|
64 |
|
|
65 |
} |
|
66 |
|
|
67 |
} |
|
68 |
|
|
69 |
public boolean existsDALInfo() { |
|
70 |
return true; |
|
71 |
} |
|
72 |
|
|
73 |
boolean needConnectToModel() { |
|
74 |
VCSGisEntity e = this.getEntity(); |
|
75 |
DataManager dataManager = DALLocator.getDataManager(); |
|
76 |
StoresRepository globalRepository = dataManager.getStoresRepository(); |
|
77 |
boolean connected = false; |
|
78 |
boolean hasModels = false; |
|
79 |
for (String dataModel : e.getDataModelsAsList()) { |
|
80 |
if( dataModel==null ) { |
|
81 |
continue; |
|
82 |
} |
|
83 |
hasModels = true; |
|
84 |
if( globalRepository.getSubrepository(dataModel)!=null ) { |
|
85 |
connected = true; |
|
86 |
break; |
|
87 |
} |
|
88 |
} |
|
89 |
if( !hasModels ) { |
|
90 |
return false; |
|
91 |
} |
|
92 |
return !connected; |
|
93 |
} |
|
94 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.89/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/AbstractWizardVCSGis.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.addlayer; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.Cursor; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.net.URL; |
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.Collection; |
|
10 |
import java.util.HashMap; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Map; |
|
13 |
import java.util.function.Function; |
|
14 |
import java.util.function.Predicate; |
|
15 |
import javax.swing.ImageIcon; |
|
16 |
import javax.swing.JButton; |
|
17 |
import javax.swing.JCheckBox; |
|
18 |
import javax.swing.JComboBox; |
|
19 |
import javax.swing.JComponent; |
|
20 |
import javax.swing.JLabel; |
|
21 |
import javax.swing.JList; |
|
22 |
import javax.swing.JOptionPane; |
|
23 |
import javax.swing.JTextField; |
|
24 |
import javax.swing.SwingUtilities; |
|
25 |
import javax.swing.UIManager; |
|
26 |
import javax.swing.event.ChangeEvent; |
|
27 |
import org.apache.commons.io.FilenameUtils; |
|
28 |
import org.apache.commons.lang3.StringUtils; |
|
29 |
import org.gvsig.app.gui.WizardPanel; |
|
30 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
31 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
32 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
33 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
34 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
35 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
36 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
37 |
import org.gvsig.geodb.TableInfo; |
|
38 |
import org.gvsig.geodb.TableInfoController; |
|
39 |
import org.gvsig.tools.ToolsLocator; |
|
40 |
import org.gvsig.tools.i18n.I18nManager; |
|
41 |
import org.gvsig.tools.locator.LocatorException; |
|
42 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
43 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
44 |
import org.gvsig.tools.swing.api.ToolsSwingUtils; |
|
45 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
|
46 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
|
47 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
|
48 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
49 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
50 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
51 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
52 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
53 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
54 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
|
55 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
56 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
57 |
import org.gvsig.vcsgis.swing.VCSGisEntitySelectorController; |
|
58 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_BEGIN_PROCESSING_ID; |
|
59 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_CHECK_ID; |
|
60 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_END_PROCESSING_ID; |
|
61 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_RELOAD_ID; |
|
62 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_SELECT_ID; |
|
63 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
|
64 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
|
65 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
|
66 |
import org.gvsig.vcsgis.swing.VCSGisSwingServices; |
|
67 |
import org.slf4j.Logger; |
|
68 |
import org.slf4j.LoggerFactory; |
|
69 |
|
|
70 |
/** |
|
71 |
* |
|
72 |
* @author jjdelcerro |
|
73 |
*/ |
|
74 |
@SuppressWarnings("UseSpecificCatch") |
|
75 |
public abstract class AbstractWizardVCSGis extends WizardPanel { |
|
76 |
|
|
77 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractWizardVCSGis.class); |
|
78 |
|
|
79 |
protected WizardVCSGisViewExtended view; |
|
80 |
private PickerController<VCSGisWorkspace> workspacePicker; |
|
81 |
protected Map<String, TableInfo> tablesInfo = null; |
|
82 |
private boolean processing; |
|
83 |
private TaskStatusController taskStatusController; |
|
84 |
private TableInfoController tableInfoController; |
|
85 |
private VCSGisEntitySelectorController entitySelector; |
|
86 |
|
|
87 |
private class VCSGisTableInfoController extends TableInfoController { |
|
88 |
|
|
89 |
public VCSGisTableInfoController(JButton btnDeselectAllColumns, JButton btnSelectAllColumns, JList lstColumns, JTextField txtName, JComboBox cboIdField, JComboBox cboGeometryField, JTextField txtProjection, JButton btnProjection, JTextField txtFilter, JButton btnFilter, JButton btnFilterBookmarks, JButton btnFilterHistory, JButton btnAdvancedProperties, JLabel lblReadOnlyNotification, JComponent pnlCfgActions, JButton btnChangeViewProjection, JCheckBox visible) { |
|
90 |
super(btnDeselectAllColumns, btnSelectAllColumns, lstColumns, txtName, cboIdField, cboGeometryField, txtProjection, btnProjection, txtFilter, btnFilter, btnFilterBookmarks, btnFilterHistory, btnAdvancedProperties, lblReadOnlyNotification, pnlCfgActions, btnChangeViewProjection, visible); |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public void put(TableInfo tableInfo) { |
|
95 |
if( tableInfo!=null ) { |
|
96 |
Boolean v = tableInfo.getVisible(); |
|
97 |
if( v == null ) { |
|
98 |
VCSGisEntity entity = ((VCSGisTableInfo)tableInfo).getEntity(); |
|
99 |
if( entity!=null ) { |
|
100 |
String category = getCategory(entity); |
|
101 |
boolean defaultVisibility = entity.getCategoryTags(category).getBoolean("visibility",true); |
|
102 |
tableInfo.setVisible(defaultVisibility); |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
super.put(tableInfo); |
|
107 |
} |
|
108 |
|
|
109 |
@Override |
|
110 |
protected void updateLabel(StringBuilder builder) throws LocatorException { |
|
111 |
super.updateLabel(builder); |
|
112 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
113 |
VCSGisTableInfo info = (VCSGisTableInfo) this.getTableInfo(); |
|
114 |
if( info.needConnectToModel() ) { |
|
115 |
builder.append(" - <b>"); |
|
116 |
builder.append(i18n.getTranslation("_Connect_to_model_required")); |
|
117 |
builder.append(" ("); |
|
118 |
builder.append(info.getEntity().getDataModels()); |
|
119 |
builder.append(")</b>"); |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
} |
|
124 |
|
|
125 |
public AbstractWizardVCSGis() { |
|
126 |
initComponents(); |
|
127 |
} |
|
128 |
|
|
129 |
private static void waitCursor(Component component, Runnable action) { |
|
130 |
Cursor saved_cursor = component.getCursor(); |
|
131 |
try { |
|
132 |
component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
|
133 |
action.run(); |
|
134 |
} finally { |
|
135 |
component.setCursor(saved_cursor); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
private void initComponents() { |
|
140 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
|
141 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
142 |
ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
|
143 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
144 |
|
|
145 |
this.view = new WizardVCSGisViewExtended(); |
|
146 |
// this.view.txtRepositoryInfo.setVisible(false); |
|
147 |
|
|
148 |
this.entitySelector = swingManager.createEntitySelectorController( |
|
149 |
this.view.treeTables, |
|
150 |
this.view.txtTablesFilter, |
|
151 |
this.view.btnTablesFilter); |
|
152 |
|
|
153 |
Predicate<VCSGisEntity> entitySelectorFilter = VCSGisEntitySelectorController.ALL_ENTITIES; |
|
154 |
|
|
155 |
if(this.requireGeometry()){ |
|
156 |
entitySelectorFilter = (VCSGisEntity t) -> (StringUtils.isNotBlank(t.getGeometryFieldName())); |
|
157 |
} |
|
158 |
|
|
159 |
this.entitySelector.setFilter(entitySelectorFilter); |
|
160 |
this.entitySelector.setViewFilter(entitySelectorFilter); |
|
161 |
this.entitySelector.setLabelEntityFormatter(this.getLabelEntityFormatter()); |
|
162 |
|
|
163 |
this.entitySelector.setChecksEnabled(true); |
|
164 |
|
|
165 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
|
166 |
|
|
167 |
this.taskStatusController = taskStatusManager.createTaskStatusController( |
|
168 |
this.view.lblStatusTitle, |
|
169 |
this.view.lblStatusMessages, |
|
170 |
this.view.pbStatus |
|
171 |
); |
|
172 |
this.taskStatusController.setShowCancelButton(false); |
|
173 |
this.taskStatusController.setShowRemoveTaskButton(false); |
|
174 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager()); |
|
175 |
|
|
176 |
toolsSwingManager.translate(this.view.lblColumns); |
|
177 |
toolsSwingManager.translate(this.view.lblWorkspace); |
|
178 |
toolsSwingManager.translate(this.view.lblFilter); |
|
179 |
toolsSwingManager.translate(this.view.lblGeometryField); |
|
180 |
toolsSwingManager.translate(this.view.lblIdField); |
|
181 |
toolsSwingManager.translate(this.view.lblName); |
|
182 |
toolsSwingManager.translate(this.view.lblProjection); |
|
183 |
toolsSwingManager.translate(this.view.lblTable); |
|
184 |
toolsSwingManager.translate(this.view.cboWorkspaces); |
|
185 |
toolsSwingManager.translate(this.view.btnAddWorkspace); |
|
186 |
toolsSwingManager.translate(this.view.btnCheckout); |
|
187 |
toolsSwingManager.translate(this.view.btnInitWorkspace); |
|
188 |
toolsSwingManager.translate(this.view.chkMaintainStructureInToC); |
|
189 |
toolsSwingManager.translate(this.view.btnTablesCheckAll); |
|
190 |
toolsSwingManager.translate(this.view.btnTablesUncheckAll); |
|
191 |
toolsSwingManager.translate(this.view.btnTablesCollapseAll); |
|
192 |
toolsSwingManager.translate(this.view.btnTablesExpandAll); |
|
193 |
toolsSwingManager.translate(this.view.chkCheckScale); |
|
194 |
toolsSwingManager.translate(this.view.chkAddToCWhenLoadingAll); |
|
195 |
toolsSwingManager.translate(this.view.tabTableInfo); |
|
196 |
toolsSwingManager.translate(this.view.lblVisible); |
|
197 |
|
|
198 |
this.view.btnInitWorkspace.setText(toHTML(this.view.btnInitWorkspace.getText())); |
|
199 |
// toolsSwingManager.translate(this.view.txtRepositoryInfo); |
|
200 |
|
|
201 |
toolsSwingManager.addClearButton(this.view.txtName); |
|
202 |
toolsSwingManager.setDefaultPopupMenu(this.view.txtName); |
|
203 |
|
|
204 |
this.view.btnInitWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
205 |
this.view.btnAddWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
206 |
|
|
207 |
this.workspacePicker = swingManager.createWorkspacePickerController( |
|
208 |
this.view.cboWorkspaces, |
|
209 |
this.view.btnAddWorkspace |
|
210 |
); |
|
211 |
|
|
212 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
|
213 |
waitCursor(this, () -> { |
|
214 |
doChangeWorkspace(); |
|
215 |
doUpdateComponents(); |
|
216 |
}); |
|
217 |
}); |
|
218 |
|
|
219 |
this.entitySelector.addActionListener((ActionEvent e) -> { |
|
220 |
switch(e.getID()){ |
|
221 |
case ACTION_RELOAD_ID: |
|
222 |
doReloadTablesInfo(); |
|
223 |
break; |
|
224 |
case ACTION_BEGIN_PROCESSING_ID: |
|
225 |
case ACTION_END_PROCESSING_ID: |
|
226 |
doUpdateComponents(); |
|
227 |
break; |
|
228 |
case ACTION_SELECT_ID: |
|
229 |
doChangeTableSelected(); |
|
230 |
break; |
|
231 |
case ACTION_CHECK_ID: |
|
232 |
doChangeTableChecked(); |
|
233 |
doUpdateComponents(); |
|
234 |
break; |
|
235 |
|
|
236 |
} |
|
237 |
}); |
|
238 |
this.view.btnTablesCheckAll.addActionListener((ActionEvent e) -> { |
|
239 |
// this.entitySelector.checkAll(); |
|
240 |
waitCursor(this, () -> { |
|
241 |
List<String> entityCodes = new ArrayList<>(); |
|
242 |
Collection<VCSGisEntity> entities = entitySelector.getEntities(); |
|
243 |
for (VCSGisEntity entity : entities) { |
|
244 |
if( entity instanceof VCSGisWorkspaceEntity ){ |
|
245 |
entityCodes.add(entity.getEntityCode()); |
|
246 |
} |
|
247 |
} |
|
248 |
entitySelector.setCheck(entityCodes, true); |
|
249 |
}); |
|
250 |
}); |
|
251 |
|
|
252 |
this.view.btnTablesUncheckAll.addActionListener((ActionEvent e) -> { |
|
253 |
this.entitySelector.clearChecks(); |
|
254 |
}); |
|
255 |
|
|
256 |
this.view.btnTablesCollapseAll.addActionListener((ActionEvent e) -> { |
|
257 |
this.entitySelector.collapseAll(); |
|
258 |
}); |
|
259 |
|
|
260 |
this.view.btnTablesExpandAll.addActionListener((ActionEvent e) -> { |
|
261 |
this.entitySelector.expandAll(); |
|
262 |
}); |
|
263 |
|
|
264 |
this.view.btnInitWorkspace.addActionListener((ActionEvent e) -> { |
|
265 |
doShowInitWorkspace(); |
|
266 |
}); |
|
267 |
|
|
268 |
this.view.btnCheckout.addActionListener((ActionEvent e) -> { |
|
269 |
doCheckout(); |
|
270 |
}); |
|
271 |
|
|
272 |
this.tableInfoController = new VCSGisTableInfoController( |
|
273 |
this.view.btnDeselectAllColumns, |
|
274 |
this.view.btnSelectAllColumns, |
|
275 |
this.view.lstColumns, |
|
276 |
this.view.txtName, |
|
277 |
this.view.cboIdField, |
|
278 |
this.view.cboGeometryField, |
|
279 |
this.view.txtProjection, |
|
280 |
this.view.btnProjection, |
|
281 |
this.view.txtFilter, |
|
282 |
this.view.btnFilter, |
|
283 |
this.view.btnFilterBookmarks, |
|
284 |
this.view.btnFilterHistory, |
|
285 |
this.view.btnAdvancedProperties, |
|
286 |
this.view.lblReadOnlyNotification, |
|
287 |
null, |
|
288 |
this.view.btnChangeViewProjection, |
|
289 |
this.view.chkVisible |
|
290 |
); |
|
291 |
this.view.btnChangeViewProjection.setVisible(this.requireGeometry()); |
|
292 |
|
|
293 |
this.view.btnInitWorkspace.setBackground(UIManager.getColor("Panel.background")); |
|
294 |
// this.view.txtRepositoryInfo.setBackground(UIManager.getColor("Panel.background")); |
|
295 |
|
|
296 |
this.clearTables(); |
|
297 |
|
|
298 |
this.view.chkMaintainStructureInToC.setVisible(false); |
|
299 |
this.view.chkMaintainStructureInToC.setSelected(true); |
|
300 |
|
|
301 |
this.view.chkCheckScale.setSelected(true); |
|
302 |
|
|
303 |
this.view.chkAddToCWhenLoadingAll.setSelected(true); |
|
304 |
|
|
305 |
this.setLayout(new BorderLayout()); |
|
306 |
this.add(this.view, BorderLayout.CENTER); |
|
307 |
|
|
308 |
ToolsSwingUtils.ensureRowsCols(this, 22, 90, 25, 100); |
|
309 |
doUpdateComponents(); |
|
310 |
} |
|
311 |
|
|
312 |
protected abstract boolean requireGeometry(); |
|
313 |
|
|
314 |
protected boolean maintainStructureInToC() { |
|
315 |
return this.view.chkMaintainStructureInToC.isSelected(); |
|
316 |
} |
|
317 |
|
|
318 |
protected void setVidibleMaintainStructureInToC(boolean visible) { |
|
319 |
this.view.chkMaintainStructureInToC.setVisible(visible); |
|
320 |
} |
|
321 |
|
|
322 |
protected Collection<TableInfo> getTablesInformation() { |
|
323 |
this.updateTableInfoFromUI(); |
|
324 |
if( this.tablesInfo == null ) { |
|
325 |
this.tablesInfo = new HashMap<>(); |
|
326 |
} |
|
327 |
return this.tablesInfo.values(); |
|
328 |
} |
|
329 |
|
|
330 |
private void clearTables() { |
|
331 |
this.entitySelector.clear(); |
|
332 |
this.tableInfoController.clear(); |
|
333 |
} |
|
334 |
|
|
335 |
private void doChangeWorkspace() { |
|
336 |
if (notInSwingThreadInvokeLater(this::doChangeWorkspace)) { |
|
337 |
return; |
|
338 |
} |
|
339 |
|
|
340 |
VCSGisWorkspace workspace = workspacePicker.get(); |
|
341 |
|
|
342 |
this.entitySelector.setWorkspace(workspace); |
|
343 |
// if (workspace == null) { |
|
344 |
// this.view.txtRepositoryInfo.setText(""); |
|
345 |
// return; |
|
346 |
// } |
|
347 |
// |
|
348 |
// this.view.txtRepositoryInfo.setText(workspace.getRepository().getLabel()); |
|
349 |
} |
|
350 |
|
|
351 |
private TableInfo getTableInfo(VCSGisEntity entity){ |
|
352 |
Collection<TableInfo> tablesInformation = getTablesInformation(); |
|
353 |
for (TableInfo tableInfo : tablesInformation) { |
|
354 |
VCSGisEntity tableInfoEntity = (VCSGisEntity) tableInfo.getProperty("entity"); |
|
355 |
if(tableInfoEntity!=null && StringUtils.equals(tableInfoEntity.getEntityCode(), entity.getEntityCode())){ |
|
356 |
return tableInfo; |
|
357 |
} |
|
358 |
} |
|
359 |
return null; |
|
360 |
} |
|
361 |
|
|
362 |
private void doChangeTableSelected() { |
|
363 |
if( notInSwingThreadInvokeLater(() -> {doChangeTableSelected();}) ) { |
|
364 |
return; |
|
365 |
} |
|
366 |
|
|
367 |
VCSGisEntity selected = this.entitySelector.getSelectedEntity(); |
|
368 |
if(selected == null){ |
|
369 |
this.tableInfoController.put(null); |
|
370 |
return; |
|
371 |
} |
|
372 |
TableInfo tableInfo = getTableInfo(selected); |
|
373 |
if (tableInfo != null) { |
|
374 |
this.updateTableInfoFromUI(); |
|
375 |
this.tableInfoController.put(tableInfo); |
|
376 |
this.tableInfoController.setEnabled(true); |
|
377 |
} else { |
|
378 |
this.tableInfoController.clear(); |
|
379 |
this.tableInfoController.setEnabled(false); |
|
380 |
} |
|
381 |
|
|
382 |
showMessage(""); |
|
383 |
doUpdateComponents(); |
|
384 |
} |
|
385 |
|
|
386 |
private void doChangeTableChecked() { |
|
387 |
List<VCSGisEntity> checkedEntities = this.entitySelector.getCheckedEntities(); |
|
388 |
List<String> entityCodes = new ArrayList<>(); |
|
389 |
for (VCSGisEntity checkedEntity : checkedEntities) { |
|
390 |
if( checkedEntity!=null && !(checkedEntity instanceof VCSGisWorkspaceEntity)){ |
|
391 |
entityCodes.add(checkedEntity.getEntityCode()); |
|
392 |
} |
|
393 |
} |
|
394 |
this.entitySelector.setCheck(entityCodes, false); |
|
395 |
|
|
396 |
Collection<TableInfo> tablesInformation = getTablesInformation(); |
|
397 |
for (TableInfo tableInfo : tablesInformation) { |
|
398 |
VCSGisEntity tableInfoEntity = (VCSGisEntity) tableInfo.getProperty("entity"); |
|
399 |
tableInfo.setSelected(checkedEntities.contains(tableInfoEntity)); |
|
400 |
} |
|
401 |
this.checkFinishable(); |
|
402 |
} |
|
403 |
|
|
404 |
|
|
405 |
private void updateTableInfoFromUI() { |
|
406 |
String previousId = this.tableInfoController.getId(); |
|
407 |
if (previousId == null) { |
|
408 |
return; |
|
409 |
} |
|
410 |
|
|
411 |
if (this.tablesInfo != null && !this.tablesInfo.isEmpty()) { |
|
412 |
TableInfo previousInfo = this.tablesInfo.get(previousId); |
|
413 |
if (previousInfo != null) { |
|
414 |
this.tableInfoController.fetch(previousInfo); |
|
415 |
} |
|
416 |
} |
|
417 |
} |
|
418 |
|
|
419 |
@Override |
|
420 |
public void initWizard() { |
|
421 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
422 |
setTabName(i18n.getTranslation("_VCSGis")); |
|
423 |
} |
|
424 |
|
|
425 |
@Override |
|
426 |
public boolean areSettingsValid() { |
|
427 |
if(processing){ |
|
428 |
return false; |
|
429 |
} |
|
430 |
boolean hasInvalidValues = false; |
|
431 |
boolean hasSelectedTables = false; |
|
432 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
433 |
if (tableInfo.isSelected()) { |
|
434 |
hasSelectedTables = true; |
|
435 |
if (!tableInfo.hasValidValues()) { |
|
436 |
hasInvalidValues = true; |
|
437 |
} |
|
438 |
} |
|
439 |
} |
|
440 |
return hasSelectedTables && !hasInvalidValues; |
|
441 |
} |
|
442 |
|
|
443 |
@Override |
|
444 |
public DataStoreParameters[] getParameters() { |
|
445 |
int sz = 0; |
|
446 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
447 |
if( tableInfo.isSelected() ) { |
|
448 |
sz++; |
|
449 |
} |
|
450 |
} |
|
451 |
if( sz == 0 ) { |
|
452 |
return null; |
|
453 |
} |
|
454 |
DataStoreParameters[] dbParameters = new DataStoreParameters[sz]; |
|
455 |
int n = 0; |
|
456 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
457 |
if( tableInfo.isSelected() ) { |
|
458 |
dbParameters[n++] = tableInfo.getParameters(); |
|
459 |
} |
|
460 |
} |
|
461 |
return dbParameters; |
|
462 |
} |
|
463 |
|
|
464 |
@Override |
|
465 |
public void execute() { |
|
466 |
executeWizard(); |
|
467 |
} |
|
468 |
|
|
469 |
@Override |
|
470 |
public void close() { |
|
471 |
|
|
472 |
} |
|
473 |
|
|
474 |
protected void checkFinishable() { |
|
475 |
boolean finishable = areSettingsValid(); |
|
476 |
callStateChanged(finishable); |
|
477 |
} |
|
478 |
|
|
479 |
private void doUpdateComponents() { |
|
480 |
VCSGisEntity entity = this.entitySelector.getSelectedEntity(); |
|
481 |
|
|
482 |
boolean theProcessing = this.processing || this.entitySelector.isProcessing(); |
|
483 |
|
|
484 |
VCSGisWorkspace ws = getWorkspace(); |
|
485 |
if(entity == null){ |
|
486 |
this.view.btnCheckout.setEnabled(false); |
|
487 |
this.tableInfoController.setEnabled(false); |
|
488 |
} else if(entity instanceof VCSGisWorkspaceEntity){ |
|
489 |
this.view.btnCheckout.setEnabled(false); |
|
490 |
this.tableInfoController.setEditable(!theProcessing && ws != null); |
|
491 |
this.tableInfoController.setEnabled(ws != null); |
|
492 |
} else { //Entidad de repositorio |
|
493 |
this.view.btnCheckout.setEnabled(!theProcessing && ws != null); |
|
494 |
this.tableInfoController.setEnabled(false); |
|
495 |
} |
|
496 |
|
|
497 |
this.entitySelector.setEnabled(!theProcessing && ws != null); |
|
498 |
this.view.btnTablesCheckAll.setEnabled(this.entitySelector.isEnabled()); |
|
499 |
this.view.btnTablesUncheckAll.setEnabled(this.entitySelector.isEnabled()); |
|
500 |
this.view.btnTablesCollapseAll.setEnabled(this.entitySelector.isEnabled()); |
|
501 |
this.view.btnTablesExpandAll.setEnabled(this.entitySelector.isEnabled()); |
|
502 |
this.workspacePicker.setEnabled(!theProcessing); |
|
503 |
this.view.btnInitWorkspace.setEnabled(!theProcessing); |
|
504 |
// this.view.txtRepositoryInfo.setEnabled(!theProcessing && ws != null); |
|
505 |
this.setVisibleStatus(theProcessing); |
|
506 |
this.checkFinishable(); |
|
507 |
} |
|
508 |
|
|
509 |
private void doShowInitWorkspace() { |
|
510 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
511 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
512 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
513 |
|
|
514 |
final VCSGisJInitWorkspace panelInitWorkspace = swingManager.createInitWorkspacePanel(); |
|
515 |
final Dialog dialogInitWorkspace = winManager.createDialog( |
|
516 |
panelInitWorkspace.asJComponent(), |
|
517 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
518 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
519 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
520 |
); |
|
521 |
|
|
522 |
panelInitWorkspace.setDialog(dialogInitWorkspace); |
|
523 |
dialogInitWorkspace.setButtonLabel( |
|
524 |
WindowManager_v2.BUTTON_OK, |
|
525 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy") |
|
526 |
); |
|
527 |
dialogInitWorkspace.addActionListener((ActionEvent e) -> { |
|
528 |
switch (dialogInitWorkspace.getAction()) { |
|
529 |
case WindowManager_v2.BUTTON_OK: |
|
530 |
int r = panelInitWorkspace.initializeWorkspace(); |
|
531 |
if (r != 0) { |
|
532 |
String message = "_Cant_initialize_workingcopy_{0}"; |
|
533 |
|
|
534 |
StringBuilder compoundMessage = new StringBuilder(); |
|
535 |
String[] messageArgs = new String[]{panelInitWorkspace.getWorkspaceName()}; |
|
536 |
|
|
537 |
compoundMessage.append(i18nManager.getTranslation( |
|
538 |
message, |
|
539 |
messageArgs |
|
540 |
)); |
|
541 |
|
|
542 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
543 |
dialogsManager.messageDialog( |
|
544 |
compoundMessage.toString(), |
|
545 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
546 |
JOptionPane.WARNING_MESSAGE |
|
547 |
); |
|
548 |
} |
|
549 |
|
|
550 |
break; |
|
551 |
|
|
552 |
} |
|
553 |
}); |
|
554 |
dialogInitWorkspace.show(WindowManager.MODE.DIALOG); |
|
555 |
} |
|
556 |
|
|
557 |
public VCSGisWorkspace getWorkspace() { |
|
558 |
return this.workspacePicker.get(); |
|
559 |
} |
|
560 |
|
|
561 |
private void doReloadTablesInfo() { |
|
562 |
if (notInSwingThreadInvokeLater(() -> { doReloadTablesInfo(); })) { |
|
563 |
return; |
|
564 |
} |
|
565 |
|
|
566 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
567 |
|
|
568 |
try { |
|
569 |
Collection<VCSGisEntity> entities = this.entitySelector.getEntities(); |
|
570 |
for (VCSGisEntity entity : entities) { |
|
571 |
if (entity instanceof VCSGisWorkspaceEntity) { |
|
572 |
JDBCStoreParameters parameters = getWorkspace().getExplorer().get(entity.getEntityName()); |
|
573 |
TableInfo tableInfo = new VCSGisTableInfo(entity, parameters, this.requireGeometry(), false); |
|
574 |
if(StringUtils.isNotBlank(entity.getLabel()) ) { |
|
575 |
tableInfo.setDocumentName(entity.getLabel()); |
|
576 |
} |
|
577 |
tableInfo.setProperty("entity", entity); |
|
578 |
this.tablesInfo.put(tableInfo.getId(), tableInfo); |
|
579 |
} |
|
580 |
} |
|
581 |
|
|
582 |
} catch (Exception e) { |
|
583 |
LOGGER.warn("_Cant_update_layers_list", e); |
|
584 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
585 |
dialogs.messageDialog( |
|
586 |
i18n.getTranslation("_Cant_update_layers_list") + "\n" + e.getMessage(), |
|
587 |
i18n.getTranslation("_Add_layer"), |
|
588 |
JOptionPane.WARNING_MESSAGE |
|
589 |
); |
|
590 |
} |
|
591 |
} |
|
592 |
|
|
593 |
private void doCheckout() { |
|
594 |
VCSGisWorkspace workspace = getWorkspace(); |
|
595 |
if (workspace == null) { |
|
596 |
return; |
|
597 |
} |
|
598 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
599 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
600 |
VCSGisEntity rEntity = this.entitySelector.getSelectedEntity(); |
|
601 |
if(rEntity== null || rEntity instanceof VCSGisWorkspaceEntity){ |
|
602 |
return; |
|
603 |
} |
|
604 |
final String entityName = rEntity.getEntityName(); |
|
605 |
Thread task = new Thread(() -> { |
|
606 |
try { |
|
607 |
processing = true; |
|
608 |
doUpdateComponents(); |
|
609 |
|
|
610 |
showMessage(i18n.getTranslation("_Checking_out")); |
|
611 |
int res = workspace.checkout( |
|
612 |
entityName, |
|
613 |
null, |
|
614 |
this.getTaskStatusController().getSimpleTaskStatus() |
|
615 |
); |
|
616 |
if (res != ERR_OK) { |
|
617 |
LOGGER.warn("_Cant_checkout_table"); |
|
618 |
dialogs.messageDialog( |
|
619 |
i18n.getTranslation("_Cant_checkout_table") + "\n" + workspace.getErrorMessage(res), |
|
620 |
i18n.getTranslation("_Add_table"), |
|
621 |
JOptionPane.WARNING_MESSAGE |
|
622 |
); |
|
623 |
return; |
|
624 |
} |
|
625 |
downloadAndRegisterResources(entityName); |
|
626 |
showMessage(i18n.getTranslation("_Checkout_finished")); |
|
627 |
JDBCStoreParameters parameters = getWorkspace().getExplorer().get(entityName); |
|
628 |
TableInfo tableInfo = new VCSGisTableInfo(workspace.getWorkspaceEntity(entityName), parameters, this.requireGeometry(), false); |
|
629 |
this.tablesInfo.put(tableInfo.getId(), tableInfo); |
|
630 |
doPostCheckout(entityName); |
|
631 |
} catch (Exception e) { |
|
632 |
LOGGER.warn("_Cant_add_table"); |
|
633 |
dialogs.messageDialog( |
|
634 |
i18n.getTranslation("_Cant_add_table") + "\n" + e.getMessage(), |
|
635 |
i18n.getTranslation("_Add_table"), |
|
636 |
JOptionPane.WARNING_MESSAGE |
|
637 |
); |
|
638 |
} finally { |
|
639 |
processing = false; |
|
640 |
doUpdateComponents(); |
|
641 |
} |
|
642 |
}, "VCSGisAddTableCheckout"); |
|
643 |
processing = true; |
|
644 |
doUpdateComponents(); |
|
645 |
task.start(); |
|
646 |
} |
|
647 |
|
|
648 |
private void doPostCheckout(String entityName) { |
|
649 |
if (notInSwingThreadInvokeLater(() -> { doPostCheckout(entityName); })) { |
|
650 |
return; |
|
651 |
} |
|
652 |
VCSGisWorkspace workspace = getWorkspace(); |
|
653 |
if (workspace == null) { |
|
654 |
return; |
|
655 |
} |
|
656 |
|
|
657 |
doChangeWorkspace(); |
|
658 |
this.entitySelector.setSelectedEntity(workspace.getWorkspaceEntity(entityName)); |
|
659 |
doChangeTableSelected(); |
|
660 |
} |
|
661 |
|
|
662 |
private void showMessage(String message) { |
|
663 |
if( notInSwingThreadInvokeLater(() -> {showMessage(message);}) ) { |
|
664 |
return; |
|
665 |
} |
|
666 |
this.view.lblStatusMessages.setText(message); |
|
667 |
} |
|
668 |
|
|
669 |
public boolean isProcessing() { |
|
670 |
return processing; |
|
671 |
} |
|
672 |
|
|
673 |
public void setVisibleStatus(boolean visible) { |
|
674 |
if( notInSwingThreadInvokeLater(() -> {setVisibleStatus(visible);}) ) { |
|
675 |
return; |
|
676 |
} |
|
677 |
this.view.lblStatusTitle.setVisible(visible); |
|
678 |
this.view.pbStatus.setVisible(visible); |
|
679 |
this.view.lblStatusMessages.setVisible(true); |
|
680 |
} |
|
681 |
|
|
682 |
public TaskStatusController getTaskStatusController() { |
|
683 |
return this.taskStatusController; |
|
684 |
} |
|
685 |
|
|
686 |
public static boolean notInSwingThreadInvokeLater(Runnable x) { |
|
687 |
if( SwingUtilities.isEventDispatchThread() ) { |
|
688 |
return false; |
|
689 |
} |
|
690 |
SwingUtilities.invokeLater(x); |
|
691 |
return true; |
|
692 |
} |
|
693 |
|
|
694 |
protected static class WizardVCSGisViewExtended extends AbstractWizardVCSGisView { |
|
695 |
|
|
696 |
@Override |
|
697 |
public ImageIcon loadImage(String imageName) { |
|
698 |
String name = FilenameUtils.getBaseName(imageName); |
|
699 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
|
700 |
if (theme.exists(name)) { |
|
701 |
return theme.get(name); |
|
702 |
} |
|
703 |
URL url = WizardVCSGisViewExtended.class.getResource("images/" + name + ".png"); |
|
704 |
if (url == null) { |
|
705 |
return null; |
|
706 |
} |
|
707 |
return new ImageIcon(url); |
|
708 |
} |
|
709 |
} |
|
710 |
|
|
711 |
private String toHTML(String s) { |
|
712 |
s = StringUtils.replace(s, "\n", "<br>"); |
|
713 |
s = StringUtils.replace(s, "<html>", ""); |
|
714 |
s = StringUtils.replace(s, "</html>", ""); |
|
715 |
s = "<html>"+s+"</html>"; |
|
716 |
return s; |
|
717 |
} |
|
718 |
|
|
719 |
protected void downloadAndRegisterResources(String tableName) { |
|
720 |
VCSGisWorkspace workspace = getWorkspace(); |
|
721 |
VCSGisWorkspaceEntity entity = workspace.getWorkspaceEntityByName(tableName); |
|
722 |
if(entity == null){ |
|
723 |
return; |
|
724 |
} |
|
725 |
VCSGisEntity lEntity = workspace.getEntity(entity.getEntityCode()); |
|
726 |
String resources = lEntity.getResources(); |
|
727 |
if (StringUtils.isNotBlank(resources)) { |
|
728 |
try { |
|
729 |
if (!workspace.existsInWorkspace(resources)) { |
|
730 |
workspace.checkout( |
|
731 |
resources, |
|
732 |
null |
|
733 |
); |
|
734 |
} |
|
735 |
} catch (Exception e) { |
|
736 |
LOGGER.warn("Can't checkout resources table '" + resources + "'", e); |
|
737 |
} |
|
738 |
workspace.getExplorer().setCustomResources(entity.getEntityName(), resources,true); |
|
739 |
} |
|
740 |
|
|
741 |
} |
|
742 |
|
|
743 |
@Override |
|
744 |
public void setMapContext(MapContext mapContext) { |
|
745 |
super.setMapContext(mapContext); |
|
746 |
this.tableInfoController.setMapContext(mapContext); |
|
747 |
} |
|
748 |
|
|
749 |
protected Function<VCSGisEntity,String> getLabelEntityFormatter() { |
|
750 |
return null; |
|
751 |
|
|
752 |
} |
|
753 |
|
|
754 |
protected boolean getCheckScale() { |
|
755 |
return this.view.chkCheckScale.isSelected(); |
|
756 |
} |
|
757 |
|
|
758 |
protected boolean getAddToCWhenLoadingAll() { |
|
759 |
return this.view.chkAddToCWhenLoadingAll.isSelected(); |
|
760 |
} |
|
761 |
|
|
762 |
protected String getCategory(VCSGisEntity entity) { |
|
763 |
return this.entitySelector.getCategory(entity); |
|
764 |
} |
|
765 |
|
|
766 |
protected void registerDataModelRepository(VCSGisWorkspace workspace, String dataModelName) { |
|
767 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
768 |
VCSGisSwingServices services = swingManager.getDefaultServices(); |
|
769 |
|
|
770 |
workspace.registerDataModelRepository(dataModelName); |
|
771 |
services.connectedToModel(workspace, dataModelName); |
|
772 |
} |
|
773 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.89/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/LayersWithGroup.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.addlayer; |
|
7 |
|
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.Collection; |
|
10 |
import java.util.Iterator; |
|
11 |
import java.util.LinkedHashMap; |
|
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
import org.apache.commons.lang.StringUtils; |
|
15 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
16 |
import org.gvsig.fmap.dal.exception.DataException; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
18 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
19 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
20 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
21 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
22 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
23 |
import org.gvsig.tools.util.IsEmpty; |
|
24 |
|
|
25 |
/** |
|
26 |
* |
|
27 |
* @author jjdelcerro |
|
28 |
*/ |
|
29 |
public class LayersWithGroup implements Iterable<FLayer>, IsEmpty { |
|
30 |
|
|
31 |
// private final VCSGisWorkspace workspace; |
|
32 |
private final Map<String, FLayer> treelayers; |
|
33 |
private final List<FLayer> layers; |
|
34 |
private final MapContext mapContext; |
|
35 |
|
|
36 |
public LayersWithGroup(MapContext mapContext) { |
|
37 |
// this.workspace = workspace; |
|
38 |
this.treelayers = new LinkedHashMap<>(); |
|
39 |
this.layers = new ArrayList<>(); |
|
40 |
this.mapContext = mapContext; |
|
41 |
} |
|
42 |
|
|
43 |
public synchronized void add(String groupName, String layerName, FLayer layer) { |
|
44 |
// layer.setVisible(true); |
|
45 |
layers.add(layer); |
|
46 |
if (StringUtils.isBlank(layerName)) { |
|
47 |
treelayers.put(layer.getName(), layer); |
|
48 |
return; |
|
49 |
} |
|
50 |
if (StringUtils.isBlank(groupName)) { |
|
51 |
treelayers.put(layerName, layer); |
|
52 |
return; |
|
53 |
} |
|
54 |
FLayers group = (FLayers) treelayers.get("$$" + groupName); |
|
55 |
if (group == null) { |
|
56 |
group = new FLayers(); |
|
57 |
group.setMapContext(this.mapContext); |
|
58 |
group.setName(groupName); |
|
59 |
group.setParentLayer(mapContext.getLayers()); |
|
60 |
treelayers.put("$$" + groupName, group); |
|
61 |
} |
|
62 |
group.add(layer); |
|
63 |
} |
|
64 |
|
|
65 |
public synchronized void updateMapContext(boolean maintainStructureInToC, boolean replaceLayerIfExists) { |
|
66 |
this.updateMapControl(null, maintainStructureInToC, replaceLayerIfExists); |
|
67 |
} |
|
68 |
|
|
69 |
public static final int UPDATE_MODE_REPLACE_LAYER_IF_EXISTS = 0; |
|
70 |
public static final int UPDATE_MODE_ADD_DUPLICATES = 1; |
|
71 |
public static final int UPDATE_MODE_SKIP_DUPLICATES = 2; |
|
72 |
|
|
73 |
public synchronized void updateMapControl(MapControl mapControl, boolean maintainStructureInToC, boolean replaceLayerIfExists) { |
|
74 |
updateMapControl(mapControl, maintainStructureInToC, UPDATE_MODE_REPLACE_LAYER_IF_EXISTS); |
|
75 |
} |
|
76 |
|
|
77 |
public synchronized void updateMapControl(MapControl mapControl, boolean maintainStructureInToC, int updateMode) { |
|
78 |
mapContext.beginAtomicEvent(); |
|
79 |
try { |
|
80 |
if (maintainStructureInToC) { |
|
81 |
FLayers layersToC = mapContext.getLayers(); |
|
82 |
for (FLayer aLayer : this) { |
|
83 |
if (aLayer == null) { |
|
84 |
continue; |
|
85 |
} |
|
86 |
if (aLayer instanceof FLayers) { |
|
87 |
FLayers group = (FLayers) aLayer; |
|
88 |
FLayer groupToC = layersToC.getLayer(aLayer.getName()); |
|
89 |
if (groupToC instanceof FLayers) { |
|
90 |
for (FLayer l : group) { |
|
91 |
FLyrVect ltoc = getLayer((FLayers)groupToC, (FLyrVect) l); |
|
92 |
switch(updateMode) { |
|
93 |
case UPDATE_MODE_REPLACE_LAYER_IF_EXISTS: |
|
94 |
if( ltoc == null ) { |
|
95 |
((FLayers) groupToC).add(l); |
|
96 |
} else { |
|
97 |
refreshLayer(ltoc); |
|
98 |
} |
|
99 |
break; |
|
100 |
case UPDATE_MODE_ADD_DUPLICATES: |
|
101 |
((FLayers) groupToC).add(l); |
|
102 |
break; |
|
103 |
case UPDATE_MODE_SKIP_DUPLICATES: |
|
104 |
if( ltoc == null ) { |
|
105 |
((FLayers) groupToC).add(l); |
|
106 |
} |
|
107 |
break; |
|
108 |
} |
|
109 |
// if( replaceLayerIfExists ) { |
|
110 |
// FLyrVect ltoc = getLayer((FLayers)groupToC, (FLyrVect) l); |
|
111 |
// if( ltoc != null ) { |
|
112 |
// refreshLayer(ltoc); |
|
113 |
// continue; |
|
114 |
// } |
|
115 |
// } |
|
116 |
// ((FLayers) groupToC).add(l); |
|
117 |
} |
|
118 |
} else { |
|
119 |
group.setVisible(true); |
|
120 |
addLayer(mapControl, group); |
|
121 |
} |
|
122 |
} else { |
|
123 |
FLyrVect ltoc = getLayer(layersToC, (FLyrVect) aLayer); |
|
124 |
switch(updateMode) { |
|
125 |
case UPDATE_MODE_REPLACE_LAYER_IF_EXISTS: |
|
126 |
if( ltoc == null ) { |
|
127 |
aLayer.setVisible(true); |
|
128 |
addLayer(mapControl, aLayer); |
|
129 |
} else { |
|
130 |
refreshLayer(ltoc); |
|
131 |
} |
|
132 |
break; |
|
133 |
case UPDATE_MODE_ADD_DUPLICATES: |
|
134 |
aLayer.setVisible(true); |
|
135 |
addLayer(mapControl, aLayer); |
|
136 |
break; |
|
137 |
case UPDATE_MODE_SKIP_DUPLICATES: |
|
138 |
if( ltoc == null ) { |
|
139 |
aLayer.setVisible(true); |
|
140 |
addLayer(mapControl, aLayer); |
|
141 |
} |
|
142 |
break; |
|
143 |
} |
|
144 |
// if( replaceLayerIfExists ) { |
|
145 |
// FLyrVect ltoc = getLayer(layersToC, (FLyrVect) aLayer); |
|
146 |
// if( ltoc != null ) { |
|
147 |
// refreshLayer(ltoc); |
|
148 |
// continue; |
|
149 |
// } |
|
150 |
// } |
|
151 |
// aLayer.setVisible(true); |
|
152 |
// addLayer(mapControl, aLayer); |
|
153 |
} |
|
154 |
} |
|
155 |
} else { |
|
156 |
for (FLayer aLayer : this.allLayers()) { |
|
157 |
addLayer(mapControl, aLayer); |
|
158 |
} |
|
159 |
} |
|
160 |
} finally { |
|
161 |
mapContext.endAtomicEvent(); |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
private void refreshLayer(FLyrVect layer) { |
|
166 |
try { |
|
167 |
FeatureStore store = layer.getFeatureStore(); |
|
168 |
if( store!=null ) { |
|
169 |
store.refresh(); |
|
170 |
} |
|
171 |
} catch (DataException ex) { |
|
172 |
|
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
private FLyrVect getLayer(FLayers group, FLyrVect layer) { |
|
177 |
FeatureStore store = ((FLyrVect) layer).getFeatureStore(); |
|
178 |
DataStoreParameters params = ((FLyrVect) layer).getDataStoreParameters(); |
|
179 |
for (FLayer layer1 : group) { |
|
180 |
if( layer1 instanceof FLyrVect ) { |
|
181 |
FeatureStore store1 = ((FLyrVect) layer1).getFeatureStore(); |
|
182 |
if( store1==null || store == null ) { |
|
183 |
if( ((FLyrVect)layer1).getDataStoreParameters().isTheSameStore(params) ) { |
|
184 |
return (FLyrVect) layer1; |
|
185 |
} |
|
186 |
} else { |
|
187 |
if( StringUtils.equals(store1.getFullName(), store.getFullName() )) { |
|
188 |
return (FLyrVect) layer1; |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
return null; |
|
194 |
} |
|
195 |
|
|
196 |
private void addLayer(MapControl mapControl, FLayer layer) { |
|
197 |
if( mapControl != null ) { |
|
198 |
mapControl.addLayer(layer); |
|
199 |
return; |
|
200 |
} |
|
201 |
this.mapContext.getLayers().add(layer); |
|
202 |
if( !this.mapContext.hasActiveLayers() ) { |
|
203 |
layer.setActive(true); |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
public synchronized void disposeLayers() { |
|
208 |
for (FLayer layer : this) { |
|
209 |
layer.dispose(); |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
213 |
@Override |
|
214 |
public boolean isEmpty() { |
|
215 |
return this.treelayers.isEmpty(); |
|
216 |
} |
|
217 |
|
|
218 |
@Override |
|
219 |
public Iterator<FLayer> iterator() { |
|
220 |
return this.treelayers.values().iterator(); |
|
221 |
} |
|
222 |
|
|
223 |
public Collection<FLayer> allLayers() { |
|
224 |
return this.layers; |
|
225 |
} |
|
226 |
|
|
227 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.89/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.util.ArrayList; |
|
4 |
import java.util.Comparator; |
|
5 |
import java.util.List; |
|
6 |
import java.util.function.Function; |
|
7 |
import javax.swing.JOptionPane; |
|
8 |
import javax.swing.SwingUtilities; |
|
9 |
import org.apache.commons.lang.StringUtils; |
|
10 |
import org.cresques.cts.IProjection; |
|
11 |
import org.gvsig.fmap.dal.DALLocator; |
|
12 |
import org.gvsig.fmap.dal.DataManager; |
|
13 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
14 |
import org.gvsig.fmap.dal.StoresRepository; |
|
15 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
16 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
|
17 |
import org.gvsig.fmap.geom.Geometry; |
|
18 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
19 |
import org.gvsig.fmap.mapcontext.BaseCreateLayerParameters; |
|
20 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
21 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
22 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
23 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
24 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
25 |
import org.gvsig.geodb.TableInfo; |
|
26 |
import static org.gvsig.geodb.vectorialdb.visibility.LayerScaleVisibilityUtils.checkForVisibilityScale; |
|
27 |
import org.gvsig.tools.ToolsLocator; |
|
28 |
import org.gvsig.tools.i18n.I18nManager; |
|
29 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
30 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
31 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
32 |
import static org.gvsig.vcsgis.app.addlayer.AbstractWizardVCSGis.LOGGER; |
|
33 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
34 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
35 |
|
|
36 |
/** |
|
37 |
* |
|
38 |
* @author gvSIG Team |
|
39 |
*/ |
|
40 |
@SuppressWarnings("UseSpecificCatch") |
|
41 |
public class WizardVCSGisVectorial extends AbstractWizardVCSGis { |
|
42 |
|
|
43 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
|
44 |
public WizardVCSGisVectorial() { |
|
45 |
super(); |
|
46 |
this.setVidibleMaintainStructureInToC(true); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected boolean requireGeometry() { |
|
51 |
return true; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public Object executeWizard() { |
|
56 |
DataManager man = DALLocator.getDataManager(); |
|
57 |
MapContextManager mapContextManager = MapContextLocator.getMapContextManager(); |
|
58 |
|
|
59 |
MapControl mapControl = this.getMapCtrl(); |
|
60 |
MapContext mapContext = mapControl.getMapContext(); |
|
61 |
|
|
62 |
LayersWithGroup layers = new LayersWithGroup(mapContext); |
|
63 |
VCSGisWorkspace workspace = this.getWorkspace(); |
|
64 |
boolean checkScale = this.getCheckScale(); |
|
65 |
boolean addToCWhenLoadingAll = this.getAddToCWhenLoadingAll(); |
|
66 |
|
|
67 |
for (TableInfo tableInfo : getTablesInformation()) { |
|
68 |
if (!tableInfo.isSelected()) { |
|
69 |
continue; |
|
70 |
} |
|
71 |
if( ((VCSGisTableInfo)tableInfo).needConnectToModel() ) { |
|
72 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
73 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
74 |
int n = dialogs.confirmDialog( |
|
75 |
i18n.getTranslation("_Some_of_the_selected_tables_require_connection_to_a_data_model") + |
|
76 |
"\n" + |
|
77 |
i18n.getTranslation("_It_is_recommended_that_you_connect_to_the_data_model_before_loading_the_tables") + |
|
78 |
"\n" + |
|
79 |
i18n.getTranslation("_Do_you_want_to_add_the_selected_tables_anyway"), |
|
80 |
i18n.getTranslation("_AddLayer"), |
|
81 |
JOptionPane.YES_NO_OPTION, |
|
82 |
JOptionPane.QUESTION_MESSAGE, |
|
83 |
"_Some_of_the_selected_tables_require_connection_to_a_data_model" |
|
84 |
); |
|
85 |
if( n != JOptionPane.YES_OPTION ) { |
|
86 |
return null; |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
Thread th = new Thread(() -> { |
|
92 |
SimpleTaskStatus taskstatus = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus("Loading layers"); |
|
93 |
taskstatus.setIndeterminate(); |
|
94 |
taskstatus.setAutoremove(true); |
|
95 |
taskstatus.add(); |
|
96 |
try { |
|
97 |
List<VCSGisTableInfo> tablesInformation = new ArrayList<>(); |
|
98 |
for (TableInfo tableInfo : getTablesInformation()) { |
|
99 |
if (!tableInfo.isSelected()) { |
|
100 |
continue; |
|
101 |
} |
|
102 |
tablesInformation.add((VCSGisTableInfo) tableInfo); |
|
103 |
} |
|
104 |
tablesInformation.sort(new Comparator<VCSGisTableInfo>() { |
|
105 |
@Override |
|
106 |
public int compare(VCSGisTableInfo o1, VCSGisTableInfo o2) { |
|
107 |
if( o1==null || o2==null ) { |
|
108 |
return 0; |
|
109 |
} |
|
110 |
VCSGisEntity e1 = o1.getEntity(); |
|
111 |
VCSGisEntity e2 = o2.getEntity(); |
|
112 |
if( e1==null || e2==null ) { |
|
113 |
return 0; |
|
114 |
} |
|
115 |
FeatureType ft1 = o1.getFeatureType(); |
|
116 |
FeatureType ft2 = o2.getFeatureType(); |
|
117 |
int order1 = (ft1==null)? 0:ft1.getTags().getInt("TOC_Order",0); |
|
118 |
int order2 = (ft2==null)? 0:ft2.getTags().getInt("TOC_Order",0); |
|
119 |
String id1 = String.format("%05d/%02d/%s/%s", order1, getLayerOrderWeight(e1), getCategory(e1), e1.getLabelOrName()); |
|
120 |
String id2 = String.format("%05d/%02d/%s/%s", order2, getLayerOrderWeight(e2), getCategory(e2), e2.getLabelOrName()); |
|
121 |
return id2.compareTo(id1); |
|
122 |
} |
|
123 |
}); |
|
124 |
|
|
125 |
List<String> dataModels = new ArrayList<>(); |
|
126 |
for (VCSGisTableInfo tableInfo : tablesInformation) { |
|
127 |
VCSGisEntity entity = tableInfo.getEntity(); |
|
128 |
List<String> entityModels = entity.getDataModelsAsList(); |
|
129 |
if( entityModels!=null ) { |
|
130 |
for (String entityModel : entityModels) { |
|
131 |
dataModels.add(entityModel); |
|
132 |
} |
|
133 |
} |
|
134 |
} |
|
135 |
if( !dataModels.isEmpty() ) { |
|
136 |
for (StoresRepository storesRepository : man.getStoresRepository().getSubrepositories() ) { |
|
137 |
dataModels.remove(storesRepository.getID()); |
|
138 |
} |
|
139 |
for (String dataModel : dataModels) { |
|
140 |
registerDataModelRepository(workspace, dataModel); |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
taskstatus.setRangeOfValues(0, tablesInformation.size()); |
|
145 |
FLayer layer; |
|
146 |
for (VCSGisTableInfo tableInfo : tablesInformation) { |
|
147 |
if( taskstatus.isCancellationRequested() ) { |
|
148 |
taskstatus.cancel(); |
|
149 |
return; |
|
150 |
} |
|
151 |
taskstatus.message(tableInfo.getEntity().getLabelOrName()); |
|
152 |
LOGGER.info("Load layer '"+tableInfo.getId()+"'"); |
|
153 |
DBStoreParameters params = tableInfo.getParameters(); |
|
154 |
VCSGisEntity entity = tableInfo.getEntity(); |
|
155 |
List<String> entityModels = entity.getDataModelsAsList(); |
|
156 |
if( entityModels!=null ) { |
|
157 |
for (String entityModel : entityModels) { |
|
158 |
dataModels.add(entityModel); |
|
159 |
} |
|
160 |
} |
|
161 |
String category = this.getCategory(entity); |
|
162 |
fixCRS(params); |
|
163 |
|
|
164 |
if( tableInfo.getVisible()==null ) { |
|
165 |
tableInfo.setVisible(entity.getCategoryTags(category).getBoolean("visibility", true)); |
|
166 |
} |
|
167 |
boolean defaultVisibility = tableInfo.getVisible(); |
|
168 |
|
|
169 |
// FeatureStore store; |
|
170 |
// try { |
|
171 |
// store = (FeatureStore) man.openStore( |
|
172 |
// params.getDataStoreName(), |
|
173 |
// params |
|
174 |
// ); |
|
175 |
// } catch (Exception e) { |
|
176 |
// LOGGER.warn("While opening DB store.", e); |
|
177 |
// taskstatus.abort(); |
|
178 |
// return; |
|
179 |
// } |
|
180 |
try { |
|
181 |
|
|
182 |
layer = mapContextManager.createLayer( |
|
183 |
tableInfo.getDocumentName(), |
|
184 |
new BaseCreateLayerParameters(params, defaultVisibility) |
|
185 |
); |
|
186 |
// layer = mapContextManager.createLayer( |
|
187 |
// tableInfo.getDocumentName(), |
|
188 |
// store |
|
189 |
// ); |
|
190 |
if( defaultVisibility ) { |
|
191 |
checkForVisibilityScale(layer, checkScale); |
|
192 |
} |
|
193 |
|
|
194 |
String tableName = params.getTable(); |
|
195 |
if (StringUtils.isBlank(tableName)) { |
|
196 |
layers.add(null, null, layer); |
|
197 |
} else { |
|
198 |
if (workspace.getWorkspaceEntityByName(tableName) == null) { |
|
199 |
layers.add(null, tableName, layer); |
|
200 |
} else { |
Also available in: Unified diff