Revision 148

View differences:

1.10/tags/gvSIG_3D_Animation_1_10_build_17/extensions/extDockingSkin/src/test/java/org/gvsig/AppTest.java
1
package org.gvsig;
2

  
3
import junit.framework.Test;
4
import junit.framework.TestCase;
5
import junit.framework.TestSuite;
6

  
7
/**
8
 * Unit test for simple App.
9
 */
10
public class AppTest 
11
    extends TestCase
12
{
13
    /**
14
     * Create the test case
15
     *
16
     * @param testName name of the test case
17
     */
18
    public AppTest( String testName )
19
    {
20
        super( testName );
21
    }
22

  
23
    /**
24
     * @return the suite of tests being tested
25
     */
26
    public static Test suite()
27
    {
28
        return new TestSuite( AppTest.class );
29
    }
30

  
31
    /**
32
     * Rigourous Test :-)
33
     */
34
    public void testApp()
35
    {
36
        assertTrue( true );
37
    }
38
}
1.10/tags/gvSIG_3D_Animation_1_10_build_17/extensions/extDockingSkin/src/main/java/org/gvsig/mdiManager/FloatingWindowContainerListener.java
1
package org.gvsig.mdiManager;
2

  
3
import java.awt.event.WindowEvent;
4
import java.awt.event.WindowListener;
5

  
6
import net.infonode.docking.DockingWindow;
7

  
8
public class FloatingWindowContainerListener implements WindowListener {
9

  
10
	DockingWindow wnd;
11
	
12
	public FloatingWindowContainerListener(DockingWindow wnd) {
13
		this.wnd = wnd;
14
	}
15
	
16
	public void windowActivated(WindowEvent arg0) {
17

  
18
	}
19

  
20
	public void windowClosed(WindowEvent arg0) {
21
	}
22

  
23
	public void windowClosing(WindowEvent arg0) {
24
		wnd.close();
25

  
26
	}
27

  
28
	public void windowDeactivated(WindowEvent arg0) {
29

  
30
	}
31

  
32
	public void windowDeiconified(WindowEvent arg0) {
33

  
34

  
35
	}
36

  
37
	public void windowIconified(WindowEvent arg0) {
38

  
39

  
40
	}
41

  
42
	public void windowOpened(WindowEvent arg0) {
43

  
44

  
45
	}
46

  
47
}
1.10/tags/gvSIG_3D_Animation_1_10_build_17/extensions/extDockingSkin/src/main/java/org/gvsig/mdiManager/DialogStack.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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 org.gvsig.mdiManager;
42

  
43
import java.awt.Cursor;
44
import java.util.ArrayList;
45
import java.util.Iterator;
46

  
47
import javax.swing.JDialog;
48

  
49
import org.apache.log4j.Logger;
50

  
51
import com.iver.andami.ui.mdiFrame.MDIFrame;
52

  
53

  
54
/**
55
 *
56
 */
57
public class DialogStack{
58
    /** log */
59
    private static Logger logger = Logger.getLogger(DialogStack.class.getName());
60

  
61
    /** Pila de di?logos modales mostrados */
62
    private ArrayList dialogStack = new ArrayList(0);
63

  
64
    private ArrayList dialogCursors = new ArrayList(0);
65

  
66
    public DialogStack(){
67
    }
68

  
69
    public void pushDialog(JDialog dlg){
70
    	dialogStack.add(dlg);
71
    }
72

  
73
    public JDialog popDialog(){
74
    	int dialogStackSize=dialogStack.size();
75
    	if (dialogStackSize<1)
76
    		return null;
77
    	return (JDialog) dialogStack.remove(dialogStackSize - 1);
78
    }
79

  
80
	/**
81
	 * @return
82
	 */
83
	public void setWaitCursor() {
84
        dialogCursors.clear();
85
		for (Iterator iter = dialogStack.iterator(); iter.hasNext();) {
86
			JDialog dlg = (JDialog) iter.next();
87
            dialogCursors.add(dlg.getCursor());
88
			dlg.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
89
 	        dlg.getGlassPane().setVisible(true);
90
 	   }
91
	}
92

  
93
	/**
94
	 *
95
	 */
96
	public void restoreCursor() {
97
		for (Iterator iter = dialogStack.iterator(); iter.hasNext();) {
98
			JDialog dlg = (JDialog) iter.next();
99

  
100
            // TODO: RECUPERAR EL CURSOR
101
            dlg.setCursor(null);
102
		    dlg.getGlassPane().setVisible(false);
103
		}
104
	}
105
}
1.10/tags/gvSIG_3D_Animation_1_10_build_17/extensions/extDockingSkin/src/main/java/org/gvsig/mdiManager/DockWindowSupport.java
1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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 org.gvsig.mdiManager;
42

  
43
import java.awt.Component;
44
import java.awt.Dimension;
45
import java.util.Hashtable;
46
import java.util.Iterator;
47

  
48
import javax.swing.JComponent;
49
import javax.swing.JDialog;
50
import javax.swing.JPanel;
51

  
52
import net.infonode.docking.RootWindow;
53
import net.infonode.docking.title.SimpleDockingWindowTitleProvider;
54

  
55
import org.gvsig.mdiManager.frames.ExternalFrame;
56

  
57
import com.iver.andami.PluginServices;
58
import com.iver.andami.ui.mdiFrame.MDIFrame;
59
import com.iver.andami.ui.mdiManager.IWindow;
60
import com.iver.andami.ui.mdiManager.WindowInfo;
61

  
62

  
63
/**
64
 *
65
 */
66
public class DockWindowSupport {
67
    private Hashtable frameView = new Hashtable();
68
    private Hashtable viewFrame = new Hashtable();
69
//    private Image icon;
70
    private DockInfoSupport vis;
71
	private RootWindow rootWindow;
72
	private MDIFrame mainFrame;
73

  
74
    /**
75
     * Creates a new FrameViewSupport object.
76
     *
77
     * @param i DOCUMENT ME!
78
     */
79
    public DockWindowSupport(MDIFrame mainFrame, RootWindow rootWindow) {
80
    	this.rootWindow = rootWindow;
81
//        icon = rootWindow.getIconImage();
82
    	this.mainFrame = mainFrame;
83
    }
84

  
85
    public MDIFrame getMainFrame() {
86
		return mainFrame;
87
	}
88

  
89
	public Iterator getWindowIterator(){
90
    	return viewFrame.keySet().iterator();
91
    }
92

  
93
    public boolean contains(IWindow v){
94
    	return viewFrame.containsKey(v);
95
    }
96

  
97
	/**
98
	 * @param wnd
99
	 * @return
100
	 */
101
	public boolean contains(DockWindow dw) {
102
		return frameView.contains(dw);
103
	}
104

  
105
    /**
106
     * DOCUMENT ME!
107
     *
108
     * @param p DOCUMENT ME!
109
     *
110
     * @return DOCUMENT ME!
111
     */
112
    public JDialog getJDialog(IWindow p) {
113
        JDialog dlg = (JDialog) viewFrame.get(p);
114

  
115
        if (dlg == null) {
116
            WindowInfo vi = vis.getWindowInfo(p);
117
            ExternalFrame nuevo = new ExternalFrame(mainFrame);
118

  
119
            nuevo.getContentPane().add((JPanel) p);
120
            nuevo.setSize(getWidth(p, vi), getHeight(p, vi) + 30);
121
            nuevo.setTitle(vi.getTitle());
122
            nuevo.setResizable(vi.isResizable());
123
            nuevo.setMinimumSize(vi.getMinimumSize());
124

  
125
            viewFrame.put(p, nuevo);
126
            frameView.put(nuevo, p);
127

  
128
            nuevo.setModal(vi.isModal());
129
            return nuevo;
130
        } else {
131
            return dlg;
132
        }
133
    }
134

  
135
    /**
136
     * DOCUMENT ME!
137
     *
138
     * @param p DOCUMENT ME!
139
     *
140
     * @return DOCUMENT ME!
141
     */
142
    public DockWindow getDockWindow(IWindow p) {
143
    	DockWindow frame = (DockWindow) viewFrame.get(p);
144

  
145
        if (frame == null) {
146
        	WindowInfo vi = vis.getWindowInfo(p);
147
        	DockWindow nuevo = createDockWindow(p);
148
            viewFrame.put(p, nuevo);
149
            frameView.put(nuevo, p);
150

  
151
            return nuevo;
152
        } else {
153
            return frame;
154
        }
155
    }
156
    
157
    /**
158
     * Gets the frame associated to the provided IWindow panel.
159
     * The frame will usually be a JInternalFrame or a JDialog.
160
     *
161
     * @param panel The IWindow panel whose frame wants to be retrieved.
162
     *
163
     * @return The associated frame, it will usually be a JInternalFrame or
164
     * a JDialog.
165
     */
166
    public Component getFrame(IWindow panel) {
167
    	Object object = viewFrame.get(panel);
168
    	if (object!=null && object instanceof Component) {
169
    		return (Component) object;
170
    	}
171
    	else {
172
    		PluginServices.getLogger().error("window_not_found_"+panel.getWindowInfo().getTitle());
173
    		return null;
174
    	}
175
    }
176

  
177
    public DockWindow createDockWindow(IWindow p)
178
    {
179
        WindowInfo wi = vis.getWindowInfo(p);
180
        DockWindow nuevo = new DockWindow(p,wi.getTitle(),null);
181
//        if (icon != null){
182
//            nuevo.setFrameIcon(new ImageIcon(icon));
183
//        }
184
        
185
        nuevo.add((JPanel) p);
186
//        nuevo.setClosable(true);
187
        nuevo.setSize(getWidth(p, wi), getHeight(p, wi));
188
//        nuevo.setTitle(wi.getTitle());
189
        nuevo.setVisible(wi.isVisible());
190
//        nuevo.setResizable(wi.isResizable());
191
        nuevo.getWindowProperties().setMinimizeEnabled(wi.isIconifiable());
192
        nuevo.getWindowProperties().setMaximizeEnabled(wi.isMaximizable());
193
        nuevo.setLocation(wi.getX(), wi.getY());
194
        nuevo.setMinimumSize(wi.getMinimumSize());
195

  
196
//        nuevo.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
197
        return nuevo;
198
    }
199

  
200
    public IWindow getWindow(Component dlg){
201
    	return (IWindow) frameView.get(dlg);
202
    }
203

  
204
    public void closeWindow(IWindow v){
205
    	Object c = viewFrame.remove(v);
206
    	frameView.remove(c);
207
    }
208

  
209
//    /**
210
//     * DOCUMENT ME!
211
//     *
212
//     * @param v DOCUMENT ME!
213
//     * @param x DOCUMENT ME!
214
//     */
215
//    public void setX(IWindow win, int x) {
216
//    	IFrame frame = (IFrame) viewFrame.get(win);
217
//    	frame.setX(x);
218
//    }
219
//
220
//    /**
221
//     * DOCUMENT ME!
222
//     *
223
//     * @param v DOCUMENT ME!
224
//     * @param y DOCUMENT ME!
225
//     */
226
//    public void setY(IWindow win, int y) {
227
//    	IFrame frame = (IFrame) viewFrame.get(win);
228
//    	frame.setY(y);
229
//    }
230

  
231
//    /**
232
//     * DOCUMENT ME!
233
//     *
234
//     * @param v DOCUMENT ME!
235
//     * @param height DOCUMENT ME!
236
//     */
237
//    public void setHeight(IWindow win, int height) {
238
//    	IFrame frame = (IFrame) viewFrame.get(win);
239
//    	frame.setHeight(height);
240
//    }
241

  
242
//    /**
243
//     * DOCUMENT ME!
244
//     *
245
//     * @param v DOCUMENT ME!
246
//     * @param width DOCUMENT ME!
247
//     */
248
//    public void setWidth(IWindow win, int width) {
249
//    	IFrame frame = (IFrame) viewFrame.get(win);
250
//    	frame.setWidth(width);
251
//    }
252

  
253
    /**
254
     * DOCUMENT ME!
255
     *
256
     * @param v DOCUMENT ME!
257
     * @param title DOCUMENT ME!
258
     */
259
    public void setTitle(IWindow win, String title) {
260
    	DockWindow dockWindow= (DockWindow) viewFrame.get(win);
261
    	dockWindow.setName(title);
262
    	String newTitle = dockWindow.getTitle();
263
    	newTitle = title;
264
    	dockWindow.getParent().invalidate();
265
    }
266
    
267
	/**
268
	 * Sets the minimum allowed size for the provided window.
269
	 * 
270
	 * @param sw
271
	 * @param minSize
272
	 */
273
	public void setMinimumSize(IWindow win, Dimension minSize) {
274
		DockWindow dockWindow= (DockWindow) viewFrame.get(win);
275
    	dockWindow.setMinimumSize(minSize);
276
	}
277

  
278
    /**
279
     * DOCUMENT ME!
280
     *
281
     * @param vis The vis to set.
282
     */
283
    public void setVis(DockInfoSupport vis) {
284
        this.vis = vis;
285
    }
286

  
287
    /**
288
     * DOCUMENT ME!
289
     *
290
     * @param v DOCUMENT ME!
291
     *
292
     * @return DOCUMENT ME!
293
     */
294
    private int getWidth(IWindow v) {
295
        WindowInfo vi = vis.getWindowInfo(v);
296

  
297
        if (vi.getWidth() == -1) {
298
            JPanel p = (JPanel) v;
299

  
300
            return p.getSize().width;
301
        } else {
302
            return vi.getWidth();
303
        }
304
    }
305

  
306
    /**
307
     * DOCUMENT ME!
308
     *
309
     * @param v DOCUMENT ME!
310
     *
311
     * @return DOCUMENT ME!
312
     */
313
    private int getWidth(IWindow v, WindowInfo wi) {
314
        if (wi.getWidth() == -1) {
315
            JPanel p = (JPanel) v;
316

  
317
            return p.getSize().width;
318
        } else {
319
            return wi.getWidth();
320
        }
321
    }
322

  
323
    /**
324
     * DOCUMENT ME!
325
     *
326
     * @param v DOCUMENT ME!
327
     *
328
     * @return DOCUMENT ME!
329
     */
330
    private int getHeight(IWindow v) {
331
        WindowInfo vi = vis.getWindowInfo(v);
332

  
333
        if (vi.getHeight() == -1) {
334
            JPanel p = (JPanel) v;
335

  
336
            return p.getSize().height;
337
        } else {
338
            return vi.getHeight();
339
        }
340
    }
341

  
342
    /**
343
     * DOCUMENT ME!
344
     *
345
     * @param v DOCUMENT ME!
346
     *
347
     * @return DOCUMENT ME!
348
     */
349
    private int getHeight(IWindow v, WindowInfo wi) {
350
        if (wi.getHeight() == -1) {
351
            JPanel p = (JPanel) v;
352

  
353
            return p.getSize().height;
354
        } else {
355
            return wi.getHeight();
356
        }
357
    }
358

  
359
    public void updateWindowInfo(IWindow win, WindowInfo windowInfo) {
360
    	Object o = viewFrame.get(win);
361
    	if (windowInfo!=null && o!=null) {
362
    		if (o instanceof JComponent) {
363
        		JComponent component = (JComponent) o;
364
        		windowInfo.updateWidth(component.getWidth());
365
				windowInfo.updateHeight(component.getHeight());
366
				windowInfo.updateX(component.getX());
367
				windowInfo.updateY(component.getY());
368
				windowInfo.updateClosed(!component.isShowing());
369
//				if (component instanceof JInternalFrame) {
370
//					JInternalFrame iframe = (JInternalFrame) component;
371
//					windowInfo.updateNormalBounds(iframe.getNormalBounds());
372
//					windowInfo.updateMaximized(iframe.isMaximum());
373
//				}
374
    		}
375
    	}
376
    }
377

  
378
}
1.10/tags/gvSIG_3D_Animation_1_10_build_17/extensions/extDockingSkin/src/main/java/org/gvsig/mdiManager/DockWindow.java
1
package org.gvsig.mdiManager;
2

  
3
import java.awt.Component;
4

  
5
import javax.swing.Icon;
6

  
7
import net.infonode.docking.View;
8

  
9
import com.iver.andami.ui.mdiManager.IWindow;
10

  
11
public class DockWindow extends View {
12
	
13

  
14
	private IWindow iWindow;
15
	/**
16
	 * 
17
	 */
18
	private static final long serialVersionUID = 1L;
19
	
20

  
21
	public DockWindow(String arg0, Icon arg1, Component arg2) {
22
		super(arg0, arg1, arg2);
23
		// TODO Auto-generated constructor stub
24
	}
25

  
26

  
27
	public DockWindow(IWindow iWindow, String name,Component lastFocusedComponent) {
28
		super(name, null, lastFocusedComponent);
29
		
30
		// Setting up the iWindow
31
		this.iWindow = iWindow;
32
	}
33
	
34
	public IWindow getIWindow() {
35
		return iWindow;
36
	}
37
	
38
	public void setIWindow(IWindow window) {
39
		iWindow = window;
40
	}
41

  
42
}
1.10/tags/gvSIG_3D_Animation_1_10_build_17/extensions/extDockingSkin/src/main/java/org/gvsig/mdiManager/DockInfoSupport.java
1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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 org.gvsig.mdiManager;
42

  
43
import java.awt.Dimension;
44
import java.awt.Rectangle;
45
import java.beans.PropertyChangeEvent;
46
import java.beans.PropertyChangeListener;
47
import java.util.Enumeration;
48
import java.util.Hashtable;
49

  
50
import javax.swing.JComponent;
51

  
52
import net.infonode.docking.title.SimpleDockingWindowTitleProvider;
53

  
54
import com.iver.andami.plugins.PluginClassLoader;
55
import com.iver.andami.ui.mdiFrame.MainFrame;
56
import com.iver.andami.ui.mdiFrame.NoSuchMenuException;
57
import com.iver.andami.ui.mdiManager.IWindow;
58
import com.iver.andami.ui.mdiManager.SingletonWindow;
59
import com.iver.andami.ui.mdiManager.WindowInfo;
60

  
61

  
62
/**
63
 * This class listens to changes in WindowInfo objects, and reflects this
64
 * changes in the associated window.
65
 */
66
public class DockInfoSupport {
67
	private static int serialId = 0;
68
	
69
	/**
70
	 * Support class which associates Frames and Windows
71
	 */
72
	private DockWindowSupport fws;
73

  
74
	// Correspondencias entre las ventanas y su informacion
75
	/**
76
	 * key: IWindow, value: WindowInfo
77
	 */
78
	private Hashtable viewInfo = new Hashtable();
79
	/**
80
	 * key: WindowInfo, value: IWindow
81
	 */
82
	private Hashtable infoView = new Hashtable();
83
	private WindowPropertyChangeListener windowInfoListener = new WindowPropertyChangeListener();
84
	private SingletonSupport sws;
85
	private MainFrame mdiFrame;
86

  
87
	/**
88
	 * Creates a new ViewInfoSupport object.
89
	 *
90
	 * @param frame DOCUMENT ME!
91
	 * @param fvs DOCUMENT ME!
92
	 * @param svs
93
	 */
94
	public DockInfoSupport(MainFrame frame, DockWindowSupport fvs,
95
		SingletonSupport svs) {
96
		this.fws = fvs;
97
		this.sws = svs;
98
		this.mdiFrame = frame;
99
	}
100

  
101
	/**
102
	 * Devuelve la vista cuyo identificador es el parametro
103
	 *
104
	 * @param id Identificador de la vista que se quiere obtener
105
	 *
106
	 * @return La vista o null si no hay ninguna vista con ese identificador
107
	 */
108
	public IWindow getWindowById(int id) {
109
		Enumeration en = infoView.keys();
110

  
111
		while (en.hasMoreElements()) {
112
			WindowInfo vi = (WindowInfo) en.nextElement();
113

  
114
			if (vi.getId() == id) {
115
				return (IWindow) infoView.get(vi);
116
			}
117
		}
118

  
119
		return null;
120
	}
121

  
122
	/**
123
	 * DOCUMENT ME!
124
	 *
125
	 * @param w DOCUMENT ME!
126
	 *
127
	 * @return DOCUMENT ME!
128
	 */
129
	public synchronized WindowInfo getWindowInfo(IWindow w) {
130
		WindowInfo wi = (WindowInfo) viewInfo.get(w);
131

  
132
		if (wi != null) {
133
			fws.updateWindowInfo(w, wi);
134
		}
135
		else {
136
			wi = w.getWindowInfo();
137

  
138
			//Para el t�tulo
139
			if (wi.getHeight() != -1) {
140
				wi.setHeight(wi.getHeight() + 40);
141
			}
142

  
143
			wi.addPropertyChangeListener(windowInfoListener);
144
			viewInfo.put(w, wi);
145
			infoView.put(wi, w);
146
			wi.setId(serialId++);
147
		}
148

  
149
		return wi;
150
	}
151

  
152
	/**
153
	 * DOCUMENT ME!
154
	 *
155
	 * @param p DOCUMENT ME!
156
	 */
157
	public void deleteWindowInfo(IWindow p) {
158
		WindowInfo vi = (WindowInfo) viewInfo.remove(p);
159
		infoView.remove(vi);
160
	}
161

  
162
	/**
163
	 * DOCUMENT ME!
164
	 *
165
	 * @author $author$
166
	 * @version $Revision: 13794 $
167
	 */
168
	public class WindowPropertyChangeListener implements PropertyChangeListener {
169
		/**
170
		 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
171
		 */
172
		public void propertyChange(PropertyChangeEvent evt) {
173
			WindowInfo winInfo = (WindowInfo) evt.getSource();
174
			IWindow win = (IWindow) infoView.get(winInfo);
175

  
176
			if (win instanceof SingletonWindow) {
177
				SingletonWindow sw = (SingletonWindow) win;
178

  
179
				if (evt.getPropertyName().equals("x")) {
180
					sws.setX(sw, ((Integer) evt.getNewValue()).intValue());
181
				} else if (evt.getPropertyName().equals("y")) {
182
					sws.setY(sw, ((Integer) evt.getNewValue()).intValue());
183
				} else if (evt.getPropertyName().equals("height")) {
184
					sws.setHeight(sw, ((Integer) evt.getNewValue()).intValue());
185
				} else if (evt.getPropertyName().equals("width")) {
186
					sws.setWidth(sw, ((Integer) evt.getNewValue()).intValue());
187
				} else if (evt.getPropertyName().equals("maximized")) {
188
					sws.setMaximized(sw, ((Boolean) evt.getNewValue()).booleanValue());
189
				} else if (evt.getPropertyName().equals("normalBounds")) {
190
					sws.setNormalBounds(sw, (Rectangle) evt.getNewValue());
191
				} else if (evt.getPropertyName().equals("minimumSize")) {
192
					sws.setMinimumSize(sw, (Dimension) evt.getNewValue());
193
				} else if (evt.getPropertyName().equals("title")) {
194
					sws.setTitle(sw, (String) evt.getNewValue());
195
				 
196
					try {
197
						mdiFrame.changeMenuName(new String[] {
198
								"Ventana", (String) evt.getOldValue()
199
						}, (String) evt.getNewValue(),
200
						(PluginClassLoader) getClass().getClassLoader());
201
					} catch (NoSuchMenuException e) {
202
						/*
203
						 * No se hace nada porque puede modificarse el t�tulo de
204
						 * una ventana antes de ser a�adida a Andami
205
						 */
206
					}
207
				}
208
			} else {
209
//				if (evt.getPropertyName().equals("x")) {
210
//					fws.setX(win, ((Integer) evt.getNewValue()).intValue());
211
//				} else if (evt.getPropertyName().equals("y")) {
212
//					fws.setY(win, ((Integer) evt.getNewValue()).intValue());
213
//				} else if (evt.getPropertyName().equals("height")) {
214
//					fws.setHeight(win, ((Integer) evt.getNewValue()).intValue());
215
//				} else if (evt.getPropertyName().equals("width")) {
216
//					fws.setWidth(win, ((Integer) evt.getNewValue()).intValue());
217
//				} else 
218
				if (evt.getPropertyName().equals("minimumSize")) {
219
					fws.setMinimumSize(win, (Dimension) evt.getNewValue());
220
				} else if (evt.getPropertyName().equals("title")) {
221
					fws.setTitle(win, (String) evt.getNewValue());
222
					try{
223
						mdiFrame.changeMenuName(new String[] {
224
								"Ventana", (String) evt.getOldValue()
225
						}, (String) evt.getNewValue(),
226
						(PluginClassLoader) getClass().getClassLoader());
227
					} catch (NoSuchMenuException e) {
228
						/*
229
						 * No se hace nada porque puede modificarse el t�tulo de
230
						 * una ventana antes de ser a�adida a Andami
231
						 */
232
					}
233
				}
234
			}
235
		}
236
	}
237
}
1.10/tags/gvSIG_3D_Animation_1_10_build_17/extensions/extDockingSkin/src/main/java/org/gvsig/mdiManager/DockingManager.java
1
package org.gvsig.mdiManager;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.Component;
5
import java.awt.Container;
6
import java.awt.Dimension;
7
import java.awt.Point;
8
import java.awt.event.ActionEvent;
9
import java.awt.event.ActionListener;
10
import java.awt.event.WindowAdapter;
11
import java.awt.event.WindowEvent;
12
import java.beans.PropertyVetoException;
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.Iterator;
16

  
17
import javax.swing.AbstractButton;
18
import javax.swing.ButtonGroup;
19
import javax.swing.ButtonModel;
20
import javax.swing.ImageIcon;
21
import javax.swing.JButton;
22
import javax.swing.JDialog;
23
import javax.swing.JFrame;
24
import javax.swing.JLabel;
25
import javax.swing.JMenuBar;
26
import javax.swing.JOptionPane;
27
import javax.swing.JToggleButton;
28
import javax.swing.JToolBar;
29

  
30
import net.infonode.docking.DockingWindow;
31
import net.infonode.docking.DockingWindowListener;
32
import net.infonode.docking.FloatingWindow;
33
import net.infonode.docking.OperationAbortedException;
34
import net.infonode.docking.RootWindow;
35
import net.infonode.docking.SplitWindow;
36
import net.infonode.docking.TabWindow;
37
import net.infonode.docking.View;
38
import net.infonode.docking.properties.RootWindowProperties;
39
import net.infonode.docking.util.DeveloperUtil;
40
import net.infonode.docking.util.DockingUtil;
41
import net.infonode.docking.util.PropertiesUtil;
42
import net.infonode.docking.util.ViewMap;
43
import net.infonode.util.Direction;
44

  
45
import org.apache.log4j.Logger;
46

  
47
import com.iver.andami.PluginServices;
48
import com.iver.andami.plugins.Extension;
49
import com.iver.andami.ui.mdiFrame.MDIFrame;
50
import com.iver.andami.ui.mdiFrame.SelectableToolBar;
51
import com.iver.andami.ui.mdiManager.IWindow;
52
import com.iver.andami.ui.mdiManager.IWindowListener;
53
import com.iver.andami.ui.mdiManager.MDIManager;
54
import com.iver.andami.ui.mdiManager.SingletonDialogAlreadyShownException;
55
import com.iver.andami.ui.mdiManager.SingletonWindow;
56
import com.iver.andami.ui.mdiManager.WindowInfo;
57

  
58
public class DockingManager extends Extension implements MDIManager,
59
		ActionListener {
60
	private MDIFrame mainFrame;
61
	// private HashMap<Object, IWindow> windowRelationship;
62
	// private HashMap<IWindow, Object> invertedWindowRelationship;
63
	// private HashMap<IWindow, WindowInfo> infoRelationship;
64
	private static Logger logger = Logger.getLogger(DockingManager.class
65
			.getName());
66

  
67
	public static final int PROJECT_MANAGER = 0;
68
	public static final int VIEWS = 1;
69
	public static final int TOOLS = 2;
70

  
71
	private TabWindow tabProject;
72
	private TabWindow tabViews;
73
	private TabWindow tabTools;
74
	private TabWindow tabRootWindow;
75
	private RootWindow rootWindow;
76

  
77
	private DialogStack dialogStack;
78

  
79
	private SingletonSupport singletonSupport;
80
	private DockWindowSupport dockWindowSupport;
81
	private DockWindowStack wss;
82
	private DockInfoSupport wis;
83

  
84
	private DockingWindow lastFocusedWindow = null;
85
	private JToggleButton projectButton;
86
	private DockWindow projectWindow;
87
	boolean showProjectWindow = true;
88

  
89
	private Dimension projectWindowSise;
90
	private JToggleButton hiddeButton;
91

  
92
	/**
93
	 * Associates JInternalFrames with the IWindow they contain
94
	 */
95
	public void init(MDIFrame frame) {
96

  
97
		this.mainFrame = frame;
98

  
99
		dockWindowSupport = new DockWindowSupport(mainFrame, rootWindow);
100
		dialogStack = new DialogStack();
101
		singletonSupport = new SingletonSupport();
102
		wis = new DockInfoSupport(mainFrame, dockWindowSupport,
103
				singletonSupport);
104
		wss = new DockWindowStack(wis);
105
		dockWindowSupport.setVis(wis);
106

  
107
		singletonSupport.setDockInfoSupport(wis);
108
		singletonSupport.setDockWindowSupport(dockWindowSupport);
109

  
110
		singletonSupport.rootWindow = this.rootWindow;
111

  
112
		initDockingSystem();
113

  
114
		// TODO Auto-generated method stub
115
		mainFrame = frame;
116

  
117
		// contentPanel.getWindowBar(Direction.LEFT).setEnabled(true);
118
		// contentPanel.getWindowBar(Direction.DOWN).setEnabled(true);
119
		// contentPanel.getWindowBar(Direction.RIGHT).setEnabled(true);
120
		// contentPanel.setWindow(new SplitWindow(true, 0.4f, new SplitWindow(
121
		// false, views[0], new SplitWindow(false, views[1], views[2])),
122
		// new TabWindow(new DockingWindow[] { views[3], views[4] })));
123

  
124
		// contentPanel.setWindow(new SplitWindow(true, 0.35f,
125
		// windowingLayout[PROJECT_MANAGER],
126
		// new SplitWindow(false,0.7f,
127
		// windowingLayout[VIEWS],
128
		// windowingLayout[TOOLS])));
129
		// DeveloperUtil.createWindowLayoutFrame("Debug Layout Window",
130
		// contentPanel)
131
		// .setVisible(true);
132

  
133
		// windowRelationship = new HashMap<Object, IWindow>();
134
		// invertedWindowRelationship = new HashMap<IWindow, Object>();
135
		// infoRelationship = new HashMap<IWindow, WindowInfo>();
136
		mainFrame.getContentPane().add(rootWindow, BorderLayout.CENTER);
137
		// contentPanel.split(dockingwindow, direccion, ni guarra)
138
	}
139

  
140
	private void initDockingSystem() {
141
		// TODO Auto-generated method stub
142

  
143
		// Creating view map
144
		View[] views = new View[20];
145
		ViewMap viewMap = new ViewMap();
146
		for (int i = 0; i < views.length; i++) {
147
			views[i] = new View("View " + i, null, new JLabel("This is view "
148
					+ i + "!"));
149
			viewMap.addView(i, views[i]);
150

  
151
		}
152
		// Creating views tab window
153
		tabProject = new TabWindow();
154
		// Adding views to the tab
155
		// tabProject.addTab(views[0]);
156
		// tabProject.addTab(views[1]);
157
		// tabProject.addTab(views[2]);
158
		tabProject.setPreferredMinimizeDirection(Direction.LEFT);
159

  
160
		// Creating views tab window
161
		tabViews = new TabWindow();
162
		// Adding views to the tab
163
		// tabViews.addTab(views[3]);
164
		// tabViews.addTab(views[4]);
165
		// tabViews.addTab(views[5]);
166
		tabViews.setPreferredMinimizeDirection(Direction.RIGHT);
167

  
168
		// Creating views tab window
169
		tabTools = new TabWindow();
170
		// Adding views to the tab
171
		// tabTools.addTab(views[6]);
172
		// tabTools.addTab(views[7]);
173
		// tabTools.addTab(views[8]);
174
		tabTools.setPreferredMinimizeDirection(Direction.DOWN);
175

  
176
		// Creating the main tab window
177
		tabRootWindow = new TabWindow();
178
		// Creating the split window
179
		SplitWindow splitRootWindow = new SplitWindow(true, 0.35f, tabProject,
180
				new SplitWindow(false, 0.7f, tabViews, tabTools));
181
		// Adding the split to the tab
182
		tabRootWindow.addTab(splitRootWindow);
183

  
184
		// Creating the root window
185
		rootWindow = new RootWindow(true, null);// DockingUtil.createRootWindow(
186
		// new
187
		// StringViewMap(), true);
188

  
189
		singletonSupport.rootWindow = rootWindow;
190

  
191
		// Setting up the root window
192
		rootWindow.getWindowBar(Direction.LEFT).setEnabled(true);
193
		rootWindow.getWindowBar(Direction.DOWN).setEnabled(true);
194
		rootWindow.getWindowBar(Direction.RIGHT).setEnabled(true);
195

  
196
		RootWindowProperties titleBarStyleProperties = PropertiesUtil
197
				.createTitleBarStyleRootWindowProperties();
198

  
199
		// Setting the style to the root window
200
		rootWindow.getRootWindowProperties().addSuperObject(
201
				titleBarStyleProperties);
202

  
203
		// Only for test
204
		// DeveloperUtil
205
		// .createWindowLayoutFrame("Debug Layout Window", rootWindow)
206
		// .setVisible(true);
207

  
208
		// Button for the project window.
209
		projectButton = new JToggleButton("project window");
210
		hiddeButton = new JToggleButton("Hidde project button");
211

  
212
		projectButton.addActionListener(this);
213

  
214
	}
215

  
216
	public IWindow addWindow(IWindow iWindow)
217
			throws SingletonDialogAlreadyShownException {
218
		// se obtiene la informaci�n de la vista
219
		WindowInfo wi = iWindow.getWindowInfo();
220
		Object wp = iWindow.getWindowProfile();
221
		if (wp == null) {
222
			wp = WindowInfo.TOOL_PROFILE;
223
			logger.warn("This window doesn't have a valid getWindowProfile");
224
		}
225
		// New window object
226
		Object newWindow = null;
227

  
228
		if ((iWindow instanceof SingletonWindow) && (wi.isModal())) {
229
			throw new RuntimeException("A modal view cannot be a SingletonView");
230
		}
231
		if (wp != null && wp.equals(WindowInfo.DIALOG_PROFILE)
232
				&& (wi.isModeless())) {
233
			wp = WindowInfo.PROPERTIES_PROFILE;
234

  
235
			// throw new RuntimeException(
236
			// "A modeless view cannot have the DIALOG_PROFILE property");
237
		}
238

  
239
		/*
240
		 * Se obtiene la referencia a la vista anterior por si es una singleton
241
		 * y est� siendo mostrada. Se obtiene su informaci�n si ya fue mostrada
242
		 */
243
		boolean singletonPreviouslyAdded = false;
244

  
245
		if (iWindow instanceof SingletonWindow) {
246
			SingletonWindow sw = (SingletonWindow) iWindow;
247
			// singletonPreviouslyAdded = singletonSupport.registerWindow(sw
248
			// .getClass(), sw.getWindowModel(), wi);
249

  
250
			if (singletonSupport.registerWindow(sw.getClass(), sw
251
					.getWindowModel(), wi)) {
252
				singletonPreviouslyAdded = true;
253
			}
254
		}
255

  
256
		if (singletonPreviouslyAdded) {
257
			System.out.println("ventana tipo singleton");
258
			if (!singletonSupport.contains((SingletonWindow) iWindow)) {
259
				// restaurar el foco;
260
				DockWindow frame = dockWindowSupport.getDockWindow(iWindow);
261
				singletonSupport.openSingletonWindow((SingletonWindow) iWindow,
262
						frame);
263
				addDockedWindow(iWindow, wi);
264
				wss.add(iWindow, new ActionListener() {
265
					public void actionPerformed(ActionEvent e) {
266
						IWindow v = wis.getWindowById(Integer.parseInt(e
267
								.getActionCommand()));
268
						DockWindow f = dockWindowSupport.getDockWindow(v);
269
						// f.getTopLevelAncestor().requestFocus();
270
						f.requestFocusInWindow();
271
						// f.requestFocus();
272
						// activateJInternalFrame(f);
273
					}
274
				});
275
				return iWindow;
276
			} else {
277
				// restaurar el foco
278
				// La vista est� actualmente abierta
279
				DockWindow frame = (DockWindow) singletonSupport
280
						.getFrame((SingletonWindow) iWindow);
281
				// activateJInternalFrame(frame);
282
				// frame.getTopLevelAncestor().requestFocus();
283
				frame.requestFocusInWindow();
284
				// frame.requestFocus();
285
				wss.setActive(iWindow);
286
				return dockWindowSupport.getWindow((DockWindow) frame);
287
			}
288

  
289
		} else {
290
			// infoRelationship.put(iWindow, wi);
291
			if (wi.isModal()) {
292
				addModalDialog(iWindow, wi);
293
			} else {
294
				if ((wp.equals(WindowInfo.PROJECT_PROFILE))
295
						&& (this.projectWindow != null)) {
296
					setProjectWindowVisible(!showProjectWindow);
297
				} else {
298
					wss.add(iWindow, new ActionListener() {
299
						public void actionPerformed(ActionEvent e) {
300
							IWindow v = wis.getWindowById(Integer.parseInt(e
301
									.getActionCommand()));
302
							if (!(v.getWindowProfile()
303
									.equals(WindowInfo.PROJECT_PROFILE))
304
									&& (projectWindow != null)) {
305
								DockWindow f = dockWindowSupport
306
										.getDockWindow(v);
307
								// f.getTopLevelAncestor().requestFocus();
308
								f.requestFocusInWindow();
309
								// f.requestFocus();
310
							} else {
311
								setProjectWindowVisible(!showProjectWindow);
312
							}
313
							// activateJInternalFrame(f);
314
						}
315
					});
316
					addDockedWindow(iWindow);
317
				}
318
			}
319
		}
320

  
321
		// windowRelationship.put(newWindow, iWindow);
322
		// invertedWindowRelationship.put(iWindow, newWindow);
323

  
324
		return iWindow;
325
	}
326

  
327
	protected void addModalDialog(IWindow iWindow, WindowInfo wi) {
328

  
329
		JDialog dlg = dockWindowSupport.getJDialog(iWindow);
330

  
331
		centerDialog(dlg);
332

  
333
		dlg.addWindowListener(new DockDialogWindowListener());
334
		dialogStack.pushDialog(dlg);
335

  
336
		dlg.setVisible(wis.getWindowInfo(iWindow).isVisible());
337

  
338
		// // Creating dialog
339
		// JDialog dialog = new JDialog(mainFrame, wi.getTitle());
340
		// dialog.setContentPane((Container) iWindow);
341
		// dialog.setSize(new Dimension(wi.getWidth(), wi.getHeight()));
342
		// dialog.setPreferredSize(new Dimension(wi.getHeight(),
343
		// wi.getWidth()));
344
		// centerDialog(dialog);
345
		// dialog.addWindowListener(new DialogWindowListener());
346
		// dialog.setModal(wi.isModal());
347
		//
348
		// // Pushing dialog
349
		// dialogStack.pushDialog(dialog);
350
		//
351
		// // Showing dialog
352
		// dialog.setVisible(true);
353
		//
354
		// return dialog;
355
	}
356

  
357
	private void addDockedWindow(IWindow iWindow) {
358
		WindowInfo wi = wis.getWindowInfo(iWindow);
359

  
360
		DockWindow wnd = dockWindowSupport.getDockWindow(iWindow);
361
		if (iWindow instanceof SingletonWindow) {
362
			SingletonWindow sv = (SingletonWindow) iWindow;
363
			singletonSupport.openSingletonWindow(sv, wnd);
364
		}
365

  
366
		addDockedWindow(iWindow, wi);
367
	}
368

  
369
	private void addDockedWindow(IWindow iWindow, WindowInfo wi) {
370
		DockWindow wnd = dockWindowSupport.getDockWindow(iWindow);
371
		wnd.addListener(new DockWindowListener());
372

  
373
		Integer type = (Integer) wnd.getIWindow().getWindowProfile();
374
		System.out.println("Class iWindow: " + iWindow.getClass());
375
		if (type == WindowInfo.DIALOG_PROFILE
376
				&& iWindow.getWindowInfo().isModeless())
377
			type = WindowInfo.PROPERTIES_PROFILE;
378
		if (type != null) {
379
			if (type.equals(WindowInfo.PROJECT_PROFILE)) {
380
				this.projectButton.setName("project window");
381
				// // tab.getParent().add(this.projectButton);
382
				// tab.addTab(wnd);
383
				SelectableToolBar[] toolBar = PluginServices.getMainFrame()
384
						.getToolbars();
385
				for (int i = 0; i < toolBar.length; i++) {
386
					SelectableToolBar tool = toolBar[i];
387
					if (toolBar[i].getName().equals("gvSIG")) {
388
						ButtonGroup gButton = new ButtonGroup();
389
						tool.addButton(gButton, this.projectButton);
390
						gButton.add(this.hiddeButton);
391
						// tool.addButton(gButton, this.projectButton);
392
					}
393
					// System.err.println("toolbar : " + toolBar[i].getName() +
394
					// " visible " + toolBar[i].isEnabled());
395
				}
396

  
397
				projectWindow = wnd;
398
				setProjectWindowVisible(true);
399
			} else if (type.equals(WindowInfo.EDITOR_PROFILE)) {
400
				DockingUtil.addWindow(wnd, rootWindow);
401
			}
402
			if (type.equals(WindowInfo.TOOL_PROFILE)) {
403
				rootWindow.getWindowBar(Direction.DOWN).addTab(wnd);
404
			}
405
			if (type.equals(WindowInfo.PROPERTIES_PROFILE)) {
406
				// DockingUtil.addWindow(wnd, rootWindow);
407

  
408
				int x = (wi.getX() <= 0) ? 100 : wi.getX();
409
				int y = (wi.getY() <= 0) ? 100 : wi.getY();
410
				Point possition = new Point(x, y);
411
				final FloatingWindow floatingWindow = rootWindow
412
						.createFloatingWindow(possition, new Dimension(wi
413
								.getWidth(), wi.getHeight()), wnd);
414
				// Show the window
415
				floatingWindow.getTopLevelAncestor().setVisible(true);
416
				((JDialog) floatingWindow.getTopLevelAncestor())
417
						.addWindowListener(new FloatingWindowContainerListener(
418
								floatingWindow));
419
				// DockingUtil.addWindow(wnd, rootWindow);
420

  
421
			}
422
		} else {
423
			JOptionPane
424
					.showMessageDialog(
425
							null,
426
							"la ventana que se va a a�adir no tiene una zona predeterminada en el skin, rellenar la funcion getWindowProfile()"
427
									+ "de la clase "
428
									+ wnd.getIWindow().getClass());
429
			DockingUtil.addWindow(wnd, rootWindow);
430

  
431
		}
432

  
433
		//
434
		// if (wi.getAdditionalInfo() != null
435
		// && wi.getAdditionalInfo().equals("ProjectWindow")) {
436
		// // rootWindow.getWindowBar(Direction.LEFT).addTab(wnd,
437
		// wi.getWidth());
438
		// // TabWindow tab = new TabWindow();
439
		// // tab.setSize(20, 50);
440
		//			
441
		// projectWindow = wnd;
442
		//			
443
		// tab = new TabWindow();
444
		// tab.setSize(20, 50);
445
		// tab.add(projectWindow);
446
		// projectWindowSise =
447
		// rootWindow.getWindowBar(Direction.LEFT).getPreferredSize();
448
		// rootWindow.getWindowBar(Direction.LEFT).add(tab);
449
		//			
450
		// // rootWindow.getWindowBar(Direction.LEFT).add(tab);
451
		//			
452
		// rootWindow.getWindowBar(Direction.DOWN).add(this.projectButton);
453
		//			
454
		//			
455
		// } else {
456
		// if (wi.isModeless()) {
457
		// final FloatingWindow floatingWindow = rootWindow
458
		// .createFloatingWindow(new Point(wi.getX(), wi.getY()),
459
		// new Dimension(wi.getWidth(), wi.getHeight()),
460
		// wnd);
461
		// // Show the window
462
		// floatingWindow.getTopLevelAncestor().setVisible(true);
463
		// ((JDialog) floatingWindow.getTopLevelAncestor())
464
		// .addWindowListener(new
465
		// FloatingWindowContainerListener(floatingWindow));
466
		// } else {
467
		// DockingUtil.addWindow(wnd, rootWindow);
468
		// }
469
		// }
470
		// DockingUtil.addWindow(wnd, rootWindow);
471
		updateDockWindowProperties(wnd, wi);
472
		if (wnd.getTopLevelAncestor() != null)
473
			wnd.getTopLevelAncestor().requestFocus();
474
		wnd.restoreFocus();
475
		// wnd.requestFocus();
476
		lastFocusedWindow = wnd;
477
	}
478

  
479
	private void updateDockWindowProperties(DockWindow frame, WindowInfo wi) {
480
		int height, width;
481
		frame.setName(wi.getTitle());
482
		frame.setVisible(wi.isVisible());
483
		// frame.setResizable(wi.isResizable());
484
		frame.getWindowProperties().setMinimizeEnabled(wi.isIconifiable());
485
		frame.getWindowProperties().setMaximizeEnabled(wi.isMaximizable());
486
		// try {
487
		// frame.setMaximum(wi.isMaximized());
488
		// } catch (PropertyVetoException e) {
489
		// TODO Auto-generated catch block
490
		// e.printStackTrace();
491
		// }
492
	}
493

  
494
	public IWindow addCentredWindow(IWindow iWindow)
495
			throws SingletonDialogAlreadyShownException {
496
		// TODO Auto-generated method stub
497
		addWindow(iWindow);
498
		return iWindow;
499
	}
500

  
501
	/**
502
	 * Situa un di�logo modal en el centro de la pantalla
503
	 * 
504
	 * @param d
505
	 *            Di�logo que se quiere situar
506
	 */
507
	private void centerDialog(JDialog d) {
508
		int offSetX = d.getWidth() / 2;
509
		int offSetY = d.getHeight() / 2;
510

  
511
		d.setLocation((mainFrame.getWidth() / 2) - offSetX, (mainFrame
512
				.getHeight() / 2)
513
				- offSetY);
514
	}
515

  
516
	public void changeWindowInfo(IWindow arg0, WindowInfo arg1) {
517
		// TODO Auto-generated method stub
518

  
519
	}
520

  
521
	public void closeAllWindows() {
522
		// TODO Auto-generated method stub
523
		System.out.println("cerrando todas");
524

  
525
		ArrayList eliminar = new ArrayList();
526
		Iterator i = dockWindowSupport.getWindowIterator();
527

  
528
		while (i.hasNext()) {
529
			eliminar.add((IWindow) i.next());
530
		}
531

  
532
		for (Iterator iter = eliminar.iterator(); iter.hasNext();) {
533
			IWindow vista = (IWindow) iter.next();
534
			closeWindow(vista);
535
		}
536

  
537
	}
538

  
539
	public boolean closeSingletonWindow(Object model) {
540
		DockWindow[] frames = (DockWindow[]) singletonSupport.getFrames(model);
541
		if (frames.length == 0)
542
			return false;
543
		for (int i = 0; i < frames.length; i++) {
544
			closeDockWindow(frames[i]);
545
		}
546
		return true;
547
	}
548

  
549
	public boolean closeSingletonWindow(Class viewClass, Object model) {
550
		DockWindow frame = (DockWindow) singletonSupport.getFrame(viewClass,
551
				model);
552
		if (frame == null)
553
			return false;
554
		closeDockWindow(frame);
555
		return true;
556
	}
557

  
558
	private void closeDockWindow(DockWindow frame) {
559
		IWindow s = (IWindow) dockWindowSupport.getWindow(frame);
560

  
561
		frame.close();
562
		callWindowClosed(s);
563
	}
564

  
565
	private void callWindowClosed(IWindow window) {
566
		if (window instanceof IWindowListener) {
567
			((IWindowListener) window).windowClosed();
568
		}
569
	}
570

  
571
	public void closeWindow(IWindow iWindow) {
572

  
573
		if (iWindow.getWindowInfo().isModal()) {
574
			closeJDialog();
575
		} else { // Si no es modal se cierra el JInternalFrame
576
			closeDockWindow(dockWindowSupport.getDockWindow(iWindow));
577
		}
578

  
579
	}
580

  
581
	private void closeJDialog() {
582
		JDialog dlg = dialogStack.popDialog();
583
		if (dlg == null)
584
			return;
585
		dlg.setVisible(false);
586
		
587
		dockWindowSupport.getWindow(dlg);
588
		IWindow s = dockWindowSupport.getWindow(dlg);
589
		
590
		callWindowClosed(s);
591
		
592
		
593
		if (s instanceof SingletonWindow) {
594
			singletonSupport.closeWindow((SingletonWindow) s);
595
		}
596
	}
597

  
598
	public IWindow[] getAllWindows() {
599
		ArrayList windows = new ArrayList();
600
		Iterator i = dockWindowSupport.getWindowIterator();
601

  
602
		while (i.hasNext()) {
603
			windows.add((IWindow) i.next());
604
		}
605
		return (IWindow[]) windows.toArray(new IWindow[0]);
606
	}
607

  
608
	public IWindow getActiveWindow() {
609
		DockingWindow dw = null;
610
		if (dw == null) {
611
			dw = lastFocusedWindow;
612
		}
613
		// System.err.println("GetfocusedView: " + dw);
614
		if (dw instanceof DockWindow) {
615
			DockWindow view = (DockWindow) dw;
616
			if (view != null) {
617
				IWindow theWindow = dockWindowSupport.getWindow(view);
618
				if (theWindow == null)
619
					return null;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff