svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / InfoToolExtension.java @ 40596
History | View | Annotate | Download (2.99 KB)
1 |
/**
|
---|---|
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 |
|
25 |
package org.gvsig.app.extension; |
26 |
|
27 |
import org.gvsig.andami.IconThemeHelper; |
28 |
import org.gvsig.andami.plugins.Extension; |
29 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
30 |
import org.gvsig.app.ApplicationLocator; |
31 |
import org.gvsig.app.project.documents.view.gui.IView; |
32 |
import org.gvsig.fmap.mapcontext.MapContext; |
33 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
34 |
import org.gvsig.fmap.mapcontrol.MapControl; |
35 |
import org.slf4j.Logger; |
36 |
import org.slf4j.LoggerFactory; |
37 |
|
38 |
|
39 |
|
40 |
/**
|
41 |
* Extension that handles the info by point tool for a selected layer set
|
42 |
* @author laura
|
43 |
*/
|
44 |
public class InfoToolExtension extends Extension { |
45 |
private static final Logger logger = LoggerFactory |
46 |
.getLogger(InfoToolExtension.class); |
47 |
|
48 |
public void initialize() { |
49 |
IconThemeHelper.registerIcon("action", "layer-info-by-point", this); |
50 |
} |
51 |
|
52 |
public void execute(String s) { |
53 |
IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
54 |
if( window instanceof IView ) { |
55 |
IView view = (IView) window; |
56 |
MapControl mapCtrl = view.getMapControl(); |
57 |
|
58 |
if (s.compareTo("layer-info-by-point") == 0) { |
59 |
mapCtrl.setTool("info");
|
60 |
view.getDocument().setModified(true);
|
61 |
} |
62 |
} |
63 |
} |
64 |
|
65 |
public boolean isEnabled() { |
66 |
IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
67 |
|
68 |
if (window == null) { |
69 |
return false; |
70 |
} |
71 |
|
72 |
if (window instanceof IView) { |
73 |
IView view = (IView) window; |
74 |
MapContext mapa = view.getViewDocument().getMapContext(); |
75 |
|
76 |
FLayer[] layers =mapa.getLayers().getActives();
|
77 |
for (int i=0;i<layers.length;i++) { |
78 |
if (layers[i].isAvailable()) {
|
79 |
return true; |
80 |
} |
81 |
} |
82 |
} |
83 |
return false; |
84 |
} |
85 |
|
86 |
public boolean isVisible() { |
87 |
IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
88 |
|
89 |
if (window == null) { |
90 |
return false; |
91 |
} |
92 |
|
93 |
if (window instanceof IView) { |
94 |
IView view = (IView) window; |
95 |
MapContext mapa = view.getViewDocument().getMapContext(); |
96 |
return mapa.getLayers().getLayersCount() > 0; |
97 |
} else {
|
98 |
return false; |
99 |
} |
100 |
} |
101 |
} |
102 |
|