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