Statistics
| Revision:

root / branches / v10 / frameworks / _fwAndami / src / com / iver / andami / plugins / IExtension.java @ 13656

History | View | Annotate | Download (5.83 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004-2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.andami.plugins;
42

    
43
import com.iver.andami.plugins.status.IExtensionStatus;
44

    
45
/**
46
 * <p>
47
 * Extensions are the way in which plugins extend Andami. Every class
48
 * implementing this interface is an extension (although this class
49
 * should not be directly implemented, extending the {@link Extension}
50
 * abstract class is the preferred way). During startup,
51
 * Andami creates an instance from each extension. Extensions are able
52
 * to add controls (tools, toolbars and menus)
53
 * to the user interface (GUI); when these controls
54
 * are clicked or modified, Andami will call the <code>execute()</code>
55
 * method from the associated extension. Extensions will also control
56
 * whether their associated controls are enabled or not, and whether
57
 * they are visible or hidden.
58
 * </p>
59
 * <p>
60
 * Besides implementing this interface, extensions are required to have
61
 * an empty constructor, because it will be invoked to create the
62
 * extension's instance.
63
 * </p>
64
 * <p>
65
 * On correctly installed plugins, an instance of every plugin's
66
 * extension will be created. Then, the <code>initialize()</code>
67
 * method will be executed for each extension.
68
 * </p>
69
 * <p>
70
 * Each time the active window is switched and every time the execute
71
 * method is called, Andami checks the <code>isEnabled()</code> and
72
 * <code>isVisible()</code> for each extension, to decide whether
73
 * they will be enabled and visible.
74
 * </p>
75
 * <p>
76
 * The <code>execute()</code> method will be called from the GUI
77
 * thread, so it will block the GUI until it finishes. Therefore,
78
 * execution must be fast. If long process must be started from
79
 * the <code>execute</code> method, a new thread must be created.
80
 * </p>
81
 * <p>
82
 * Normally, extensions should not directly implement this interface,
83
 * but they should extend the <code>Extension</code> abstract class.
84
 * </p>
85
 *
86
 * @see Extension
87
 */
88
public interface IExtension {
89
        /**
90
         * Extension's initialization code should be here.
91
         * This method is called for all the extensions during
92
         * Andami's initialization.
93
     */
94
    public void initialize();
95

    
96
    /**
97
     * Extension's post-initialization code should be here.
98
         * This method is called for all the extensions during
99
         * Andami's initialization, after <code>initialize()</code>
100
         * has been called for ALL the extensions.
101
     */
102
    public void postInitialize();
103
    /**
104
     * Extension's termination code should be here.
105
     * This method is called for all the extensions during
106
     * Andami's termination.
107
     */
108
    public void terminate();
109

    
110
    /**
111
     * This method is executed when the user clicks on any of the
112
     * controls associated with this extension (menus, tools, etc).
113
     *
114
     * @param actionCommand An String specifying the action to
115
     * execute. This is useful when there are different
116
     * controls associated with the same extension.
117
     */
118
    public void execute(String actionCommand);
119

    
120
    /**
121
     * This method is invoked by Andami to check whether the extension
122
     * (and its associated controls) is enabled or disabled.
123
     * Disabled controls (menus and buttons) are shown in light grey
124
     * colour, and it is not possible to click on them.
125
     *
126
     * @return true if the extension should be enabled, false otherwise
127
     */
128
    public boolean isEnabled();
129

    
130
    /**
131
     * This method is invoked by Andami to check whether the extension
132
     * (and its associated controls) is visible or hidden.
133
     *
134
     * @return true if the extension should be visible, false otherwise
135
     */
136
    public boolean isVisible();
137

    
138
    /**
139
     * This method is used when this extension is installed as
140
     * ExclusiveUIExtension. This extension will be asked for
141
     * each installed extension to determine which of them
142
     * should be enabled.
143
     *
144
     * @return true if the provided extension should be enabled,
145
     * false if it should be disabled.
146
     */
147
    public boolean isEnabled(IExtension extension);
148

    
149
    /**
150
     * This method is used when this extension is installed as
151
     * ExclusiveUIExtension. This extension will be asked for
152
     * each installed extension to determine which of them
153
     * should be visible.
154
     *
155
     * @return true if the provided extension should be visible,
156
     * false if it should be hidden.
157
     */
158
    public boolean isVisible(IExtension extension);
159

    
160
    /**
161
     * Gets the status of the extension, which may be queried to check
162
     * if the extension has some unsaved data or some associated background
163
     * tasks.
164
     *
165
     * @see IExtensionStatus
166
     * @return An IExtensionStatus object, containing the status of this
167
     * extension.
168
     */
169
    public IExtensionStatus getStatus();
170
    public IExtensionStatus getStatus(IExtension extension);
171
}