Statistics
| Revision:

svn-gvsig-desktop / tags / Root_v10 / examples / exaExampleCenterViewToPoint / src / org / gvsig / examples / example1 / ExampleExtension.java @ 13670

History | View | Annotate | Download (6.89 KB)

1 11685 caballero
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
43 11689 caballero
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
44
 *
45
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
46
 *
47
 * This program is free software; you can redistribute it and/or
48
 * modify it under the terms of the GNU General Public License
49
 * as published by the Free Software Foundation; either version 2
50
 * of the License, or (at your option) any later version.
51
 *
52
 * This program is distributed in the hope that it will be useful,
53
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
54
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
55
 * GNU General Public License for more details.
56
 *
57
 * You should have received a copy of the GNU General Public License
58
 * along with this program; if not, write to the Free Software
59
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
60
 *
61
 * For more information, contact:
62
 *
63
 *  Generalitat Valenciana
64
 *   Conselleria d'Infraestructures i Transport
65
 *   Av. Blasco Ib??ez, 50
66
 *   46010 VALENCIA
67
 *   SPAIN
68
 *
69
 *      +34 963862235
70
 *   gvsig@gva.es
71
 *      www.gvsig.gva.es
72
 *
73
 *    or
74
 *
75
 *   IVER T.I. S.A
76
 *   Salamanca 50
77
 *   46005 Valencia
78
 *   Spain
79
 *
80
 *   +34 963163400
81
 *   dac@iver.es
82
 */
83 11685 caballero
package org.gvsig.examples.example1;
84
85
import com.iver.andami.PluginServices;
86
import com.iver.andami.plugins.Extension;
87
import com.iver.andami.plugins.ExtensionDecorator;
88
import com.iver.andami.preferences.IPreference;
89
import com.iver.andami.preferences.IPreferenceExtension;
90
91
import com.iver.cit.gvsig.About;
92
import com.iver.cit.gvsig.gui.panels.FPanelAbout;
93
94
import com.iver.utiles.extensionPoints.ExtensionPoints;
95
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
96
97
import org.gvsig.examples.example1.preferences.CenterViewToPointPage;
98
import org.gvsig.examples.example1.toc.PropertiesTocMenuEntry;
99
100
import java.util.ArrayList;
101
102
103
/**
104
 * Example of extension with a dialog of preferences, option in a context menu,
105
 * Exclusive extensions and about page.
106
 *
107
 * @author Vicente Caballero Navarro
108
 */
109
public class ExampleExtension extends Extension implements IPreferenceExtension {
110 11689 caballero
    private CenterViewToPointPage centerViewPage = new CenterViewToPointPage();
111 11685 caballero
112
    /* (non-Javadoc)
113
     * @see com.iver.andami.plugins.IExtension#initialize()
114
     */
115
    public void initialize() {
116
    }
117
118
    /* (non-Javadoc)
119
     * @see com.iver.andami.plugins.IExtension#postInitialize()
120
     */
121
    public void postInitialize() {
122
        super.postInitialize();
123
124
        ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
125
        extensionPoints.add("View_TocActions", "CenterViewToPoint",
126
            new PropertiesTocMenuEntry());
127
128
        About about = (About) PluginServices.getExtension(About.class);
129
        FPanelAbout panelAbout = about.getAboutPanel();
130
        java.net.URL aboutURL = this.getClass().getResource("/about.htm");
131
        panelAbout.addAboutUrl(PluginServices.getText(this, "example_extension"),
132
            aboutURL);
133
134
        exclusiveExtensions();
135
    }
136
137 11689 caballero
    /**
138
     *
139
     */
140 11685 caballero
    private void exclusiveExtensions() {
141
        ArrayList goodExtensions = new ArrayList();
142
        String[] ss = new String[] {
143
                "com.iver.core.Consola", "com.iver.core.StatusBar",
144
                "com.iver.cit.gvsig.ViewControls", "com.iver.cit.gvsig.AddLayer",
145
                "com.iver.cit.gvsig.ProjectExtension",
146
                "com.iver.cit.gvsig.About", "com.iver.cit.gvsig.LayoutControls",
147
                "com.iver.cit.gvsig.ViewPropertiesExtension",
148
                "com.iver.cit.gvsig.ZoomPrev",
149
                "com.iver.cit.gvsig.ViewProjectWindow",
150
                "com.iver.cit.gvsig.Print", "com.iver.cit.gvsig.PrintProperties",
151
                "com.iver.cit.gvsig.LayoutEditableControls",
152
                "com.iver.cit.gvsig.LayoutUndoExtension",
153
                "com.iver.cit.gvsig.LayoutRedoExtension",
154
                "com.iver.cit.gvsig.LayoutInsertToolsExtension",
155
                "com.iver.cit.gvsig.LayoutGraphicControls",
156
                "com.iver.cit.gvsig.LayoutEditVertexExtension",
157
                "com.iver.cit.gvsig.ViewSelectionControls",
158
                "org.gvsig.examples.example1.extension.CenterViewToPointExtension",
159
                "org.gvsig.examples.example1.extension.InfoToolExampleExtension",
160 11728 caballero
                "org.gvsig.examples.example1.extension.OpenCSVToPointsExtension",
161
                "org.gvsig.examples.example1.ExampleExtension"
162 11685 caballero
            };
163
164
        for (int i = 0; i < ss.length; i++) {
165
            goodExtensions.add(ss[i]);
166
        }
167
168
        ExtensionDecorator[] exts = PluginServices.getDecoratedExtensions();
169
170
        for (int i = 0; i < exts.length; i++) {
171
            if (!goodExtensions.contains(exts[i].getExtension().getClass()
172
                                                    .getName())) {
173
                exts[i].setVisibility(ExtensionDecorator.ALWAYS_INVISIBLE);
174
                System.out.println(exts[i].getExtension().getClass().getName());
175
            } else {
176
                exts[i].setVisibility(ExtensionDecorator.INACTIVE);
177
                System.err.println(exts[i].getExtension().getClass().getName());
178
            }
179
        }
180
    }
181
182
    /* (non-Javadoc)
183
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
184
     */
185
    public void execute(String arg0) {
186
    }
187
188
    /* (non-Javadoc)
189
     * @see com.iver.andami.plugins.IExtension#isEnabled()
190
     */
191
    public boolean isEnabled() {
192
        return false;
193
    }
194
195
    /* (non-Javadoc)
196
     * @see com.iver.andami.plugins.IExtension#isVisible()
197
     */
198
    public boolean isVisible() {
199
        return false;
200
    }
201
202
    /* (non-Javadoc)
203
     * @see com.iver.andami.preferences.IPreferenceExtension#getPreferencesPage()
204
     */
205
    public IPreference getPreferencesPage() {
206
        return centerViewPage;
207
    }
208
}