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 / LayerPropertiesExtension.java @ 43147
History | View | Annotate | Download (3.85 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 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 |
*
|
11 |
* 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 |
*
|
16 |
* 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 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.app.extension; |
24 |
|
25 |
import org.gvsig.andami.IconThemeHelper; |
26 |
import org.gvsig.andami.plugins.Extension; |
27 |
import org.gvsig.app.ApplicationLocator; |
28 |
import org.gvsig.app.ApplicationManager; |
29 |
import org.gvsig.app.project.ProjectManager; |
30 |
import org.gvsig.app.project.documents.view.ViewDocument; |
31 |
import org.gvsig.app.project.documents.view.ViewManager; |
32 |
import org.gvsig.app.project.documents.view.gui.IView; |
33 |
import org.gvsig.app.project.documents.view.gui.LayerProperties; |
34 |
import org.gvsig.app.project.documents.view.toc.gui.FPopupMenu; |
35 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
36 |
import org.gvsig.tools.ToolsLocator; |
37 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
38 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
39 |
|
40 |
public class LayerPropertiesExtension extends Extension { |
41 |
|
42 |
@Override
|
43 |
public void initialize() { |
44 |
} |
45 |
|
46 |
@Override
|
47 |
public void postInitialize() { |
48 |
FPopupMenu.registerExtensionPoint(); |
49 |
IconThemeHelper.registerIcon("action", "layer-properties", this); |
50 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
51 |
ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME); |
52 |
viewManager.addTOCContextAction("layer-properties","group-last",10000,900); |
53 |
} |
54 |
|
55 |
@Override
|
56 |
public void execute(String s) { |
57 |
|
58 |
ApplicationManager application = ApplicationLocator.getManager(); |
59 |
|
60 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
61 |
if (view == null) { |
62 |
return;
|
63 |
} |
64 |
ViewDocument document = view.getViewDocument(); |
65 |
if (!document.getMapContext().hasActiveLayers()) {
|
66 |
return;
|
67 |
} |
68 |
|
69 |
if (s.equalsIgnoreCase("layer-properties")) { |
70 |
FLayer layer = document.getMapContext().getLayers().getActives()[0];
|
71 |
LayerProperties dlg = new LayerProperties(layer);
|
72 |
WindowManager wm = ToolsSwingLocator.getWindowManager(); |
73 |
wm.showWindow( |
74 |
dlg.asJComponent(), |
75 |
ToolsLocator.getI18nManager().getTranslation("propiedades_de_la_capa"),
|
76 |
WindowManager.MODE.WINDOW |
77 |
); |
78 |
} |
79 |
} |
80 |
|
81 |
@Override
|
82 |
public boolean isEnabled() { |
83 |
ApplicationManager application = ApplicationLocator.getManager(); |
84 |
|
85 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
86 |
if (view == null) { |
87 |
return false; |
88 |
} |
89 |
ViewDocument document = view.getViewDocument(); |
90 |
return document.getMapContext().hasActiveLayers();
|
91 |
} |
92 |
|
93 |
@Override
|
94 |
public boolean isVisible() { |
95 |
ApplicationManager application = ApplicationLocator.getManager(); |
96 |
|
97 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
98 |
if (view == null) { |
99 |
return false; |
100 |
} |
101 |
ViewDocument document = view.getViewDocument(); |
102 |
return document.getMapContext().hasLayers();
|
103 |
} |
104 |
|
105 |
} |