svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / ViewManager.java @ 44543
History | View | Annotate | Download (18.3 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 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, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | package org.gvsig.app.project.documents.view; |
25 | |||
26 | 44281 | jjdelcerro | import java.util.HashMap; |
27 | import java.util.Iterator; |
||
28 | import java.util.List; |
||
29 | 41081 | jjdelcerro | import java.util.Map; |
30 | 44281 | jjdelcerro | import java.util.function.Predicate; |
31 | 41081 | jjdelcerro | |
32 | 40435 | jjdelcerro | import javax.swing.ImageIcon; |
33 | 44281 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
34 | 40435 | jjdelcerro | |
35 | import org.gvsig.andami.IconThemeHelper; |
||
36 | import org.gvsig.andami.PluginServices; |
||
37 | 41081 | jjdelcerro | import org.gvsig.andami.PluginsLocator; |
38 | import org.gvsig.andami.actioninfo.ActionInfo; |
||
39 | import org.gvsig.andami.actioninfo.ActionInfoManager; |
||
40 | 40435 | jjdelcerro | import org.gvsig.andami.ui.mdiManager.IWindow; |
41 | 44281 | jjdelcerro | import org.gvsig.app.project.Project; |
42 | 40435 | jjdelcerro | import org.gvsig.app.project.ProjectManager; |
43 | import org.gvsig.app.project.documents.AbstractDocument; |
||
44 | import org.gvsig.app.project.documents.AbstractDocumentManager; |
||
45 | import org.gvsig.app.project.documents.Document; |
||
46 | import org.gvsig.app.project.documents.actions.CopyDocumentAction; |
||
47 | import org.gvsig.app.project.documents.actions.CutDocumentAction; |
||
48 | import org.gvsig.app.project.documents.actions.PasteDocumentAction; |
||
49 | import org.gvsig.app.project.documents.gui.IDocumentWindow; |
||
50 | import org.gvsig.app.project.documents.gui.WindowLayout; |
||
51 | 44281 | jjdelcerro | import org.gvsig.app.project.documents.view.dalactions.ViewZoomAction.ViewZoomActionFactory; |
52 | 40435 | jjdelcerro | import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
53 | import org.gvsig.app.project.documents.view.gui.ViewProperties; |
||
54 | 41559 | jjdelcerro | import org.gvsig.app.project.documents.view.toc.AbstractActionInfoAdapterToTocContextMenuAction; |
55 | 44304 | jjdelcerro | import org.gvsig.fmap.dal.AbstractStoresRepository; |
56 | 44281 | jjdelcerro | import org.gvsig.fmap.dal.DALLocator; |
57 | import org.gvsig.fmap.dal.DataManager; |
||
58 | import org.gvsig.fmap.dal.DataStore; |
||
59 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
60 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
61 | 40435 | jjdelcerro | import org.gvsig.fmap.mapcontext.MapContext; |
62 | import org.gvsig.fmap.mapcontext.MapContextLocator; |
||
63 | import org.gvsig.fmap.mapcontext.MapContextManager; |
||
64 | 41350 | jjdelcerro | import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesHelper; |
65 | 44281 | jjdelcerro | import org.gvsig.fmap.mapcontext.layers.FLayer; |
66 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
67 | 40435 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
68 | import org.gvsig.tools.dynobject.DynStruct; |
||
69 | 41081 | jjdelcerro | import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
70 | import org.gvsig.tools.extensionpoint.ExtensionPoint; |
||
71 | 41104 | jjdelcerro | import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
72 | 40435 | jjdelcerro | import org.gvsig.tools.persistence.PersistenceManager; |
73 | 44281 | jjdelcerro | import org.gvsig.tools.util.UnmodifiableBasicMap; |
74 | import org.gvsig.tools.util.UnmodifiableBasicSet; |
||
75 | import org.gvsig.tools.util.UnmodifiableBasicSetAdapter; |
||
76 | 40435 | jjdelcerro | import org.slf4j.Logger; |
77 | import org.slf4j.LoggerFactory; |
||
78 | |||
79 | /**
|
||
80 | * Factory of View.
|
||
81 | *
|
||
82 | 44281 | jjdelcerro | * @author 2005- Vicente Caballero
|
83 | * @author 2009- Joaquin del Cerro
|
||
84 | *
|
||
85 | 40435 | jjdelcerro | */
|
86 | public class ViewManager extends AbstractDocumentManager { |
||
87 | 44281 | jjdelcerro | |
88 | private static final Logger LOGGER = LoggerFactory.getLogger(ViewManager.class); |
||
89 | |||
90 | 44304 | jjdelcerro | private static class ViewDocumentStoresRepository extends AbstractStoresRepository { |
91 | 44281 | jjdelcerro | |
92 | 44304 | jjdelcerro | public ViewDocumentStoresRepository(String name) { |
93 | super(name);
|
||
94 | } |
||
95 | |||
96 | 44281 | jjdelcerro | private Map<String, DataStoreParameters> getAll(Predicate<DataStore> filter, int limit) { |
97 | Map<String, DataStoreParameters> all = new HashMap<>(); |
||
98 | Project project = ProjectManager.getInstance().getCurrentProject(); |
||
99 | List<Document> views = project.getDocuments(TYPENAME); |
||
100 | for (Document view : views) { |
||
101 | for (FLayer layer : ((ViewDocument) view).layers()) {
|
||
102 | if (layer instanceof FLyrVect) { |
||
103 | FeatureStore store = ((FLyrVect) layer).getFeatureStore(); |
||
104 | if (filter == null || filter.test(store)) { |
||
105 | all.put(store.getName(), store.getParameters()); |
||
106 | } |
||
107 | 44307 | jjdelcerro | // UnmodifiableBasicMap<String, DataStore> children = store.getChildren();
|
108 | // if (children != null) {
|
||
109 | // for (DataStore dataStore : children) {
|
||
110 | // if (filter == null || filter.test(dataStore)) {
|
||
111 | // all.put(dataStore.getName(), dataStore.getParameters());
|
||
112 | // }
|
||
113 | // }
|
||
114 | // }
|
||
115 | 44281 | jjdelcerro | } |
116 | if (limit > 0 && all.size() >= limit) { |
||
117 | break;
|
||
118 | } |
||
119 | } |
||
120 | } |
||
121 | if (all.isEmpty()) {
|
||
122 | return null; |
||
123 | } |
||
124 | return all;
|
||
125 | } |
||
126 | |||
127 | @Override
|
||
128 | 44304 | jjdelcerro | protected DataStoreParameters getMyParameters(final String name) { |
129 | 44281 | jjdelcerro | Map<String, DataStoreParameters> all = this.getAll(new Predicate<DataStore>() { |
130 | @Override
|
||
131 | public boolean test(DataStore t) { |
||
132 | return StringUtils.equalsIgnoreCase(name, t.getName());
|
||
133 | } |
||
134 | }, 1);
|
||
135 | if (all == null) { |
||
136 | return null; |
||
137 | } |
||
138 | return all.get(name);
|
||
139 | } |
||
140 | |||
141 | @Override
|
||
142 | public boolean containsKey(final String key) { |
||
143 | Map<String, DataStoreParameters> all = this.getAll(new Predicate<DataStore>() { |
||
144 | @Override
|
||
145 | public boolean test(DataStore t) { |
||
146 | return StringUtils.equalsIgnoreCase(key, t.getName());
|
||
147 | } |
||
148 | }, 1);
|
||
149 | if (all == null) { |
||
150 | return false; |
||
151 | } |
||
152 | return all.containsKey(key);
|
||
153 | } |
||
154 | |||
155 | @Override
|
||
156 | 44304 | jjdelcerro | protected UnmodifiableBasicSet<String> getMyKeySet() { |
157 | 44281 | jjdelcerro | Map<String, DataStoreParameters> all = this.getAll(null, 0); |
158 | if (all == null) { |
||
159 | return null; |
||
160 | } |
||
161 | return new UnmodifiableBasicSetAdapter<>(all.keySet()); |
||
162 | } |
||
163 | |||
164 | @Override
|
||
165 | 44304 | jjdelcerro | protected boolean isEmptyMyRepository() { |
166 | 44281 | jjdelcerro | Map<String, DataStoreParameters> all = this.getAll(null, 1); |
167 | return all.isEmpty();
|
||
168 | } |
||
169 | |||
170 | @Override
|
||
171 | 44304 | jjdelcerro | protected int getMySize() { |
172 | 44281 | jjdelcerro | Map<String, DataStoreParameters> all = this.getAll(null, 0); |
173 | return all.size();
|
||
174 | } |
||
175 | |||
176 | @Override
|
||
177 | public Iterator<DataStoreParameters> iterator() { |
||
178 | Map<String, DataStoreParameters> all = this.getAll(null, 0); |
||
179 | return all.values().iterator();
|
||
180 | } |
||
181 | |||
182 | public static void selfRegister() { |
||
183 | DataManager dataManager = DALLocator.getDataManager(); |
||
184 | 44306 | jjdelcerro | dataManager.getStoresRepository().addRepository(new ViewDocumentStoresRepository("Project layers")); |
185 | 44281 | jjdelcerro | } |
186 | } |
||
187 | private static final String PERSISTENCE_VIEW_DOCUMENT_DEFINITION_NAME |
||
188 | = "DefaultViewDocument";
|
||
189 | 40435 | jjdelcerro | public static String TYPENAME = "project.document.view2d"; |
190 | private DynStruct persistenceDefinition;
|
||
191 | 44281 | jjdelcerro | |
192 | 40435 | jjdelcerro | public ViewManager() {
|
193 | 44281 | jjdelcerro | // Do nothing
|
194 | 40435 | jjdelcerro | } |
195 | 44281 | jjdelcerro | |
196 | 40435 | jjdelcerro | public int getPriority() { |
197 | return 0; |
||
198 | } |
||
199 | |||
200 | public ImageIcon getIcon() { |
||
201 | 44281 | jjdelcerro | return PluginServices.getIconTheme().get("document-view-icon"); |
202 | 40435 | jjdelcerro | } |
203 | |||
204 | public ImageIcon getIconSelected() { |
||
205 | 44281 | jjdelcerro | return PluginServices.getIconTheme().get("document-view-icon-sel"); |
206 | 40435 | jjdelcerro | } |
207 | |||
208 | public String getTitle() { |
||
209 | return PluginServices.getText(this, "Vista"); |
||
210 | } |
||
211 | |||
212 | public String getTypeName() { |
||
213 | return TYPENAME;
|
||
214 | } |
||
215 | 44281 | jjdelcerro | |
216 | 40435 | jjdelcerro | public Class getMainWindowClass() { |
217 | return DefaultViewPanel.class;
|
||
218 | } |
||
219 | 44281 | jjdelcerro | |
220 | 40435 | jjdelcerro | public AbstractDocument createDocument() { |
221 | 41634 | jjdelcerro | AbstractDocument doc = new DefaultViewDocument(this); |
222 | 44281 | jjdelcerro | if (this.notifyObservers(NOTIFY_AFTER_CREATEDOCUMENT, doc).isCanceled()) { |
223 | 41634 | jjdelcerro | return null; |
224 | } |
||
225 | 44281 | jjdelcerro | return doc;
|
226 | |||
227 | 40435 | jjdelcerro | } |
228 | |||
229 | 42873 | jjdelcerro | @Override
|
230 | 41634 | jjdelcerro | public IWindow getMainWindow(Document doc, WindowLayout layout) { |
231 | 42873 | jjdelcerro | IDocumentWindow win = (IDocumentWindow) super.getMainWindow(doc, layout);
|
232 | 44281 | jjdelcerro | if (win == null) { |
233 | 42873 | jjdelcerro | win = this.createDocumentWindow(doc);
|
234 | 44281 | jjdelcerro | if (layout != null && win != null) { |
235 | 42873 | jjdelcerro | win.setWindowLayout(layout); |
236 | } |
||
237 | 44281 | jjdelcerro | if (this.notifyObservers(NOTIFY_AFTER_CREATEMAINWINDOW, win).isCanceled()) { |
238 | 43633 | jjdelcerro | return null; |
239 | } |
||
240 | 41634 | jjdelcerro | } |
241 | 44281 | jjdelcerro | if (this.notifyObservers(NOTIFY_AFTER_GETMAINWINDOW, win).isCanceled()) { |
242 | 41634 | jjdelcerro | return null; |
243 | } |
||
244 | ((AbstractDocument) doc).raiseEventCreateWindow(win);
|
||
245 | return win;
|
||
246 | } |
||
247 | 40435 | jjdelcerro | |
248 | 42873 | jjdelcerro | @Override
|
249 | 41634 | jjdelcerro | public IWindow getPropertiesWindow(Document doc) { |
250 | 42873 | jjdelcerro | IWindow win = super.getPropertiesWindow(doc);
|
251 | 44281 | jjdelcerro | if (win == null) { |
252 | 42873 | jjdelcerro | win = new ViewProperties((DefaultViewDocument) doc);
|
253 | 44281 | jjdelcerro | if (this.notifyObservers(NOTIFY_AFTER_CREATEPROPERTIESWINDOW, win).isCanceled()) { |
254 | 43633 | jjdelcerro | return null; |
255 | } |
||
256 | 42873 | jjdelcerro | } |
257 | 44281 | jjdelcerro | if (this.notifyObservers(NOTIFY_AFTER_GETPROPERTIESWINDOW, win).isCanceled()) { |
258 | 41634 | jjdelcerro | return null; |
259 | } |
||
260 | return win;
|
||
261 | } |
||
262 | |||
263 | 41081 | jjdelcerro | public void addTOCContextAction(String theAction) { |
264 | 44281 | jjdelcerro | ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
265 | ActionInfo action = actionManager.getAction(theAction); |
||
266 | if (action == null) { |
||
267 | String errmsg = "Action '" + theAction + "' not found"; |
||
268 | LOGGER.info(errmsg); |
||
269 | throw new RuntimeException(errmsg); |
||
270 | } |
||
271 | this.addTOCContextAction(action);
|
||
272 | 41081 | jjdelcerro | } |
273 | 44281 | jjdelcerro | |
274 | 42175 | jjdelcerro | public void addTOCContextAction(String theAction, String group, int groupOrder, int order) { |
275 | 44281 | jjdelcerro | ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
276 | ActionInfo action = actionManager.getAction(theAction); |
||
277 | if (action == null) { |
||
278 | String errmsg = "Action '" + theAction + "' not found"; |
||
279 | LOGGER.info(errmsg); |
||
280 | throw new RuntimeException(errmsg); |
||
281 | } |
||
282 | this.addTOCContextAction(
|
||
283 | action.getName(), |
||
284 | new ActionInfoAdapterToContextMenuAction(action, group, groupOrder, 0) |
||
285 | 42175 | jjdelcerro | ); |
286 | } |
||
287 | 44281 | jjdelcerro | |
288 | 41081 | jjdelcerro | public void addTOCContextAction(ActionInfo action) { |
289 | 44281 | jjdelcerro | this.addTOCContextAction(action.getName(), new ActionInfoAdapterToContextMenuAction(action, "default", 9000)); |
290 | 41081 | jjdelcerro | } |
291 | 44281 | jjdelcerro | |
292 | 41559 | jjdelcerro | public void addTOCContextAction(ActionInfo action, String group, int groupOrder) { |
293 | 44281 | jjdelcerro | this.addTOCContextAction(action.getName(), new ActionInfoAdapterToContextMenuAction(action, group, groupOrder)); |
294 | 41559 | jjdelcerro | } |
295 | 44281 | jjdelcerro | |
296 | 41559 | jjdelcerro | class ActionInfoAdapterToContextMenuAction extends AbstractActionInfoAdapterToTocContextMenuAction { |
297 | 44281 | jjdelcerro | |
298 | ActionInfoAdapterToContextMenuAction(ActionInfo action, String group, int groupOrder) { |
||
299 | 41559 | jjdelcerro | super(action, group, groupOrder);
|
300 | 44281 | jjdelcerro | } |
301 | |||
302 | ActionInfoAdapterToContextMenuAction(ActionInfo action, String group, int groupOrder, int order) { |
||
303 | super(action, group, groupOrder, order);
|
||
304 | } |
||
305 | 41081 | jjdelcerro | } |
306 | 44281 | jjdelcerro | |
307 | 41559 | jjdelcerro | /**
|
308 | 44281 | jjdelcerro | * @deprecated use addTOCContextAction(ActionInfo action, String group, int
|
309 | * groupOrder)
|
||
310 | 41559 | jjdelcerro | * @param id
|
311 | 44281 | jjdelcerro | * @param action
|
312 | 41559 | jjdelcerro | */
|
313 | 41081 | jjdelcerro | public void addTOCContextAction(String id, IContextMenuAction action) { |
314 | 44281 | jjdelcerro | initializeRegisterTOCActions(); |
315 | ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add( |
||
316 | "View_TocActions", ""); |
||
317 | if (action instanceof ExtensionBuilder) { |
||
318 | exPoint.append(id, "", (ExtensionBuilder) action);
|
||
319 | return;
|
||
320 | } |
||
321 | exPoint.append(id, "", new ContextMenuActionAdapterToExtensionBuilder(action)); |
||
322 | 41081 | jjdelcerro | } |
323 | |||
324 | class ContextMenuActionAdapterToExtensionBuilder implements ExtensionBuilder { |
||
325 | 44281 | jjdelcerro | |
326 | IContextMenuAction menuAction = null;
|
||
327 | |||
328 | ContextMenuActionAdapterToExtensionBuilder(IContextMenuAction menuAction) { |
||
329 | this.menuAction = menuAction;
|
||
330 | } |
||
331 | |||
332 | public Object create() { |
||
333 | return this.menuAction; |
||
334 | } |
||
335 | |||
336 | public Object create(Object[] args) { |
||
337 | return this.menuAction; |
||
338 | } |
||
339 | |||
340 | public Object create(Map args) { |
||
341 | return this.menuAction; |
||
342 | } |
||
343 | 41081 | jjdelcerro | } |
344 | 44281 | jjdelcerro | |
345 | 41104 | jjdelcerro | private static void initializeRegisterTOCActions() { |
346 | 44281 | jjdelcerro | ExtensionPointManager epManager = ToolsLocator.getExtensionPointManager(); |
347 | 41104 | jjdelcerro | |
348 | 44281 | jjdelcerro | if (!epManager.has("View_TocActions")) { |
349 | epManager.add( |
||
350 | "View_TocActions",
|
||
351 | "Context menu options of the TOC "
|
||
352 | + " in the view window "
|
||
353 | + "(register instances of "
|
||
354 | + "org.gvsig.app.gui.toc.AbstractTocContextMenuAction)"
|
||
355 | ); |
||
356 | } |
||
357 | 41104 | jjdelcerro | } |
358 | 44281 | jjdelcerro | |
359 | 40435 | jjdelcerro | /**
|
360 | * Registers in the points of extension the Factory with alias.
|
||
361 | *
|
||
362 | */
|
||
363 | public static void register() { |
||
364 | ViewManager factory = new ViewManager();
|
||
365 | 44281 | jjdelcerro | ProjectManager.getInstance().registerDocumentFactory(factory); |
366 | |||
367 | 40435 | jjdelcerro | PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
368 | manager.registerFactory(factory); |
||
369 | |||
370 | 41104 | jjdelcerro | initializeRegisterTOCActions(); |
371 | 40435 | jjdelcerro | |
372 | 44281 | jjdelcerro | ProjectManager.getInstance().registerDocumentAction(TYPENAME, new CopyDocumentAction());
|
373 | ProjectManager.getInstance().registerDocumentAction(TYPENAME, new CutDocumentAction());
|
||
374 | ProjectManager.getInstance().registerDocumentAction(TYPENAME, new PasteDocumentAction());
|
||
375 | |||
376 | IconThemeHelper.registerIcon("document", "document-view-icon", ViewManager.class); |
||
377 | IconThemeHelper.registerIcon("document", "document-view-icon-sel", ViewManager.class); |
||
378 | |||
379 | IconThemeHelper.registerIcon("cursor", "cursor-crux", ViewManager.class); |
||
380 | IconThemeHelper.registerIcon("cursor", "cursor-info-by-point", ViewManager.class); |
||
381 | IconThemeHelper.registerIcon("cursor", "cursor-pan", ViewManager.class); |
||
382 | IconThemeHelper.registerIcon("cursor", "cursor-query-area", ViewManager.class); |
||
383 | IconThemeHelper.registerIcon("cursor", "cursor-select-by-point", ViewManager.class); |
||
384 | 41121 | jldominguez | IconThemeHelper.registerIcon("cursor", "cursor-select-by-polygon", ViewManager.class); |
385 | IconThemeHelper.registerIcon("cursor", "cursor-select-by-rectangle", ViewManager.class); |
||
386 | 44281 | jjdelcerro | IconThemeHelper.registerIcon("cursor", "cursor-zoom-in", ViewManager.class); |
387 | IconThemeHelper.registerIcon("cursor", "cursor-zoom-out", ViewManager.class); |
||
388 | 40435 | jjdelcerro | |
389 | 44281 | jjdelcerro | IconThemeHelper.registerIcon("layer", "layer-icon", ViewManager.class); |
390 | IconThemeHelper.registerIcon("layer", "layer-icon-group", ViewManager.class); |
||
391 | IconThemeHelper.registerIcon("layer", "layer-icon-vectorial", ViewManager.class); |
||
392 | IconThemeHelper.registerIcon("layer", "layer-icon-csv", ViewManager.class); |
||
393 | IconThemeHelper.registerIcon("layer", "layer-icon-dgn", ViewManager.class); |
||
394 | IconThemeHelper.registerIcon("layer", "layer-icon-dxf", ViewManager.class); |
||
395 | IconThemeHelper.registerIcon("layer", "layer-icon-postgresql", ViewManager.class); |
||
396 | IconThemeHelper.registerIcon("layer", "layer-icon-mysql", ViewManager.class); |
||
397 | IconThemeHelper.registerIcon("layer", "layer-icon-jdbc", ViewManager.class); |
||
398 | //IconThemeHelper.registerIcon("layer", "layer-icon-unavailable", ViewManager.class);
|
||
399 | IconThemeHelper.registerIcon("layer", "layer-chk-unavailable", ViewManager.class); |
||
400 | IconThemeHelper.registerIcon("layer", "layer-chk-temporary", ViewManager.class); |
||
401 | 40435 | jjdelcerro | |
402 | 44281 | jjdelcerro | IconThemeHelper.registerIcon("legend", "legend-overview-single-symbol", ViewManager.class); |
403 | IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-interval", ViewManager.class); |
||
404 | IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-unique-value", ViewManager.class); |
||
405 | 40435 | jjdelcerro | |
406 | 44281 | jjdelcerro | MapContextManager mapContextMgr = MapContextLocator.getMapContextManager(); |
407 | mapContextMgr.registerIconLayer("CSV", "layer-icon-csv"); |
||
408 | mapContextMgr.registerIconLayer("DGN", "layer-icon-dgn"); |
||
409 | mapContextMgr.registerIconLayer("DXF", "layer-icon-dxf"); |
||
410 | mapContextMgr.registerIconLayer("jdbc", "layer-icon-jdbc"); |
||
411 | mapContextMgr.registerIconLayer("PostgreSQL", "layer-icon-postgresql"); |
||
412 | mapContextMgr.registerIconLayer("MySQL", "layer-icon-mysql"); |
||
413 | |||
414 | if (factory.persistenceDefinition == null) { |
||
415 | 40435 | jjdelcerro | factory.persistenceDefinition = manager.addDefinition( |
416 | 44281 | jjdelcerro | ViewDocument.class, |
417 | PERSISTENCE_VIEW_DOCUMENT_DEFINITION_NAME, |
||
418 | "Default view document persistence definition",
|
||
419 | null,
|
||
420 | null
|
||
421 | 40435 | jjdelcerro | ); |
422 | factory.persistenceDefinition.extend(manager.getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME));
|
||
423 | |||
424 | factory.persistenceDefinition.addDynFieldBoolean("useMapOverview").setMandatory(true); |
||
425 | factory.persistenceDefinition.addDynFieldObject("mainMapContext").setClassOfValue(MapContext.class).setMandatory(true); |
||
426 | factory.persistenceDefinition.addDynFieldObject("overviewMapContext").setClassOfValue(MapContext.class).setMandatory(false); |
||
427 | 41350 | jjdelcerro | factory.persistenceDefinition.addDynFieldObject("propertiesHelper").setClassOfValue(ExtendedPropertiesHelper.class)
|
428 | 44281 | jjdelcerro | .setMandatory(false);
|
429 | |||
430 | 40435 | jjdelcerro | } |
431 | 44281 | jjdelcerro | ViewDocumentStoresRepository.selfRegister(); |
432 | ViewZoomActionFactory.selfRegister(); |
||
433 | 40435 | jjdelcerro | } |
434 | |||
435 | @SuppressWarnings("rawtypes") |
||
436 | public DynStruct getDefinition(String className) { |
||
437 | |||
438 | 44281 | jjdelcerro | if (this.persistenceDefinition.getName().equalsIgnoreCase(className)) { |
439 | 40435 | jjdelcerro | return this.persistenceDefinition; |
440 | } |
||
441 | 44281 | jjdelcerro | if (this.persistenceDefinition.getFullName().equalsIgnoreCase(className)) { |
442 | 40435 | jjdelcerro | return this.persistenceDefinition; |
443 | } |
||
444 | 44281 | jjdelcerro | if (this.getDocumentClass().getName().equals(className)) { |
445 | 40435 | jjdelcerro | return this.persistenceDefinition; |
446 | } |
||
447 | |||
448 | return null; |
||
449 | } |
||
450 | |||
451 | @SuppressWarnings("rawtypes") |
||
452 | protected Class getDocumentClass() { |
||
453 | return DefaultViewDocument.class;
|
||
454 | } |
||
455 | |||
456 | public boolean manages(Object object) { |
||
457 | return object instanceof ViewDocument; |
||
458 | } |
||
459 | } |