svn-gvsig-desktop / trunk / frameworks / _fwAndami / src / com / iver / andami / ui / mdiFrame / MDIFrame.java @ 3583
History | View | Annotate | Download (31.5 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.andami.ui.mdiFrame; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Component; |
45 |
import java.awt.Dimension; |
46 |
import java.awt.FlowLayout; |
47 |
import java.awt.Insets; |
48 |
import java.awt.event.ActionEvent; |
49 |
import java.awt.event.ActionListener; |
50 |
import java.awt.event.ComponentEvent; |
51 |
import java.awt.event.ComponentListener; |
52 |
import java.awt.event.ContainerEvent; |
53 |
import java.awt.event.ContainerListener; |
54 |
import java.awt.event.MouseAdapter; |
55 |
import java.awt.event.MouseEvent; |
56 |
import java.awt.event.WindowAdapter; |
57 |
import java.awt.event.WindowEvent; |
58 |
import java.net.URL; |
59 |
import java.util.ArrayList; |
60 |
import java.util.HashMap; |
61 |
import java.util.Iterator; |
62 |
import java.util.NoSuchElementException; |
63 |
import java.util.Vector; |
64 |
|
65 |
import javax.swing.AbstractButton; |
66 |
import javax.swing.ButtonGroup; |
67 |
import javax.swing.ImageIcon; |
68 |
import javax.swing.JComponent; |
69 |
import javax.swing.JFrame; |
70 |
import javax.swing.JLabel; |
71 |
import javax.swing.JMenu; |
72 |
import javax.swing.JMenuBar; |
73 |
import javax.swing.JOptionPane; |
74 |
import javax.swing.JPanel; |
75 |
import javax.swing.JPopupMenu; |
76 |
import javax.swing.KeyStroke; |
77 |
import javax.swing.MenuElement; |
78 |
import javax.swing.SwingUtilities; |
79 |
import javax.swing.Timer; |
80 |
|
81 |
import org.apache.log4j.Logger; |
82 |
|
83 |
import com.iver.andami.Launcher; |
84 |
import com.iver.andami.PluginServices; |
85 |
import com.iver.andami.messages.Messages; |
86 |
import com.iver.andami.messages.NotificationManager; |
87 |
import com.iver.andami.plugins.ExtensionDecorator; |
88 |
import com.iver.andami.plugins.PluginClassLoader; |
89 |
import com.iver.andami.plugins.config.generate.ActionTool; |
90 |
import com.iver.andami.plugins.config.generate.Label; |
91 |
import com.iver.andami.plugins.config.generate.Menu; |
92 |
import com.iver.andami.plugins.config.generate.PopupMenu; |
93 |
import com.iver.andami.plugins.config.generate.SelectableTool; |
94 |
import com.iver.andami.plugins.config.generate.SkinExtensionType; |
95 |
import com.iver.andami.plugins.config.generate.ToolBar; |
96 |
import com.iver.andami.ui.mdiManager.MDIManager; |
97 |
import com.iver.andami.ui.mdiManager.MDIManagerFactory; |
98 |
|
99 |
|
100 |
/**
|
101 |
* Frame principal de la aplicaci?n.
|
102 |
*
|
103 |
* @version $Revision: 3583 $
|
104 |
*/
|
105 |
public class MDIFrame extends JFrame implements ComponentListener, |
106 |
ContainerListener, ActionListener, MainFrame { |
107 |
/** DOCUMENT ME! */
|
108 |
private static Logger logger = Logger.getLogger(MDIFrame.class.getName()); |
109 |
private MDIManager mdiManager = MDIManagerFactory.createManager();
|
110 |
|
111 |
/** Elementos de la aplicaci?n */
|
112 |
private JMenuBar menuBar = new JMenuBar(); |
113 |
|
114 |
/** DOCUMENT ME! */
|
115 |
private JPanel toolBars = new JPanel(); |
116 |
|
117 |
/** DOCUMENT ME! */
|
118 |
private NewStatusBar bEstado = null; |
119 |
|
120 |
/** Asocia los nombres con las barras de herramientas */
|
121 |
private HashMap toolBarMap = new HashMap(); |
122 |
|
123 |
/**
|
124 |
* actionCommand del tool seleccionado
|
125 |
*/
|
126 |
private String selectedTool; |
127 |
|
128 |
/** Asocia los nombres con los popupMenus */
|
129 |
private HashMap popupMap = new HashMap(); |
130 |
|
131 |
/** Asocia controles con la clase de la extension asociada */
|
132 |
private HashMap controlClass = new HashMap(); |
133 |
|
134 |
/**
|
135 |
* Asocia la informaci?n sobre las etiquetas que van en la status bar con
|
136 |
* cada extension
|
137 |
*/
|
138 |
private HashMap classLabels = new HashMap(); |
139 |
|
140 |
/** ProgressListeners (ver interfaz com.iver.mdiApp.ui.ProgressListener) */
|
141 |
private ArrayList progressListeners = new ArrayList(); |
142 |
|
143 |
/** Timer para invocar los enventos de la interfaz anterior */
|
144 |
private Timer progressTimer = null; |
145 |
|
146 |
/** Tabla hash que asocia las clases con las extensiones */
|
147 |
private HashMap classesExtensions = new HashMap(); |
148 |
|
149 |
/** ?ltima clase que activ? etiquetas */
|
150 |
private Class lastLabelClass; |
151 |
|
152 |
/** Instancia que pone los tooltip en la barra de estado */
|
153 |
private TooltipListener tooltipListener = new TooltipListener(); |
154 |
private HashMap infoCodedMenus = new HashMap(); |
155 |
|
156 |
private String titlePrefix; |
157 |
private ButtonGroup buttonGroup=new ButtonGroup(); |
158 |
/**
|
159 |
* Realiza tareas para poner en marcha la aplicaci?n
|
160 |
*
|
161 |
* @throws RuntimeException DOCUMENT ME!
|
162 |
*/
|
163 |
public void init() { |
164 |
if (!SwingUtilities.isEventDispatchThread()) { |
165 |
throw new RuntimeException("Not Event Dispatch Thread"); |
166 |
} |
167 |
|
168 |
//Se a?aden los listeners del JFrame
|
169 |
this.addWindowListener(new WindowAdapter() { |
170 |
public void windowClosing(WindowEvent e) { |
171 |
/*JOptionPane dlgSalir = new JOptionPane(Utilities.getMessage(this,"quiere_salir"),
|
172 |
JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
|
173 |
*/
|
174 |
int option = JOptionPane.showConfirmDialog(MDIFrame.this, |
175 |
Messages.getString("MDIFrame.quiere_salir"),
|
176 |
Messages.getString("MDIFrame.salir"),
|
177 |
JOptionPane.YES_NO_OPTION);
|
178 |
|
179 |
if (option == JOptionPane.YES_OPTION) { |
180 |
Launcher.closeApplication(); |
181 |
} |
182 |
} |
183 |
}); |
184 |
this.addComponentListener(this); |
185 |
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); |
186 |
|
187 |
//Se configura la barra de menu
|
188 |
setJMenuBar(menuBar); |
189 |
|
190 |
//Se configura el layout del JFrame principal
|
191 |
this.getContentPane().setLayout(new BorderLayout()); |
192 |
|
193 |
/*
|
194 |
* Se configura y se a?ade el JPanel de las barras de
|
195 |
* herramientas
|
196 |
*/
|
197 |
FlowLayout layout = new FlowLayout(FlowLayout.LEFT); |
198 |
layout.setHgap(0);
|
199 |
layout.setVgap(0);
|
200 |
toolBars.setLayout(layout); |
201 |
getContentPane().add(toolBars, BorderLayout.PAGE_START);
|
202 |
|
203 |
// Se a?ade la barra de estado a la aplicaci?n
|
204 |
bEstado = new NewStatusBar();
|
205 |
bEstado.setInfoText(Messages.getString("StatusBar.Aplicacion_iniciada"));
|
206 |
getContentPane().add(bEstado, BorderLayout.SOUTH);
|
207 |
|
208 |
this.toolBars.addContainerListener(this); |
209 |
|
210 |
pack(); |
211 |
|
212 |
this.setSize(500, 500); |
213 |
this.setExtendedState(MAXIMIZED_BOTH);
|
214 |
|
215 |
mdiManager.init(this);
|
216 |
} |
217 |
|
218 |
public void setTitle(String title) { |
219 |
super.setTitle(titlePrefix + ":" + title); |
220 |
} |
221 |
|
222 |
/**
|
223 |
* A?ade un modo de operaci?n a la caja de herramientas
|
224 |
*
|
225 |
* @param ext Texto del boton, si es null no aparece texto
|
226 |
* @param ext Icono del boton, si es null no aparece icono
|
227 |
* @param ext Extensi?n asociada al control
|
228 |
* @param selectableTool Enable text del control
|
229 |
*
|
230 |
* @throws ClassNotFoundException
|
231 |
* @throws RuntimeException DOCUMENT ME!
|
232 |
*/
|
233 |
public void addTool(PluginClassLoader loader, SkinExtensionType ext, |
234 |
ToolBar toolBar, SelectableTool selectableTool) |
235 |
throws ClassNotFoundException { |
236 |
if (!SwingUtilities.isEventDispatchThread()) { |
237 |
throw new RuntimeException("No Event Dispatch Thread"); |
238 |
} |
239 |
|
240 |
// Para traducir
|
241 |
PluginServices ps = PluginServices.getPluginServices(loader.getPluginName()); |
242 |
|
243 |
JToggleButton btn;
|
244 |
URL image = loader.getResource(selectableTool.getIcon());
|
245 |
|
246 |
if (image != null) { |
247 |
btn = new JToggleButton(selectableTool.getText(), |
248 |
new ImageIcon(image)); |
249 |
} else {
|
250 |
btn = new JToggleButton(selectableTool.getText()); |
251 |
} |
252 |
|
253 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
254 |
btn.addMouseListener(tooltipListener); |
255 |
btn.addActionListener(this);
|
256 |
btn.setFocusable(false);
|
257 |
btn.setActionCommand(selectableTool.getActionCommand()); |
258 |
btn.setToolTipText(selectableTool.getTooltip()); |
259 |
btn.setEnabled(false);
|
260 |
btn.setVisible(false);
|
261 |
|
262 |
if (selectableTool.getIsDefault()) {
|
263 |
btn.setSelected(true);
|
264 |
selectedTool = btn.getActionCommand(); |
265 |
} |
266 |
|
267 |
String name = getName(toolBar.getName(), loader);
|
268 |
|
269 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(name); |
270 |
|
271 |
if (jtb == null) { |
272 |
jtb = new SelectableToolBar(toolBar.getName());
|
273 |
jtb.setRollover(true);
|
274 |
toolBarMap.put(name, jtb); |
275 |
toolBars.add(jtb); |
276 |
} |
277 |
|
278 |
jtb.addButton(buttonGroup, btn); |
279 |
|
280 |
controlClass.put(btn, loader.loadClass(ext.getClassName())); |
281 |
|
282 |
if (selectableTool.getTooltip() != null) { |
283 |
btn.setToolTip(ps.getText(selectableTool.getTooltip())); |
284 |
} |
285 |
|
286 |
if (selectableTool.getEnableText() != null) { |
287 |
btn.setEnableText(ps.getText(selectableTool.getEnableText())); |
288 |
} |
289 |
|
290 |
if (selectableTool.getLast() == true) { |
291 |
jtb.addSeparator(); |
292 |
} |
293 |
} |
294 |
|
295 |
/**
|
296 |
* A?ade un bot?n a la barra de herramientas
|
297 |
*
|
298 |
* @param ext Texto del boton, si es null no aparece texto
|
299 |
* @param ext Extensi?n asociada al control
|
300 |
* @param toolBar Icono del boton, si es null no aparece texto
|
301 |
* @param actionTool Tooltip de la barra de herramientas
|
302 |
*
|
303 |
* @throws ClassNotFoundException
|
304 |
* @throws RuntimeException DOCUMENT ME!
|
305 |
*/
|
306 |
public void addTool(PluginClassLoader loader, SkinExtensionType ext, |
307 |
ToolBar toolBar, ActionTool actionTool) throws ClassNotFoundException { |
308 |
if (!SwingUtilities.isEventDispatchThread()) { |
309 |
throw new RuntimeException("No Event Dispatch Thread"); |
310 |
} |
311 |
|
312 |
// Para traducir los textos que vengan
|
313 |
PluginServices ps = PluginServices.getPluginServices(loader.getPluginName()); |
314 |
|
315 |
JButton btn;
|
316 |
URL image = loader.getResource(actionTool.getIcon());
|
317 |
|
318 |
if (image != null) { |
319 |
btn = new JButton(actionTool.getText(), new ImageIcon(image)); |
320 |
} else {
|
321 |
btn = new JButton(actionTool.getText()); |
322 |
} |
323 |
|
324 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
325 |
btn.addMouseListener(tooltipListener); |
326 |
btn.addActionListener(this);
|
327 |
btn.setFocusable(false);
|
328 |
btn.setActionCommand(actionTool.getActionCommand()); |
329 |
btn.setEnabled(false);
|
330 |
btn.setVisible(false);
|
331 |
|
332 |
String name = getName(toolBar.getName(), loader);
|
333 |
|
334 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(name); |
335 |
|
336 |
if (jtb == null) { |
337 |
jtb = new SelectableToolBar(toolBar.getName());
|
338 |
jtb.setRollover(true);
|
339 |
toolBarMap.put(name, jtb); |
340 |
toolBars.add(jtb); |
341 |
} |
342 |
|
343 |
jtb.add(btn); |
344 |
|
345 |
controlClass.put(btn, loader.loadClass(ext.getClassName())); |
346 |
|
347 |
if (actionTool.getTooltip() != null) { |
348 |
btn.setToolTip(ps.getText(actionTool.getTooltip())); |
349 |
} |
350 |
|
351 |
if (actionTool.getEnableText() != null) { |
352 |
btn.setEnableText(ps.getText(actionTool.getEnableText())); |
353 |
} |
354 |
|
355 |
if (actionTool.getLast() == true) { |
356 |
jtb.addSeparator(); |
357 |
} |
358 |
} |
359 |
|
360 |
/**
|
361 |
* Crea la estructura de men?s necesaria para a?adir el menu a la barra.
|
362 |
* Devuelve el padre del cual deve colgar el menu que se pasa como
|
363 |
* par?metro
|
364 |
*
|
365 |
* @param menu Menu cuya soporte se quiere a?adir
|
366 |
* @param loader DOCUMENT ME!
|
367 |
*
|
368 |
* @return Padre del men? que se pasa como par?metro
|
369 |
*/
|
370 |
private JMenu createMenuAncestors(Menu menu, PluginClassLoader loader) { |
371 |
JMenu menuPadre = null; |
372 |
|
373 |
String[] menues = menu.getText().split("/"); |
374 |
PluginServices ps = PluginServices.getPluginServices(loader.getPluginName()); |
375 |
|
376 |
for (int i = 0; i < menues.length; i++) { |
377 |
menues[i] = ps.getText(menues[i]); |
378 |
} |
379 |
|
380 |
//Se busca el padre en la menuBar
|
381 |
for (int i = 0; i < menuBar.getMenuCount(); i++) { |
382 |
if (menuBar.getMenu(i).getText().compareToIgnoreCase(menues[0]) == 0) { |
383 |
menuPadre = (JMenu) menuBar.getMenu(i);
|
384 |
} |
385 |
} |
386 |
|
387 |
//Si no se encuentra el padre se crea
|
388 |
if (menuPadre == null) { |
389 |
menuPadre = new JMenu(menues[0]); |
390 |
menuBar.add(menuPadre); |
391 |
} |
392 |
|
393 |
//Se crea el resto de menus
|
394 |
Vector temp = new Vector(); |
395 |
|
396 |
for (int i = 1; i < (menues.length - 1); i++) { |
397 |
temp.add(menues[i]); |
398 |
} |
399 |
|
400 |
menuPadre = createMenus(temp, menuPadre); |
401 |
|
402 |
return menuPadre;
|
403 |
} |
404 |
|
405 |
/**
|
406 |
* A?ade la informaci?n del menu al framework. Debido a que los men?es se
|
407 |
* pueden introducir en un orden determinado por el usuario, pero los
|
408 |
* plugins se instalan en un orden arbitrario, primero se almacena la
|
409 |
* informaci?n de todos los menus para luego ordenarlos y posteriormente
|
410 |
* a?adirlos al interfaz
|
411 |
*
|
412 |
* @param loader Posicion del menu. Se ordena por este campo
|
413 |
* @param ext Array con los nombres de los padres del menu
|
414 |
* @param menu Texto del menu
|
415 |
*
|
416 |
* @throws ClassNotFoundException
|
417 |
* @throws RuntimeException DOCUMENT ME!
|
418 |
*/
|
419 |
public void addMenu(PluginClassLoader loader, SkinExtensionType ext, |
420 |
Menu menu) throws ClassNotFoundException { |
421 |
if (!SwingUtilities.isEventDispatchThread()) { |
422 |
throw new RuntimeException("No Event Dispatch Thread"); |
423 |
} |
424 |
|
425 |
JMenu menuPadre = createMenuAncestors(menu, loader);
|
426 |
|
427 |
//Se registra y a?ade el menu
|
428 |
/* String[] aux = menu.getText().split("/");
|
429 |
|
430 |
if (aux.length == 2)
|
431 |
if (aux[1].equals("----"))
|
432 |
{
|
433 |
menuPadre.addSeparator();
|
434 |
return;
|
435 |
} */
|
436 |
if (menu.getIs_separator())
|
437 |
{ |
438 |
menuPadre.addSeparator(); |
439 |
return;
|
440 |
} |
441 |
|
442 |
JMenuItem nuevoMenu = createJMenuItem(loader, menu);
|
443 |
nuevoMenu.addMouseListener(tooltipListener); |
444 |
nuevoMenu.addActionListener(this);
|
445 |
menuPadre.add(nuevoMenu); |
446 |
controlClass.put(nuevoMenu, loader.loadClass(ext.getClassName())); |
447 |
} |
448 |
|
449 |
/**
|
450 |
* Dado un array de nombres de menu traducidos, encuentra el men?
|
451 |
*
|
452 |
* @param nombres DOCUMENT ME!
|
453 |
* @param padre DOCUMENT ME!
|
454 |
*
|
455 |
* @return DOCUMENT ME!
|
456 |
*/
|
457 |
private javax.swing.JMenuItem getMenu(Vector nombres, JMenu padre) { |
458 |
javax.swing.JMenuItem buscado = null;
|
459 |
|
460 |
for (int i = 0; i < padre.getMenuComponentCount(); i++) { |
461 |
javax.swing.JMenuItem hijo = (javax.swing.JMenuItem) padre.getMenuComponent(i); |
462 |
|
463 |
if (hijo.getText().compareToIgnoreCase((String) nombres.get(0)) == 0) { |
464 |
buscado = hijo; |
465 |
} |
466 |
} |
467 |
|
468 |
//Si no se encuentra el menu
|
469 |
if (buscado == null) { |
470 |
return null; |
471 |
} |
472 |
|
473 |
nombres.remove(0);
|
474 |
|
475 |
//Si se ha llegado al fin de la ruta completa
|
476 |
if (nombres.isEmpty()) {
|
477 |
return buscado;
|
478 |
} else {
|
479 |
if (buscado instanceof JMenu) { |
480 |
return getMenu(nombres, (JMenu) buscado); |
481 |
} else {
|
482 |
return null; |
483 |
} |
484 |
} |
485 |
} |
486 |
|
487 |
/**
|
488 |
* Crea la estructura de menus recursivamente. Por ejemplo, si se le pasa
|
489 |
* en el par?metro nombres el array {"Search", "References", "Workspace"}
|
490 |
* crear? un men? Search, un submen? del anterior que se llamar?
|
491 |
* References y debajo de ?ste ?ltimo otro menu llamado Workspace
|
492 |
*
|
493 |
* @param nombres Array con los nombres de los men?s que se quieren crear
|
494 |
* @param padre Menu padre de los men?s creados. Es ?til porque es un
|
495 |
* algoritmo recursivo
|
496 |
*
|
497 |
* @return Devuelve el men? creado. Al final de toda la recursividad,
|
498 |
* devolver? el men? de m?s abajo en la jerarqu?a
|
499 |
*
|
500 |
* @throws RuntimeException DOCUMENT ME!
|
501 |
*/
|
502 |
private JMenu createMenus(Vector nombres, JMenu padre) { |
503 |
if (!SwingUtilities.isEventDispatchThread()) { |
504 |
throw new RuntimeException("No Event Dispatch Thread"); |
505 |
} |
506 |
|
507 |
//si no quedan nombres de menu por crear se vuelve: caso base
|
508 |
if (nombres.size() == 0) { |
509 |
return padre;
|
510 |
} |
511 |
|
512 |
//Se busca el menu por si ya existiera para no crearlo otra vez
|
513 |
JMenu buscado = null; |
514 |
|
515 |
for (int i = 0; i < padre.getMenuComponentCount(); i++) { |
516 |
try {
|
517 |
JMenu hijo = (JMenu) padre.getMenuComponent(i); |
518 |
|
519 |
if (hijo.getText().compareToIgnoreCase((String) nombres.get(0)) == 0) { |
520 |
buscado = hijo; |
521 |
} |
522 |
} catch (ClassCastException e) { |
523 |
/*
|
524 |
* Se ha encontrado un elemento hoja del arbol de men?es
|
525 |
*/
|
526 |
} |
527 |
} |
528 |
|
529 |
if (buscado != null) { |
530 |
//Si lo hemos encontrado creamos el resto
|
531 |
nombres.remove(0);
|
532 |
|
533 |
return createMenus(nombres, buscado);
|
534 |
} else {
|
535 |
//Si no lo hemos encontrado se crea el menu, se a?ade al padre
|
536 |
//y se crea el resto
|
537 |
JMenu menuPadre = new JMenu((String) nombres.get(0)); |
538 |
padre.add(menuPadre); |
539 |
|
540 |
nombres.remove(0);
|
541 |
|
542 |
return createMenus(nombres, menuPadre);
|
543 |
} |
544 |
} |
545 |
|
546 |
/**
|
547 |
* M?todo invocado en respuesta a ciertos eventos de la interfaz que pueden
|
548 |
* ocultar botones de las barras de herramientas y que redimensiona ?sta
|
549 |
* de manera conveniente para que no se oculte ninguno
|
550 |
*/
|
551 |
private void ajustarToolBar() { |
552 |
int margen = 8; |
553 |
int numFilas = 1; |
554 |
double acum = margen;
|
555 |
|
556 |
int toolHeight = 0; |
557 |
|
558 |
for (int i = 0; i < toolBars.getComponentCount(); i++) { |
559 |
Component c = toolBars.getComponent(i);
|
560 |
|
561 |
if (!c.isVisible()) {
|
562 |
continue;
|
563 |
} |
564 |
|
565 |
double width = c.getPreferredSize().getWidth();
|
566 |
acum = acum + width; |
567 |
|
568 |
if (acum > this.getWidth()) { |
569 |
numFilas++; |
570 |
acum = width + margen; |
571 |
} |
572 |
|
573 |
if (c.getPreferredSize().getHeight() > toolHeight) {
|
574 |
toolHeight = c.getPreferredSize().height; |
575 |
} |
576 |
} |
577 |
|
578 |
toolBars.setPreferredSize(new Dimension(this.getWidth(), |
579 |
(int) (numFilas * toolHeight)));
|
580 |
|
581 |
toolBars.updateUI(); |
582 |
} |
583 |
|
584 |
/**
|
585 |
* DOCUMENT ME!
|
586 |
*
|
587 |
* @param classesExtensions
|
588 |
*/
|
589 |
public void setClassesExtensions(HashMap classesExtensions) { |
590 |
this.classesExtensions = classesExtensions;
|
591 |
} |
592 |
|
593 |
/**
|
594 |
* M?todo de callback invocado cuando se selecciona un men? o un bot?n de
|
595 |
* la barra de herramientas. Se busca la extensi?n asociada y se ejecuta
|
596 |
*
|
597 |
* @param e Evento producido
|
598 |
*/
|
599 |
public void actionPerformed(ActionEvent e) { |
600 |
AbstractButton control = (AbstractButton) e.getSource(); |
601 |
com.iver.andami.plugins.Extension ext = (com.iver.andami.plugins.Extension) classesExtensions.get((Class) controlClass.get(
|
602 |
control)); |
603 |
String actionCommand = control.getActionCommand();
|
604 |
|
605 |
try {
|
606 |
ext.execute(actionCommand); |
607 |
if (control instanceof JToggleButton) |
608 |
{ |
609 |
selectedTool = actionCommand; |
610 |
} |
611 |
} catch (RuntimeException t) { |
612 |
NotificationManager.addError(Messages.getString( |
613 |
"MDIFrame.Error_no_capturado_por_el_usuario"), t);
|
614 |
} |
615 |
|
616 |
enableControls(); |
617 |
showMemory(); |
618 |
} |
619 |
|
620 |
/**
|
621 |
* DOCUMENT ME!
|
622 |
*
|
623 |
* @param name DOCUMENT ME!
|
624 |
* @param loader DOCUMENT ME!
|
625 |
*
|
626 |
* @return DOCUMENT ME!
|
627 |
*/
|
628 |
private String getName(String name, PluginClassLoader loader) { |
629 |
if (name.indexOf('.') == -1) { |
630 |
return loader.getPluginName() + "." + name; |
631 |
} else {
|
632 |
return name;
|
633 |
} |
634 |
} |
635 |
|
636 |
/**
|
637 |
* DOCUMENT ME!
|
638 |
*
|
639 |
* @param loader DOCUMENT ME!
|
640 |
* @param menu DOCUMENT ME!
|
641 |
*
|
642 |
* @throws RuntimeException DOCUMENT ME!
|
643 |
*/
|
644 |
public void addPopupMenu(PluginClassLoader loader, PopupMenu menu) { |
645 |
if (!SwingUtilities.isEventDispatchThread()) { |
646 |
throw new RuntimeException("No Event Dispatch Thread"); |
647 |
} |
648 |
|
649 |
String name = getName(menu.getName(), loader);
|
650 |
|
651 |
//Se crea el control popupmenu
|
652 |
JPopUpMenu popupMenu = (JPopUpMenu) popupMap.get(name); |
653 |
|
654 |
if (popupMenu == null) { |
655 |
popupMenu = new JPopUpMenu(menu.getName());
|
656 |
popupMap.put(name, popupMenu); |
657 |
} |
658 |
|
659 |
// Se a?aden las entradas
|
660 |
Menu[] menues = menu.getMenu(); |
661 |
|
662 |
for (int i = 0; i < menues.length; i++) { |
663 |
//Se registra y a?ade el menu
|
664 |
JMenuItem nuevoMenu = createJMenuItem(loader, menues[i]);
|
665 |
|
666 |
popupMenu.add(nuevoMenu); |
667 |
} |
668 |
} |
669 |
|
670 |
/**
|
671 |
* DOCUMENT ME!
|
672 |
*
|
673 |
* @param loader
|
674 |
* @param menu
|
675 |
*
|
676 |
* @return
|
677 |
*
|
678 |
* @throws RuntimeException DOCUMENT ME!
|
679 |
*/
|
680 |
private JMenuItem createJMenuItem(PluginClassLoader loader, Menu menu) { |
681 |
JMenuItem nuevoMenu = null; |
682 |
|
683 |
PluginServices ps = PluginServices.getPluginServices(loader.getPluginName()); |
684 |
String texto = menu.getText();
|
685 |
texto = texto.substring(texto.lastIndexOf('/') + 1); |
686 |
texto = ps.getText(texto); |
687 |
|
688 |
if (menu.getIcon() != null) { |
689 |
System.out.println("Intentando cargar el icono " + menu.getIcon()); |
690 |
nuevoMenu = new JMenuItem(texto, |
691 |
new ImageIcon(loader.getResource(menu.getIcon()))); |
692 |
} else {
|
693 |
nuevoMenu = new JMenuItem(texto); |
694 |
} |
695 |
|
696 |
if (menu.getMnemonic() != null) { |
697 |
if (menu.getMnemonic().length() != 1) { |
698 |
throw new RuntimeException( |
699 |
"Mnemonic must be 1 character length");
|
700 |
} |
701 |
|
702 |
nuevoMenu.setMnemonic(KeyMapping.getKey(menu.getMnemonic().charAt(0)));
|
703 |
} |
704 |
|
705 |
if (menu.getKey() != null) { |
706 |
nuevoMenu.setAccelerator(KeyStroke.getKeyStroke(KeyMapping.getKey(
|
707 |
menu.getKey().charAt(0)), ActionEvent.ALT_MASK)); |
708 |
} |
709 |
|
710 |
nuevoMenu.setActionCommand(menu.getActionCommand()); |
711 |
|
712 |
if (menu.getTooltip() != null) { |
713 |
nuevoMenu.setToolTip(ps.getText(menu.getTooltip())); |
714 |
} |
715 |
|
716 |
if (menu.getEnableText() != null) { |
717 |
nuevoMenu.setEnableText(ps.getText(menu.getEnableText())); |
718 |
} |
719 |
|
720 |
nuevoMenu.setEnabled(true);
|
721 |
nuevoMenu.setVisible(true);
|
722 |
|
723 |
return nuevoMenu;
|
724 |
} |
725 |
|
726 |
/**
|
727 |
* Muestra u oculta el menu de nombre 'name'
|
728 |
*
|
729 |
* @param name Nombre del menu que se quiere mostrar
|
730 |
* @param x Evento de raton
|
731 |
* @param y DOCUMENT ME!
|
732 |
* @param c DOCUMENT ME!
|
733 |
*/
|
734 |
private void showPopupMenu(String name, int x, int y, Component c) { |
735 |
JPopupMenu menu = (JPopupMenu) popupMap.get(name); |
736 |
|
737 |
if (menu != null) { |
738 |
menu.show(c, x, y); |
739 |
} |
740 |
} |
741 |
|
742 |
/**
|
743 |
* DOCUMENT ME!
|
744 |
*
|
745 |
* @param name DOCUMENT ME!
|
746 |
* @param listener DOCUMENT ME!
|
747 |
*/
|
748 |
public void removePopupMenuListener(String name, ActionListener listener) { |
749 |
JPopupMenu menu = (JPopupMenu) popupMap.get(name); |
750 |
|
751 |
if (menu != null) { |
752 |
Component[] jmenuitems = menu.getComponents(); |
753 |
|
754 |
for (int i = 0; i < jmenuitems.length; i++) { |
755 |
if (jmenuitems[i] instanceof JMenuItem) { |
756 |
((JMenuItem) jmenuitems[i]).removeActionListener(listener);
|
757 |
} |
758 |
} |
759 |
} |
760 |
} |
761 |
|
762 |
/**
|
763 |
* DOCUMENT ME!
|
764 |
*
|
765 |
* @param popupName
|
766 |
* @param c DOCUMENT ME!
|
767 |
* @param listener
|
768 |
* @param loader
|
769 |
*/
|
770 |
public void addPopupMenuListener(String popupName, Component c, |
771 |
ActionListener listener, PluginClassLoader loader) {
|
772 |
final String name = getName(popupName, loader); |
773 |
|
774 |
JPopupMenu menu = (JPopupMenu) popupMap.get(name); |
775 |
|
776 |
if (menu != null) { |
777 |
Component[] jmenuitems = menu.getComponents(); |
778 |
|
779 |
for (int i = 0; i < jmenuitems.length; i++) { |
780 |
if (jmenuitems[i] instanceof JMenuItem) { |
781 |
((JMenuItem) jmenuitems[i]).addActionListener(listener);
|
782 |
} |
783 |
} |
784 |
} |
785 |
|
786 |
c.addMouseListener(new MouseAdapter() { |
787 |
public void mousePressed(MouseEvent e) { |
788 |
if (e.isPopupTrigger()) {
|
789 |
showPopupMenu(name, e.getX(), e.getY(), e.getComponent()); |
790 |
} |
791 |
} |
792 |
|
793 |
public void mouseReleased(MouseEvent e) { |
794 |
if (e.isPopupTrigger()) {
|
795 |
showPopupMenu(name, e.getX(), e.getY(), e.getComponent()); |
796 |
} |
797 |
} |
798 |
}); |
799 |
} |
800 |
|
801 |
/**
|
802 |
* Itera por los controles preguntando a las extensiones si estos est?n
|
803 |
* habilitados y visibles
|
804 |
*
|
805 |
* @throws RuntimeException DOCUMENT ME!
|
806 |
*/
|
807 |
public void enableControls() { |
808 |
if (!SwingUtilities.isEventDispatchThread()) { |
809 |
throw new RuntimeException("No Event Dispatch Thread"); |
810 |
} |
811 |
|
812 |
Iterator e = classesExtensions.values().iterator();
|
813 |
HashMap estadoExtensiones = new HashMap(); |
814 |
HashMap visibilidadExtensiones = new HashMap(); |
815 |
|
816 |
while (e.hasNext()) {
|
817 |
ExtensionDecorator ext = (ExtensionDecorator) e.next(); |
818 |
|
819 |
try {
|
820 |
if (estadoExtensiones.get(ext) == null) { |
821 |
boolean b;
|
822 |
if (ext.getVisibility() == ExtensionDecorator.ALWAYS_VISIBLE)
|
823 |
b = true;
|
824 |
else if (ext.getVisibility() == ExtensionDecorator.ALWAYS_INVISIBLE) |
825 |
b = false;
|
826 |
else b = ext.isVisible();
|
827 |
Boolean visible = new Boolean(b); |
828 |
Boolean enabled = new Boolean(false); |
829 |
|
830 |
if (visible.booleanValue()) {
|
831 |
enabled = new Boolean(ext.isEnabled()); |
832 |
} |
833 |
|
834 |
estadoExtensiones.put(ext, enabled); |
835 |
visibilidadExtensiones.put(ext, visible); |
836 |
} |
837 |
} catch (Throwable e1) { |
838 |
NotificationManager.addError(Messages.getString( |
839 |
"MDIFrame.Error_no_capturado_por_el_usuario"), e1);
|
840 |
estadoExtensiones.put(ext, Boolean.FALSE);
|
841 |
} |
842 |
} |
843 |
|
844 |
//Se habilitan y deshabilitan los controles
|
845 |
e = controlClass.keySet().iterator(); |
846 |
|
847 |
while (e.hasNext()) {
|
848 |
JComponent control = (JComponent) e.next(); |
849 |
|
850 |
try {
|
851 |
com.iver.andami.plugins.Extension ext = (com.iver.andami.plugins.Extension) classesExtensions.get((Class) controlClass.get(
|
852 |
control)); |
853 |
boolean enabled = ((Boolean) estadoExtensiones.get(ext)).booleanValue(); |
854 |
boolean visible = ((Boolean) visibilidadExtensiones.get(ext)).booleanValue(); |
855 |
control.setEnabled(enabled); |
856 |
control.setVisible(visible); |
857 |
} catch (Exception ex) { |
858 |
control.setEnabled(false);
|
859 |
control.setVisible(false);
|
860 |
} |
861 |
} |
862 |
|
863 |
//Se itera por los men?es para ocultar los que no tengan hijos visibles
|
864 |
for (int i = 0; i < menuBar.getMenuCount(); i++) { |
865 |
MenuElement menu = menuBar.getMenu(i);
|
866 |
ocultarMenus(menu); |
867 |
} |
868 |
|
869 |
//Se ocultan las barras que no tienen herramientas
|
870 |
Iterator it = toolBarMap.values().iterator();
|
871 |
|
872 |
while (it.hasNext()) {
|
873 |
SelectableToolBar t = (SelectableToolBar) it.next(); |
874 |
boolean todosOcultos = true; |
875 |
|
876 |
for (int i = 0; i < t.getComponentCount(); i++) { |
877 |
if (t.getComponent(i).isVisible()) {
|
878 |
todosOcultos = false;
|
879 |
} |
880 |
} |
881 |
|
882 |
if (todosOcultos) {
|
883 |
t.setVisible(false);
|
884 |
} else {
|
885 |
t.setVisible(true);
|
886 |
} |
887 |
} |
888 |
|
889 |
if (mdiManager != null) { |
890 |
JPanel f = (JPanel) mdiManager.getActiveView(); |
891 |
|
892 |
if (f != null) { |
893 |
if (lastLabelClass != f.getClass()) {
|
894 |
lastLabelClass = f.getClass(); |
895 |
|
896 |
Label[] lbls = (Label[]) classLabels.get(lastLabelClass); |
897 |
|
898 |
if (lbls != null) { |
899 |
bEstado.setLabelSet(lbls); |
900 |
} |
901 |
} |
902 |
} |
903 |
} |
904 |
|
905 |
ajustarToolBar(); |
906 |
|
907 |
showMemory(); |
908 |
} |
909 |
|
910 |
/**
|
911 |
* Establece la visibilidad de un menu y todos sus descendientes en la
|
912 |
* jerarquia teniendo en cuenta la visibilidad de todos los submenus.
|
913 |
*
|
914 |
* @param menu Menu que se quiere visualizar
|
915 |
*
|
916 |
* @return Devuelve true si el menu es visible y false en caso contrario
|
917 |
*/
|
918 |
private boolean ocultarMenus(MenuElement menu) { |
919 |
MenuElement[] submenus = menu.getSubElements(); |
920 |
|
921 |
//Si no tiene hijos se devuelve su visibilidad
|
922 |
if (submenus.length == 0) { |
923 |
return menu.getComponent().isVisible();
|
924 |
} |
925 |
|
926 |
/*
|
927 |
* Si tiene hijos se devuelve true si alg?no de ellos es visible,
|
928 |
* pero se itera por todos ellos
|
929 |
*/
|
930 |
boolean visible = false; |
931 |
|
932 |
for (int i = 0; i < submenus.length; i++) { |
933 |
if (ocultarMenus(submenus[i])) {
|
934 |
if (!(menu instanceof JPopupMenu)) { |
935 |
menu.getComponent().setVisible(true);
|
936 |
} |
937 |
|
938 |
visible = true;
|
939 |
} |
940 |
} |
941 |
|
942 |
if (visible) {
|
943 |
return true; |
944 |
} |
945 |
|
946 |
menu.getComponent().setVisible(false);
|
947 |
|
948 |
return false; |
949 |
} |
950 |
|
951 |
/**
|
952 |
* Muestra la memoria consumida por el programa
|
953 |
*/
|
954 |
private void showMemory() { |
955 |
Runtime r = Runtime.getRuntime(); |
956 |
long mem = r.totalMemory() - r.freeMemory();
|
957 |
logger.debug("Memoria total: " + mem);
|
958 |
} |
959 |
|
960 |
/**
|
961 |
* DOCUMENT ME!
|
962 |
*
|
963 |
* @return
|
964 |
*/
|
965 |
public MDIManager getMDIManager() {
|
966 |
return mdiManager;
|
967 |
} |
968 |
|
969 |
/**
|
970 |
* Establece el mensaje en la barra de estado asociado a una etiqueta
|
971 |
*
|
972 |
* @return DOCUMENT ME!
|
973 |
*/
|
974 |
public NewStatusBar getStatusBar() {
|
975 |
return bEstado;
|
976 |
} |
977 |
/**
|
978 |
* You can use this function to select the appropiate
|
979 |
* tool inside the toolbars
|
980 |
*/
|
981 |
public void setSelectedTool(String actionCommand) |
982 |
{ |
983 |
Iterator it = toolBarMap.values().iterator();
|
984 |
while (it.hasNext()) {
|
985 |
SelectableToolBar t = (SelectableToolBar) it.next(); |
986 |
t.setSelectedTool(actionCommand); |
987 |
} |
988 |
selectedTool = actionCommand; |
989 |
|
990 |
} |
991 |
|
992 |
/**
|
993 |
* DOCUMENT ME!
|
994 |
*
|
995 |
* @param clase
|
996 |
* @param label
|
997 |
*/
|
998 |
public void setLabels(Class clase, Label[] label) { |
999 |
classLabels.put(clase, label); |
1000 |
} |
1001 |
|
1002 |
/**
|
1003 |
* @see com.iver.andami.ui.mdiFrame.MainFrame#removeMenu(com.iver.andami.plugins.config.generate.Menu)
|
1004 |
*/
|
1005 |
public void removeMenu(Menu menu) { |
1006 |
JMenuItem delete = (JMenuItem) infoCodedMenus.get(menu); |
1007 |
|
1008 |
if (delete == null) { |
1009 |
throw new NoSuchElementException(menu.getText()); |
1010 |
} |
1011 |
|
1012 |
delete.getParent().remove(delete); |
1013 |
infoCodedMenus.remove(menu); |
1014 |
} |
1015 |
|
1016 |
/**
|
1017 |
* @see com.iver.andami.ui.mdiFrame.MainFrame#addMenu(com.iver.andami.plugins.config.generate.Menu,
|
1018 |
* java.awt.event.ActionListener, PluginClassLoader)
|
1019 |
*/
|
1020 |
public void addMenu(Menu menu, ActionListener listener, |
1021 |
PluginClassLoader loader) { |
1022 |
JMenu menuPadre = createMenuAncestors(menu, loader);
|
1023 |
|
1024 |
//Se registra y a?ade el menu
|
1025 |
JMenuItem nuevoMenu = createJMenuItem(loader, menu);
|
1026 |
nuevoMenu.addMouseListener(tooltipListener); |
1027 |
nuevoMenu.addActionListener(listener); |
1028 |
menuPadre.add(nuevoMenu); |
1029 |
|
1030 |
infoCodedMenus.put(menu, nuevoMenu); |
1031 |
} |
1032 |
|
1033 |
/**
|
1034 |
* @see com.iver.andami.ui.mdiFrame.MainFrame#changeMenuName(java.lang.String[],
|
1035 |
* String, com.iver.andami.plugins.PluginClassLoader)
|
1036 |
*/
|
1037 |
public void changeMenuName(String[] menu, String newName, |
1038 |
PluginClassLoader loader) { |
1039 |
PluginServices ps = PluginServices.getPluginServices(loader.getPluginName()); |
1040 |
|
1041 |
for (int i = 0; i < menu.length; i++) { |
1042 |
menu[i] = ps.getText(menu[i]); |
1043 |
} |
1044 |
|
1045 |
JMenu menuPadre = null; |
1046 |
|
1047 |
//Se busca el padre en la menuBar
|
1048 |
for (int i = 0; i < menuBar.getMenuCount(); i++) { |
1049 |
if (menuBar.getMenu(i).getText().compareToIgnoreCase(menu[0]) == 0) { |
1050 |
menuPadre = (JMenu) menuBar.getMenu(i);
|
1051 |
} |
1052 |
} |
1053 |
|
1054 |
if (menuPadre == null) { |
1055 |
throw new NoSuchMenuException(menu[0]); |
1056 |
} |
1057 |
|
1058 |
Vector nombres = new Vector(); |
1059 |
|
1060 |
for (int i = 1; i < menu.length; i++) { |
1061 |
nombres.add(menu[i]); |
1062 |
} |
1063 |
|
1064 |
javax.swing.JMenuItem m = getMenu(nombres, menuPadre); |
1065 |
|
1066 |
if (m != null) { |
1067 |
m.setText(newName); |
1068 |
}else{
|
1069 |
throw new NoSuchMenuException(); |
1070 |
} |
1071 |
} |
1072 |
|
1073 |
/**
|
1074 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
1075 |
*/
|
1076 |
public void componentHidden(ComponentEvent arg0) { |
1077 |
} |
1078 |
|
1079 |
/**
|
1080 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
1081 |
*/
|
1082 |
public void componentMoved(ComponentEvent arg0) { |
1083 |
} |
1084 |
|
1085 |
/**
|
1086 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
1087 |
*/
|
1088 |
public void componentResized(ComponentEvent arg0) { |
1089 |
ajustarToolBar(); |
1090 |
bEstado.setFixedLabelWidth(this.getWidth() * 0.3); |
1091 |
} |
1092 |
|
1093 |
/**
|
1094 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
1095 |
*/
|
1096 |
public void componentShown(ComponentEvent arg0) { |
1097 |
} |
1098 |
|
1099 |
/**
|
1100 |
* @see java.awt.event.ContainerListener#componentAdded(java.awt.event.ContainerEvent)
|
1101 |
*/
|
1102 |
public void componentAdded(ContainerEvent arg0) { |
1103 |
ajustarToolBar(); |
1104 |
} |
1105 |
|
1106 |
/**
|
1107 |
* @see java.awt.event.ContainerListener#componentRemoved(java.awt.event.ContainerEvent)
|
1108 |
*/
|
1109 |
public void componentRemoved(ContainerEvent arg0) { |
1110 |
ajustarToolBar(); |
1111 |
} |
1112 |
|
1113 |
/**
|
1114 |
* DOCUMENT ME!
|
1115 |
*
|
1116 |
* @author $author$
|
1117 |
* @version $Revision: 3583 $
|
1118 |
*/
|
1119 |
public class TooltipListener extends MouseAdapter { |
1120 |
/**
|
1121 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
|
1122 |
*/
|
1123 |
public void mouseEntered(MouseEvent e) { |
1124 |
JComponent control = (JComponent) e.getSource(); |
1125 |
EnableTextSupport ets = (EnableTextSupport) e.getSource(); |
1126 |
|
1127 |
String texto = null; |
1128 |
texto = control.getToolTipText(); |
1129 |
|
1130 |
if (texto != null) { |
1131 |
bEstado.setInfoTextTemporal(texto); |
1132 |
} |
1133 |
} |
1134 |
|
1135 |
/**
|
1136 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
|
1137 |
*/
|
1138 |
public void mouseExited(MouseEvent arg0) { |
1139 |
bEstado.restaurarTexto(); |
1140 |
} |
1141 |
|
1142 |
/**
|
1143 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
1144 |
*/
|
1145 |
public void mousePressed(MouseEvent e) { |
1146 |
bEstado.restaurarTexto(); |
1147 |
} |
1148 |
} |
1149 |
public String getTitlePrefix() { |
1150 |
return titlePrefix;
|
1151 |
} |
1152 |
public void setTitlePrefix(String titlePrefix) { |
1153 |
this.titlePrefix = titlePrefix;
|
1154 |
} |
1155 |
|
1156 |
public String getSelectedTool() { |
1157 |
return selectedTool;
|
1158 |
} |
1159 |
|
1160 |
|
1161 |
/**
|
1162 |
* Get a previously added JComponent by name. For example
|
1163 |
* you can use it if you need to obtain a JToolBar to
|
1164 |
* add some customized component.
|
1165 |
* @param name
|
1166 |
* @return the JComponent or null if none has been found
|
1167 |
*/
|
1168 |
public JComponent getComponentByName(String name) |
1169 |
{ |
1170 |
Iterator e = controlClass.keySet().iterator();
|
1171 |
|
1172 |
while (e.hasNext()) {
|
1173 |
JComponent control = (JComponent) e.next(); |
1174 |
String nameCtrl = control.getName();
|
1175 |
if (nameCtrl != null) |
1176 |
if (nameCtrl.compareTo(name) == 0) |
1177 |
return control;
|
1178 |
} |
1179 |
Iterator it = toolBarMap.values().iterator();
|
1180 |
while (it.hasNext()) {
|
1181 |
SelectableToolBar t = (SelectableToolBar) it.next(); |
1182 |
String nameCtrl = t.getName();
|
1183 |
if (nameCtrl != null) |
1184 |
if (nameCtrl.compareTo(name) == 0) |
1185 |
return t;
|
1186 |
|
1187 |
} |
1188 |
|
1189 |
return null; |
1190 |
} |
1191 |
} |