root / trunk / libraries / libCorePlugin / src / com / iver / core / mdiManager / ViewStackSupport.java @ 3002
History | View | Annotate | Download (3.8 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.ActionEvent; |
44 |
import java.awt.event.ActionListener; |
45 |
import java.lang.reflect.InvocationTargetException; |
46 |
import java.util.Hashtable; |
47 |
import java.util.Vector; |
48 |
|
49 |
import javax.swing.SwingUtilities; |
50 |
|
51 |
import com.iver.andami.PluginServices; |
52 |
import com.iver.andami.persistence.generate.PluginsStatus; |
53 |
import com.iver.andami.plugins.config.generate.Menu; |
54 |
import com.iver.andami.ui.mdiManager.View; |
55 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
56 |
|
57 |
/**
|
58 |
*
|
59 |
*/
|
60 |
public class ViewStackSupport { |
61 |
private Vector vistas = new Vector(); |
62 |
|
63 |
private ViewInfoSupport vis;
|
64 |
|
65 |
private Hashtable viewMenu = new Hashtable(); |
66 |
|
67 |
/**
|
68 |
* @param vis
|
69 |
*/
|
70 |
public ViewStackSupport(ViewInfoSupport vis) {
|
71 |
this.vis = vis;
|
72 |
} |
73 |
|
74 |
public void add(View v, final ActionListener listener) { |
75 |
vistas.add(v); |
76 |
ViewInfo vi = vis.getViewInfo(v); |
77 |
int id = vi.getId();
|
78 |
Menu m = new Menu(); |
79 |
m.setActionCommand(""+id);
|
80 |
m.setTooltip("activa la ventana");
|
81 |
m.setText("ventana/"+vi.getTitle());
|
82 |
viewMenu.put(v, m); |
83 |
PluginServices.getMainFrame().addMenu(m, listener, PluginServices.getPluginServices(this).getClassLoader() );
|
84 |
} |
85 |
|
86 |
public void remove(View v){ |
87 |
Menu m = (Menu) viewMenu.get(v); |
88 |
if (m == null) return; |
89 |
PluginServices.getMainFrame().removeMenu(m); |
90 |
viewMenu.remove(v); |
91 |
vistas.remove(v); |
92 |
} |
93 |
|
94 |
/**
|
95 |
* FJP: No se usa, y no s? para qu? estaba pensado.
|
96 |
*/
|
97 |
public void ctrltab(){ |
98 |
View v = (View) vistas.remove(vistas.size() - 1); |
99 |
vistas.add(0, v);
|
100 |
} |
101 |
|
102 |
public View getActiveView(){ |
103 |
if (vistas.size() == 0) return null; |
104 |
|
105 |
View aux = (View) vistas.get(vistas.size() - 1); |
106 |
System.err.println("getActiveView = " + aux.getViewInfo().getTitle()); |
107 |
return aux;
|
108 |
} |
109 |
/**
|
110 |
* Se utiliza cuando ya est? abierta la vista para indicar
|
111 |
* que la pasamos a activa. De esta forma evitamos que el
|
112 |
* getActiveView devuelva algo que no es.
|
113 |
* En realidad lo que haces es mover la vista a la ?ltima
|
114 |
* posici?n.
|
115 |
* @param v
|
116 |
*/
|
117 |
public void setActive(View v) |
118 |
{ |
119 |
View copia = null; |
120 |
boolean bCopiar = false; |
121 |
for (int i=0; i < vistas.size(); i++) |
122 |
{ |
123 |
View aux = (View) vistas.get(i); |
124 |
if (aux == v)
|
125 |
{ |
126 |
copia = aux; |
127 |
bCopiar = true;
|
128 |
} |
129 |
if (bCopiar)
|
130 |
{ |
131 |
if (i < vistas.size()-1) |
132 |
{ |
133 |
View siguiente = (View) vistas.get(i+1); |
134 |
vistas.set(i,siguiente); |
135 |
} |
136 |
else // La ?ltima |
137 |
vistas.set(i,copia); |
138 |
} |
139 |
} // for
|
140 |
} |
141 |
} |