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 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40558 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40435 | jjdelcerro | *
|
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 | 40435 | jjdelcerro | *
|
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 | 40435 | jjdelcerro | *
|
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 | 40435 | jjdelcerro | */
|
23 | package org.gvsig.app.extension; |
||
24 | |||
25 | 42506 | jjdelcerro | import org.gvsig.andami.IconThemeHelper; |
26 | 40435 | jjdelcerro | import org.gvsig.andami.plugins.Extension; |
27 | 41248 | jjdelcerro | import org.gvsig.app.ApplicationLocator; |
28 | import org.gvsig.app.ApplicationManager; |
||
29 | 42506 | jjdelcerro | import org.gvsig.app.project.ProjectManager; |
30 | 40435 | jjdelcerro | import org.gvsig.app.project.documents.view.ViewDocument; |
31 | 42506 | jjdelcerro | import org.gvsig.app.project.documents.view.ViewManager; |
32 | 41264 | jjdelcerro | import org.gvsig.app.project.documents.view.gui.IView; |
33 | 42175 | jjdelcerro | import org.gvsig.app.project.documents.view.gui.LayerProperties; |
34 | 42506 | jjdelcerro | import org.gvsig.app.project.documents.view.toc.gui.FPopupMenu; |
35 | 42175 | jjdelcerro | 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 | 40435 | jjdelcerro | |
40 | 42175 | jjdelcerro | public class LayerPropertiesExtension extends Extension { |
41 | 41248 | jjdelcerro | |
42 | 43147 | jjdelcerro | @Override
|
43 | 40435 | jjdelcerro | public void initialize() { |
44 | } |
||
45 | |||
46 | 42506 | jjdelcerro | @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 | 43147 | jjdelcerro | @Override
|
56 | 40435 | jjdelcerro | public void execute(String s) { |
57 | 42175 | jjdelcerro | |
58 | 41248 | jjdelcerro | ApplicationManager application = ApplicationLocator.getManager(); |
59 | 40435 | jjdelcerro | |
60 | 41264 | jjdelcerro | IView view = (IView) application.getActiveComponent(ViewDocument.class); |
61 | if (view == null) { |
||
62 | 41248 | jjdelcerro | return;
|
63 | 40435 | jjdelcerro | } |
64 | 41264 | jjdelcerro | ViewDocument document = view.getViewDocument(); |
65 | 43147 | jjdelcerro | if (!document.getMapContext().hasActiveLayers()) {
|
66 | 42175 | jjdelcerro | return;
|
67 | } |
||
68 | 41264 | jjdelcerro | |
69 | 42175 | jjdelcerro | 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 | 41248 | jjdelcerro | } |
79 | 40435 | jjdelcerro | } |
80 | |||
81 | 43147 | jjdelcerro | @Override
|
82 | 41248 | jjdelcerro | public boolean isEnabled() { |
83 | 42175 | jjdelcerro | 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 | 43147 | jjdelcerro | return document.getMapContext().hasActiveLayers();
|
91 | 40435 | jjdelcerro | } |
92 | |||
93 | 43147 | jjdelcerro | @Override
|
94 | 40435 | jjdelcerro | public boolean isVisible() { |
95 | 41248 | jjdelcerro | ApplicationManager application = ApplicationLocator.getManager(); |
96 | |||
97 | 42175 | jjdelcerro | IView view = (IView) application.getActiveComponent(ViewDocument.class); |
98 | if (view == null) { |
||
99 | return false; |
||
100 | } |
||
101 | ViewDocument document = view.getViewDocument(); |
||
102 | 43147 | jjdelcerro | return document.getMapContext().hasLayers();
|
103 | 40435 | jjdelcerro | } |
104 | |||
105 | } |