Statistics
| Revision:

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 / ViewPropertiesExtension.java @ 41574

History | View | Annotate | Download (2.88 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
import org.gvsig.andami.IconThemeHelper;
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.andami.preferences.IPreference;
28
import org.gvsig.andami.preferences.IPreferenceExtension;
29 41248 jjdelcerro
import org.gvsig.app.ApplicationLocator;
30
import org.gvsig.app.ApplicationManager;
31 40713 jldominguez
import org.gvsig.app.gui.preferencespage.LayerOrderPage;
32 40435 jjdelcerro
import org.gvsig.app.gui.preferencespage.ViewBehaviorPage;
33
import org.gvsig.app.project.documents.view.ViewDocument;
34 41264 jjdelcerro
import org.gvsig.app.project.documents.view.gui.IView;
35 40435 jjdelcerro
import org.gvsig.app.project.documents.view.gui.ViewProperties;
36
37
public class ViewPropertiesExtension extends Extension implements IPreferenceExtension {
38 41248 jjdelcerro
39
    private ViewBehaviorPage vb = new ViewBehaviorPage();
40
    private LayerOrderPage lo_page = new LayerOrderPage();
41
42 40435 jjdelcerro
    public void initialize() {
43 41248 jjdelcerro
        IconThemeHelper.registerIcon("preferences", "grid-preferences", this);
44
        IconThemeHelper.registerIcon("preferences", "layer-order-preferences", this);
45 40435 jjdelcerro
    }
46
47
    public void execute(String s) {
48 41248 jjdelcerro
        ApplicationManager application = ApplicationLocator.getManager();
49 40435 jjdelcerro
50 41264 jjdelcerro
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
51
        if (view == null) {
52 41248 jjdelcerro
            return;
53 40435 jjdelcerro
        }
54 41264 jjdelcerro
        ViewDocument document = view.getViewDocument();
55
56 41248 jjdelcerro
        if (s.equalsIgnoreCase("view-properties")) {
57
            ViewProperties viewProperties = new ViewProperties(document);
58
            application.getUIManager().addWindow(viewProperties);
59
            if (viewProperties.isAcceppted()) {
60
                document.setModified(true);
61
            }
62
        }
63 40435 jjdelcerro
    }
64
65 41248 jjdelcerro
    public boolean isEnabled() {
66 40435 jjdelcerro
        return true;
67
    }
68
69
    public boolean isVisible() {
70 41248 jjdelcerro
        ApplicationManager application = ApplicationLocator.getManager();
71
72 41264 jjdelcerro
        return application.getActiveComponent(ViewDocument.class) != null;
73 40435 jjdelcerro
    }
74
75
    public IPreference[] getPreferencesPages() {
76 41248 jjdelcerro
        return new IPreference[]{vb, lo_page};
77 40435 jjdelcerro
    }
78
}