root / trunk / libraries / libCorePlugin / src / com / iver / core / mdiManager / ViewInfoSupport.java @ 6877
History | View | Annotate | Download (5.79 KB)
1 | 1104 | fjp | /* 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 | 592 | fernando | package com.iver.core.mdiManager; |
42 | |||
43 | 1341 | fernando | import com.iver.andami.plugins.PluginClassLoader; |
44 | import com.iver.andami.ui.mdiFrame.MainFrame; |
||
45 | 1344 | fernando | import com.iver.andami.ui.mdiFrame.NoSuchMenuException; |
46 | 1341 | fernando | import com.iver.andami.ui.mdiManager.SingletonView; |
47 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
48 | 1341 | fernando | import com.iver.andami.ui.mdiManager.ViewInfo; |
49 | 592 | fernando | |
50 | 1344 | fernando | import java.beans.PropertyChangeEvent; |
51 | import java.beans.PropertyChangeListener; |
||
52 | 1341 | fernando | |
53 | 1344 | fernando | import java.util.Enumeration; |
54 | import java.util.Hashtable; |
||
55 | |||
56 | |||
57 | 592 | fernando | /**
|
58 | *
|
||
59 | */
|
||
60 | public class ViewInfoSupport { |
||
61 | 1344 | fernando | private static int serialId = 0; |
62 | private FrameViewSupport fvs;
|
||
63 | 592 | fernando | |
64 | 1344 | fernando | /** Correspondencias entre las vistas y su informacion */
|
65 | private Hashtable viewInfo = new Hashtable(); |
||
66 | private Hashtable infoView = new Hashtable(); |
||
67 | private ViewPropertyChangeListener viewInfoListener = new ViewPropertyChangeListener(); |
||
68 | 975 | fernando | private SingletonViewSupport svs;
|
69 | 1341 | fernando | private MainFrame mdiFrame;
|
70 | 592 | fernando | |
71 | 1344 | fernando | /**
|
72 | * Creates a new ViewInfoSupport object.
|
||
73 | *
|
||
74 | * @param frame DOCUMENT ME!
|
||
75 | * @param fvs DOCUMENT ME!
|
||
76 | * @param svs
|
||
77 | */
|
||
78 | public ViewInfoSupport(MainFrame frame, FrameViewSupport fvs,
|
||
79 | SingletonViewSupport svs) { |
||
80 | this.fvs = fvs;
|
||
81 | this.svs = svs;
|
||
82 | this.mdiFrame = frame;
|
||
83 | } |
||
84 | 592 | fernando | |
85 | 1344 | fernando | /**
|
86 | * Devuelve la vista cuyo identificador es el parametro
|
||
87 | *
|
||
88 | * @param id Identificador de la vista que se quiere obtener
|
||
89 | *
|
||
90 | * @return La vista o null si no hay ninguna vista con ese identificador
|
||
91 | */
|
||
92 | 6877 | cesar | public IWindow getViewById(int id) { |
93 | 1344 | fernando | Enumeration en = infoView.keys();
|
94 | 592 | fernando | |
95 | 1344 | fernando | while (en.hasMoreElements()) {
|
96 | ViewInfo vi = (ViewInfo) en.nextElement(); |
||
97 | 592 | fernando | |
98 | 1344 | fernando | if (vi.getId() == id) {
|
99 | 6877 | cesar | return (IWindow) infoView.get(vi);
|
100 | 1344 | fernando | } |
101 | } |
||
102 | 592 | fernando | |
103 | 1344 | fernando | return null; |
104 | } |
||
105 | 592 | fernando | |
106 | 1344 | fernando | /**
|
107 | * DOCUMENT ME!
|
||
108 | *
|
||
109 | * @param v DOCUMENT ME!
|
||
110 | *
|
||
111 | * @return DOCUMENT ME!
|
||
112 | */
|
||
113 | 6877 | cesar | public synchronized ViewInfo getViewInfo(IWindow v) { |
114 | 1344 | fernando | ViewInfo vi = (ViewInfo) viewInfo.get(v); |
115 | 592 | fernando | |
116 | 1344 | fernando | if (vi == null) { |
117 | vi = v.getViewInfo(); |
||
118 | 592 | fernando | |
119 | 1344 | fernando | //Para el t?tulo
|
120 | if (vi.getHeight() != -1) { |
||
121 | vi.setHeight(vi.getHeight() + 40);
|
||
122 | } |
||
123 | 592 | fernando | |
124 | 1344 | fernando | vi.addPropertyChangeListener(viewInfoListener); |
125 | viewInfo.put(v, vi); |
||
126 | infoView.put(vi, v); |
||
127 | vi.setId(serialId++); |
||
128 | } |
||
129 | |||
130 | return vi;
|
||
131 | } |
||
132 | |||
133 | /**
|
||
134 | * DOCUMENT ME!
|
||
135 | *
|
||
136 | * @param p DOCUMENT ME!
|
||
137 | */
|
||
138 | 6877 | cesar | public void deleteViewInfo(IWindow p) { |
139 | 1344 | fernando | ViewInfo vi = (ViewInfo) viewInfo.remove(p); |
140 | infoView.remove(vi); |
||
141 | } |
||
142 | |||
143 | /**
|
||
144 | * DOCUMENT ME!
|
||
145 | *
|
||
146 | * @author $author$
|
||
147 | * @version $Revision$
|
||
148 | */
|
||
149 | public class ViewPropertyChangeListener implements PropertyChangeListener { |
||
150 | /**
|
||
151 | * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
|
||
152 | */
|
||
153 | public void propertyChange(PropertyChangeEvent evt) { |
||
154 | ViewInfo v = (ViewInfo) evt.getSource(); |
||
155 | 6877 | cesar | IWindow view = (IWindow) infoView.get(v); |
156 | 1344 | fernando | |
157 | if (view instanceof SingletonView) { |
||
158 | SingletonView sv = (SingletonView) view; |
||
159 | |||
160 | if (evt.getPropertyName().equals("x")) { |
||
161 | svs.setX(sv, ((Integer) evt.getNewValue()).intValue());
|
||
162 | } else if (evt.getPropertyName().equals("y")) { |
||
163 | svs.setY(sv, ((Integer) evt.getNewValue()).intValue());
|
||
164 | } else if (evt.getPropertyName().equals("height")) { |
||
165 | svs.setHeight(sv, ((Integer) evt.getNewValue()).intValue());
|
||
166 | } else if (evt.getPropertyName().equals("width")) { |
||
167 | svs.setWidth(sv, ((Integer) evt.getNewValue()).intValue());
|
||
168 | } else if (evt.getPropertyName().equals("title")) { |
||
169 | svs.setTitle(sv, (String) evt.getNewValue());
|
||
170 | |||
171 | try {
|
||
172 | mdiFrame.changeMenuName(new String[] { |
||
173 | "ventana", (String) evt.getOldValue() |
||
174 | }, (String) evt.getNewValue(),
|
||
175 | (PluginClassLoader) getClass().getClassLoader()); |
||
176 | } catch (NoSuchMenuException e) {
|
||
177 | /*
|
||
178 | 4726 | caballero | * No se hace nada porque puede modificarse el t?tulo de
|
179 | 1344 | fernando | * una ventana antes de ser a?adida a Andami
|
180 | */
|
||
181 | 4726 | caballero | } |
182 | 1344 | fernando | } |
183 | } else {
|
||
184 | if (evt.getPropertyName().equals("x")) { |
||
185 | fvs.setX(view, ((Integer) evt.getNewValue()).intValue());
|
||
186 | } else if (evt.getPropertyName().equals("y")) { |
||
187 | fvs.setY(view, ((Integer) evt.getNewValue()).intValue());
|
||
188 | } else if (evt.getPropertyName().equals("height")) { |
||
189 | fvs.setHeight(view, ((Integer) evt.getNewValue()).intValue());
|
||
190 | } else if (evt.getPropertyName().equals("width")) { |
||
191 | fvs.setWidth(view, ((Integer) evt.getNewValue()).intValue());
|
||
192 | } else if (evt.getPropertyName().equals("title")) { |
||
193 | fvs.setTitle(view, (String) evt.getNewValue());
|
||
194 | try{
|
||
195 | mdiFrame.changeMenuName(new String[] { |
||
196 | "ventana", (String) evt.getOldValue() |
||
197 | }, (String) evt.getNewValue(),
|
||
198 | (PluginClassLoader) getClass().getClassLoader()); |
||
199 | } catch (NoSuchMenuException e) {
|
||
200 | /*
|
||
201 | 4726 | caballero | * No se hace nada porque puede modificarse el t?tulo de
|
202 | 1344 | fernando | * una ventana antes de ser a?adida a Andami
|
203 | */
|
||
204 | } |
||
205 | } |
||
206 | } |
||
207 | } |
||
208 | } |
||
209 | 592 | fernando | } |