Revision 3309
tags/Root_Coreplugin_CAD/libraries/libCorePlugin/src/com/iver/core/ConfigExtension.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 com.iver.core; |
|
42 |
|
|
43 |
|
|
44 |
/** |
|
45 |
*/ |
|
46 |
import com.iver.andami.PluginServices; |
|
47 |
import com.iver.andami.plugins.Extension; |
|
48 |
import com.iver.core.configExtensions.ConfigPlugins; |
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
/** |
|
53 |
* Extensi?n para abrir el di?logo de configuraci?n de ANDAMI. |
|
54 |
* |
|
55 |
* @author Vicente Caballero Navarro |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
public class ConfigExtension implements Extension { |
|
60 |
|
|
61 |
/* (non-Javadoc) |
|
62 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String) |
|
63 |
*/ |
|
64 |
public void execute(String actionCommand) { |
|
65 |
ConfigPlugins cp=new ConfigPlugins(); |
|
66 |
PluginServices.getMDIManager().addView(cp); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* DOCUMENT ME! |
|
71 |
* |
|
72 |
* @return DOCUMENT ME! |
|
73 |
*/ |
|
74 |
public boolean isVisible() { |
|
75 |
return true; |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* @see com.iver.mdiApp.plugins.Extension#isEnabled() |
|
80 |
*/ |
|
81 |
public boolean isEnabled() { |
|
82 |
return true; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* @see com.iver.andami.plugins.Extension#inicializar() |
|
87 |
*/ |
|
88 |
public void inicializar() { |
|
89 |
} |
|
90 |
} |
|
0 | 91 |
tags/Root_Coreplugin_CAD/libraries/libCorePlugin/src/com/iver/core/mdiManager/ViewInfoSupport.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 com.iver.core.mdiManager; |
|
42 |
|
|
43 |
import com.iver.andami.plugins.PluginClassLoader; |
|
44 |
import com.iver.andami.ui.mdiFrame.MainFrame; |
|
45 |
import com.iver.andami.ui.mdiFrame.NoSuchMenuException; |
|
46 |
import com.iver.andami.ui.mdiManager.SingletonView; |
|
47 |
import com.iver.andami.ui.mdiManager.View; |
|
48 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
|
49 |
|
|
50 |
import java.beans.PropertyChangeEvent; |
|
51 |
import java.beans.PropertyChangeListener; |
|
52 |
|
|
53 |
import java.util.Enumeration; |
|
54 |
import java.util.Hashtable; |
|
55 |
|
|
56 |
|
|
57 |
/** |
|
58 |
* |
|
59 |
*/ |
|
60 |
public class ViewInfoSupport { |
|
61 |
private static int serialId = 0; |
|
62 |
private FrameViewSupport fvs; |
|
63 |
|
|
64 |
/** 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 |
private SingletonViewSupport svs; |
|
69 |
private MainFrame mdiFrame; |
|
70 |
|
|
71 |
/** |
|
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 |
|
|
85 |
/** |
|
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 |
public View getViewById(int id) { |
|
93 |
Enumeration en = infoView.keys(); |
|
94 |
|
|
95 |
while (en.hasMoreElements()) { |
|
96 |
ViewInfo vi = (ViewInfo) en.nextElement(); |
|
97 |
|
|
98 |
if (vi.getId() == id) { |
|
99 |
return (View) infoView.get(vi); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
return null; |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* DOCUMENT ME! |
|
108 |
* |
|
109 |
* @param v DOCUMENT ME! |
|
110 |
* |
|
111 |
* @return DOCUMENT ME! |
|
112 |
*/ |
|
113 |
public synchronized ViewInfo getViewInfo(View v) { |
|
114 |
ViewInfo vi = (ViewInfo) viewInfo.get(v); |
|
115 |
|
|
116 |
if (vi == null) { |
|
117 |
vi = v.getViewInfo(); |
|
118 |
|
|
119 |
//Para el t?tulo |
|
120 |
if (vi.getHeight() != -1) { |
|
121 |
vi.setHeight(vi.getHeight() + 40); |
|
122 |
} |
|
123 |
|
|
124 |
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 |
public void deleteViewInfo(View p) { |
|
139 |
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 |
View view = (View) infoView.get(v); |
|
156 |
|
|
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 |
* No se hace nada porque puede modificarse el t?tulo de |
|
179 |
* una ventana antes de ser a?adida a Andami |
|
180 |
*/ |
|
181 |
} |
|
182 |
} |
|
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 |
* No se hace nada porque puede modificarse el t?tulo de |
|
202 |
* una ventana antes de ser a?adida a Andami |
|
203 |
*/ |
|
204 |
} |
|
205 |
} |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
} |
|
0 | 210 |
tags/Root_Coreplugin_CAD/libraries/libCorePlugin/src/com/iver/core/mdiManager/ComplexDesktopPane.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 10-mar-2005 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
21 |
USA. |
|
22 |
* |
|
23 |
* For more information, contact: |
|
24 |
* |
|
25 |
* Generalitat Valenciana |
|
26 |
* Conselleria d'Infraestructures i Transport |
|
27 |
* Av. Blasco Ib??ez, 50 |
|
28 |
* 46010 VALENCIA |
|
29 |
* SPAIN |
|
30 |
* |
|
31 |
* +34 963862235 |
|
32 |
* gvsig@gva.es |
|
33 |
* www.gvsig.gva.es |
|
34 |
* |
|
35 |
* or |
|
36 |
* |
|
37 |
* IVER T.I. S.A |
|
38 |
* Salamanca 50 |
|
39 |
* 46005 Valencia |
|
40 |
* Spain |
|
41 |
* |
|
42 |
* +34 963163400 |
|
43 |
* dac@iver.es |
|
44 |
*/ |
|
45 |
package com.iver.core.mdiManager; |
|
46 |
|
|
47 |
import javax.swing.JPanel; |
|
48 |
|
|
49 |
|
|
50 |
import javax.swing.JSplitPane; |
|
51 |
import java.awt.BorderLayout; |
|
52 |
import javax.swing.JDesktopPane; |
|
53 |
import com.iver.utiles.console.JConsole; |
|
54 |
public class ComplexDesktopPane extends JPanel { |
|
55 |
|
|
56 |
private JSplitPane jSplitPane = null; |
|
57 |
private JDesktopPane jDesktopPane = null; |
|
58 |
private JConsole jConsole = null; |
|
59 |
/** |
|
60 |
* This is the default constructor |
|
61 |
*/ |
|
62 |
public ComplexDesktopPane() { |
|
63 |
super(); |
|
64 |
initialize(); |
|
65 |
} |
|
66 |
/** |
|
67 |
* This method initializes this |
|
68 |
* |
|
69 |
* @return void |
|
70 |
*/ |
|
71 |
private void initialize() { |
|
72 |
this.setLayout(new BorderLayout()); |
|
73 |
this.setSize(300,200); |
|
74 |
this.add(getJSplitPane(), java.awt.BorderLayout.CENTER); |
|
75 |
} |
|
76 |
/** |
|
77 |
* This method initializes jSplitPane |
|
78 |
* |
|
79 |
* @return javax.swing.JSplitPane |
|
80 |
*/ |
|
81 |
private JSplitPane getJSplitPane() { |
|
82 |
if (jSplitPane == null) { |
|
83 |
jSplitPane = new JSplitPane(); |
|
84 |
jSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); |
|
85 |
jSplitPane.setResizeWeight(0.8); |
|
86 |
jSplitPane.setTopComponent(getDesktopPane()); |
|
87 |
jSplitPane.setBottomComponent(getJConsole()); |
|
88 |
} |
|
89 |
return jSplitPane; |
|
90 |
} |
|
91 |
/** |
|
92 |
* This method initializes jDesktopPane |
|
93 |
* |
|
94 |
* @return javax.swing.JDesktopPane |
|
95 |
*/ |
|
96 |
public JDesktopPane getDesktopPane() { |
|
97 |
if (jDesktopPane == null) { |
|
98 |
jDesktopPane = new JDesktopPane(); |
|
99 |
} |
|
100 |
return jDesktopPane; |
|
101 |
} |
|
102 |
/** |
|
103 |
* This method initializes jConsole |
|
104 |
* |
|
105 |
* @return com.iver.utiles.console.JConsole |
|
106 |
*/ |
|
107 |
private JConsole getJConsole() { |
|
108 |
if (jConsole == null) { |
|
109 |
jConsole = new JConsole(); |
|
110 |
} |
|
111 |
return jConsole; |
|
112 |
} |
|
113 |
} |
|
0 | 114 |
tags/Root_Coreplugin_CAD/libraries/libCorePlugin/src/com/iver/core/mdiManager/SingletonViewSupport.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 com.iver.core.mdiManager; |
|
42 |
|
|
43 |
import java.awt.Component; |
|
44 |
import java.util.ArrayList; |
|
45 |
import java.util.Comparator; |
|
46 |
import java.util.Iterator; |
|
47 |
import java.util.TreeMap; |
|
48 |
|
|
49 |
import javax.swing.JComponent; |
|
50 |
import javax.swing.JInternalFrame; |
|
51 |
|
|
52 |
import com.iver.andami.ui.mdiManager.SingletonDialogAlreadyShownException; |
|
53 |
import com.iver.andami.ui.mdiManager.SingletonView; |
|
54 |
import com.iver.andami.ui.mdiManager.View; |
|
55 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
|
56 |
|
|
57 |
|
|
58 |
/** |
|
59 |
* DOCUMENT ME! |
|
60 |
* |
|
61 |
* @author $author$ |
|
62 |
* @version $Revision$ |
|
63 |
*/ |
|
64 |
public class SingletonViewSupport { |
|
65 |
private static int singletonViewInfoID = 0; |
|
66 |
/** Hashtable que asocia contenido con vistas */ |
|
67 |
private HashMap contentViewInfo = new HashMap(); |
|
68 |
private ViewInfoSupport vis; |
|
69 |
private FrameViewSupport frameViewSupport; |
|
70 |
private HashMap contentFrame = new HashMap(); |
|
71 |
|
|
72 |
/** |
|
73 |
* DOCUMENT ME! |
|
74 |
* |
|
75 |
* @param vis DOCUMENT ME! |
|
76 |
* @param fvs |
|
77 |
* |
|
78 |
* @see com.iver.andami.ui.mdiManager.MDIManager#init(com.iver.andami.ui.mdiFrame.MDIFrame) |
|
79 |
*/ |
|
80 |
public SingletonViewSupport(ViewInfoSupport vis, FrameViewSupport fvs) { |
|
81 |
this.vis = vis; |
|
82 |
this.frameViewSupport = fvs; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Devuelve una referencia a la vista si ya est? mostrada o null si la |
|
87 |
* vista no ha sido a?adida o ya fue cerrada |
|
88 |
* |
|
89 |
* @param viewClass DOCUMENT ME! |
|
90 |
* @param model DOCUMENT ME! |
|
91 |
* @param vi DOCUMENT ME! |
|
92 |
* |
|
93 |
* @return true si la vista existe ya y false si la vista no existe |
|
94 |
* |
|
95 |
* @throws SingletonDialogAlreadyShownException DOCUMENT ME! |
|
96 |
*/ |
|
97 |
public boolean registerView(Class viewClass, Object model, ViewInfo vi) { |
|
98 |
//Se comprueba si la vista est? siendo mostrada |
|
99 |
SingletonViewInfo svi = new SingletonViewInfo(viewClass, model); |
|
100 |
|
|
101 |
if (contentViewInfo.containsKey(svi)) { |
|
102 |
if (vi.isModal()) { |
|
103 |
throw new SingletonDialogAlreadyShownException(); |
|
104 |
} |
|
105 |
|
|
106 |
vi.setViewInfo((ViewInfo)contentViewInfo.get(svi)); |
|
107 |
|
|
108 |
return true; |
|
109 |
} else { |
|
110 |
//La vista singleton no estaba mostrada |
|
111 |
//Se asocia el modelo con la vista |
|
112 |
contentViewInfo.put(svi, vi); |
|
113 |
return false; |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
public void openSingletonView(SingletonView sv, JComponent frame){ |
|
118 |
SingletonViewInfo svi = new SingletonViewInfo(sv.getClass(), sv.getViewModel()); |
|
119 |
contentFrame.put(svi, frame); |
|
120 |
} |
|
121 |
|
|
122 |
public boolean contains(SingletonView sv){ |
|
123 |
SingletonViewInfo svi = new SingletonViewInfo(sv.getClass(), sv.getViewModel()); |
|
124 |
return contentFrame.containsKey(svi); |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* DOCUMENT ME! |
|
129 |
* |
|
130 |
* @param s |
|
131 |
*/ |
|
132 |
public void closeView(SingletonView s) { |
|
133 |
SingletonViewInfo svi = new SingletonViewInfo(s.getClass(), s.getViewModel()); |
|
134 |
ViewInfo viewInfo = (ViewInfo) contentViewInfo.get(svi); |
|
135 |
JInternalFrame c = (JInternalFrame) contentFrame.get(svi); |
|
136 |
viewInfo.setWidth(c.getWidth()); |
|
137 |
viewInfo.setHeight(c.getHeight()); |
|
138 |
viewInfo.setX(c.getX()); |
|
139 |
viewInfo.setY(c.getY()); |
|
140 |
|
|
141 |
contentFrame.remove(svi); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Representa una vista singleton manteniendo el modelo y la clase de la |
|
146 |
* vista que lo muestra |
|
147 |
* |
|
148 |
* @author Fernando Gonz?lez Cort?s |
|
149 |
*/ |
|
150 |
public class SingletonViewInfo { |
|
151 |
|
|
152 |
public int id; |
|
153 |
|
|
154 |
/** Clase de la vista */ |
|
155 |
public Class clase; |
|
156 |
|
|
157 |
/** Modelo que representa la vista */ |
|
158 |
public Object modelo; |
|
159 |
|
|
160 |
/** |
|
161 |
* Creates a new SingletonView object. |
|
162 |
* |
|
163 |
* @param clase Clase de la vista |
|
164 |
* @param modelo Modelo que representa la vista |
|
165 |
*/ |
|
166 |
public SingletonViewInfo(Class clase, Object modelo) { |
|
167 |
this.clase = clase; |
|
168 |
this.modelo = modelo; |
|
169 |
this.id = singletonViewInfoID; |
|
170 |
singletonViewInfoID++; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* @see java.lang.Object#equals(java.lang.Object) |
|
175 |
*/ |
|
176 |
public boolean equals(Object obj) { |
|
177 |
if (obj.getClass() != SingletonViewInfo.class) { |
|
178 |
throw new IllegalArgumentException(); |
|
179 |
} |
|
180 |
|
|
181 |
SingletonViewInfo s = (SingletonViewInfo) obj; |
|
182 |
|
|
183 |
if ((clase == s.clase) && (modelo == s.modelo)) { |
|
184 |
return true; |
|
185 |
} else { |
|
186 |
return false; |
|
187 |
} |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
private JInternalFrame getFrame(SingletonViewInfo svi){ |
|
192 |
ViewInfo vi = (ViewInfo) contentViewInfo.get(svi); |
|
193 |
return (JInternalFrame) contentFrame.get(svi); |
|
194 |
} |
|
195 |
|
|
196 |
public JInternalFrame getFrame(Class viewClass, Object model){ |
|
197 |
SingletonViewInfo svi = new SingletonViewInfo(viewClass, model); |
|
198 |
return getFrame(svi); |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* @param model |
|
203 |
* @return |
|
204 |
*/ |
|
205 |
public JInternalFrame[] getFrames(Object model) { |
|
206 |
ArrayList ret = new ArrayList(); |
|
207 |
|
|
208 |
ArrayList keys = contentFrame.getKeys(); |
|
209 |
for (int i = 0; i < keys.size(); i++) { |
|
210 |
SingletonViewInfo svi = (SingletonViewInfo) keys.get(i); |
|
211 |
|
|
212 |
if (svi.modelo == model){ |
|
213 |
ret.add(contentFrame.get(svi)); |
|
214 |
} |
|
215 |
} |
|
216 |
|
|
217 |
return (JInternalFrame[]) ret.toArray(new JInternalFrame[0]); |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* @param view |
|
222 |
* @return |
|
223 |
*/ |
|
224 |
public JInternalFrame getFrame(SingletonView sv) { |
|
225 |
SingletonViewInfo svi = new SingletonViewInfo(sv.getClass(), sv.getViewModel()); |
|
226 |
return getFrame(svi); |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* @param sv |
|
231 |
* @param i |
|
232 |
*/ |
|
233 |
public void setX(SingletonView sv, int x) { |
|
234 |
JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getViewModel())); |
|
235 |
|
|
236 |
if (o == null) return; |
|
237 |
o.setLocation(x, o.getY()); |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* @param sv |
|
242 |
* @param i |
|
243 |
*/ |
|
244 |
public void setY(SingletonView sv, int y) { |
|
245 |
JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getViewModel())); |
|
246 |
|
|
247 |
if (o == null) return; |
|
248 |
|
|
249 |
o.setLocation(o.getX(), y); |
|
250 |
} |
|
251 |
|
|
252 |
/** |
|
253 |
* @param sv |
|
254 |
* @param i |
|
255 |
*/ |
|
256 |
public void setHeight(SingletonView sv, int height) { |
|
257 |
JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getViewModel())); |
|
258 |
|
|
259 |
if (o == null) return; |
|
260 |
|
|
261 |
o.setSize(o.getWidth(), height); |
|
262 |
} |
|
263 |
|
|
264 |
/** |
|
265 |
* @param sv |
|
266 |
* @param i |
|
267 |
*/ |
|
268 |
public void setWidth(SingletonView sv, int width) { |
|
269 |
JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getViewModel())); |
|
270 |
|
|
271 |
if (o == null) return; |
|
272 |
o.setSize(width, o.getHeight()); |
|
273 |
} |
|
274 |
|
|
275 |
/** |
|
276 |
* @param sv |
|
277 |
* @param string |
|
278 |
*/ |
|
279 |
public void setTitle(SingletonView sv, String title) { |
|
280 |
JInternalFrame o = (JInternalFrame) contentFrame.get(new SingletonViewInfo(sv.getClass(), sv.getViewModel())); |
|
281 |
|
|
282 |
if (o == null) return; |
|
283 |
o.setTitle(title); |
|
284 |
} |
|
285 |
|
|
286 |
private class HashMap { |
|
287 |
private ArrayList keys = new ArrayList(); |
|
288 |
private ArrayList values = new ArrayList(); |
|
289 |
|
|
290 |
public void put(SingletonViewInfo key, Object value) { |
|
291 |
int index = -1; |
|
292 |
for (int i = 0; i < keys.size(); i++) { |
|
293 |
if (keys.get(i).equals(key)){ |
|
294 |
index = i; |
|
295 |
break; |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
if (index != -1){ |
|
300 |
keys.add(index, key); |
|
301 |
values.add(index, value); |
|
302 |
}else{ |
|
303 |
keys.add(key); |
|
304 |
values.add(value); |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
public boolean containsKey(SingletonViewInfo key){ |
|
309 |
for (int i = 0; i < keys.size(); i++) { |
|
310 |
if (keys.get(i).equals(key)){ |
|
311 |
return true; |
|
312 |
} |
|
313 |
} |
|
314 |
|
|
315 |
return false; |
|
316 |
} |
|
317 |
|
|
318 |
public Object get(SingletonViewInfo key){ |
|
319 |
for (int i = 0; i < keys.size(); i++) { |
|
320 |
if (keys.get(i).equals(key)){ |
|
321 |
return values.get(i); |
|
322 |
} |
|
323 |
} |
|
324 |
|
|
325 |
return null; |
|
326 |
} |
|
327 |
|
|
328 |
public void remove(SingletonViewInfo key){ |
|
329 |
for (int i = 0; i < keys.size(); i++) { |
|
330 |
if (keys.get(i).equals(key)){ |
|
331 |
keys.remove(i); |
|
332 |
values.remove(i); |
|
333 |
} |
|
334 |
} |
|
335 |
} |
|
336 |
|
|
337 |
public ArrayList getKeys(){ |
|
338 |
return keys; |
|
339 |
} |
|
340 |
} |
|
341 |
} |
|
0 | 342 |
tags/Root_Coreplugin_CAD/libraries/libCorePlugin/src/com/iver/core/mdiManager/ViewStackSupport.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 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 |
int index = vistas.size()-1; |
|
105 |
while (index >= 0) |
|
106 |
{ |
|
107 |
View aux = (View) vistas.get(index); |
|
108 |
if (!aux.getViewInfo().isPalette()) |
|
109 |
{ |
|
110 |
System.err.println("getActiveView = " + aux.getViewInfo().getTitle()); |
|
111 |
return aux; |
|
112 |
} |
|
113 |
index--; |
|
114 |
} |
|
115 |
return null; |
|
116 |
} |
|
117 |
/** |
|
118 |
* Se utiliza cuando ya est? abierta la vista para indicar |
|
119 |
* que la pasamos a activa. De esta forma evitamos que el |
|
120 |
* getActiveView devuelva algo que no es. |
|
121 |
* En realidad lo que haces es mover la vista a la ?ltima |
|
122 |
* posici?n. |
|
123 |
* @param v |
|
124 |
*/ |
|
125 |
public void setActive(View v) |
|
126 |
{ |
|
127 |
View copia = null; |
|
128 |
boolean bCopiar = false; |
|
129 |
// Si es de tipo palette, no se pone como activa. |
|
130 |
// De esta forma, nunca nos la devolver?.... Bueno, |
|
131 |
// igual si cerramos la de encima. Voy a ponerle en |
|
132 |
// getActiveView que si es de tipo Palette, devuelva la |
|
133 |
// de abajo. |
|
134 |
if (v.getViewInfo().isPalette()) return; |
|
135 |
|
|
136 |
for (int i=0; i < vistas.size(); i++) |
|
137 |
{ |
|
138 |
View aux = (View) vistas.get(i); |
|
139 |
if (aux == v) |
|
140 |
{ |
|
141 |
copia = aux; |
|
142 |
bCopiar = true; |
|
143 |
} |
|
144 |
if (bCopiar) |
|
145 |
{ |
|
146 |
if (i < vistas.size()-1) |
|
147 |
{ |
|
148 |
View siguiente = (View) vistas.get(i+1); |
|
149 |
vistas.set(i,siguiente); |
|
150 |
} |
|
151 |
else // La ?ltima |
|
152 |
vistas.set(i,copia); |
|
153 |
} |
|
154 |
} // for |
|
155 |
} |
|
156 |
} |
|
0 | 157 |
tags/Root_Coreplugin_CAD/libraries/libCorePlugin/src/com/iver/core/mdiManager/NewSkin.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 com.iver.core.mdiManager; |
|
42 |
|
|
43 |
import java.awt.BorderLayout; |
|
44 |
import java.awt.Component; |
|
45 |
import java.awt.Cursor; |
|
46 |
import java.awt.event.ActionEvent; |
|
47 |
import java.awt.event.ActionListener; |
|
48 |
import java.awt.event.WindowAdapter; |
|
49 |
import java.awt.event.WindowEvent; |
|
50 |
import java.beans.PropertyVetoException; |
|
51 |
import java.util.ArrayList; |
|
52 |
import java.util.Iterator; |
|
53 |
import java.util.Stack; |
|
54 |
|
|
55 |
import javax.swing.DefaultDesktopManager; |
|
56 |
import javax.swing.DesktopManager; |
|
57 |
import javax.swing.JDesktopPane; |
|
58 |
import javax.swing.JDialog; |
|
59 |
import javax.swing.JInternalFrame; |
|
60 |
import javax.swing.JLayeredPane; |
|
61 |
import javax.swing.event.InternalFrameEvent; |
|
62 |
import javax.swing.event.InternalFrameListener; |
|
63 |
|
|
64 |
import org.apache.log4j.Logger; |
|
65 |
|
|
66 |
import com.iver.andami.plugins.Extension; |
|
67 |
import com.iver.andami.ui.mdiFrame.GlassPane; |
|
68 |
import com.iver.andami.ui.mdiFrame.MDIFrame; |
|
69 |
import com.iver.andami.ui.mdiManager.MDIManager; |
|
70 |
import com.iver.andami.ui.mdiManager.MDIUtilities; |
|
71 |
import com.iver.andami.ui.mdiManager.SingletonDialogAlreadyShownException; |
|
72 |
import com.iver.andami.ui.mdiManager.SingletonView; |
|
73 |
import com.iver.andami.ui.mdiManager.View; |
|
74 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
|
75 |
import com.iver.andami.ui.mdiManager.ViewListener; |
|
76 |
|
|
77 |
/** |
|
78 |
* |
|
79 |
*/ |
|
80 |
public class NewSkin implements MDIManager, Extension { |
|
81 |
/** |
|
82 |
* Variable privada <code>desktopManager</code> para usarlo cuando sale |
|
83 |
* una ventana que no queremos que nos restaure las que tenemos maximizadas. |
|
84 |
* Justo antes de usar el setMaximize(false), le pegamos el cambiazo. |
|
85 |
*/ |
|
86 |
private static DesktopManager desktopManager = new DefaultDesktopManager(); |
|
87 |
|
|
88 |
/** log */ |
|
89 |
private static Logger logger = Logger.getLogger(NewSkin.class.getName()); |
|
90 |
|
|
91 |
/** Panel de la MDIFrame */ |
|
92 |
private JDesktopPane panel = new JDesktopPane(); |
|
93 |
|
|
94 |
/** MDIFrame */ |
|
95 |
private MDIFrame mainFrame; |
|
96 |
|
|
97 |
private GlassPane glassPane = new GlassPane(); |
|
98 |
|
|
99 |
private DialogStackSupport dss; |
|
100 |
|
|
101 |
private FrameViewSupport fvs; |
|
102 |
|
|
103 |
private ViewInfoSupport vis; |
|
104 |
|
|
105 |
private ViewStackSupport vss; |
|
106 |
|
|
107 |
private SingletonViewSupport svs; |
|
108 |
|
|
109 |
private Cursor lastCursor = null; |
|
110 |
|
|
111 |
/** |
|
112 |
* @see com.iver.andami.ui.mdiManager.MDIManager#init(com.iver.andami.ui.mdiFrame.MDIFrame) |
|
113 |
*/ |
|
114 |
public void init(MDIFrame f) { |
|
115 |
// Inicializa el Frame y la consola |
|
116 |
mainFrame = f; |
|
117 |
mainFrame.setGlassPane(glassPane); |
|
118 |
panel.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); |
|
119 |
|
|
120 |
mainFrame.getContentPane().add(panel, BorderLayout.CENTER); |
|
121 |
panel.setDesktopManager(desktopManager); |
|
122 |
|
|
123 |
fvs = new FrameViewSupport(mainFrame); |
|
124 |
dss = new DialogStackSupport(mainFrame); |
|
125 |
svs = new SingletonViewSupport(vis, fvs); |
|
126 |
vis = new ViewInfoSupport(mainFrame, fvs, svs); |
|
127 |
fvs.setVis(vis); |
|
128 |
vss = new ViewStackSupport(vis); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* @see com.iver.andami.ui.mdiManager.MDIManager#addView(com.iver.andami.ui.mdiManager.View) |
|
133 |
*/ |
|
134 |
public View addView(View p) throws SingletonDialogAlreadyShownException { |
|
135 |
// se obtiene la informaci?n de la vista |
|
136 |
ViewInfo vi = vis.getViewInfo(p); |
|
137 |
|
|
138 |
// Se comprueban las incompatibilidades que pudieran haber en la vista |
|
139 |
MDIUtilities.checkViewInfo(vi); |
|
140 |
if ((p instanceof SingletonView) && (vi.isModal())) { |
|
141 |
throw new RuntimeException("A modal view cannot be a SingletonView"); |
|
142 |
} |
|
143 |
|
|
144 |
/* |
|
145 |
* Se obtiene la referencia a la vista anterior por si es una singleton |
|
146 |
* y est? siendo mostrada. Se obtiene su informaci?n si ya fue mostrada |
|
147 |
*/ |
|
148 |
boolean singletonPreviouslyAdded = false; |
|
149 |
|
|
150 |
if (p instanceof SingletonView) { |
|
151 |
SingletonView sv = (SingletonView) p; |
|
152 |
if (svs.registerView(sv.getClass(), sv.getViewModel(), vis |
|
153 |
.getViewInfo(sv))) { |
|
154 |
singletonPreviouslyAdded = true; |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
if (singletonPreviouslyAdded) { |
|
159 |
// Si la vista no est? actualmente abierta |
|
160 |
if (!svs.contains((SingletonView) p)) { |
|
161 |
JInternalFrame frame = fvs.getJInternalFrame(p); |
|
162 |
svs.openSingletonView((SingletonView) p, frame); |
|
163 |
addJInternalFrame(frame, vi); |
|
164 |
vss.add(p, new ActionListener() { |
|
165 |
public void actionPerformed(ActionEvent e) { |
|
166 |
View v = vis.getViewById(Integer.parseInt(e |
|
167 |
.getActionCommand())); |
|
168 |
JInternalFrame f = fvs.getJInternalFrame(v); |
|
169 |
activateJInternalFrame(f); |
|
170 |
} |
|
171 |
}); |
|
172 |
return p; |
|
173 |
} else { |
|
174 |
// La vista est? actualmente abierta |
|
175 |
JInternalFrame frame = (JInternalFrame) svs |
|
176 |
.getFrame((SingletonView) p); |
|
177 |
activateJInternalFrame(frame); |
|
178 |
vss.setActive(p); |
|
179 |
return fvs.getView((JInternalFrame) frame); |
|
180 |
} |
|
181 |
} else { |
|
182 |
if (vi.isModal()) { |
|
183 |
addJDialog(p); |
|
184 |
} else { |
|
185 |
// Se sit?a la vista en la pila de vistas |
|
186 |
vss.add(p, new ActionListener() { |
|
187 |
public void actionPerformed(ActionEvent e) { |
|
188 |
View v = vis.getViewById(Integer.parseInt(e |
|
189 |
.getActionCommand())); |
|
190 |
JInternalFrame f = fvs.getJInternalFrame(v); |
|
191 |
activateJInternalFrame(f); |
|
192 |
} |
|
193 |
}); |
|
194 |
addJInternalFrame(p); |
|
195 |
} |
|
196 |
|
|
197 |
return p; |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* DOCUMENT ME! |
|
203 |
* |
|
204 |
* @param wnd |
|
205 |
* DOCUMENT ME! |
|
206 |
* @param vi |
|
207 |
* DOCUMENT ME! |
|
208 |
*/ |
|
209 |
private void addJInternalFrame(JInternalFrame wnd, ViewInfo vi) { |
|
210 |
wnd.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); |
|
211 |
wnd.addInternalFrameListener(new FrameListener()); |
|
212 |
|
|
213 |
if (vi.isModeless() || vi.isPalette()) { |
|
214 |
panel.add(wnd, JDesktopPane.PALETTE_LAYER); |
|
215 |
if (vi.isPalette()) |
|
216 |
wnd.setFocusable(false); |
|
217 |
} else { |
|
218 |
panel.add(wnd); |
|
219 |
} |
|
220 |
|
|
221 |
activateJInternalFrame(wnd); |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* DOCUMENT ME! |
|
226 |
* |
|
227 |
* @param p |
|
228 |
*/ |
|
229 |
private void addJInternalFrame(View p) { |
|
230 |
ViewInfo vi = vis.getViewInfo(p); |
|
231 |
|
|
232 |
JInternalFrame wnd = fvs.getJInternalFrame(p); |
|
233 |
|
|
234 |
if (p instanceof SingletonView) { |
|
235 |
SingletonView sv = (SingletonView) p; |
|
236 |
svs.openSingletonView(sv, wnd); |
|
237 |
} |
|
238 |
|
|
239 |
addJInternalFrame(wnd, vi); |
|
240 |
} |
|
241 |
|
|
242 |
/** |
|
243 |
* DOCUMENT ME! |
|
244 |
* |
|
245 |
* @param wnd |
|
246 |
*/ |
|
247 |
private void activateJInternalFrame(JInternalFrame wnd) { |
|
248 |
try { |
|
249 |
wnd.moveToFront(); |
|
250 |
logger.debug("Activando " + wnd.getTitle()); |
|
251 |
wnd.setSelected(true); |
|
252 |
wnd.setIcon(false); |
|
253 |
} catch (PropertyVetoException e) { |
|
254 |
logger.error(e); |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
/** |
|
259 |
* Situa un di?logo modal en el centro de la pantalla |
|
260 |
* |
|
261 |
* @param d |
|
262 |
* Di?logo que se quiere situar |
|
263 |
*/ |
|
264 |
private void centerDialog(JDialog d) { |
|
265 |
int offSetX = d.getWidth() / 2; |
|
266 |
int offSetY = d.getHeight() / 2; |
|
267 |
|
|
268 |
d.setLocation((mainFrame.getWidth() / 2) - offSetX, (mainFrame |
|
269 |
.getHeight() / 2) |
|
270 |
- offSetY); |
|
271 |
} |
|
272 |
|
|
273 |
/** |
|
274 |
* DOCUMENT ME! |
|
275 |
* |
|
276 |
* @param p |
|
277 |
*/ |
|
278 |
private void addJDialog(View p) { |
|
279 |
JDialog dlg = fvs.getJDialog(p); |
|
280 |
|
|
281 |
centerDialog(dlg); |
|
282 |
|
|
283 |
dlg.addWindowListener(new DialogWindowListener()); |
|
284 |
dss.pushDialog(dlg); |
|
285 |
|
|
286 |
dlg.setVisible(vis.getViewInfo(p).isVisible()); |
|
287 |
} |
|
288 |
|
|
289 |
/** |
|
290 |
* @see com.iver.andami.ui.mdiManager.MDIManager#getActiveView() |
|
291 |
*/ |
|
292 |
public View getActiveView() { |
|
293 |
JInternalFrame jif = panel.getSelectedFrame(); |
|
294 |
|
|
295 |
if (jif != null) { |
|
296 |
View theView = fvs.getView(jif); |
|
297 |
if (theView == null) |
|
298 |
return null; |
|
299 |
if (theView.getViewInfo().isPalette()) |
|
300 |
return vss.getActiveView(); |
|
301 |
else |
|
302 |
return fvs.getView(jif); |
|
303 |
} |
|
304 |
// return vss.getActiveView(); |
|
305 |
|
|
306 |
return null; |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeView(com.iver.andami.ui.mdiManager.View) |
|
311 |
*/ |
|
312 |
public void closeView(View p) { |
|
313 |
// Si es un di?logo modal |
|
314 |
if (p.getViewInfo().isModal()) { |
|
315 |
closeJDialog(); |
|
316 |
} else { // Si no es modal se cierra el JInternalFrame |
|
317 |
closeJInternalFrame(fvs.getJInternalFrame(p)); |
|
318 |
} |
|
319 |
} |
|
320 |
|
|
321 |
/** |
|
322 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeAllViews() |
|
323 |
*/ |
|
324 |
public void closeAllViews() { |
|
325 |
ArrayList eliminar = new ArrayList(); |
|
326 |
Iterator i = fvs.getViewIterator(); |
|
327 |
|
|
328 |
while (i.hasNext()) { |
|
329 |
eliminar.add((View) i.next()); |
|
330 |
} |
|
331 |
|
|
332 |
for (Iterator iter = eliminar.iterator(); iter.hasNext();) { |
|
333 |
View vista = (View) iter.next(); |
|
334 |
closeView(vista); |
|
335 |
} |
|
336 |
} |
|
337 |
|
|
338 |
/** |
|
339 |
* @see com.iver.andami.ui.mdiManager.MDIManager#getViewInfo(com.iver.andami.ui.mdiManager.View) |
|
340 |
*/ |
|
341 |
public ViewInfo getViewInfo(View v) { |
|
342 |
return vis.getViewInfo(v); |
|
343 |
} |
|
344 |
|
|
345 |
/** |
|
346 |
* DOCUMENT ME! |
|
347 |
* |
|
348 |
* @param dialog |
|
349 |
* @throws RuntimeException |
|
350 |
* DOCUMENT ME! |
|
351 |
*/ |
|
352 |
private void closeJDialog() { |
|
353 |
JDialog dlg = dss.popDialog(); |
|
354 |
|
|
355 |
dlg.setVisible(false); |
|
356 |
|
|
357 |
View s = (View) fvs.getView(dlg); |
|
358 |
|
|
359 |
callViewClosed(s); |
|
360 |
|
|
361 |
fvs.closeView(s); |
|
362 |
|
|
363 |
// Si es singleton se desasocia el modelo con la vista |
|
364 |
if (s instanceof SingletonView) { |
|
365 |
svs.closeView((SingletonView) s); |
|
366 |
} |
|
367 |
} |
|
368 |
|
|
369 |
/** |
|
370 |
* DOCUMENT ME! |
|
371 |
* |
|
372 |
* @param view |
|
373 |
* DOCUMENT ME! |
|
374 |
*/ |
|
375 |
private void callViewClosed(View view) { |
|
376 |
if (view instanceof ViewListener) { |
|
377 |
((ViewListener) view).viewClosed(); |
|
378 |
} |
|
379 |
} |
|
380 |
|
|
381 |
/** |
|
382 |
* DOCUMENT ME! |
|
383 |
* |
|
384 |
* @param view |
|
385 |
* DOCUMENT ME! |
|
386 |
*/ |
|
387 |
private void callViewActivated(View view) { |
|
388 |
logger.debug("View " + view.getViewInfo().getTitle() |
|
389 |
+ " activated (callViewActivated)"); |
|
390 |
if (view instanceof ViewListener) { |
|
391 |
((ViewListener) view).viewActivated(); |
|
392 |
} |
|
393 |
} |
|
394 |
|
|
395 |
/** |
|
396 |
* DOCUMENT ME! |
|
397 |
* |
|
398 |
* @param frame |
|
399 |
*/ |
|
400 |
private void closeJInternalFrame(JInternalFrame frame) { |
|
401 |
try { |
|
402 |
View s = (View) fvs.getView(frame); |
|
403 |
|
|
404 |
frame.setClosed(true); |
|
405 |
callViewClosed(s); |
|
406 |
} catch (PropertyVetoException e) { |
|
407 |
logger |
|
408 |
.error( |
|
409 |
"Not compatible with property veto's. Use ViewInfo instead.", |
|
410 |
e); |
|
411 |
} |
|
412 |
} |
|
413 |
|
|
414 |
/** |
|
415 |
* @see com.iver.andami.plugins.Extension#inicializar() |
|
416 |
*/ |
|
417 |
public void inicializar() { |
|
418 |
} |
|
419 |
|
|
420 |
/** |
|
421 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String) |
|
422 |
*/ |
|
423 |
public void execute(String actionCommand) { |
|
424 |
if (actionCommand.equals("cascada")) { |
|
425 |
} else if (actionCommand.equals("mosaico")) { |
|
426 |
} |
|
427 |
} |
|
428 |
|
|
429 |
/** |
|
430 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
|
431 |
*/ |
|
432 |
public boolean isEnabled() { |
|
433 |
// TODO Auto-generated method stub |
|
434 |
return false; |
|
435 |
} |
|
436 |
|
|
437 |
/** |
|
438 |
* @see com.iver.andami.plugins.Extension#isVisible() |
|
439 |
*/ |
|
440 |
public boolean isVisible() { |
|
441 |
// TODO Auto-generated method stub |
|
442 |
return true; |
|
443 |
} |
|
444 |
|
|
445 |
/** |
|
446 |
* @see com.iver.andami.ui.mdiManager.MDIManager#setWaitCursor() |
|
447 |
*/ |
|
448 |
public void setWaitCursor() { |
|
449 |
if (mainFrame != null) { |
|
450 |
glassPane.setVisible(true); |
|
451 |
lastCursor = mainFrame.getCursor(); |
|
452 |
dss.setWaitCursor(); |
|
453 |
glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
|
454 |
} |
|
455 |
} |
|
456 |
|
|
457 |
/** |
|
458 |
* @see com.iver.andami.ui.mdiManager.MDIManager#restoreCursor() |
|
459 |
*/ |
|
460 |
public void restoreCursor() { |
|
461 |
if (mainFrame != null) { |
|
462 |
glassPane.setVisible(false); |
|
463 |
dss.restoreCursor(); |
|
464 |
glassPane.setCursor(lastCursor); |
|
465 |
} |
|
466 |
} |
|
467 |
|
|
468 |
/** |
|
469 |
* Listener para los eventos de cerrado de los di?logos. Tiene su raz?n de |
|
470 |
* ser en que los di?logos han de devolverse al pool cuando se cierran |
|
471 |
* |
|
472 |
* @author Fernando Gonz?lez Cort?s |
|
473 |
*/ |
|
474 |
public class DialogWindowListener extends WindowAdapter { |
|
475 |
/** |
|
476 |
* Captura el evento de cerrado de los di?logos con el fin de realizar |
|
477 |
* tareas de mantenimiento |
|
478 |
* |
|
479 |
* @param e |
|
480 |
* evento |
|
481 |
*/ |
|
482 |
public void windowClosing(WindowEvent e) { |
|
483 |
closeJDialog(); |
|
484 |
} |
|
485 |
} |
|
486 |
|
|
487 |
/** |
|
488 |
* DOCUMENT ME! |
|
489 |
*/ |
|
490 |
public class FrameListener implements InternalFrameListener { |
|
491 |
/** |
|
492 |
* @see javax.swing.event.InternalFrameListener#internalFrameActivated(javax.swing.event.InternalFrameEvent) |
|
493 |
*/ |
|
494 |
public void internalFrameActivated(InternalFrameEvent e) { |
|
495 |
// logger.debug("internalFrameActivated " + |
|
496 |
// e.getInternalFrame().getTitle()); |
|
497 |
|
|
498 |
// activatedInternalFramesStack.push(e.getInternalFrame()); |
|
499 |
|
|
500 |
View panel = fvs.getView((JInternalFrame) e.getSource()); |
|
501 |
|
|
502 |
ViewInfo vi = vis.getViewInfo(panel); |
|
503 |
if (vi.isPalette()) |
|
504 |
return; |
|
505 |
|
|
506 |
vss.setActive(panel); |
|
507 |
|
|
508 |
JInternalFrame frame = fvs.getJInternalFrame(panel); |
|
509 |
|
|
510 |
if (!frame.isMaximizable() && frame.isMaximum()) { |
|
511 |
try { |
|
512 |
frame.setMaximum(false); |
|
513 |
} catch (PropertyVetoException e1) { |
|
514 |
} |
|
515 |
} |
|
516 |
mainFrame.enableControls(); |
|
517 |
if (vi.getSelectedTool() != null) |
|
518 |
mainFrame.setSelectedTool(vi.getSelectedTool()); |
|
519 |
callViewActivated(panel); |
|
520 |
|
|
521 |
} |
|
522 |
|
Also available in: Unified diff