Revision 5168
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.40/org.gvsig.vcsgis.app/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</artifactId> |
|
6 |
<version>1.0.40</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.vcsgis.app</artifactId> |
|
9 |
<packaging>pom</packaging> |
|
10 |
<name>${project.artifactId}</name> |
|
11 |
<modules> |
|
12 |
<module>org.gvsig.vcsgis.app.mainplugin</module> |
|
13 |
<module>org.gvsig.vcsgis.app.server</module> |
|
14 |
</modules> |
|
15 |
|
|
16 |
</project> |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.40/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Mon Dec 20 08:21:46 CET 2021 |
|
2 |
buildNumber=48 |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.40/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/FeatureStoresTreeModel.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.vcsgis.app; |
|
7 |
|
|
8 |
import java.util.HashMap; |
|
9 |
import java.util.Map; |
|
10 |
import javax.swing.Icon; |
|
11 |
import javax.swing.ImageIcon; |
|
12 |
import javax.swing.event.TreeModelListener; |
|
13 |
import javax.swing.tree.TreeModel; |
|
14 |
import javax.swing.tree.TreePath; |
|
15 |
import org.gvsig.app.ApplicationLocator; |
|
16 |
import org.gvsig.fmap.dal.DataStore; |
|
17 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
18 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
19 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
20 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
|
21 |
import org.gvsig.fmap.mapcontext.layers.vectorial.VectorLayer; |
|
22 |
import org.gvsig.fmap.mapcontrol.LayersTreeModel; |
|
23 |
import org.gvsig.tools.evaluator.Evaluator; |
|
24 |
import org.gvsig.tools.evaluator.EvaluatorData; |
|
25 |
import org.gvsig.tools.evaluator.EvaluatorException; |
|
26 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
|
27 |
import org.gvsig.tools.swing.api.IconGetter; |
|
28 |
import org.gvsig.tools.swing.api.ListElement; |
|
29 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
* @author fdiaz |
|
35 |
*/ |
|
36 |
public class FeatureStoresTreeModel implements TreeModel, IconGetter { |
|
37 |
|
|
38 |
private final LayersTreeModel delegated; |
|
39 |
private final ListElement<Object> root; |
|
40 |
private final Map<Object,Icon> icons; |
|
41 |
|
|
42 |
public FeatureStoresTreeModel() { |
|
43 |
this.delegated = (LayersTreeModel) ApplicationLocator.getApplicationManager().createProjectLayersTreeModel(); |
|
44 |
this.icons = new HashMap<>(); |
|
45 |
this.delegated.setFilter(new Evaluator() { |
|
46 |
@Override |
|
47 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
48 |
FLayer layer = (FLayer) data.getDataValue("layer"); |
|
49 |
return (layer instanceof VectorLayer); |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public String getName() { |
|
54 |
return "VectorialLayersFilter"; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public String getDescription() { |
|
59 |
return null; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public String getSQL() { |
|
64 |
return null; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public EvaluatorFieldsInfo getFieldsInfo() { |
|
69 |
return null; |
|
70 |
} |
|
71 |
}); |
|
72 |
this.root = new ListElement<>("Project", this.delegated.getRoot()); |
|
73 |
} |
|
74 |
|
|
75 |
private Object getNode(Object value) { |
|
76 |
if( value instanceof ListElement ) { |
|
77 |
return ((ListElement) value).getValue(); |
|
78 |
} |
|
79 |
return value; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public Object getRoot() { |
|
84 |
return this.root; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public Object getChild(Object parent, int index) { |
|
89 |
parent = this.getNode(parent); |
|
90 |
Object x = this.delegated.getChild(parent, index); |
|
91 |
if( x instanceof VectorLayer ) { |
|
92 |
SingleLayer layer = (SingleLayer)x; |
|
93 |
DataStore store = (DataStore) layer.getDataStore(); |
|
94 |
return store; |
|
95 |
} |
|
96 |
return x; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public int getChildCount(Object parent) { |
|
101 |
parent = this.getNode(parent); |
|
102 |
return this.delegated.getChildCount(parent); |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public boolean isLeaf(Object node) { |
|
107 |
node = this.getNode(node); |
|
108 |
return this.delegated.isLeaf(node); |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public void valueForPathChanged(TreePath path, Object newValue) { |
|
113 |
this.delegated.valueForPathChanged(path, newValue); |
|
114 |
} |
|
115 |
|
|
116 |
@Override |
|
117 |
public int getIndexOfChild(Object parent, Object child) { |
|
118 |
parent = this.getNode(parent); |
|
119 |
return this.delegated.getIndexOfChild(parent, child); |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public void addTreeModelListener(TreeModelListener l) { |
|
124 |
this.delegated.addTreeModelListener(l); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public void removeTreeModelListener(TreeModelListener l) { |
|
129 |
this.delegated.removeTreeModelListener(l); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public Icon getIcon(Object item) { |
|
134 |
if( !this.icons.containsKey(item) ) { |
|
135 |
String iconName; |
|
136 |
if( item instanceof DataStore ) { |
|
137 |
iconName = MapContextLocator.getMapContextManager().getIconLayer((DataStore)item); |
|
138 |
} else if( item instanceof FLayers ) { |
|
139 |
FLayers layers = (FLayers) item; |
|
140 |
if( layers.getParentLayer()!=null && layers.getParentLayer().getParentLayer()==null ) { |
|
141 |
iconName = "view-navigation-zoom-all"; |
|
142 |
} else { |
|
143 |
iconName = "layer-icon-group"; |
|
144 |
} |
|
145 |
} else if( item == root ) { |
|
146 |
iconName = "common-folder-open"; |
|
147 |
} else { |
|
148 |
iconName = "common-leaf"; |
|
149 |
} |
|
150 |
ImageIcon icon = ToolsSwingLocator.getIconThemeManager().getCurrent().get(iconName); |
|
151 |
this.icons.put(item, icon); |
|
152 |
} |
|
153 |
return this.icons.get(item); |
|
154 |
} |
|
155 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.40/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/VCSGisSwingServicesImpl.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.vcsgis.app; |
|
7 |
|
|
8 |
import java.io.File; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.HashMap; |
|
11 |
import java.util.HashSet; |
|
12 |
import java.util.Iterator; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Map; |
|
15 |
import java.util.Set; |
|
16 |
import javax.json.JsonArray; |
|
17 |
import javax.json.JsonObject; |
|
18 |
import javax.json.JsonValue; |
|
19 |
import javax.swing.ComboBoxModel; |
|
20 |
import javax.swing.DefaultComboBoxModel; |
|
21 |
import javax.swing.DefaultListModel; |
|
22 |
import javax.swing.Icon; |
|
23 |
import javax.swing.ListModel; |
|
24 |
import javax.swing.tree.TreeModel; |
|
25 |
import org.apache.commons.lang3.StringUtils; |
|
26 |
import org.gvsig.andami.PluginsLocator; |
|
27 |
import org.gvsig.app.ApplicationLocator; |
|
28 |
import org.gvsig.app.ApplicationManager; |
|
29 |
import org.gvsig.app.project.Project; |
|
30 |
import org.gvsig.app.project.ProjectManager; |
|
31 |
import org.gvsig.app.project.documents.Document; |
|
32 |
import org.gvsig.app.project.documents.DocumentManager; |
|
33 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
34 |
import org.gvsig.app.project.documents.table.TableManager; |
|
35 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
36 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
37 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
38 |
import org.gvsig.fmap.dal.DALLocator; |
|
39 |
import org.gvsig.fmap.dal.DataManager; |
|
40 |
import org.gvsig.fmap.dal.exception.DataException; |
|
41 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
42 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
|
43 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
44 |
import org.gvsig.fmap.geom.Geometry; |
|
45 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
|
46 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
47 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
|
48 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
49 |
import org.gvsig.fmap.geom.primitive.Point; |
|
50 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
51 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
52 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
53 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
54 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
55 |
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer; |
|
56 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
57 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2; |
|
58 |
import org.gvsig.json.Json; |
|
59 |
import org.gvsig.json.JsonArrayBuilder; |
|
60 |
import org.gvsig.json.JsonObjectBuilder; |
|
61 |
import org.gvsig.tools.ToolsLocator; |
|
62 |
import org.gvsig.tools.i18n.I18nManager; |
|
63 |
import org.gvsig.tools.util.LabeledValue; |
|
64 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
65 |
import org.gvsig.vcsgis.app.addlayer.LayersWithGroup; |
|
66 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
67 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
68 |
import org.gvsig.vcsgis.lib.VCSGisRuntimeException; |
|
69 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
70 |
import org.gvsig.vcsgis.swing.VCSGisSwingServices; |
|
71 |
import org.slf4j.LoggerFactory; |
|
72 |
|
|
73 |
/** |
|
74 |
* |
|
75 |
* @author gvSIG Team |
|
76 |
*/ |
|
77 |
@SuppressWarnings("UseSpecificCatch") |
|
78 |
public class VCSGisSwingServicesImpl implements VCSGisSwingServices { |
|
79 |
|
|
80 |
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(VCSGisSwingServicesImpl.class); |
|
81 |
|
|
82 |
private static final String VCSGISMODELS_PROJECT_PROPERTY = "VCSGisModels"; |
|
83 |
|
|
84 |
private Map<Integer,ISymbol> highlightedPolygonSymbols; |
|
85 |
private Map<Integer,ISymbol> highlightedLineSymbols; |
|
86 |
private Map<Integer,ISymbol> highlightedPointSymbols; |
|
87 |
|
|
88 |
@Override |
|
89 |
public TreeModel getFeatureStoresTreeModel() { |
|
90 |
return new FeatureStoresTreeModel(); |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public ListModel getFeatureStoresListModel() { |
|
95 |
DefaultListModel<FeatureStore> model = new DefaultListModel(); |
|
96 |
|
|
97 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
98 |
Project project = appManager.getCurrentProject(); |
|
99 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
100 |
for (Document document : tables) { |
|
101 |
TableDocument table = (TableDocument) document; |
|
102 |
model.addElement(table.getFeatureStore()); |
|
103 |
} |
|
104 |
|
|
105 |
return model; |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public void addTableToProject(VCSGisWorkspace ws, FeatureStore store) { |
|
110 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
111 |
|
|
112 |
DocumentManager tableManager = appManager.getProjectManager().getDocumentManager( |
|
113 |
TableManager.TYPENAME |
|
114 |
); |
|
115 |
|
|
116 |
Project project = appManager.getCurrentProject(); |
|
117 |
TableDocument tableDoc = (TableDocument) tableManager.createDocument(); |
|
118 |
|
|
119 |
tableDoc.setName(store.getName()); |
|
120 |
tableDoc.setStore(store); |
|
121 |
project.addDocument(tableDoc); |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public ComboBoxModel getViewDocumentsComboBoxModel() { |
|
126 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
127 |
DefaultComboBoxModel<LabeledValue> model = new DefaultComboBoxModel(); |
|
128 |
model.addElement(new LabeledValueImpl(i18n.getTranslation("_Select_a_view"), null)); |
|
129 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
130 |
Project project = appManager.getCurrentProject(); |
|
131 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
132 |
for (Document document : views) { |
|
133 |
ViewDocument view = (ViewDocument) document; |
|
134 |
model.addElement(new LabeledValueImpl(view.getName(), view)); |
|
135 |
} |
|
136 |
return model; |
|
137 |
} |
|
138 |
|
|
139 |
// @Override |
|
140 |
// public void addLayerToView(FeatureStore store, LabeledValue labeledView) { |
|
141 |
// addLayerToView(store, labeledView, null, null, false); |
|
142 |
// } |
|
143 |
// |
|
144 |
@Override |
|
145 |
public void addLayerToView(FeatureStore store, LabeledValue labeledView, String groupName, String name, boolean replaceLayerIfExists) { |
|
146 |
ViewDocument view; |
|
147 |
if( labeledView == null ) { |
|
148 |
view = null; |
|
149 |
} else if (labeledView.getValue() == null){ |
|
150 |
view = null; |
|
151 |
} else { |
|
152 |
view = (ViewDocument) labeledView.getValue(); |
|
153 |
} |
|
154 |
addLayerToView(store, view, groupName, name, replaceLayerIfExists); |
|
155 |
} |
|
156 |
|
|
157 |
|
|
158 |
private void addLayerToView(FeatureStore store, ViewDocument view, String groupName, String name, boolean replaceLayerIfExists) { |
|
159 |
try { |
|
160 |
if( store == null ) { |
|
161 |
return; |
|
162 |
} |
|
163 |
if( view==null ) { |
|
164 |
IView viewWin = getActiveView(); |
|
165 |
if(viewWin == null){ |
|
166 |
return; |
|
167 |
} |
|
168 |
view = viewWin.getViewDocument(); |
|
169 |
} |
|
170 |
String layerName = name; |
|
171 |
if(StringUtils.isBlank(layerName)){ |
|
172 |
layerName = store.getName(); |
|
173 |
} |
|
174 |
FLayer layer = MapContextLocator.getMapContextManager().createLayer(layerName, store); |
|
175 |
LayersWithGroup helper = new LayersWithGroup(view.getMapContext()); |
|
176 |
helper.add(groupName, name, layer); |
|
177 |
helper.updateMapContext(true, replaceLayerIfExists); |
|
178 |
} catch (Exception ex) { |
|
179 |
VCSGisManager manager = VCSGisLocator.getManager(); |
|
180 |
throw new VCSGisRuntimeException( |
|
181 |
VCSGisManager.ERR_CANT_ADD_LAYER, |
|
182 |
manager.getErrorMessage(VCSGisManager.ERR_CANT_ADD_LAYER), |
|
183 |
ex); |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
@Override |
|
188 |
public void highlight(int mode, Geometry geom) { |
|
189 |
highlight(mode, geom, null); |
|
190 |
} |
|
191 |
|
|
192 |
@Override |
|
193 |
public void highlight(int mode, Geometry geom, FeatureStore store) { |
|
194 |
if (this.highlightedPointSymbols == null) { |
|
195 |
this.highlightedPointSymbols = new HashMap<>(); |
|
196 |
this.highlightedLineSymbols = new HashMap<>(); |
|
197 |
this.highlightedPolygonSymbols = new HashMap<>(); |
|
198 |
try { |
|
199 |
File pluginfolder = PluginsLocator.getManager().getPlugin(this).getPluginDirectory(); |
|
200 |
File folder = new File(pluginfolder, "symbols"); |
|
201 |
ISymbol[] symbols = MapContextLocator.getSymbolManager().loadSymbols(folder); |
|
202 |
for (ISymbol symbol : symbols) { |
|
203 |
if (symbol instanceof ISymbol_v2) { |
|
204 |
String symbolid = ((ISymbol_v2) symbol).getID(); |
|
205 |
switch(symbolid) { |
|
206 |
case "vcsgis-repository-polygon": |
|
207 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
208 |
break; |
|
209 |
case "vcsgis-repository-line": |
|
210 |
this.highlightedLineSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
211 |
break; |
|
212 |
case "vcsgis-repository-point": |
|
213 |
this.highlightedPointSymbols.put(HIGHLIGHT_REPOSITORY, symbol); |
|
214 |
break; |
|
215 |
|
|
216 |
case "vcsgis-workspace-polygon": |
|
217 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
218 |
break; |
|
219 |
case "vcsgis-workspace-line": |
|
220 |
this.highlightedLineSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
221 |
break; |
|
222 |
case "vcsgis-workspace-point": |
|
223 |
this.highlightedPointSymbols.put(HIGHLIGHT_WORKSPACE, symbol); |
|
224 |
break; |
|
225 |
|
|
226 |
case "vcsgis-workspace-previous-polygon": |
|
227 |
this.highlightedPolygonSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
228 |
break; |
|
229 |
case "vcsgis-workspace-previous-line": |
|
230 |
this.highlightedLineSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
231 |
break; |
|
232 |
case "vcsgis-workspace-previous-point": |
|
233 |
this.highlightedPointSymbols.put(HIGHLIGHT_WORKSPACE_PREVIOUS, symbol); |
|
234 |
break; |
|
235 |
} |
|
236 |
} |
|
237 |
} |
|
238 |
} catch (Exception ex) { |
|
239 |
} |
|
240 |
} |
|
241 |
List<ViewDocument> viewList; |
|
242 |
if(store == null){ |
|
243 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
244 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
245 |
viewList = new ArrayList<>(); |
|
246 |
viewList.add(viewdoc); |
|
247 |
} else { |
|
248 |
viewList = getViewDocumentsHavingAStore(store); |
|
249 |
} |
|
250 |
for (ViewDocument viewDoc : viewList) { |
|
251 |
MapContext mapContext = viewDoc.getMapContext(); |
|
252 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
253 |
if (geom != null) { |
|
254 |
ISymbol symbol = null; |
|
255 |
if (geom instanceof Point || geom instanceof MultiPoint) { |
|
256 |
symbol = this.highlightedPointSymbols.get(mode); |
|
257 |
} else if (geom instanceof Curve || geom instanceof MultiCurve) { |
|
258 |
symbol = this.highlightedLineSymbols.get(mode); |
|
259 |
} else if (geom instanceof Surface || geom instanceof MultiSurface) { |
|
260 |
symbol = this.highlightedPolygonSymbols.get(mode); |
|
261 |
} |
|
262 |
if (symbol != null) { |
|
263 |
int symbolid = gl.getSymbolId(symbol); |
|
264 |
if (symbolid < 0) { |
|
265 |
gl.addSymbol(symbol); |
|
266 |
symbolid = gl.getSymbolId(symbol); |
|
267 |
} |
|
268 |
gl.addGraphic("vcsgis-highlighted", geom, symbolid); |
|
269 |
} |
|
270 |
} |
|
271 |
mapContext.invalidate(); |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
@Override |
|
276 |
public void centerActiveViewToGeometry(Geometry geometry) { |
|
277 |
if(geometry != null){ |
|
278 |
IView view = getActiveView(); |
|
279 |
if(view != null){ |
|
280 |
ViewDocument viewDocument = view.getViewDocument(); |
|
281 |
viewDocument.center(geometry.getEnvelope()); |
|
282 |
} |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
@Override |
|
287 |
public void centerViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) { |
|
288 |
if(geometry != null){ |
|
289 |
List<ViewDocument> views = getViewDocumentsHavingAStore(store); |
|
290 |
for (ViewDocument view : views) { |
|
291 |
if(view != null){ |
|
292 |
view.center(geometry.getEnvelope()); |
|
293 |
} |
|
294 |
} |
|
295 |
} |
|
296 |
} |
|
297 |
|
|
298 |
@Override |
|
299 |
public void zoomActiveViewToGeometry(Geometry geometry) { |
|
300 |
if(geometry != null){ |
|
301 |
IView view = getActiveView(); |
|
302 |
if(view != null){ |
|
303 |
ViewDocument viewDocument = view.getViewDocument(); |
|
304 |
viewDocument.getMapContext().getViewPort().setEnvelope(geometry.getEnvelope()); |
|
305 |
} |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
@Override |
|
310 |
public void zoomViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) { |
|
311 |
if(geometry != null){ |
|
312 |
List<ViewDocument> views = getViewDocumentsHavingAStore(store); |
|
313 |
for (ViewDocument view : views) { |
|
314 |
if(view != null){ |
|
315 |
view.getMapContext().getViewPort().setEnvelope(geometry.getEnvelope()); |
|
316 |
} |
|
317 |
} |
|
318 |
} |
|
319 |
} |
|
320 |
|
|
321 |
private IView getActiveView() { |
|
322 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
323 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
324 |
return view; |
|
325 |
} |
|
326 |
|
|
327 |
@Override |
|
328 |
public void cleanHighligthed() { |
|
329 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
330 |
ProjectManager projectManager = application.getProjectManager(); |
|
331 |
Project project = projectManager.getCurrentProject(); |
|
332 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
333 |
for (Document doc : views) { |
|
334 |
ViewDocument viewdoc = (ViewDocument)doc; |
|
335 |
MapContext mapContext = viewdoc.getMapContext(); |
|
336 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
337 |
//FIXME: Refrescar el mapContext solo cuando se ha borrado el graphics |
|
338 |
if(gl.removeGraphics("vcsgis-highlighted")) { |
|
339 |
mapContext.invalidate(); |
|
340 |
} |
|
341 |
} |
|
342 |
} |
|
343 |
|
|
344 |
@Override |
|
345 |
public void cleanActiveViewHighligthed() { |
|
346 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
347 |
ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
348 |
if(viewdoc != null){ |
|
349 |
MapContext mapContext = viewdoc.getMapContext(); |
|
350 |
GraphicLayer gl = mapContext.getGraphicsLayer(); |
|
351 |
gl.removeGraphics("vcsgis-highlighted"); |
|
352 |
mapContext.invalidate(); |
|
353 |
} |
|
354 |
} |
|
355 |
|
|
356 |
@Override |
|
357 |
public void refreshDocument(FeatureStore store){ |
|
358 |
if(store == null){ |
|
359 |
return; |
|
360 |
} |
|
361 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
362 |
ProjectManager projectManager = application.getProjectManager(); |
|
363 |
Project project = projectManager.getCurrentProject(); |
|
364 |
|
|
365 |
String storeFullName = store.getFullName(); |
|
366 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
367 |
for (Document doc : views) { |
|
368 |
ViewDocument view = (ViewDocument)doc; |
|
369 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
370 |
FLayer layer = it.next(); |
|
371 |
if(layer instanceof FLyrVect){ |
|
372 |
if( StringUtils.equals(((FLyrVect) layer).getFeatureStore().getFullName(), storeFullName)){ |
|
373 |
view.getMapContext().invalidate(); |
|
374 |
break; |
|
375 |
} |
|
376 |
} |
|
377 |
} |
|
378 |
} |
|
379 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
380 |
for (Document doc : tables) { |
|
381 |
TableDocument table = (TableDocument)doc; |
|
382 |
FeatureStore featureStore = table.getStore(); |
|
383 |
if( StringUtils.equals(featureStore.getFullName(), storeFullName)){ |
|
384 |
try { |
|
385 |
featureStore.refresh(); |
|
386 |
} catch (DataException e) { |
|
387 |
LOGGER.warn("Error refreshing table", e); |
|
388 |
} |
|
389 |
} |
|
390 |
} |
|
391 |
} |
|
392 |
|
|
393 |
@Override |
|
394 |
public void refreshDocument(Set<FeatureStore> stores){ |
|
395 |
if(stores == null || stores.isEmpty()){ |
|
396 |
return; |
|
397 |
} |
|
398 |
|
|
399 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
400 |
ProjectManager projectManager = application.getProjectManager(); |
|
401 |
Project project = projectManager.getCurrentProject(); |
|
402 |
|
|
403 |
Set<ViewDocument> viewsToRefresh = new HashSet<>(); |
|
404 |
for (FeatureStore store : stores) { |
|
405 |
String storeFullName = store.getFullName(); |
|
406 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
407 |
for (Document doc : views) { |
|
408 |
ViewDocument view = (ViewDocument)doc; |
|
409 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
410 |
FLayer layer = it.next(); |
|
411 |
if(layer instanceof FLyrVect){ |
|
412 |
if( StringUtils.equals(((FLyrVect) layer).getFeatureStore().getFullName(), storeFullName)){ |
|
413 |
viewsToRefresh.add(view); |
|
414 |
break; |
|
415 |
} |
|
416 |
} |
|
417 |
} |
|
418 |
} |
|
419 |
|
|
420 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
421 |
for (Document doc : tables) { |
|
422 |
TableDocument table = (TableDocument)doc; |
|
423 |
FeatureStore featureStore = table.getStore(); |
|
424 |
if( StringUtils.equals(featureStore.getFullName(), storeFullName)){ |
|
425 |
try { |
|
426 |
featureStore.refresh(); |
|
427 |
} catch (DataException e) { |
|
428 |
LOGGER.warn("Error refreshing table", e); |
|
429 |
} |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
|
|
434 |
for (ViewDocument viewDocument : viewsToRefresh) { |
|
435 |
viewDocument.getMapContext().invalidate(); |
|
436 |
} |
|
437 |
|
|
438 |
} |
|
439 |
|
|
440 |
|
|
441 |
public List<ViewDocument> getViewDocumentsHavingAStore(FeatureStore store){ |
|
442 |
if(store == null){ |
|
443 |
return null; |
|
444 |
} |
|
445 |
List<ViewDocument> viewList = new ArrayList<>(); |
|
446 |
|
|
447 |
String storeFullName = store.getFullName(); |
|
448 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
449 |
ProjectManager projectManager = application.getProjectManager(); |
|
450 |
Project project = projectManager.getCurrentProject(); |
|
451 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
452 |
for (Document doc : views) { |
|
453 |
ViewDocument view = (ViewDocument) doc; |
|
454 |
for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) { |
|
455 |
FLayer layer = it.next(); |
|
456 |
if (layer instanceof FLyrVect) { |
|
457 |
if (StringUtils.equals( |
|
458 |
((FLyrVect) layer).getFeatureStore().getFullName(), |
|
459 |
store.getFullName() |
|
460 |
)) { |
|
461 |
viewList.add(view); |
|
462 |
break; |
|
463 |
} |
|
464 |
} |
|
465 |
} |
|
466 |
} |
|
467 |
return viewList; |
|
468 |
} |
|
469 |
|
|
470 |
// @Override |
|
471 |
// public void addLayerToActiveView(FeatureStore store, String name) { |
|
472 |
// if(store != null && StringUtils.isNotBlank(name)){ |
|
473 |
// IView view = getActiveView(); |
|
474 |
// if(view != null){ |
|
475 |
// ViewDocument viewDocument = view.getViewDocument(); |
|
476 |
// this.addLayerToView(store, viewDocument, null, name, false); |
|
477 |
// } |
|
478 |
// } |
|
479 |
// } |
|
480 |
// |
|
481 |
@Override |
|
482 |
public boolean isThereAnyActiveView() { |
|
483 |
return this.getActiveView() != null; |
|
484 |
} |
|
485 |
|
|
486 |
@Override |
|
487 |
public void addTableToProject(VCSGisWorkspace ws, FeatureStore store, String tableName) { |
|
488 |
ApplicationManager appManager = ApplicationLocator.getApplicationManager(); |
|
489 |
|
|
490 |
DocumentManager tableManager = appManager.getProjectManager().getDocumentManager( |
|
491 |
TableManager.TYPENAME |
|
492 |
); |
|
493 |
|
|
494 |
Project project = appManager.getCurrentProject(); |
|
495 |
TableDocument tableDoc = (TableDocument) tableManager.createDocument(); |
|
496 |
|
|
497 |
tableDoc.setName(tableName); |
|
498 |
tableDoc.setStore(store); |
|
499 |
project.addDocument(tableDoc); |
|
500 |
} |
|
501 |
|
|
502 |
@Override |
|
503 |
public Icon getFeatureStoresTreeModelIcon(TreeModel model, Object obj) { |
|
504 |
if( model instanceof FeatureStoresTreeModel ) { |
|
505 |
return ((FeatureStoresTreeModel)model).getIcon(obj); |
|
506 |
} |
|
507 |
return null; |
|
508 |
} |
|
509 |
|
|
510 |
@Override |
|
511 |
public void connectedToModel(VCSGisWorkspace workspace, String model) { |
|
512 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
513 |
Project project = application.getCurrentProject(); |
|
514 |
|
|
515 |
Map<String,JsonObject> models = new HashMap<>(); |
|
516 |
String x = (String) project.getProperty(VCSGISMODELS_PROJECT_PROPERTY); |
|
517 |
if( x != null ) { |
|
518 |
JsonArray array = Json.createArray(x); |
|
519 |
for (JsonValue value : array) { |
|
520 |
JsonObject item = (JsonObject) value; |
|
521 |
String modelName = item.getString("model", null); |
|
522 |
JDBCServerExplorerParameters wsparameters = (JDBCServerExplorerParameters) Json.toObject(item.getJsonObject("parameters")); |
|
523 |
String url = wsparameters.getUrl(); |
|
524 |
String key = modelName + "("+ url + ")"; |
|
525 |
models.put(key, item); |
|
526 |
} |
|
527 |
} |
|
528 |
JDBCServerExplorerParameters parameters = workspace.getExplorerParameters(); |
|
529 |
String url = parameters.getUrl(); |
|
530 |
String key = model + "("+ url + ")"; |
|
531 |
JsonObjectBuilder item = Json.createObjectBuilder(); |
|
532 |
item.add("model", model); |
|
533 |
item.add("parameters", parameters); |
|
534 |
models.put(key, item.build()); |
|
535 |
JsonArrayBuilder array = Json.createArrayBuilder(); |
|
536 |
for (JsonObject n : models.values()) { |
|
537 |
array.add(n); |
|
538 |
} |
|
539 |
project.setProperty(VCSGISMODELS_PROJECT_PROPERTY, array.build().toString()); |
|
540 |
} |
|
541 |
|
|
542 |
public void projectLoaded(Project project) { |
|
543 |
String x = (String) project.getProperty(VCSGISMODELS_PROJECT_PROPERTY); |
|
544 |
if (x == null) { |
|
545 |
return; |
|
546 |
} |
|
547 |
// TODO: El projecto se guardo cuando estaba conectado a uno o mas |
|
548 |
// modelos de datos... |
|
549 |
// ¿ Preguntamos al usuario si nos reconectamos automaticamente |
|
550 |
// o nos reconectamos sin decirle nada ? |
|
551 |
// Si preguntamos que recuerde la respuesta. |
|
552 |
|
|
553 |
VCSGisManager manager = VCSGisLocator.getVCSGisManager(); |
|
554 |
DataManager dataManager = DALLocator.getDataManager(); |
|
555 |
JsonArray array = Json.createArray(x); |
|
556 |
for (JsonValue value : array) { |
|
557 |
String modelName = "unkbown"; |
|
558 |
String url = "unknown"; |
|
559 |
try { |
|
560 |
JsonObject item = (JsonObject) value; |
|
561 |
modelName = item.getString("model", null); |
|
562 |
JDBCServerExplorerParameters wsparameters = (JDBCServerExplorerParameters) Json.toObject(item.get("parameters")); |
|
563 |
url = wsparameters.getUrl(); |
|
564 |
|
|
565 |
JDBCServerExplorer wsexplorer = (JDBCServerExplorer) dataManager.openServerExplorer(wsparameters.getProviderName(), wsparameters); |
|
566 |
VCSGisWorkspace workspace = manager.openWorkspace(wsexplorer); |
|
567 |
|
|
568 |
workspace.registerDataModelRepository(modelName); |
|
569 |
} catch (Exception ex) { |
|
570 |
LOGGER.warn("Can't register data model '" + modelName + "' of workspace '" + url + "'.", ex); |
|
571 |
// TODO: ¿ avisar al usuario o basta con lo que saca en la linea de mensajes del MDI ? |
|
572 |
} |
|
573 |
} |
|
574 |
} |
|
575 |
|
|
576 |
@Override |
|
577 |
public Geometry getExtentOfCurrentDocument() { |
|
578 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
579 |
Project project = application.getCurrentProject(); |
|
580 |
|
|
581 |
ViewDocument view = (ViewDocument) project.getActiveDocument(ViewDocument.class); |
|
582 |
if( view == null ) { |
|
583 |
return null; |
|
584 |
} |
|
585 |
return view.getMapContext().getViewPort().getEnvelope().getBox2D(); |
|
586 |
} |
|
587 |
|
|
588 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.40/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.JPanel; |
|
31 |
import javax.swing.SwingUtilities; |
|
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
33 |
import org.gvsig.andami.ui.mdiManager.MDIManager; |
|
34 |
import org.gvsig.app.ApplicationLocator; |
|
35 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.i18n.I18nManager; |
|
37 |
import org.gvsig.tools.swing.api.Component; |
|
38 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
39 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
40 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
41 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
42 |
import org.gvsig.vcsgis.swing.VCSGisPanel; |
|
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 |
|
|
46 |
/** |
|
47 |
* |
|
48 |
* @author gvSIG Team |
|
49 |
*/ |
|
50 |
public class VCSGisDialogsHelper { |
|
51 |
private static final Logger LOGGER = LoggerFactory.getLogger(VCSGisDialogsHelper.class); |
|
52 |
|
|
53 |
public static class VCSGisDialogInfo { |
|
54 |
|
|
55 |
private VCSGisPanel panel; |
|
56 |
private final String name; |
|
57 |
private final String title; |
|
58 |
private String header; |
|
59 |
private String okLabel; |
|
60 |
private boolean closed; |
|
61 |
private Runnable action; |
|
62 |
private Dialog dialog; |
|
63 |
private boolean autoclose; |
|
64 |
|
|
65 |
public VCSGisDialogInfo(String name, VCSGisPanel thePanel, String title) { |
|
66 |
this.name = name; |
|
67 |
this.panel = thePanel; |
|
68 |
this.title = title; |
|
69 |
this.closed = true; |
|
70 |
this.autoclose = false; |
|
71 |
|
|
72 |
this.panel.asJComponent().addComponentListener(new ComponentAdapter() { |
|
73 |
@Override |
|
74 |
public void componentHidden(ComponentEvent e) { |
|
75 |
closed = true; |
|
76 |
} |
|
77 |
}); |
|
78 |
} |
|
79 |
|
|
80 |
public VCSGisDialogInfo(String name, VCSGisPanel thePanel, String title, String header, String okLabel) { |
|
81 |
this(name, thePanel, title); |
|
82 |
this.header = header; |
|
83 |
this.okLabel = okLabel; |
|
84 |
} |
|
85 |
|
|
86 |
private void performDialogAction() { |
|
87 |
action.run(); |
|
88 |
} |
|
89 |
|
|
90 |
public void setAction(Runnable action) { |
|
91 |
this.action = action; |
|
92 |
} |
|
93 |
|
|
94 |
public Component getPanel() { |
|
95 |
return this.panel; |
|
96 |
} |
|
97 |
|
|
98 |
public boolean isClosed() { |
|
99 |
return this.closed; |
|
100 |
} |
|
101 |
|
|
102 |
public String getName() { |
|
103 |
return this.name; |
|
104 |
} |
|
105 |
|
|
106 |
public void setAutoclose(boolean autoclose) { |
|
107 |
this.autoclose = autoclose; |
|
108 |
} |
|
109 |
|
|
110 |
private Dialog createDialog() { |
|
111 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
112 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
113 |
|
|
114 |
Dialog theDialog = winManager.createDialog( |
|
115 |
this.panel.asJComponent(), |
|
116 |
i18n.getTranslation(title), |
|
117 |
i18n.getTranslation(header), |
|
118 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
119 |
); |
|
120 |
theDialog.setAutoclose(false); |
|
121 |
|
|
122 |
this.panel.setDialog(theDialog); |
|
123 |
theDialog.setButtonLabel( |
|
124 |
WindowManager_v2.BUTTON_OK, |
|
125 |
i18n.getTranslation(okLabel) |
|
126 |
); |
|
127 |
theDialog.setButtonLabel( |
|
128 |
WindowManager_v2.BUTTON_CANCEL, |
|
129 |
i18n.getTranslation("_Close") |
|
130 |
); |
|
131 |
if (this.panel.isProcessing()) { |
|
132 |
theDialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false); |
|
133 |
} |
|
134 |
theDialog.addActionListener((ActionEvent e) -> { |
|
135 |
switch (theDialog.getAction()) { |
|
136 |
case WindowManager_v2.BUTTON_OK: |
|
137 |
Thread task = new Thread(() -> { |
|
138 |
if(this.autoclose){ |
|
139 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false); |
|
140 |
} |
|
141 |
performDialogAction(); |
|
142 |
if(this.autoclose){ |
|
143 |
close(); |
|
144 |
} |
|
145 |
}, "VCSGis" + name); |
|
146 |
task.start(); |
|
147 |
break; |
|
148 |
case WindowManager_v2.BUTTON_CANCEL: |
|
149 |
close(); |
|
150 |
break; |
|
151 |
} |
|
152 |
}); |
|
153 |
return theDialog; |
|
154 |
} |
|
155 |
|
|
156 |
public void show() { |
|
157 |
if (!this.closed) { |
|
158 |
MDIManager manager = ApplicationLocator.getApplicationManager().getUIManager(); |
|
159 |
manager.moveToFrom(manager.getWindow((JPanel) this.panel.asJComponent())); |
|
160 |
return; |
|
161 |
} |
|
162 |
this.closed = false; |
|
163 |
if( this.action==null ) { |
|
164 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
165 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
166 |
winManager.showWindow( |
|
167 |
this.panel.asJComponent(), |
|
168 |
i18n.getTranslation(this.title), |
|
169 |
WindowManager.MODE.WINDOW |
|
170 |
); |
|
171 |
} else { |
|
172 |
this.dialog = this.createDialog(); |
|
173 |
this.dialog.show(WindowManager.MODE.WINDOW); |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
private void close() { |
|
178 |
if (this.closed || this.dialog == null) { |
|
179 |
this.panel = null; |
|
180 |
this.dialog = null; |
|
181 |
return; |
|
182 |
} |
|
183 |
if(!SwingUtilities.isEventDispatchThread()){ |
|
184 |
SwingUtilities.invokeLater(this::close); |
|
185 |
return; |
|
186 |
} |
|
187 |
this.dialog.asJComponent().setVisible(false); |
|
188 |
this.panel = null; |
|
189 |
this.dialog = null; |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
private Map<String, VCSGisDialogInfo> dialogsInfo; |
|
194 |
|
|
195 |
public VCSGisDialogInfo getDialog(String name) { |
|
196 |
if (this.dialogsInfo == null) { |
|
197 |
return null; |
|
198 |
} |
|
199 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
200 |
return info; |
|
201 |
} |
|
202 |
|
|
203 |
public VCSGisDialogInfo getOrCreateDialog(String name, VCSGisPanel panel, String title, String header, String okLabel, Runnable action) { |
|
204 |
if (this.dialogsInfo == null) { |
|
205 |
this.dialogsInfo = new HashMap<>(); |
|
206 |
} |
|
207 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
208 |
if (info == null || info.isClosed() ) { |
|
209 |
info = new VCSGisDialogInfo(name, panel, title, header, okLabel); |
|
210 |
info.setAction(action); |
|
211 |
this.dialogsInfo.put(name, info); |
|
212 |
} |
|
213 |
return info; |
|
214 |
} |
|
215 |
|
|
216 |
public VCSGisDialogInfo getOrCreateDialog(String name, VCSGisPanel panel, String title) { |
|
217 |
if (this.dialogsInfo == null) { |
|
218 |
this.dialogsInfo = new HashMap<>(); |
|
219 |
} |
|
220 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
221 |
if (info == null || info.isClosed()) { |
|
222 |
info = new VCSGisDialogInfo(name, panel, title); |
|
223 |
this.dialogsInfo.put(name, info); |
|
224 |
} |
|
225 |
return info; |
|
226 |
} |
|
227 |
|
|
228 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.40/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.Cursor; |
|
5 |
import java.awt.event.ActionEvent; |
|
6 |
import java.net.URL; |
|
7 |
import java.util.Collection; |
|
8 |
import java.util.HashMap; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 |
import java.util.function.Function; |
|
12 |
import java.util.function.Predicate; |
|
13 |
import javax.swing.ImageIcon; |
|
14 |
import javax.swing.JOptionPane; |
|
15 |
import javax.swing.SwingUtilities; |
|
16 |
import javax.swing.UIManager; |
|
17 |
import javax.swing.event.ChangeEvent; |
|
18 |
import org.apache.commons.io.FilenameUtils; |
|
19 |
import org.apache.commons.lang3.StringUtils; |
|
20 |
import org.gvsig.app.gui.WizardPanel; |
|
21 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
22 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
23 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
24 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
25 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
26 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
27 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
28 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
29 |
import org.gvsig.geodb.TableInfo; |
|
30 |
import org.gvsig.geodb.TableInfoController; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
32 |
import org.gvsig.tools.i18n.I18nManager; |
|
33 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
34 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
35 |
import org.gvsig.tools.swing.api.ToolsSwingUtils; |
|
36 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
|
37 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
|
38 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
|
39 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
40 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
41 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
42 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
43 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
44 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
45 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
|
46 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
47 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
48 |
import org.gvsig.vcsgis.swing.VCSGisEntitySelectorController; |
|
49 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_BEGIN_PROCESSING_ID; |
|
50 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_CHECK_ID; |
|
51 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_END_PROCESSING_ID; |
|
52 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_RELOAD_ID; |
|
53 |
import static org.gvsig.vcsgis.swing.VCSGisEntitySelectorController.ACTION_SELECT_ID; |
|
54 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
|
55 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
|
56 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
|
57 |
import org.slf4j.Logger; |
|
58 |
import org.slf4j.LoggerFactory; |
|
59 |
|
|
60 |
/** |
|
61 |
* |
|
62 |
* @author jjdelcerro |
|
63 |
*/ |
|
64 |
@SuppressWarnings("UseSpecificCatch") |
|
65 |
public abstract class AbstractWizardVCSGis extends WizardPanel { |
|
66 |
|
|
67 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractWizardVCSGis.class); |
|
68 |
|
|
69 |
private WizardVCSGisViewExtended view; |
|
70 |
private PickerController<VCSGisWorkspace> workspacePicker; |
|
71 |
protected Map<String, TableInfo> tablesInfo = null; |
|
72 |
private boolean processing; |
|
73 |
private TaskStatusController taskStatusController; |
|
74 |
private TableInfoController tableInfoController; |
|
75 |
private VCSGisEntitySelectorController entitySelector; |
|
76 |
|
|
77 |
|
|
78 |
public AbstractWizardVCSGis() { |
|
79 |
initComponents(); |
|
80 |
} |
|
81 |
|
|
82 |
private void initComponents() { |
|
83 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
|
84 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
85 |
ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
|
86 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
87 |
|
|
88 |
this.view = new WizardVCSGisViewExtended(); |
|
89 |
// this.view.txtRepositoryInfo.setVisible(false); |
|
90 |
|
|
91 |
this.entitySelector = swingManager.createEntitySelectorController( |
|
92 |
this.view.treeTables, |
|
93 |
this.view.txtTablesFilter, |
|
94 |
this.view.btnTablesFilter); |
|
95 |
|
|
96 |
Predicate<VCSGisEntity> entitySelectorFilter = VCSGisEntitySelectorController.ALL_ENTITIES; |
|
97 |
|
|
98 |
if(this.requireGeometry()){ |
|
99 |
entitySelectorFilter = (VCSGisEntity t) -> (StringUtils.isNotBlank(t.getGeometryFieldName())); |
|
100 |
} |
|
101 |
|
|
102 |
this.entitySelector.setFilter(entitySelectorFilter); |
|
103 |
this.entitySelector.setViewFilter(entitySelectorFilter); |
|
104 |
this.entitySelector.setLabelEntityFormatter(this.getLabelEntityFormatter()); |
|
105 |
|
|
106 |
this.entitySelector.setChecksEnabled(true); |
|
107 |
|
|
108 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
|
109 |
|
|
110 |
this.taskStatusController = taskStatusManager.createTaskStatusController( |
|
111 |
this.view.lblStatusTitle, |
|
112 |
this.view.lblStatusMessages, |
|
113 |
this.view.pbStatus |
|
114 |
); |
|
115 |
this.taskStatusController.setShowCancelButton(false); |
|
116 |
this.taskStatusController.setShowRemoveTaskButton(false); |
|
117 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager()); |
|
118 |
|
|
119 |
toolsSwingManager.translate(this.view.lblColumns); |
|
120 |
toolsSwingManager.translate(this.view.lblWorkspace); |
|
121 |
toolsSwingManager.translate(this.view.lblFilter); |
|
122 |
toolsSwingManager.translate(this.view.lblGeometryField); |
|
123 |
toolsSwingManager.translate(this.view.lblIdField); |
|
124 |
toolsSwingManager.translate(this.view.lblName); |
|
125 |
toolsSwingManager.translate(this.view.lblProjection); |
|
126 |
toolsSwingManager.translate(this.view.lblTable); |
|
127 |
toolsSwingManager.translate(this.view.cboWorkspaces); |
|
128 |
toolsSwingManager.translate(this.view.btnAddWorkspace); |
|
129 |
toolsSwingManager.translate(this.view.btnCheckout); |
|
130 |
toolsSwingManager.translate(this.view.btnInitWorkspace); |
|
131 |
toolsSwingManager.translate(this.view.chkMaintainStructureInToC); |
|
132 |
|
|
133 |
this.view.btnInitWorkspace.setText(toHTML(this.view.btnInitWorkspace.getText())); |
|
134 |
// toolsSwingManager.translate(this.view.txtRepositoryInfo); |
|
135 |
|
|
136 |
toolsSwingManager.addClearButton(this.view.txtName); |
|
137 |
toolsSwingManager.setDefaultPopupMenu(this.view.txtName); |
|
138 |
|
|
139 |
this.view.btnInitWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
140 |
this.view.btnAddWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
141 |
|
|
142 |
this.workspacePicker = swingManager.createWorkspacePickerController( |
|
143 |
this.view.cboWorkspaces, |
|
144 |
this.view.btnAddWorkspace |
|
145 |
); |
|
146 |
|
|
147 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
|
148 |
doChangeWorkspace(); |
|
149 |
doUpdateComponents(); |
|
150 |
}); |
|
151 |
|
|
152 |
this.entitySelector.addActionListener((ActionEvent e) -> { |
|
153 |
switch(e.getID()){ |
|
154 |
case ACTION_RELOAD_ID: |
|
155 |
doReloadTablesInfo(); |
|
156 |
break; |
|
157 |
case ACTION_BEGIN_PROCESSING_ID: |
|
158 |
case ACTION_END_PROCESSING_ID: |
|
159 |
doUpdateComponents(); |
|
160 |
break; |
|
161 |
case ACTION_SELECT_ID: |
|
162 |
doChangeTableSelected(); |
|
163 |
break; |
|
164 |
case ACTION_CHECK_ID: |
|
165 |
doChangeTableChecked(); |
|
166 |
doUpdateComponents(); |
|
167 |
break; |
|
168 |
|
|
169 |
} |
|
170 |
}); |
|
171 |
|
|
172 |
this.view.btnInitWorkspace.addActionListener((ActionEvent e) -> { |
|
173 |
doShowInitWorkspace(); |
|
174 |
}); |
|
175 |
|
|
176 |
this.view.btnCheckout.addActionListener((ActionEvent e) -> { |
|
177 |
doCheckout(); |
|
178 |
}); |
|
179 |
|
|
180 |
this.tableInfoController = new TableInfoController( |
|
181 |
this.view.btnDeselectAllColumns, |
|
182 |
this.view.btnSelectAllColumns, |
|
183 |
this.view.lstColumns, |
|
184 |
this.view.txtName, |
|
185 |
this.view.cboIdField, |
|
186 |
this.view.cboGeometryField, |
|
187 |
this.view.txtProjection, |
|
188 |
this.view.btnProjection, |
|
189 |
this.view.txtFilter, |
|
190 |
this.view.btnFilter, |
|
191 |
this.view.btnFilterBookmarks, |
|
192 |
this.view.btnFilterHistory, |
|
193 |
this.view.btnAdvancedProperties, |
|
194 |
this.view.lblReadOnlyNotification, |
|
195 |
null, |
|
196 |
this.view.btnChangeViewProjection |
|
197 |
); |
|
198 |
this.view.btnChangeViewProjection.setVisible(this.requireGeometry()); |
|
199 |
|
|
200 |
this.view.btnInitWorkspace.setBackground(UIManager.getColor("Panel.background")); |
|
201 |
// this.view.txtRepositoryInfo.setBackground(UIManager.getColor("Panel.background")); |
|
202 |
|
|
203 |
this.clearTables(); |
|
204 |
|
|
205 |
this.view.chkMaintainStructureInToC.setVisible(false); |
|
206 |
this.view.chkMaintainStructureInToC.setSelected(true); |
|
207 |
|
|
208 |
this.setLayout(new BorderLayout()); |
|
209 |
this.add(this.view, BorderLayout.CENTER); |
|
210 |
|
|
211 |
ToolsSwingUtils.ensureRowsCols(this, 22, 90, 25, 100); |
|
212 |
doUpdateComponents(); |
|
213 |
} |
|
214 |
|
|
215 |
protected abstract boolean requireGeometry(); |
|
216 |
|
|
217 |
protected boolean maintainStructureInToC() { |
|
218 |
return this.view.chkMaintainStructureInToC.isSelected(); |
|
219 |
} |
|
220 |
|
|
221 |
protected void setVidibleMaintainStructureInToC(boolean visible) { |
|
222 |
this.view.chkMaintainStructureInToC.setVisible(visible); |
|
223 |
} |
|
224 |
|
|
225 |
protected Collection<TableInfo> getTablesInformation() { |
|
226 |
this.updateTableInfoFromUI(); |
|
227 |
if( this.tablesInfo == null ) { |
|
228 |
this.tablesInfo = new HashMap<>(); |
|
229 |
} |
|
230 |
return this.tablesInfo.values(); |
|
231 |
} |
|
232 |
|
|
233 |
private void clearTables() { |
|
234 |
this.entitySelector.clear(); |
|
235 |
this.tableInfoController.clear(); |
|
236 |
} |
|
237 |
|
|
238 |
private void doChangeWorkspace() { |
|
239 |
if (notInSwingThreadInvokeLater(this::doChangeWorkspace)) { |
|
240 |
return; |
|
241 |
} |
|
242 |
|
|
243 |
VCSGisWorkspace workspace = workspacePicker.get(); |
|
244 |
|
|
245 |
this.entitySelector.setWorkspace(workspace); |
|
246 |
// if (workspace == null) { |
|
247 |
// this.view.txtRepositoryInfo.setText(""); |
|
248 |
// return; |
|
249 |
// } |
|
250 |
// |
|
251 |
// this.view.txtRepositoryInfo.setText(workspace.getRepository().getLabel()); |
|
252 |
} |
|
253 |
|
|
254 |
private TableInfo getTableInfo(VCSGisEntity entity){ |
|
255 |
Collection<TableInfo> tablesInformation = getTablesInformation(); |
|
256 |
for (TableInfo tableInfo : tablesInformation) { |
|
257 |
VCSGisEntity tableInfoEntity = (VCSGisEntity) tableInfo.getProperty("entity"); |
|
258 |
if(tableInfoEntity!=null && StringUtils.equals(tableInfoEntity.getEntityCode(), entity.getEntityCode())){ |
|
259 |
return tableInfo; |
|
260 |
} |
|
261 |
} |
|
262 |
return null; |
|
263 |
} |
|
264 |
|
|
265 |
private void doChangeTableSelected() { |
|
266 |
if( notInSwingThreadInvokeLater(() -> {doChangeTableSelected();}) ) { |
|
267 |
return; |
|
268 |
} |
|
269 |
|
|
270 |
VCSGisEntity selected = this.entitySelector.getSelectedEntity(); |
|
271 |
if(selected == null){ |
|
272 |
this.tableInfoController.put(null); |
|
273 |
return; |
|
274 |
} |
|
275 |
TableInfo tableInfo = getTableInfo(selected); |
|
276 |
if (tableInfo != null) { |
|
277 |
this.updateTableInfoFromUI(); |
|
278 |
this.tableInfoController.put(tableInfo); |
|
279 |
this.tableInfoController.setEnabled(true); |
|
280 |
} else { |
|
281 |
this.tableInfoController.clear(); |
|
282 |
this.tableInfoController.setEnabled(false); |
|
283 |
} |
|
284 |
|
|
285 |
showMessage(""); |
|
286 |
doUpdateComponents(); |
|
287 |
} |
|
288 |
|
|
289 |
private void doChangeTableChecked() { |
|
290 |
List<VCSGisEntity> checkedEntities = this.entitySelector.getCheckedEntities(); |
|
291 |
for (VCSGisEntity checkedEntity : checkedEntities) { |
|
292 |
if(!(checkedEntity instanceof VCSGisWorkspaceEntity)){ |
|
293 |
this.entitySelector.unCheck(checkedEntity); |
|
294 |
} |
|
295 |
} |
|
296 |
Collection<TableInfo> tablesInformation = getTablesInformation(); |
|
297 |
for (TableInfo tableInfo : tablesInformation) { |
|
298 |
VCSGisEntity tableInfoEntity = (VCSGisEntity) tableInfo.getProperty("entity"); |
|
299 |
tableInfo.setSelected(checkedEntities.contains(tableInfoEntity)); |
|
300 |
} |
|
301 |
this.checkFinishable(); |
|
302 |
} |
|
303 |
|
|
304 |
|
|
305 |
private void updateTableInfoFromUI() { |
|
306 |
String previousId = this.tableInfoController.getId(); |
|
307 |
if (previousId == null) { |
|
308 |
return; |
|
309 |
} |
|
310 |
|
|
311 |
if (this.tablesInfo != null && !this.tablesInfo.isEmpty()) { |
|
312 |
TableInfo previousInfo = this.tablesInfo.get(previousId); |
|
313 |
if (previousInfo != null) { |
|
314 |
this.tableInfoController.fetch(previousInfo); |
|
315 |
} |
|
316 |
} |
|
317 |
} |
|
318 |
|
|
319 |
@Override |
|
320 |
public void initWizard() { |
|
321 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
322 |
setTabName(i18n.getTranslation("_VCSGis")); |
|
323 |
} |
|
324 |
|
|
325 |
@Override |
|
326 |
public boolean areSettingsValid() { |
|
327 |
if(processing){ |
|
328 |
return false; |
|
329 |
} |
|
330 |
boolean hasInvalidValues = false; |
|
331 |
boolean hasSelectedTables = false; |
|
332 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
333 |
if (tableInfo.isSelected()) { |
|
334 |
hasSelectedTables = true; |
|
335 |
if (!tableInfo.hasValidValues()) { |
|
336 |
hasInvalidValues = true; |
|
337 |
} |
|
338 |
} |
|
339 |
} |
|
340 |
return hasSelectedTables && !hasInvalidValues; |
|
341 |
} |
|
342 |
|
|
343 |
@Override |
|
344 |
public DataStoreParameters[] getParameters() { |
|
345 |
int sz = 0; |
|
346 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
347 |
if( tableInfo.isSelected() ) { |
|
348 |
sz++; |
|
349 |
} |
|
350 |
} |
|
351 |
if( sz == 0 ) { |
|
352 |
return null; |
|
353 |
} |
|
354 |
DataStoreParameters[] dbParameters = new DataStoreParameters[sz]; |
|
355 |
int n = 0; |
|
356 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
357 |
if( tableInfo.isSelected() ) { |
|
358 |
dbParameters[n++] = tableInfo.getParameters(); |
|
359 |
} |
|
360 |
} |
|
361 |
return dbParameters; |
|
362 |
} |
|
363 |
|
|
364 |
@Override |
|
365 |
public void execute() { |
|
366 |
executeWizard(); |
|
367 |
} |
|
368 |
|
|
369 |
@Override |
|
370 |
public void close() { |
|
371 |
|
|
372 |
} |
|
373 |
|
|
374 |
protected void checkFinishable() { |
|
375 |
boolean finishable = areSettingsValid(); |
|
376 |
callStateChanged(finishable); |
|
377 |
} |
|
378 |
|
|
379 |
private void doUpdateComponents() { |
|
380 |
VCSGisEntity entity = this.entitySelector.getSelectedEntity(); |
|
381 |
|
|
382 |
boolean theProcessing = this.processing || this.entitySelector.isProcessing(); |
|
383 |
|
|
384 |
VCSGisWorkspace ws = getWorkspace(); |
|
385 |
if(entity == null){ |
|
386 |
this.view.btnCheckout.setEnabled(false); |
|
387 |
this.tableInfoController.setEnabled(false); |
|
388 |
} else if(entity instanceof VCSGisWorkspaceEntity){ |
|
389 |
this.view.btnCheckout.setEnabled(false); |
|
390 |
this.tableInfoController.setEditable(!theProcessing && ws != null); |
|
391 |
this.tableInfoController.setEnabled(ws != null); |
|
392 |
} else { //Entidad de repositorio |
|
393 |
this.view.btnCheckout.setEnabled(!theProcessing && ws != null); |
|
394 |
this.tableInfoController.setEnabled(false); |
|
395 |
} |
|
396 |
|
|
397 |
this.entitySelector.setEnabled(!theProcessing && ws != null); |
|
398 |
this.workspacePicker.setEnabled(!theProcessing); |
|
399 |
this.view.btnInitWorkspace.setEnabled(!theProcessing); |
|
400 |
// this.view.txtRepositoryInfo.setEnabled(!theProcessing && ws != null); |
|
401 |
this.setVisibleStatus(theProcessing); |
|
402 |
this.checkFinishable(); |
|
403 |
} |
|
404 |
|
|
405 |
private void doShowInitWorkspace() { |
|
406 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
407 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
408 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
409 |
|
|
410 |
final VCSGisJInitWorkspace panelInitWorkspace = swingManager.createInitWorkspacePanel(); |
|
411 |
final Dialog dialogInitWorkspace = winManager.createDialog( |
|
412 |
panelInitWorkspace.asJComponent(), |
|
413 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
414 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
415 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
416 |
); |
|
417 |
|
|
418 |
panelInitWorkspace.setDialog(dialogInitWorkspace); |
|
419 |
dialogInitWorkspace.setButtonLabel( |
|
420 |
WindowManager_v2.BUTTON_OK, |
|
421 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy") |
|
422 |
); |
|
423 |
dialogInitWorkspace.addActionListener((ActionEvent e) -> { |
|
424 |
switch (dialogInitWorkspace.getAction()) { |
|
425 |
case WindowManager_v2.BUTTON_OK: |
|
426 |
int r = panelInitWorkspace.initializeWorkspace(); |
|
427 |
if (r != 0) { |
|
428 |
String message = "_Cant_initialize_workingcopy_{0}"; |
|
429 |
|
|
430 |
StringBuilder compoundMessage = new StringBuilder(); |
|
431 |
String[] messageArgs = new String[]{panelInitWorkspace.getWorkspaceName()}; |
|
432 |
|
|
433 |
compoundMessage.append(i18nManager.getTranslation( |
|
434 |
message, |
|
435 |
messageArgs |
|
436 |
)); |
|
437 |
|
|
438 |
ThreadSafeDialogsManager dialogsManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
439 |
dialogsManager.messageDialog( |
|
440 |
compoundMessage.toString(), |
|
441 |
i18nManager.getTranslation("_VCS_Initialize_workingcopy"), |
|
442 |
JOptionPane.WARNING_MESSAGE |
|
443 |
); |
|
444 |
} |
|
445 |
|
|
446 |
break; |
|
447 |
|
|
448 |
} |
|
449 |
}); |
|
450 |
dialogInitWorkspace.show(WindowManager.MODE.DIALOG); |
|
451 |
} |
|
452 |
|
|
453 |
public VCSGisWorkspace getWorkspace() { |
|
454 |
return this.workspacePicker.get(); |
|
455 |
} |
|
456 |
|
|
457 |
private void doReloadTablesInfo() { |
|
458 |
if (notInSwingThreadInvokeLater(() -> { doReloadTablesInfo(); })) { |
|
459 |
return; |
|
460 |
} |
|
461 |
|
|
462 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
463 |
|
|
464 |
try { |
|
465 |
Collection<VCSGisEntity> entities = this.entitySelector.getEntities(); |
|
466 |
for (VCSGisEntity entity : entities) { |
|
467 |
if (entity instanceof VCSGisWorkspaceEntity) { |
|
468 |
JDBCStoreParameters parameters = getWorkspace().getExplorer().get(entity.getEntityName()); |
|
469 |
TableInfo tableInfo = new TableInfo(entity.getEntityName(), parameters, this.requireGeometry(), false); |
|
470 |
if(StringUtils.isNotBlank(entity.getLabel()) ) { |
|
471 |
tableInfo.setDocumentName(entity.getLabel()); |
|
472 |
} |
|
473 |
tableInfo.setProperty("entity", entity); |
|
474 |
this.tablesInfo.put(tableInfo.getId(), tableInfo); |
|
475 |
} |
|
476 |
} |
|
477 |
|
|
478 |
} catch (Exception e) { |
|
479 |
LOGGER.warn("_Cant_update_layers_list", e); |
|
480 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
481 |
dialogs.messageDialog( |
Also available in: Unified diff