Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / ui / mdiManager / MDIManager.java @ 41314

History | View | Annotate | Download (11.3 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
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui.mdiManager;
25

    
26
import java.awt.GridBagConstraints;
27
import java.beans.PropertyVetoException;
28
import java.util.Locale;
29

    
30
import javax.swing.ImageIcon;
31
import javax.swing.JPanel;
32

    
33
import org.gvsig.andami.ui.mdiFrame.MDIFrame;
34
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
35
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
36

    
37

    
38

    
39
/**
40
 * <p>
41
 * This interface acts as window manager. It is the place to create
42
 * new windows, close existing ones or modify their properties
43
 * (size, position, etc).
44
 * </p>
45
 * <p>
46
 * Any class extending from JPanel and implementing the {@link IWindow}
47
 * interface may become an Andami window. Andami will create a real
48
 * window (normally a JInternalFrame) and put the JPanel inside the
49
 * real window. In order to differentiate the contents (panels
50
 * extending JPanel and implementing IWindow) from the real window
51
 * (normally JInternalFrames or JDialogs), we will use
52
 * <i>window</i> to refer to the contents and <i>frame</i>
53
 * to refer to the real window.
54
 * </p>
55
 * <p>
56
 * This class is implemented by the Andami Skin (currently libCorePlugin),
57
 * which will decide the final implementation of frames. A different frame
58
 * implementation could be used by switching the Skin.
59
 * </p>
60
 * 
61
 * @see IWindow
62
 * @see WindowInfo
63
 * @see SingletonWindow
64
 *
65
 */
66
public interface MDIManager {
67
        
68
    /**
69
     * Initializes the MDIFrame. It must be called before starting
70
     * to use it. It receives the application's main frame
71
     * (MDIFrame) as parameter.  
72
     *
73
     * @param f Application's main frame.
74
     */
75
    public void init(MDIFrame f);
76

    
77
    /**
78
     * <p>
79
     * Creates a new frame with the provided contents, and shows this
80
     * new window. The new frame's properties are set according to
81
     * the WindowInfo object from IWindow's <code>getWindowInfo()</code>
82
     * method.
83
     * The new frame is disposed when closed. 
84
     * </p>
85
     * <p>
86
     * If the provided IWindow also implements SingletonWindow, and
87
     * another SingletonWindow already exists and uses the same
88
     * model, this later window will be sent to the foreground
89
     * and no new window will be created.
90
     * </p>
91
     *
92
     * @param p Panel with the contents of the new window.
93
     *
94
     * @return Returns the added IWindow, or in case it is a
95
     * SingletonWindow and there is another SingletonWindow with
96
     * the same model that it is already shown, returns this 
97
     * later SingletonWindow.
98
     */
99
    public IWindow addWindow(IWindow p) throws SingletonDialogAlreadyShownException;
100

    
101
    
102
    /*
103
     * Constants used by the method showWindow 
104
     */
105
    public final MODE WINDOW = WindowManager.MODE.WINDOW;
106
    public final MODE TOOL = WindowManager.MODE.TOOL;
107
    public final MODE DIALOG = WindowManager.MODE.DIALOG;
108
    
109
    /**
110
     * Useful method to simplify the presentation of a window. 
111
     * For more precise control over the behavior of the window 
112
     * use addWindow
113
     * 
114
     * This methos 
115
     * @param panel to show as a window
116
     * @param title title of the window
117
     * @param mode type of the window to create
118
     */
119
    public void showWindow(JPanel panel, String title, MODE mode);
120

    
121
    /**
122
     * Return the window associated to the SingletonWindow class and the model
123
     * specified. If not exists any singleton window associated to this
124
     * null is returned.
125
     * 
126
     * @param windowClass, the class that implement SingletonWindow
127
     * @param model, the model associated to the SingletonWindow
128
     * @return the requested window or null.
129
     */
130
    public SingletonWindow getSingletonWindow(Class windowClass, Object model) ;
131
    
132
    /**
133
     * <p>
134
     * Creates a new frame with the provided contents, and shows this
135
     * new window. The new frame will be centered, regardless the
136
     * position specified in the WindowInfo object from IWindow's
137
     * <code>getWindowInfo()</code> method.
138
     * The new frame is disposed when closed. 
139
     * </p>
140
     * <p>
141
     * If the provided IWindow also implements SingletonWindow, and
142
     * another SingletonWindow already exists and uses the same
143
     * model, this later window will be sent to the foreground
144
     * and no new window will be created.
145
     * </p>
146
     *
147
     * @param p Panel with the contents of the new window.
148
     *
149
     * @return Returns the added IWindow, or in case it is a
150
     * SingletonWindow and there is another SingletonWindow with
151
     * the same model that it is already shown, returns this 
152
     * later SingletonWindow.
153
     * 
154
     * @author Pablo Piqueras Bartolom?
155
     */
156
    public IWindow addCentredWindow(IWindow p) throws SingletonDialogAlreadyShownException;
157

    
158
    public static final int ALIGN_FIRST_LINE_START = GridBagConstraints.FIRST_LINE_START;
159
    public static final int ALIGN_PAGE_START = GridBagConstraints.PAGE_START;
160
    public static final int ALIGN_FIRST_LINE_END = GridBagConstraints.FIRST_LINE_END;
161
    public static final int ALIGN_FIRST_LINE_END_CASCADE = GridBagConstraints.FIRST_LINE_END + GridBagConstraints.BELOW_BASELINE;
162
    public static final int ALIGN_LINE_START = GridBagConstraints.LINE_START;
163
    public static final int ALIGN_LINE_END = GridBagConstraints.LINE_END;
164
    public static final int ALIGN_LAST_LINE_START = GridBagConstraints.LAST_LINE_START;
165
    public static final int ALIGN_PAGE_END = GridBagConstraints.PAGE_END;
166
    public static final int ALIGN_LAST_LINE_END = GridBagConstraints.LAST_LINE_END;
167
    public static final int ALIGN_CENTER = GridBagConstraints.CENTER;
168
    
169
    public IWindow addWindow(IWindow p, int align) throws SingletonDialogAlreadyShownException;
170

    
171
    /**
172
     * <p>
173
     * Returns the currently active window, excluding the modal windows and the
174
     * PALETTE windows. If the currently active window is modal or PALETTE type,
175
     * the previous non-modal and non-PALETTE active window is returned.
176
     * </p>
177
     * <p>
178
     * Modal windows and PALETTE windows are considered to be auxiliary windows,
179
     * that is the reason why they are not returned.
180
     * </p> 
181
     *
182
     * @return A reference to the active window, or null if there is no
183
     * active window
184
     */
185
    public IWindow getActiveWindow();
186

    
187
    /**
188
     * <p>
189
     * Returns the currently focused window, excluding the modal windows.
190
     * If the currently focused window is modal,
191
     * the previous non-modal focused window is returned.
192
     * </p>
193
     *
194
     * @return A reference to the focused window, or null if there is no
195
     * focused window
196
     */
197
    public IWindow getFocusWindow();
198
    
199
    /**
200
     * Gets all the open windows. Minimized and maximized windows are
201
     * included. The application's main frame is excluded; it can be
202
     * accessed using <code>PluginServices.getMainFrame()</code>.
203
     *
204
     * @return An IWindow array containing all the open windows.
205
     */
206
    public IWindow[] getAllWindows();
207
    
208
    /**
209
     * Gets all the open windows (as {@link #getAllWindows()}),
210
     * but in this method the windows are returned in the same
211
     * deepness order that they have in the application.
212
     *
213
     * @return   An ordered array containing all the panels in the application.
214
     * The first element of the array is the topmost (foreground) window in the
215
     * application. The last element is the bottom (background) window.
216
     */
217
    public IWindow[] getOrderedWindows();
218

    
219
    /**
220
     * Close the SingletonWindow whose class and model are provided as
221
     * parameters.
222
     * 
223
     * @param viewClass Class of the window which is to be closed
224
     * @param model Model of the window which is to be closed
225
     *
226
     * @return true if there is an open window whose class and model
227
     *         match the provided parameteres, false otherwise.
228
     */
229
    public boolean closeSingletonWindow(Class viewClass, Object model);
230

    
231
    /**
232
     * Close the SingletonWindow whose model is provided as parameter.
233
     *
234
     * @param model Model of the window which is to be closed
235
     *
236
     * @return true if there is an open window whose model matchs
237
     *         the provided one, false otherwise.
238
     */
239
    public boolean closeSingletonWindow(Object model);
240

    
241
    /**
242
     * Close the provided window.
243
     *
244
     * @param p window to be closed
245
     */
246
    public void closeWindow(IWindow p);
247

    
248
    /**
249
     * Close all the currently open windows
250
     */
251
    public void closeAllWindows();
252

    
253
    /**
254
     * Gets the WindowInfo object associated with the provided window.
255
     *
256
     * @param v window whose information is to be retrieved
257
     *
258
     * @return WindowInfo The WindowInfo object containing the information
259
     * about the provided window 
260
     * 
261
     * @see WindowInfo
262
     */
263
    public WindowInfo getWindowInfo(IWindow v);
264

    
265
    /**
266
     * Shows the wait cursor and blocks all the events from main window until
267
     * {@link #restoreCursor()} is called.
268
     */
269
    public void setWaitCursor();
270

    
271
    /**
272
     * Sets the normal cursor and unblocks events from main window.
273
     * 
274
     * @see #setWaitCursor()
275
     */
276
    public void restoreCursor();
277

    
278
    /**
279
     * Maximizes or restores the provided window
280
     * 
281
     * @param v The window to be maximized or restored 
282
     * @param bMaximum If true, the window will be maximized,
283
     *  if false, it will be restored
284
     * @throws PropertyVetoException
285
     */
286
    public void setMaximum(IWindow v, boolean bMaximum) throws PropertyVetoException;
287
    
288
    /**
289
     * Updates the window properties (size, location, etc) according to the
290
     * provided WindowInfo object.
291
     * 
292
     * @param v The window whose properties are to be changed
293
     * @param vi The WindowInfo object containing the new properties to be set
294
     */
295
    public void changeWindowInfo(IWindow v, WindowInfo vi);
296
    
297
    /**
298
     * Forces a window to be repainted. Normally, this is not necessary,
299
     * as windows are refreshed when necessary.
300
     * 
301
     * @param win The window to be refreshed.
302
     */
303
    public void refresh(IWindow win);
304

    
305
    /**
306
     * Sets the provided image as background image in the main window. The image
307
     * will be centered, set in mosaic or expanded to fill the full window,
308
     * depending on the <code>typeDesktop</code> argument.
309
     * 
310
     * @param image The image to be set as background image
311
     * @param typeDesktop Decides whether the image should be centered, set
312
     * in mosaic or expanded. Accepted values are: Theme.CENTERED,
313
     * Theme.MOSAIC and Theme.EXPAND.
314
     */
315
    public void setBackgroundImage(ImageIcon image, String typeDesktop);
316
    
317
    public void setLocale(Locale locale);
318
      
319
}