svn-gvsig-desktop / tags / v1_0_2_Build_915 / libraries / libCorePlugin / src / com / iver / core / mdiManager / WindowStackSupport.java @ 12217
History | View | Annotate | Download (4.23 KB)
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 com.iver.core.mdiManager; |
42 |
|
43 |
import java.awt.event.ActionListener; |
44 |
import java.util.Hashtable; |
45 |
import java.util.Vector; |
46 |
|
47 |
import com.iver.andami.PluginServices; |
48 |
import com.iver.andami.plugins.config.generate.Menu; |
49 |
import com.iver.andami.ui.mdiManager.IWindow; |
50 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
51 |
|
52 |
/**
|
53 |
*
|
54 |
*/
|
55 |
public class WindowStackSupport { |
56 |
private Vector vistas = new Vector(); |
57 |
|
58 |
private WindowInfoSupport vis;
|
59 |
|
60 |
private Hashtable viewMenu = new Hashtable(); |
61 |
|
62 |
/**
|
63 |
* @param vis
|
64 |
*/
|
65 |
public WindowStackSupport(WindowInfoSupport vis) {
|
66 |
this.vis = vis;
|
67 |
} |
68 |
|
69 |
public void add(IWindow v, final ActionListener listener) { |
70 |
vistas.add(v); |
71 |
WindowInfo vi = vis.getWindowInfo(v); |
72 |
int id = vi.getId();
|
73 |
Menu m = new Menu(); |
74 |
m.setActionCommand(""+id);
|
75 |
m.setTooltip(PluginServices.getText(this, "activa_la_ventana")); |
76 |
m.setText("ventana/"+vi.getTitle());
|
77 |
viewMenu.put(v, m); |
78 |
PluginServices.getMainFrame().addMenu(m, listener, PluginServices.getPluginServices(this).getClassLoader() );
|
79 |
} |
80 |
|
81 |
public void remove(IWindow v){ |
82 |
Menu m = (Menu) viewMenu.get(v); |
83 |
if (m == null) return; |
84 |
PluginServices.getMainFrame().removeMenu(m); |
85 |
viewMenu.remove(v); |
86 |
vistas.remove(v); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* FJP: No se usa, y no s? para qu? estaba pensado.
|
91 |
*/
|
92 |
public void ctrltab(){ |
93 |
IWindow v = (IWindow) vistas.remove(vistas.size() - 1);
|
94 |
vistas.add(0, v);
|
95 |
} |
96 |
|
97 |
public IWindow getActiveWindow(){
|
98 |
if (vistas.size() == 0) return null; |
99 |
int index = vistas.size()-1; |
100 |
while (index >= 0) |
101 |
{ |
102 |
IWindow aux = (IWindow) vistas.get(index); |
103 |
if (!aux.getWindowInfo().isPalette())
|
104 |
{ |
105 |
// System.err.println("getActiveView = " + aux.getWindowInfo().getTitle());
|
106 |
return aux;
|
107 |
} |
108 |
index--; |
109 |
} |
110 |
return null; |
111 |
} |
112 |
/**
|
113 |
* Se utiliza cuando ya est? abierta la vista para indicar
|
114 |
* que la pasamos a activa. De esta forma evitamos que el
|
115 |
* getActiveView devuelva algo que no es.
|
116 |
* En realidad lo que haces es mover la vista a la ?ltima
|
117 |
* posici?n.
|
118 |
* @param v
|
119 |
*/
|
120 |
public void setActive(IWindow v) |
121 |
{ |
122 |
IWindow copia = null;
|
123 |
boolean bCopiar = false; |
124 |
// Si es de tipo palette, no se pone como activa.
|
125 |
// De esta forma, nunca nos la devolver?.... Bueno,
|
126 |
// igual si cerramos la de encima. Voy a ponerle en
|
127 |
// getActiveView que si es de tipo Palette, devuelva la
|
128 |
// de abajo.
|
129 |
if (v.getWindowInfo().isPalette()) return; |
130 |
|
131 |
for (int i=0; i < vistas.size(); i++) |
132 |
{ |
133 |
IWindow aux = (IWindow) vistas.get(i); |
134 |
if (aux == v)
|
135 |
{ |
136 |
copia = aux; |
137 |
bCopiar = true;
|
138 |
} |
139 |
if (bCopiar)
|
140 |
{ |
141 |
if (i < vistas.size()-1) |
142 |
{ |
143 |
IWindow siguiente = (IWindow) vistas.get(i+1);
|
144 |
vistas.set(i,siguiente); |
145 |
} |
146 |
else // La ?ltima |
147 |
vistas.set(i,copia); |
148 |
} |
149 |
} // for
|
150 |
} |
151 |
} |