gvsig-raster / org.gvsig.raster.wms / trunk / org.gvsig.raster.wms / org.gvsig.raster.wms.app.wmsclient / src / main / java / org / gvsig / raster / wms / app / wmsclient / WMSClientExtension.java @ 22301
History | View | Annotate | Download (3.64 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
package org.gvsig.raster.wms.app.wmsclient; |
24 |
|
25 |
import org.gvsig.andami.IconThemeHelper; |
26 |
import org.gvsig.andami.plugins.Extension; |
27 |
import org.gvsig.app.extension.AddLayer; |
28 |
import org.gvsig.fmap.dal.DataParameters; |
29 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
30 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
32 |
import org.gvsig.raster.wms.app.wmsclient.gui.toc.WMSPropsTocMenuEntry; |
33 |
import org.gvsig.raster.wms.app.wmsclient.gui.wizard.WMSWizard; |
34 |
import org.gvsig.raster.wms.app.wmsclient.layer.DynObjectSetWMSInfo; |
35 |
import org.gvsig.raster.wms.app.wmsclient.layer.FLyrWMS; |
36 |
import org.gvsig.raster.wms.io.WMSDataParameters; |
37 |
import org.gvsig.tools.ToolsLocator; |
38 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
39 |
import org.gvsig.tools.util.Factory; |
40 |
import org.gvsig.tools.util.IsApplicable; |
41 |
|
42 |
|
43 |
/**
|
44 |
* Extension for adding WMS support to gvSIG.
|
45 |
*
|
46 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
47 |
*/
|
48 |
public class WMSClientExtension extends Extension { |
49 |
|
50 |
public void initialize() { |
51 |
|
52 |
// Adds an entry to the TOC's floating menu to those layers defined in this extension
|
53 |
ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add( |
54 |
"View_TocActions");
|
55 |
|
56 |
exPoint.append("WMSProperties", "", new WMSPropsTocMenuEntry()); |
57 |
|
58 |
// Adds a new tab to the "add layer" wizard for WMS layer creation
|
59 |
AddLayer.addWizard(WMSWizard.class); |
60 |
|
61 |
ToolsLocator.getExtensionPointManager().add("CatalogLayers").append(
|
62 |
"OGC:WMS", "", FLyrWMS.class); |
63 |
initilizeIcons(); |
64 |
DynObjectSetWMSInfo.registerDynClass(); |
65 |
} |
66 |
|
67 |
private static class WMSLayerFactory implements Factory<FLayer> { |
68 |
@Override
|
69 |
public String getName() { |
70 |
return FLyrWMS.class.getName();
|
71 |
} |
72 |
|
73 |
@Override
|
74 |
public FLayer create(Object... os) { |
75 |
DataParameters parameters = (DataParameters) os[0];
|
76 |
if( !(parameters instanceof WMSDataParameters) ) { |
77 |
return null; |
78 |
} |
79 |
return new FLyrWMS(); |
80 |
} |
81 |
} |
82 |
|
83 |
public void postInitialize() { |
84 |
FLyrWMS.registerPersistent(); |
85 |
MapContextManager mapContextManager = MapContextLocator.getMapContextManager(); |
86 |
mapContextManager.registerLayer(new WMSLayerFactory());
|
87 |
} |
88 |
|
89 |
public void execute(String actionCommand) { |
90 |
// no commands, no code.
|
91 |
} |
92 |
|
93 |
public boolean isEnabled() { |
94 |
// may return whatever
|
95 |
return false; |
96 |
} |
97 |
|
98 |
public boolean isVisible() { |
99 |
// may return whatever
|
100 |
return false; |
101 |
} |
102 |
|
103 |
void initilizeIcons(){
|
104 |
IconThemeHelper.registerIcon(null, "aplication-preferences-uparrow", this); |
105 |
IconThemeHelper.registerIcon(null, "aplication-preferences-downarrow", this); |
106 |
IconThemeHelper.registerIcon(null, "icon-layer-wms", this); |
107 |
} |
108 |
} |