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 / ViewSimpleSelectionControl.java @ 41258
History | View | Annotate | Download (2.99 KB)
1 | 41066 | jldominguez | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | 41248 | jjdelcerro | * This program is free software; you can redistribute it and/or modify it under
|
7 | * the terms of the GNU General Public License as published by the Free Software
|
||
8 | * Foundation; either version 3 of the License, or (at your option) any later
|
||
9 | * version.
|
||
10 | 41066 | jldominguez | *
|
11 | 41248 | jjdelcerro | * This program is distributed in the hope that it will be useful, but WITHOUT
|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||
14 | * details.
|
||
15 | 41066 | jldominguez | *
|
16 | 41248 | jjdelcerro | * You should have received a copy of the GNU General Public License along with
|
17 | * this program; if not, write to the Free Software Foundation, Inc., 51
|
||
18 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
19 | 41066 | jldominguez | *
|
20 | 41248 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 41066 | jldominguez | */
|
23 | package org.gvsig.app.extension; |
||
24 | |||
25 | import org.gvsig.andami.IconThemeHelper; |
||
26 | import org.gvsig.andami.plugins.Extension; |
||
27 | 41248 | jjdelcerro | import org.gvsig.app.ApplicationLocator; |
28 | import org.gvsig.app.ApplicationManager; |
||
29 | 41066 | jldominguez | import org.gvsig.app.project.documents.view.ViewDocument; |
30 | import org.gvsig.app.project.documents.view.gui.IView; |
||
31 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
32 | import org.slf4j.Logger; |
||
33 | import org.slf4j.LoggerFactory; |
||
34 | |||
35 | /**
|
||
36 | * Extension that handles the simple selection tool
|
||
37 | *
|
||
38 | */
|
||
39 | public class ViewSimpleSelectionControl extends Extension { |
||
40 | 41248 | jjdelcerro | |
41 | 41066 | jldominguez | private static final Logger logger = LoggerFactory |
42 | .getLogger(ViewSimpleSelectionControl.class); |
||
43 | |||
44 | 41248 | jjdelcerro | public void initialize() { |
45 | registerIcons(); |
||
46 | } |
||
47 | 41066 | jldominguez | |
48 | 41248 | jjdelcerro | private void registerIcons() { |
49 | IconThemeHelper.registerIcon("action", "selection-simple-select", this); |
||
50 | } |
||
51 | 41066 | jldominguez | |
52 | 41248 | jjdelcerro | public void execute(String actionCommand) { |
53 | ApplicationManager application = ApplicationLocator.getManager(); |
||
54 | 41066 | jldominguez | |
55 | 41248 | jjdelcerro | ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class); |
56 | if (document == null) { |
||
57 | return;
|
||
58 | } |
||
59 | IView view = (IView) document.getMainComponent(); |
||
60 | MapControl mapCtrl = view.getMapControl(); |
||
61 | if (actionCommand.equalsIgnoreCase("selection-simple-select-view")) { |
||
62 | mapCtrl.setTool("pointSelection");
|
||
63 | document.setModified(true);
|
||
64 | } |
||
65 | 41066 | jldominguez | } |
66 | |||
67 | 41248 | jjdelcerro | public boolean isEnabled() { |
68 | ApplicationManager application = ApplicationLocator.getManager(); |
||
69 | 41066 | jldominguez | |
70 | 41248 | jjdelcerro | ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class); |
71 | if (document == null) { |
||
72 | return false; |
||
73 | 41066 | jldominguez | } |
74 | 41248 | jjdelcerro | return document.getMapContext().hasActiveVectorLayers();
|
75 | } |
||
76 | |||
77 | public boolean isVisible() { |
||
78 | ApplicationManager application = ApplicationLocator.getManager(); |
||
79 | |||
80 | ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class); |
||
81 | if (document == null) { |
||
82 | return false; |
||
83 | } |
||
84 | return document.getMapContext().hasVectorLayers();
|
||
85 | } |
||
86 | |||
87 | 41066 | jldominguez | } |