Revision 41314 trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/MDIFrame.java
MDIFrame.java | ||
---|---|---|
10 | 10 |
* |
11 | 11 |
* This program is distributed in the hope that it will be useful, |
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | 14 |
* GNU General Public License for more details. |
15 | 15 |
* |
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
19 |
* MA 02110-1301, USA.
|
|
19 |
* MA 02110-1301, USA. |
|
20 | 20 |
* |
21 | 21 |
* For any additional information, do not hesitate to contact us |
22 | 22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
... | ... | |
44 | 44 |
import java.util.HashMap; |
45 | 45 |
import java.util.Iterator; |
46 | 46 |
import java.util.List; |
47 |
import java.util.Locale; |
|
47 | 48 |
import java.util.Map; |
48 |
import java.util.Map.Entry; |
|
49 | 49 |
import java.util.NoSuchElementException; |
50 | 50 |
import java.util.StringTokenizer; |
51 | 51 |
import java.util.Vector; |
... | ... | |
53 | 53 |
import javax.swing.AbstractButton; |
54 | 54 |
import javax.swing.ButtonGroup; |
55 | 55 |
import javax.swing.ImageIcon; |
56 |
import javax.swing.JButton; |
|
57 | 56 |
import javax.swing.JComponent; |
58 | 57 |
import javax.swing.JFileChooser; |
59 | 58 |
import javax.swing.JFrame; |
... | ... | |
73 | 72 |
|
74 | 73 |
import org.gvsig.andami.IconThemeHelper; |
75 | 74 |
import org.gvsig.andami.Launcher; |
76 |
import org.gvsig.andami.LibraryExtension; |
|
77 | 75 |
import org.gvsig.andami.PluginServices; |
78 | 76 |
import org.gvsig.andami.PluginsLocator; |
79 | 77 |
import org.gvsig.andami.actioninfo.ActionInfo; |
... | ... | |
90 | 88 |
import org.gvsig.andami.plugins.config.generate.SelectableTool; |
91 | 89 |
import org.gvsig.andami.plugins.config.generate.SkinExtensionType; |
92 | 90 |
import org.gvsig.andami.plugins.config.generate.ToolBar; |
91 |
import org.gvsig.andami.ui.mdiFrame.TranslatableButtonHelper.TranslatableButton; |
|
93 | 92 |
import org.gvsig.andami.ui.mdiManager.MDIManager; |
94 | 93 |
import org.gvsig.andami.ui.mdiManager.MDIManagerFactory; |
95 | 94 |
import org.gvsig.gui.beans.controls.IControl; |
... | ... | |
102 | 101 |
|
103 | 102 |
/** |
104 | 103 |
* Main application window. |
105 |
* |
|
104 |
* |
|
105 |
* Use Launcher.getMDIFrame to get the instance of this class. |
|
106 |
* |
|
106 | 107 |
* @version $Revision: 39484 $ |
107 | 108 |
*/ |
108 | 109 |
@SuppressWarnings("unchecked") |
109 | 110 |
public class MDIFrame extends JFrame implements ComponentListener, |
110 |
ContainerListener, ActionListener, MainFrame { |
|
111 |
ContainerListener, ActionListener, MainFrame {
|
|
111 | 112 |
|
112 | 113 |
private static final long serialVersionUID = -2472484309160847654L; |
113 | 114 |
|
114 | 115 |
private static Logger logger = LoggerFactory.getLogger(MDIFrame.class); |
116 |
|
|
117 |
private static MDIFrame instance = null; |
|
118 |
|
|
115 | 119 |
private MDIManager mdiManager = MDIManagerFactory.createManager(); |
116 | 120 |
|
117 |
/** Elementos de la aplicaci�n */ |
|
121 |
/** |
|
122 |
* Elementos de la aplicaci�n |
|
123 |
*/ |
|
118 | 124 |
private JMenuBar menuBar = new JMenuBar(); |
119 | 125 |
|
120 |
/** Panel which contains the toolbars */ |
|
126 |
/** |
|
127 |
* Panel which contains the toolbars |
|
128 |
*/ |
|
121 | 129 |
private JPanel toolBars = new JPanel(); |
122 | 130 |
|
123 |
/** Status bar */ |
|
131 |
/** |
|
132 |
* Status bar |
|
133 |
*/ |
|
124 | 134 |
private NewStatusBar bEstado = null; |
125 | 135 |
|
126 |
/** Asocia los nombres con las barras de herramientas */ |
|
136 |
/** |
|
137 |
* Asocia los nombres con las barras de herramientas |
|
138 |
*/ |
|
127 | 139 |
private HashMap toolBarMap = new HashMap(); |
128 | 140 |
|
129 |
/** Almacena los grupos de selectableTools */ |
|
141 |
/** |
|
142 |
* Almacena los grupos de selectableTools |
|
143 |
*/ |
|
130 | 144 |
private HashMap buttonGroupMap = new HashMap(); |
131 | 145 |
/** |
132 | 146 |
* Stores the initially selected tools. |
... | ... | |
142 | 156 |
// this should be the same value defined at plugin-config.xsd |
143 | 157 |
private String defaultGroup = "unico"; |
144 | 158 |
|
145 |
/** Asocia los nombres con los popupMenus */ |
|
159 |
/** |
|
160 |
* Asocia los nombres con los popupMenus |
|
161 |
*/ |
|
146 | 162 |
private HashMap popupMap = new HashMap(); |
147 | 163 |
|
148 |
/** Asocia controles con la clase de la extension asociada */ |
|
149 |
private HashMap controlClass = new HashMap(); |
|
164 |
/** |
|
165 |
* Asocia controles con la clase de la extension asociada |
|
166 |
*/ |
|
167 |
private List<JComponent> controls = new ArrayList<JComponent>(); |
|
150 | 168 |
|
151 | 169 |
/** |
152 | 170 |
* Asocia la informaci�n sobre las etiquetas que van en la status bar con |
... | ... | |
155 | 173 |
private HashMap classLabels = new HashMap(); |
156 | 174 |
|
157 | 175 |
// private HashMap classControls = new HashMap(); |
158 |
|
|
159 |
/** ProgressListeners (ver interfaz com.iver.mdiApp.ui.ProgressListener) */ |
|
176 |
/** |
|
177 |
* ProgressListeners (ver interfaz com.iver.mdiApp.ui.ProgressListener) |
|
178 |
*/ |
|
160 | 179 |
private ArrayList progressListeners = new ArrayList(); |
161 | 180 |
|
162 |
/** Timer para invocar los enventos de la interfaz anterior */ |
|
163 |
private Timer progressTimer = null; |
|
181 |
/** |
|
182 |
* Timer para invocar los enventos de la interfaz anterior |
|
183 |
*/ |
|
184 |
private Timer progressTimer = null; |
|
164 | 185 |
|
165 |
/** Tabla hash que asocia las clases con las extensiones */ |
|
166 |
private Map classesExtensions = new HashMap<Class<? extends IExtension>, ExtensionDecorator>(); |
|
167 |
|
|
168 |
/** �ltima clase que activ� etiquetas */ |
|
186 |
/** |
|
187 |
* Tabla hash que asocia las clases con las extensiones |
|
188 |
*/ |
|
189 |
// private Map classesExtensions = new HashMap<Class<? extends IExtension>, ExtensionDecorator>(); |
|
190 |
/** |
|
191 |
* �ltima clase que activ� etiquetas |
|
192 |
*/ |
|
169 | 193 |
private Class lastLabelClass; |
170 | 194 |
|
171 |
/** Instancia que pone los tooltip en la barra de estado */ |
|
195 |
/** |
|
196 |
* Instancia que pone los tooltip en la barra de estado |
|
197 |
*/ |
|
172 | 198 |
private TooltipListener tooltipListener = new TooltipListener(); |
173 |
|
|
174 |
private HashMap infoCodedMenus = new HashMap(); |
|
175 | 199 |
|
200 |
private HashMap infoCodedMenus = new HashMap(); |
|
201 |
|
|
176 | 202 |
private String titlePrefix; |
177 | 203 |
|
178 | 204 |
private static final String noIcon = "no-icon"; |
179 | 205 |
|
206 |
private MDIFrame() { |
|
207 |
|
|
208 |
} |
|
209 |
|
|
210 |
public static MDIFrame getInstance() { |
|
211 |
if ( instance == null ) { |
|
212 |
instance = new MDIFrame(); |
|
213 |
} |
|
214 |
return instance; |
|
215 |
} |
|
216 |
|
|
180 | 217 |
/** |
181 | 218 |
* Makes some initialization tasks. |
182 |
*
|
|
219 |
* |
|
183 | 220 |
* @throws RuntimeException |
184 |
* DOCUMENT ME! |
|
185 | 221 |
*/ |
186 | 222 |
public void init() { |
187 |
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
|
188 |
if (!SwingUtilities.isEventDispatchThread()) {
|
|
223 |
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
|
224 |
if ( !SwingUtilities.isEventDispatchThread() ) {
|
|
189 | 225 |
throw new RuntimeException("Not Event Dispatch Thread"); |
190 | 226 |
} |
191 | 227 |
|
192 |
// Se a�aden los listeners del JFrame
|
|
228 |
// Se a?aden los listeners del JFrame
|
|
193 | 229 |
this.addWindowListener(new WindowAdapter() { |
194 | 230 |
|
195 | 231 |
@Override |
... | ... | |
207 | 243 |
this.getContentPane().setLayout(new BorderLayout()); |
208 | 244 |
|
209 | 245 |
/* |
210 |
* Se configura y se a�ade el JPanel de las barras de
|
|
246 |
* Se configura y se a?ade el JPanel de las barras de
|
|
211 | 247 |
* herramientas |
212 | 248 |
*/ |
213 | 249 |
FlowLayout layout = new FlowLayout(FlowLayout.LEFT); |
... | ... | |
216 | 252 |
toolBars.setLayout(layout); |
217 | 253 |
getContentPane().add(toolBars, BorderLayout.PAGE_START); |
218 | 254 |
|
219 |
// Se a�ade la barra de estado a la aplicaci�n
|
|
255 |
// Add the status bar of the application
|
|
220 | 256 |
bEstado = new NewStatusBar(); |
221 | 257 |
bEstado.message(Messages.getString("StatusBar.Aplicacion_iniciada"), JOptionPane.INFORMATION_MESSAGE); |
222 | 258 |
getContentPane().add(bEstado, BorderLayout.SOUTH); |
... | ... | |
229 | 265 |
* afterwards |
230 | 266 |
*/ |
231 | 267 |
setSize( |
232 |
MainFrame.MAIN_FRAME_SIZE_DEFAULT[0], |
|
233 |
MainFrame.MAIN_FRAME_SIZE_DEFAULT[1]); |
|
268 |
MainFrame.MAIN_FRAME_SIZE_DEFAULT[0],
|
|
269 |
MainFrame.MAIN_FRAME_SIZE_DEFAULT[1]);
|
|
234 | 270 |
setLocation( |
235 |
MainFrame.MAIN_FRAME_POS_DEFAULT[0], |
|
236 |
MainFrame.MAIN_FRAME_POS_DEFAULT[1]); |
|
271 |
MainFrame.MAIN_FRAME_POS_DEFAULT[0],
|
|
272 |
MainFrame.MAIN_FRAME_POS_DEFAULT[1]);
|
|
237 | 273 |
setExtendedState( |
238 |
MainFrame.MAIN_FRAME_EXT_STATE_DEFAULT); |
|
274 |
MainFrame.MAIN_FRAME_EXT_STATE_DEFAULT);
|
|
239 | 275 |
|
240 | 276 |
mdiManager.init(this); |
241 |
|
|
242 |
/* |
|
243 |
* pack() would resize the main frame |
|
244 |
* |
|
245 |
*/ |
|
246 |
// pack(); |
|
247 |
|
|
248 | 277 |
} |
249 |
|
|
250 |
|
|
251 | 278 |
|
252 |
/* |
|
253 |
* (non-javadoc) |
|
254 |
* |
|
255 |
* @see java.awt.Frame.setTitle(String title) |
|
256 |
*/ |
|
257 | 279 |
@Override |
258 | 280 |
public void setTitle(final String title) { |
259 |
if (!SwingUtilities.isEventDispatchThread()) {
|
|
281 |
if ( !SwingUtilities.isEventDispatchThread() ) {
|
|
260 | 282 |
SwingUtilities.invokeLater(new Runnable() { |
261 | 283 |
public void run() { |
262 |
setTitle(title);
|
|
284 |
setTitle(title);
|
|
263 | 285 |
} |
264 | 286 |
}); |
265 | 287 |
return; |
... | ... | |
267 | 289 |
super.setTitle(titlePrefix + " : " + title); |
268 | 290 |
} |
269 | 291 |
|
270 |
/** |
|
271 |
* A�ade un modo de operaci�n a la caja de herramientas |
|
272 |
* |
|
273 |
* @param ext |
|
274 |
* Texto del boton, si es null no aparece texto |
|
275 |
* @param ext |
|
276 |
* Icono del boton, si es null no aparece icono |
|
277 |
* @param ext |
|
278 |
* Extensi�n asociada al control |
|
279 |
* @param selectableTool |
|
280 |
* Enable text del control |
|
281 |
* |
|
282 |
* @throws ClassNotFoundException |
|
283 |
* @throws RuntimeException |
|
284 |
* DOCUMENT ME! |
|
285 |
*/ |
|
286 |
public void addTool(PluginClassLoader loader, SkinExtensionType ext, |
|
287 |
ToolBar toolBar, SelectableTool selectableTool) |
|
288 |
throws ClassNotFoundException { |
|
289 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
290 |
throw new RuntimeException("No Event Dispatch Thread"); |
|
292 |
public void addTool(final PluginClassLoader loader, final SkinExtensionType ext, |
|
293 |
final ToolBar toolBar, final SelectableTool selectableTool) |
|
294 |
throws ClassNotFoundException { |
|
295 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
|
296 |
try { |
|
297 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
298 |
public void run() { |
|
299 |
try { |
|
300 |
addTool(loader, ext, toolBar, selectableTool); |
|
301 |
} catch (ClassNotFoundException ex) { |
|
302 |
logger.warn("??? Eehh????", ex); |
|
303 |
} |
|
304 |
} |
|
305 |
}); |
|
306 |
} catch (Exception ex) { |
|
307 |
// Do nothing |
|
308 |
} |
|
309 |
return; |
|
291 | 310 |
} |
292 |
|
|
293 |
Class<? extends IExtension> classExtension = (Class<? extends IExtension>) loader.loadClass(ext.getClassName()); |
|
294 |
|
|
295 |
// Para traducir |
|
296 |
PluginServices ps = |
|
297 |
PluginServices.getPluginServices(loader.getPluginName()); |
|
311 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
298 | 312 |
|
299 | 313 |
JToolBarToggleButton btn; |
300 |
ImageIcon image =
|
|
301 |
PluginServices.getIconTheme().get(selectableTool.getIcon()); |
|
314 |
ImageIcon image |
|
315 |
= PluginServices.getIconTheme().get(selectableTool.getIcon());
|
|
302 | 316 |
|
303 |
if (image != null) {
|
|
317 |
if ( image != null ) {
|
|
304 | 318 |
btn = new JToolBarToggleButton(selectableTool.getText(), image); |
305 | 319 |
} else { |
306 |
logger.error(PluginServices.getText(this, "Unable_to_find_icon") |
|
307 |
+ ": " + selectableTool.getIcon()); |
|
308 |
btn = |
|
309 |
new JToolBarToggleButton(selectableTool.getText(), |
|
310 |
PluginServices.getIconTheme().get(noIcon)); |
|
320 |
logger.warn("Unable to find icon '" + selectableTool.getIcon() + "'."); |
|
321 |
btn |
|
322 |
= new JToolBarToggleButton(selectableTool.getText(), |
|
323 |
PluginServices.getIconTheme().get(noIcon)); |
|
311 | 324 |
} |
312 | 325 |
|
313 |
org.gvsig.andami.ui.mdiFrame.ToggleButtonModel buttonModel =
|
|
314 |
new org.gvsig.andami.ui.mdiFrame.ToggleButtonModel(); |
|
326 |
org.gvsig.andami.ui.mdiFrame.ToggleButtonModel buttonModel |
|
327 |
= new org.gvsig.andami.ui.mdiFrame.ToggleButtonModel();
|
|
315 | 328 |
btn.setModel(buttonModel); |
316 | 329 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
317 | 330 |
btn.addMouseListener(tooltipListener); |
... | ... | |
325 | 338 |
|
326 | 339 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(name); |
327 | 340 |
|
328 |
if (jtb == null) {
|
|
341 |
if ( jtb == null ) {
|
|
329 | 342 |
jtb = new SelectableToolBar(name); |
330 | 343 |
jtb.setRollover(true); |
331 | 344 |
jtb.setAndamiVisibility(toolBar.getIsVisible()); |
... | ... | |
334 | 347 |
} |
335 | 348 |
|
336 | 349 |
ButtonGroup group; |
337 |
if (buttonGroupMap.containsKey(selectableTool.getGroup())) {
|
|
350 |
if ( buttonGroupMap.containsKey(selectableTool.getGroup()) ) {
|
|
338 | 351 |
group = (ButtonGroup) buttonGroupMap.get(selectableTool.getGroup()); |
339 | 352 |
} else { |
340 | 353 |
group = new ButtonGroup(); |
... | ... | |
344 | 357 |
jtb.addButton(group, btn); |
345 | 358 |
buttonModel.setGroupName(selectableTool.getGroup()); |
346 | 359 |
|
347 |
if (selectableTool.getIsDefault()) {
|
|
360 |
if ( selectableTool.getIsDefault() ) {
|
|
348 | 361 |
btn.setSelected(true); |
349 | 362 |
initialSelectedTools.put(selectableTool.getGroup(), |
350 |
btn.getActionCommand()); |
|
363 |
btn.getActionCommand());
|
|
351 | 364 |
} |
352 | 365 |
|
353 |
controlClass.put(btn, classExtension);
|
|
366 |
addControl(btn);
|
|
354 | 367 |
|
355 |
if (selectableTool.getName() != null) {
|
|
368 |
if ( selectableTool.getName() != null ) {
|
|
356 | 369 |
btn.setName(selectableTool.getName()); |
357 | 370 |
} |
358 | 371 |
|
359 |
if (selectableTool.getTooltip() != null) { |
|
360 |
btn.setToolTip(ps.getText(selectableTool.getTooltip())); |
|
372 |
if ( selectableTool.getTooltip() != null ) { |
|
373 |
btn.setToolTip(i18nManager.getTranslation(selectableTool.getTooltip())); |
|
374 |
btn.setToolTipKey(selectableTool.getTooltip()); |
|
361 | 375 |
} |
362 | 376 |
|
363 |
if (selectableTool.getEnableText() != null) {
|
|
364 |
btn.setEnableText(ps.getText(selectableTool.getEnableText()));
|
|
377 |
if ( selectableTool.getEnableText() != null ) {
|
|
378 |
btn.setEnableText(i18nManager.getTranslation(selectableTool.getEnableText()));
|
|
365 | 379 |
} |
366 | 380 |
|
367 |
if (selectableTool.getLast() == true) {
|
|
381 |
if ( selectableTool.getLast() == true ) {
|
|
368 | 382 |
jtb.addSeparator(); |
369 | 383 |
} |
370 | 384 |
} |
371 | 385 |
|
372 | 386 |
/** |
373 |
* A�ade un bot�n a la barra de herramientas
|
|
374 |
*
|
|
387 |
* Add a button to the toolbar.
|
|
388 |
* |
|
375 | 389 |
* @param ext |
376 |
* Texto del boton, si es null no aparece texto
|
|
390 |
* Texto del boton, si es null no aparece texto |
|
377 | 391 |
* @param ext |
378 |
* Extensi�n asociada al control
|
|
392 |
* Extension asociada al control
|
|
379 | 393 |
* @param toolBar |
380 |
* Icono del boton, si es null no aparece texto
|
|
394 |
* Icono del boton, si es null no aparece texto |
|
381 | 395 |
* @param actionTool |
382 |
* Tooltip de la barra de herramientas
|
|
383 |
*
|
|
396 |
* Tooltip de la barra de herramientas |
|
397 |
* |
|
384 | 398 |
* @throws ClassNotFoundException |
385 | 399 |
* @throws RuntimeException |
386 |
* DOCUMENT ME! |
|
387 | 400 |
*/ |
388 |
public void addTool(PluginClassLoader loader, SkinExtensionType ext, |
|
389 |
ToolBar toolBar, ActionTool actionTool) throws ClassNotFoundException { |
|
390 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
391 |
throw new RuntimeException("No Event Dispatch Thread"); |
|
401 |
public void addTool(final PluginClassLoader loader, final SkinExtensionType ext, |
|
402 |
final ToolBar toolBar, final ActionTool actionTool) throws ClassNotFoundException { |
|
403 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
|
404 |
try { |
|
405 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
406 |
public void run() { |
|
407 |
try { |
|
408 |
addTool(loader, ext, toolBar, actionTool); |
|
409 |
} catch (ClassNotFoundException ex) { |
|
410 |
logger.warn("??? Eehh????", ex); |
|
411 |
} |
|
412 |
} |
|
413 |
}); |
|
414 |
} catch (Exception ex) { |
|
415 |
// Do nothing |
|
416 |
} |
|
417 |
return; |
|
392 | 418 |
} |
393 |
Class<? extends IExtension> classExtension = (Class<? extends IExtension>) loader.loadClass(ext.getClassName()); |
|
394 |
|
|
395 |
// Para traducir los textos que vengan |
|
396 |
PluginServices ps = |
|
397 |
PluginServices.getPluginServices(loader.getPluginName()); |
|
398 | 419 |
|
420 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
421 |
|
|
399 | 422 |
JToolBarButton btn; |
400 | 423 |
ImageIcon image = IconThemeHelper.getImageIcon(actionTool.getIcon()); |
401 | 424 |
|
402 |
if (image != null) {
|
|
425 |
if ( image != null ) {
|
|
403 | 426 |
btn = new JToolBarButton(actionTool.getText(), image); |
404 | 427 |
} else { |
405 |
logger.error(PluginServices.getText(this, "Unable_to_find_icon") |
|
406 |
+ ": " + actionTool.getIcon()); |
|
407 |
btn = |
|
408 |
new JToolBarButton(actionTool.getText(), PluginServices |
|
409 |
.getIconTheme().get(noIcon)); |
|
428 |
logger.warn("Unable to find icon '" + actionTool.getIcon() + "'."); |
|
429 |
btn |
|
430 |
= new JToolBarButton(actionTool.getText(), PluginServices |
|
431 |
.getIconTheme().get(noIcon)); |
|
410 | 432 |
} |
411 | 433 |
|
412 | 434 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
... | ... | |
421 | 443 |
|
422 | 444 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(name); |
423 | 445 |
|
424 |
if (jtb == null) {
|
|
446 |
if ( jtb == null ) {
|
|
425 | 447 |
jtb = new SelectableToolBar(name); |
426 | 448 |
jtb.setRollover(true); |
427 | 449 |
jtb.setAndamiVisibility(toolBar.getIsVisible()); |
... | ... | |
431 | 453 |
|
432 | 454 |
jtb.add(btn); |
433 | 455 |
|
434 |
controlClass.put(btn, classExtension);
|
|
456 |
addControl(btn);
|
|
435 | 457 |
|
436 |
if (actionTool.getName() != null) {
|
|
458 |
if ( actionTool.getName() != null ) {
|
|
437 | 459 |
btn.setName(actionTool.getName()); |
438 | 460 |
} |
439 | 461 |
|
440 |
if (actionTool.getTooltip() != null) { |
|
441 |
btn.setToolTip(ps.getText(actionTool.getTooltip())); |
|
462 |
if ( actionTool.getTooltip() != null ) { |
|
463 |
btn.setToolTip(i18nManager.getTranslation(actionTool.getTooltip())); |
|
464 |
btn.setToolTipKey(actionTool.getTooltip()); |
|
442 | 465 |
} |
443 | 466 |
|
444 |
if (actionTool.getEnableText() != null) {
|
|
445 |
btn.setEnableText(ps.getText(actionTool.getEnableText()));
|
|
467 |
if ( actionTool.getEnableText() != null ) {
|
|
468 |
btn.setEnableText(i18nManager.getTranslation(actionTool.getEnableText()));
|
|
446 | 469 |
} |
447 | 470 |
|
448 |
if (actionTool.getLast() == true) {
|
|
471 |
if ( actionTool.getLast() == true ) {
|
|
449 | 472 |
jtb.addSeparator(); |
450 | 473 |
} |
451 | 474 |
} |
452 | 475 |
|
453 |
public void addTool(final ActionInfo action, final String toolBarName) {
|
|
454 |
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
|
476 |
public void addTool(final ActionInfo action, final String toolBarName) {
|
|
477 |
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
|
455 | 478 |
|
456 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
457 |
SwingUtilities.invokeLater(new Runnable() { |
|
458 |
public void run() { |
|
459 |
addTool(action, toolBarName); |
|
460 |
} |
|
461 |
}); |
|
462 |
return; |
|
463 |
} |
|
464 |
JToolBarButton btn = new JToolBarButton(action.getIcon()); |
|
465 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
|
466 |
btn.addMouseListener(tooltipListener); |
|
467 |
btn.addActionListener(this); |
|
468 |
btn.setFocusable(false); |
|
469 |
btn.setActionCommand(action.getCommand()); |
|
470 |
btn.setEnabled(false); |
|
471 |
btn.setVisible(false); |
|
472 |
btn.setName(action.getName()); |
|
473 |
if (action.getTooltip() != null) { |
|
474 |
btn.setToolTip(i18nManager.getTranslation(action.getTooltip())); |
|
475 |
} |
|
479 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
|
480 |
SwingUtilities.invokeLater(new Runnable() { |
|
481 |
public void run() { |
|
482 |
addTool(action, toolBarName); |
|
483 |
} |
|
484 |
}); |
|
485 |
return; |
|
486 |
} |
|
487 |
JToolBarButton btn = new JToolBarButton(action.getIcon()); |
|
488 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
|
489 |
btn.addMouseListener(tooltipListener); |
|
490 |
btn.addActionListener(this); |
|
491 |
btn.setFocusable(false); |
|
492 |
btn.setActionCommand(action.getCommand()); |
|
493 |
btn.setEnabled(false); |
|
494 |
btn.setVisible(false); |
|
495 |
btn.setName(action.getName()); |
|
496 |
if ( action.getTooltip() != null ) { |
|
497 |
btn.setToolTip(i18nManager.getTranslation(action.getTooltip())); |
|
498 |
btn.setToolTipKey(action.getTooltip()); |
|
499 |
} |
|
476 | 500 |
|
477 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(toolBarName);
|
|
478 |
if (jtb == null) {
|
|
479 |
jtb = new SelectableToolBar(toolBarName);
|
|
480 |
jtb.setRollover(true);
|
|
481 |
jtb.setAndamiVisibility(true);
|
|
482 |
toolBarMap.put(toolBarName, jtb);
|
|
483 |
toolBars.add(jtb);
|
|
484 |
}
|
|
485 |
jtb.add(btn);
|
|
501 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(toolBarName);
|
|
502 |
if ( jtb == null ) {
|
|
503 |
jtb = new SelectableToolBar(toolBarName);
|
|
504 |
jtb.setRollover(true);
|
|
505 |
jtb.setAndamiVisibility(true);
|
|
506 |
toolBarMap.put(toolBarName, jtb);
|
|
507 |
toolBars.add(jtb);
|
|
508 |
}
|
|
509 |
jtb.add(btn);
|
|
486 | 510 |
|
487 |
controlClass.put(btn, action.getExtension().getClass()); |
|
488 |
} |
|
511 |
addControl(btn); |
|
489 | 512 |
|
513 |
} |
|
514 |
|
|
490 | 515 |
/** |
491 | 516 |
* Creates the needed menu structure to add the menu to the bar. |
492 | 517 |
* Returns the father which must hold the menu which was |
493 | 518 |
* provided as parameter. |
494 |
*
|
|
495 |
* Crea la estructura de men�s necesaria para a�adir el menu a la barra.
|
|
519 |
* |
|
520 |
* Crea la estructura de menus necesaria para a?adir el menu a la barra.
|
|
496 | 521 |
* Devuelve el padre del cual debe colgar el menu que se pasa como |
497 |
* par�metro.
|
|
498 |
*
|
|
522 |
* parametro.
|
|
523 |
* |
|
499 | 524 |
* @param menu |
500 |
* The Menu whose support is going to be added
|
|
525 |
* The Menu whose support is going to be added |
|
501 | 526 |
* @param loader |
502 |
* The plugin's class loader
|
|
503 |
*
|
|
527 |
* The plugin's class loader |
|
528 |
* |
|
504 | 529 |
* @return The proper father for the menu which was provided as parameter |
505 | 530 |
*/ |
506 | 531 |
private JMenu createMenuAncestors(Menu menu, PluginClassLoader loader) { |
... | ... | |
508 | 533 |
} |
509 | 534 |
|
510 | 535 |
private JMenu createMenuAncestors(String text) { |
511 |
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
|
512 |
|
|
536 |
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
|
537 |
|
|
513 | 538 |
MenuElement menuPadre = null; |
514 | 539 |
|
515 | 540 |
String[] menues = text.split("/"); |
... | ... | |
519 | 544 |
|
520 | 545 |
JMenu padre = null; |
521 | 546 |
|
522 |
if (menuPadre == null) { |
|
523 |
padre = new JMenu(i18nManager.getTranslation(menues[0])); |
|
547 |
if ( menuPadre == null ) { |
|
548 |
padre = new JMenuTraslatable(i18nManager.getTranslation(menues[0])); |
|
549 |
((JMenuTraslatable) padre).setTextKey(menues[0]); |
|
524 | 550 |
padre.setName(menues[0]); |
551 |
addControl(padre); |
|
525 | 552 |
menuBar.add(padre); |
526 |
} else |
|
527 |
if (menuPadre instanceof JMenu) { |
|
528 |
padre = (JMenu) menuPadre; |
|
529 |
} else { |
|
530 |
logger.error(i18nManager.getTranslation("error_creating_menu_Ancestor_does_not_exist")); |
|
531 |
return null; |
|
532 |
} |
|
553 |
} else if ( menuPadre instanceof JMenu ) { |
|
554 |
padre = (JMenu) menuPadre; |
|
555 |
} else { |
|
556 |
logger.warn("Error creating menu. Ancestor does not exist (" + text + ")."); |
|
557 |
return null; |
|
558 |
} |
|
533 | 559 |
|
534 | 560 |
// Se crea el resto de menus |
535 | 561 |
ArrayList temp = new ArrayList(); |
536 | 562 |
|
537 |
for (int i = 1; i < (menues.length - 1); i++) {
|
|
563 |
for ( int i = 1; i < (menues.length - 1); i++ ) {
|
|
538 | 564 |
temp.add(menues[i]); |
539 | 565 |
} |
540 | 566 |
|
... | ... | |
544 | 570 |
} |
545 | 571 |
|
546 | 572 |
/** |
547 |
* A�ade la informaci�n del menu al framework. Debido a que los men�es
|
|
548 |
* se |
|
573 |
* A?ade la informacion del menu al framework.
|
|
574 |
* Debido a que los men�es se
|
|
549 | 575 |
* pueden introducir en un orden determinado por el usuario, pero los |
550 | 576 |
* plugins se instalan en un orden arbitrario, primero se almacena la |
551 |
* informaci�n de todos los menus para luego ordenarlos y posteriormente
|
|
552 |
* a�adirlos al interfaz
|
|
553 |
*
|
|
577 |
* informacion de todos los menus para luego ordenarlos y posteriormente
|
|
578 |
* a?adirlos al interfaz
|
|
579 |
* |
|
554 | 580 |
* @param loader |
555 |
* Posicion del menu. Se ordena por este campo
|
|
581 |
* Posicion del menu. Se ordena por este campo |
|
556 | 582 |
* @param ext |
557 |
* Array con los nombres de los padres del menu
|
|
583 |
* Array con los nombres de los padres del menu |
|
558 | 584 |
* @param menu |
559 |
* Texto del menu
|
|
560 |
*
|
|
585 |
* Texto del menu |
|
586 |
* |
|
561 | 587 |
* @throws ClassNotFoundException |
562 | 588 |
* @throws RuntimeException |
563 |
* DOCUMENT ME! |
|
564 | 589 |
*/ |
565 |
public void addMenu(PluginClassLoader loader, SkinExtensionType ext, |
|
566 |
Menu menu) throws ClassNotFoundException { |
|
567 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
568 |
throw new RuntimeException("No Event Dispatch Thread"); |
|
590 |
public void addMenu(final PluginClassLoader loader, final SkinExtensionType ext, |
|
591 |
final Menu menu) throws ClassNotFoundException { |
|
592 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
|
593 |
try { |
|
594 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
595 |
public void run() { |
|
596 |
try { |
|
597 |
addMenu(loader, ext, menu); |
|
598 |
} catch (ClassNotFoundException ex) { |
|
599 |
logger.warn("??? Eehh????", ex); |
|
600 |
} |
|
601 |
} |
|
602 |
}); |
|
603 |
} catch (Exception ex) { |
|
604 |
// Do nothing |
|
605 |
} |
|
606 |
return; |
|
569 | 607 |
} |
570 |
JMenu menuPadre = createMenuAncestors(menu, loader);
|
|
608 |
JMenu menuPadre = createMenuAncestors(menu, loader);
|
|
571 | 609 |
|
572 |
if (menu.getIs_separator()) {
|
|
610 |
if ( menu.getIs_separator() ) {
|
|
573 | 611 |
menuPadre.addSeparator(); |
574 | 612 |
return; |
575 | 613 |
} |
576 | 614 |
|
577 | 615 |
JMenuItem nuevoMenu = createJMenuItem(loader, menu); |
578 | 616 |
nuevoMenu.addMouseListener(tooltipListener); |
579 |
//nuevoMenu.addActionListener(this); |
|
580 | 617 |
menuPadre.add(nuevoMenu); |
581 |
Class<? extends IExtension> classExtension = (Class<? extends IExtension>) loader.loadClass(ext.getClassName());
|
|
582 |
controlClass.put(nuevoMenu, classExtension); |
|
618 |
addControl(nuevoMenu);
|
|
619 |
|
|
583 | 620 |
} |
584 | 621 |
|
585 |
public void addMenu(final ActionInfo action, final String text) {
|
|
586 |
if (!SwingUtilities.isEventDispatchThread()) {
|
|
587 |
SwingUtilities.invokeLater(new Runnable() {
|
|
588 |
public void run() {
|
|
589 |
addMenu(action,text);
|
|
590 |
}
|
|
591 |
});
|
|
592 |
return;
|
|
622 |
public void addMenu(final ActionInfo action, final String text) { |
|
623 |
if ( !SwingUtilities.isEventDispatchThread() ) {
|
|
624 |
SwingUtilities.invokeLater(new Runnable() {
|
|
625 |
public void run() {
|
|
626 |
addMenu(action, text);
|
|
627 |
}
|
|
628 |
});
|
|
629 |
return;
|
|
593 | 630 |
} |
594 |
JMenu menuPadre = createMenuAncestors(text);
|
|
631 |
JMenu menuPadre = createMenuAncestors(text);
|
|
595 | 632 |
JMenuItem nuevoMenu = createJMenuItem(action, text); |
596 | 633 |
nuevoMenu.addMouseListener(tooltipListener); |
597 | 634 |
menuPadre.add(nuevoMenu); |
598 | 635 |
Class<? extends IExtension> classExtension = action.getExtension().getClass(); |
599 |
controlClass.put(nuevoMenu, classExtension);
|
|
636 |
addControl(nuevoMenu);
|
|
600 | 637 |
} |
601 |
|
|
638 |
|
|
602 | 639 |
/** |
603 |
* Dado un array de nombres de menu, encuentra el men�
|
|
604 |
*
|
|
640 |
* Dado lista de nombres de menu, encuentra el menu
|
|
641 |
* |
|
605 | 642 |
* @param nombres |
606 |
* DOCUMENT ME! |
|
607 | 643 |
* @param padre |
608 |
* DOCUMENT ME! |
|
609 |
* |
|
610 |
* @return DOCUMENT ME! |
|
644 |
* @return |
|
611 | 645 |
*/ |
612 | 646 |
private javax.swing.JMenuItem getMenu(List nombres, MenuElement parent) { |
613 |
if (parent instanceof javax.swing.JMenu) {
|
|
647 |
if ( parent instanceof javax.swing.JMenu ) {
|
|
614 | 648 |
javax.swing.JMenu parentItem = (javax.swing.JMenu) parent; |
615 | 649 |
|
616 |
for (int i = 0; i < parentItem.getMenuComponentCount(); i++) { |
|
617 |
|
|
618 |
String item_name = parentItem.getMenuComponent(i).getName(); |
|
619 |
if (((item_name != null) && (item_name.compareTo((String) nombres.get(0)) == 0)) |
|
620 |
|| |
|
621 |
/* |
|
622 |
* We also accept "leaf menus" with no name |
|
623 |
* (Project manager, View-1, View-2, etc) |
|
624 |
*/ |
|
625 |
lastMenuItemWithoutName(parentItem.getMenuComponent(i), nombres)) |
|
626 |
{ |
|
627 |
|
|
650 |
for ( int i = 0; i < parentItem.getMenuComponentCount(); i++ ) { |
|
651 |
|
|
652 |
String item_name = parentItem.getMenuComponent(i).getName(); |
|
653 |
if ( ((item_name != null) && (item_name.compareTo((String) nombres.get(0)) == 0)) |
|
654 |
|| /* |
|
655 |
* We also accept "leaf menus" with no name |
|
656 |
* (Project manager, View-1, View-2, etc) |
|
657 |
*/ lastMenuItemWithoutName(parentItem.getMenuComponent(i), nombres) ) { |
|
658 |
|
|
628 | 659 |
nombres.remove(0); |
629 |
if (nombres.isEmpty()) {
|
|
630 |
if (parentItem.getMenuComponent(i) instanceof javax.swing.JMenuItem) {
|
|
660 |
if ( nombres.isEmpty() ) {
|
|
661 |
if ( parentItem.getMenuComponent(i) instanceof javax.swing.JMenuItem ) {
|
|
631 | 662 |
return (javax.swing.JMenuItem) parentItem |
632 |
.getMenuComponent(i); |
|
663 |
.getMenuComponent(i);
|
|
633 | 664 |
} else { |
634 | 665 |
logger.error(PluginServices.getText(this, |
635 |
"Menu_type_not_supported_") |
|
636 |
+ " " |
|
637 |
+ parentItem.getMenuComponent(i).getClass() |
|
666 |
"Menu_type_not_supported_")
|
|
667 |
+ " "
|
|
668 |
+ parentItem.getMenuComponent(i).getClass()
|
|
638 | 669 |
.getName()); |
639 | 670 |
return null; |
640 | 671 |
} |
641 | 672 |
} else { |
642 | 673 |
return getMenu(nombres, |
643 |
(MenuElement) parentItem.getMenuComponent(i)); |
|
674 |
(MenuElement) parentItem.getMenuComponent(i));
|
|
644 | 675 |
} |
645 | 676 |
} |
646 | 677 |
} |
647 |
} else |
|
648 |
if (parent instanceof JMenuBar) { |
|
649 |
javax.swing.JMenuBar parentItem = (javax.swing.JMenuBar) parent; |
|
678 |
} else if ( parent instanceof JMenuBar ) { |
|
679 |
javax.swing.JMenuBar parentItem = (javax.swing.JMenuBar) parent; |
|
650 | 680 |
|
651 |
for (int i = 0; i < parentItem.getMenuCount(); i++) {
|
|
652 |
if ((parentItem.getMenu(i).getName() != null // not a
|
|
653 |
// JToolBar.Separator
|
|
681 |
for ( int i = 0; i < parentItem.getMenuCount(); i++ ) {
|
|
682 |
if ( (parentItem.getMenu(i).getName() != null // not a
|
|
683 |
// JToolBar.Separator |
|
654 | 684 |
) |
655 | 685 |
&& (parentItem.getMenu(i).getName() |
656 |
.compareTo((String) nombres.get(0)) == 0)) {
|
|
657 |
nombres.remove(0);
|
|
658 |
if (nombres.isEmpty()) {
|
|
659 |
if (parentItem.getMenu(i) instanceof javax.swing.JMenuItem) {
|
|
660 |
return parentItem.getMenu(i);
|
|
661 |
} else {
|
|
662 |
logger.error(PluginServices.getText(this,
|
|
686 |
.compareTo((String) nombres.get(0)) == 0) ) {
|
|
687 |
nombres.remove(0); |
|
688 |
if ( nombres.isEmpty() ) {
|
|
689 |
if ( parentItem.getMenu(i) instanceof javax.swing.JMenuItem ) {
|
|
690 |
return parentItem.getMenu(i); |
|
691 |
} else { |
|
692 |
logger.error(PluginServices.getText(this, |
|
663 | 693 |
"Menu_type_not_supported_") |
664 | 694 |
+ " " |
665 | 695 |
+ parentItem.getMenu(i).getClass() |
666 |
.getName()); |
|
667 |
return null; |
|
668 |
} |
|
669 |
} else { |
|
670 |
return getMenu(nombres, parentItem.getMenu(i)); |
|
696 |
.getName()); |
|
697 |
return null; |
|
671 | 698 |
} |
699 |
} else { |
|
700 |
return getMenu(nombres, parentItem.getMenu(i)); |
|
672 | 701 |
} |
673 | 702 |
} |
674 |
} else { |
|
675 |
logger.error(PluginServices.getText(this, |
|
703 |
} |
|
704 |
} else { |
|
705 |
logger.error(PluginServices.getText(this, |
|
676 | 706 |
"Menu_type_not_supported_") |
677 | 707 |
+ " " |
678 | 708 |
+ parent.getClass().getName() + " " + parent.toString()); |
679 |
}
|
|
709 |
} |
|
680 | 710 |
return null; |
681 | 711 |
} |
682 | 712 |
|
... | ... | |
686 | 716 |
* @return |
687 | 717 |
*/ |
688 | 718 |
private boolean lastMenuItemWithoutName(Component mc, List names) { |
689 |
|
|
719 |
|
|
690 | 720 |
/* |
691 | 721 |
* names must have 1 string |
692 | 722 |
*/ |
693 |
if (names == null || names.size() != 1) {
|
|
723 |
if ( names == null || names.size() != 1 ) {
|
|
694 | 724 |
return false; |
695 | 725 |
} |
696 |
if (!(mc instanceof JMenuItem)) {
|
|
726 |
if ( !(mc instanceof JMenuItem) ) {
|
|
697 | 727 |
return false; |
698 | 728 |
} |
699 | 729 |
JMenuItem jmi = (JMenuItem) mc; |
700 |
if (jmi.getName() != null) {
|
|
730 |
if ( jmi.getName() != null ) {
|
|
701 | 731 |
/* |
702 | 732 |
* Name must be null, so this is a menu leaf |
703 | 733 |
*/ |
704 | 734 |
return false; |
705 | 735 |
} |
706 |
if (jmi.getText() == null) {
|
|
736 |
if ( jmi.getText() == null ) {
|
|
707 | 737 |
return false; |
708 | 738 |
} |
709 | 739 |
return jmi.getText().compareTo((String) names.get(0)) == 0; |
710 | 740 |
} |
711 | 741 |
|
742 |
private class JMenuTraslatable extends JMenu implements TranslatableButton { |
|
743 |
|
|
744 |
private TranslatableButtonHelper i18nHelper = new TranslatableButtonHelper(); |
|
745 |
|
|
746 |
public JMenuTraslatable(String text) { |
|
747 |
super(text); |
|
748 |
} |
|
749 |
|
|
750 |
public void setTextKey(String key) { |
|
751 |
this.i18nHelper.setText(key); |
|
752 |
} |
|
753 |
|
|
754 |
public void setToolTipKey(String key) { |
|
755 |
this.i18nHelper.setTooltip(key); |
|
756 |
} |
|
757 |
|
|
758 |
public void translate() { |
|
759 |
if ( this.i18nHelper.needTranslation() ) { |
|
760 |
this.i18nHelper.translate(); |
|
761 |
this.setText(this.i18nHelper.getText()); |
|
762 |
} |
|
763 |
} |
|
764 |
|
|
765 |
} |
|
766 |
|
|
712 | 767 |
/** |
713 | 768 |
* Crea la estructura de menus recursivamente. Por ejemplo, si se le pasa |
714 | 769 |
* en el par�metro nombres el array {"Search", "References", "Workspace"} |
715 | 770 |
* crear� un men� Search, un submen� del anterior que se llamar� |
716 | 771 |
* References y debajo de �ste �ltimo otro menu llamado Workspace |
717 |
*
|
|
772 |
* |
|
718 | 773 |
* @param nombres |
719 |
* Array con los nombres de los men�s que se quieren crear
|
|
774 |
* Array con los nombres de los men�s que se quieren crear |
|
720 | 775 |
* @param padre |
721 |
* Menu padre de los men�s creados. Es �til porque es un
|
|
722 |
* algoritmo recursivo
|
|
723 |
*
|
|
776 |
* Menu padre de los men�s creados. Es �til porque es un |
|
777 |
* algoritmo recursivo |
|
778 |
* |
|
724 | 779 |
* @return Devuelve el men� creado. Al final de toda la recursividad, |
725 |
* devolver� el men� de m�s abajo en la jerarqu�a
|
|
726 |
*
|
|
780 |
* devolver� el men� de m�s abajo en la jerarqu�a |
|
781 |
* |
|
727 | 782 |
* @throws RuntimeException |
728 |
* DOCUMENT ME! |
|
729 | 783 |
*/ |
730 | 784 |
private JMenu createMenus(ArrayList nombres, JMenu padre) { |
731 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
785 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
|
786 |
logger.warn("Este metodo requiere que se este ejecutando en el hilo de eventos de AWT."); |
|
732 | 787 |
throw new RuntimeException("No Event Dispatch Thread"); |
733 | 788 |
} |
789 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
734 | 790 |
|
735 | 791 |
// si no quedan nombres de menu por crear se vuelve: caso base |
736 |
if (nombres.size() == 0) {
|
|
792 |
if ( nombres.isEmpty() ) {
|
|
737 | 793 |
return padre; |
738 | 794 |
} |
739 | 795 |
|
740 | 796 |
// Se busca el menu por si ya existiera para no crearlo otra vez |
741 | 797 |
JMenu buscado = null; |
742 | 798 |
|
743 |
for (int i = 0; i < padre.getMenuComponentCount(); i++) {
|
|
799 |
for ( int i = 0; i < padre.getMenuComponentCount(); i++ ) {
|
|
744 | 800 |
try { |
745 | 801 |
JMenu hijo = (JMenu) padre.getMenuComponent(i); |
746 | 802 |
|
747 |
if (hijo.getName().compareTo((String) nombres.get(0)) == 0) {
|
|
803 |
if ( hijo.getName().compareTo((String) nombres.get(0)) == 0 ) {
|
|
748 | 804 |
buscado = hijo; |
749 | 805 |
} |
750 | 806 |
} catch (ClassCastException e) { |
... | ... | |
754 | 810 |
} |
755 | 811 |
} |
756 | 812 |
|
757 |
if (buscado != null) {
|
|
813 |
if ( buscado != null ) {
|
|
758 | 814 |
// Si lo hemos encontrado creamos el resto |
759 | 815 |
nombres.remove(0); |
760 | 816 |
|
... | ... | |
763 | 819 |
// Si no lo hemos encontrado se crea el menu, se a�ade al padre |
764 | 820 |
// y se crea el resto |
765 | 821 |
String nombre = (String) nombres.get(0); |
766 |
JMenu menuPadre = new JMenu(PluginServices.getText(this, nombre)); |
|
822 |
JMenuTraslatable menuPadre = new JMenuTraslatable(i18nManager.getTranslation(nombre)); |
|
823 |
menuPadre.setTextKey(nombre); |
|
767 | 824 |
menuPadre.setName(nombre); |
825 |
addControl(menuPadre); |
|
768 | 826 |
padre.add(menuPadre); |
769 | 827 |
|
770 | 828 |
nombres.remove(0); |
... | ... | |
786 | 844 |
|
787 | 845 |
int toolHeight = 0; |
788 | 846 |
|
789 |
for (int i = 0; i < toolBars.getComponentCount(); i++) {
|
|
847 |
for ( int i = 0; i < toolBars.getComponentCount(); i++ ) {
|
|
790 | 848 |
Component c = toolBars.getComponent(i); |
791 | 849 |
|
792 |
if (!c.isVisible()) {
|
|
850 |
if ( !c.isVisible() ) {
|
|
793 | 851 |
continue; |
794 | 852 |
} |
795 | 853 |
|
796 | 854 |
double width = c.getPreferredSize().getWidth(); |
797 | 855 |
acum = acum + width; |
798 | 856 |
|
799 |
if (acum > this.getWidth()) {
|
|
857 |
if ( acum > this.getWidth() ) {
|
|
800 | 858 |
numFilas++; |
801 | 859 |
acum = width + margen; |
802 | 860 |
} |
803 | 861 |
|
804 |
if (c.getPreferredSize().getHeight() > toolHeight) {
|
|
862 |
if ( c.getPreferredSize().getHeight() > toolHeight ) {
|
|
805 | 863 |
toolHeight = c.getPreferredSize().height; |
806 | 864 |
} |
807 | 865 |
} |
808 | 866 |
|
809 | 867 |
toolBars.setPreferredSize(new Dimension(this.getWidth(), |
810 |
(numFilas * toolHeight))); |
|
868 |
(numFilas * toolHeight)));
|
|
811 | 869 |
|
812 | 870 |
toolBars.updateUI(); |
813 | 871 |
} |
814 | 872 |
|
815 |
/** |
|
816 |
* DOCUMENT ME! |
|
817 |
* |
|
818 |
* @param classesExtensions |
|
819 |
*/ |
|
820 | 873 |
public void setClassesExtensions(Map<Class<? extends IExtension>, ExtensionDecorator> classesExtensions) { |
821 |
Map<Class<? extends IExtension>, ExtensionDecorator> extensions = new HashMap<Class<? extends IExtension>, ExtensionDecorator>(); |
|
822 |
for ( Entry<Class<? extends IExtension>, ExtensionDecorator> entry: classesExtensions.entrySet()) { |
|
823 |
if( ! (entry.getValue().getExtension() instanceof LibraryExtension) ) { |
|
824 |
extensions.put(entry.getKey(), entry.getValue()); |
|
825 |
} |
|
826 |
} |
|
827 |
this.classesExtensions = extensions; |
|
874 |
// Ya no es necesario que se mantenga el Map con las extensiones. |
|
875 |
|
|
876 |
// Map<Class<? extends IExtension>, ExtensionDecorator> extensions = new HashMap<Class<? extends IExtension>, ExtensionDecorator>(); |
|
877 |
// for ( Entry<Class<? extends IExtension>, ExtensionDecorator> entry: classesExtensions.entrySet()) { |
|
878 |
// if( ! (entry.getValue().getExtension() instanceof LibraryExtension) ) { |
|
879 |
// extensions.put(entry.getKey(), entry.getValue()); |
|
880 |
// } |
|
881 |
// } |
|
882 |
// this.classesExtensions = extensions; |
|
828 | 883 |
} |
829 | 884 |
|
830 | 885 |
/** |
831 | 886 |
* Metodo de callback invocado cuando se selecciona un menu o un boton |
832 | 887 |
* de |
833 | 888 |
* la barra de herramientas. Se busca la extensi�n asociada y se ejecuta |
834 |
*
|
|
889 |
* |
|
835 | 890 |
* @param e |
836 |
* Evento producido
|
|
891 |
* Evento producido |
|
837 | 892 |
*/ |
838 | 893 |
public void actionPerformed(ActionEvent e) { |
839 |
|
|
840 |
// org.gvsig.andami.plugins.IExtension ext = |
|
841 |
// (org.gvsig.andami.plugins.IExtension) classesExtensions |
|
842 |
// .get(controlClass.get(control)); |
|
843 |
String actionName = "(unknow)"; |
|
894 |
|
|
895 |
String actionName = "(unknow)"; |
|
844 | 896 |
try { |
845 | 897 |
JComponent control = (JComponent) e.getSource(); |
846 | 898 |
actionName = control.getName(); |
847 |
|
|
848 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager();
|
|
849 |
ActionInfo action = actionManager.getAction(control.getName());
|
|
850 |
Object args = null;
|
|
851 |
if( control instanceof IControl ) { |
|
852 |
args = ((IControl) control).getValue();
|
|
899 |
|
|
900 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager();
|
|
901 |
ActionInfo action = actionManager.getAction(control.getName());
|
|
902 |
Object args = null;
|
|
903 |
if ( control instanceof IControl ) {
|
|
904 |
args = ((IControl) control).getValue();
|
|
853 | 905 |
} |
854 |
if( args == null ) { |
|
855 |
action.execute();
|
|
906 |
if ( args == null ) {
|
|
907 |
action.execute();
|
|
856 | 908 |
} else { |
857 |
action.execute(args);
|
|
909 |
action.execute(args);
|
|
858 | 910 |
} |
859 |
|
|
860 |
// logger.info("{}.execute('{}')", ext.getClass().getSimpleName(), actionCommand); |
|
861 |
// ext.execute(actionCommand); |
|
862 |
|
|
863 |
String actionCommand = e.getActionCommand(); |
|
911 |
String actionCommand = e.getActionCommand(); |
|
864 | 912 |
try { |
865 | 913 |
JToolBarToggleButton toggle = (JToolBarToggleButton) control; |
866 | 914 |
ToggleButtonModel model = (ToggleButtonModel) toggle.getModel(); |
... | ... | |
870 | 918 |
} |
871 | 919 |
|
872 | 920 |
} catch (Throwable ex) { |
873 |
logger.error("Can't perform action '"+actionName+"'.",ex); |
|
874 |
// if (ext == null) { |
|
875 |
// logger.error(Messages |
|
876 |
// .getString("No_extension_associated_with_this_event_") |
|
877 |
// + e.getActionCommand()); |
|
878 |
// } |
|
879 |
// NotificationManager.addError(Messages |
|
880 |
// .getString("MDIFrame.Error_no_capturado_por_el_usuario"), t); |
|
921 |
logger.error("Can't perform action '" + actionName + "'.", ex); |
|
881 | 922 |
} |
882 | 923 |
|
883 | 924 |
enableControls(); |
884 | 925 |
showMemory(); |
885 | 926 |
} |
886 | 927 |
|
887 |
/** |
|
888 |
* DOCUMENT ME! |
|
889 |
* |
|
890 |
* @param name |
|
891 |
* DOCUMENT ME! |
|
892 |
* @param loader |
|
893 |
* DOCUMENT ME! |
|
894 |
* |
|
895 |
* @return DOCUMENT ME! |
|
896 |
*/ |
|
897 | 928 |
private String getName(String name, PluginClassLoader loader) { |
898 |
if (name.indexOf('.') == -1) {
|
|
929 |
if ( name.indexOf('.') == -1 ) {
|
|
899 | 930 |
return loader.getPluginName() + "." + name; |
900 | 931 |
} else { |
901 | 932 |
return name; |
902 | 933 |
} |
903 | 934 |
} |
904 | 935 |
|
905 |
/** |
|
906 |
* DOCUMENT ME! |
|
907 |
* |
|
908 |
* @param loader |
|
909 |
* DOCUMENT ME! |
|
910 |
* @param menu |
|
911 |
* DOCUMENT ME! |
|
912 |
* |
|
913 |
* @throws RuntimeException |
|
914 |
* DOCUMENT ME! |
|
915 |
*/ |
|
916 | 936 |
public void addPopupMenu(PluginClassLoader loader, PopupMenu menu) { |
917 |
if (!SwingUtilities.isEventDispatchThread()) {
|
|
937 |
if ( !SwingUtilities.isEventDispatchThread() ) {
|
|
918 | 938 |
throw new RuntimeException("No Event Dispatch Thread"); |
919 | 939 |
} |
920 | 940 |
|
... | ... | |
923 | 943 |
// Se crea el control popupmenu |
924 | 944 |
JPopUpMenu popupMenu = (JPopUpMenu) popupMap.get(name); |
925 | 945 |
|
926 |
if (popupMenu == null) {
|
|
946 |
if ( popupMenu == null ) {
|
|
927 | 947 |
popupMenu = new JPopUpMenu(menu.getName()); |
928 | 948 |
popupMap.put(name, popupMenu); |
929 | 949 |
} |
930 | 950 |
|
931 | 951 |
Menu[] menues = menu.getMenu(); |
932 |
for (int i = 0; i < menues.length; i++) {
|
|
952 |
for ( int i = 0; i < menues.length; i++ ) {
|
|
933 | 953 |
JMenuItem nuevoMenu = createJMenuItem(loader, menues[i]); |
934 | 954 |
popupMenu.add(nuevoMenu); |
935 | 955 |
} |
936 | 956 |
} |
937 | 957 |
|
938 |
/** |
|
939 |
* DOCUMENT ME! |
|
940 |
* |
|
941 |
* @param loader |
|
942 |
* @param menu |
|
943 |
* |
|
944 |
* @return |
|
945 |
* |
|
946 |
* @throws RuntimeException |
|
947 |
* DOCUMENT ME! |
|
948 |
*/ |
|
949 | 958 |
private JMenuItem createJMenuItem(PluginClassLoader loader, Menu menu) { |
950 | 959 |
JMenuItem nuevoMenu = null; |
951 | 960 |
|
952 |
PluginServices ps = |
|
953 |
PluginServices.getPluginServices(loader.getPluginName()); |
|
954 |
|
|
961 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
962 |
|
|
955 | 963 |
String text = menu.getText(); |
956 | 964 |
int n = text.lastIndexOf('/'); |
957 |
if( n>=0 ) {
|
|
958 |
text = text.substring(n + 1);
|
|
965 |
if ( n >= 0 ) {
|
|
966 |
text = text.substring(n + 1);
|
|
959 | 967 |
} |
960 |
String translatedText = ps.getText(text);
|
|
968 |
String translatedText = i18nManager.getTranslation(text);
|
|
961 | 969 |
|
962 | 970 |
IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
963 |
if (menu.getIcon() != null) {
|
|
964 |
if( iconTheme.exists(menu.getIcon()) ) {
|
|
965 |
ImageIcon image = iconTheme.get(menu.getIcon());
|
|
971 |
if ( menu.getIcon() != null ) {
|
|
972 |
if ( iconTheme.exists(menu.getIcon()) ) {
|
|
973 |
ImageIcon image = iconTheme.get(menu.getIcon());
|
|
966 | 974 |
nuevoMenu = new JMenuItem(translatedText, image); |
967 | 975 |
} else { |
968 | 976 |
nuevoMenu = new JMenuItem(translatedText); |
969 |
logger.info("menu icon '"+ menu.getIcon()+ "' not exists.");
|
|
977 |
logger.info("menu icon '" + menu.getIcon() + "' not exists.");
|
|
970 | 978 |
} |
971 | 979 |
} else { |
972 | 980 |
nuevoMenu = new JMenuItem(translatedText); |
973 | 981 |
} |
982 |
nuevoMenu.setTextKey(text); |
|
974 | 983 |
nuevoMenu.setName(menu.getName()); |
975 |
// if (menu.getMnemonic() != null) { |
|
976 |
// if (menu.getMnemonic().length() != 1) { |
|
977 |
// throw new RuntimeException( |
|
978 |
// "Mnemonic must be 1 character length"); |
|
979 |
// } |
|
980 |
// nuevoMenu.setMnemonic(KeyMapping.getKey(menu.getMnemonic() |
|
981 |
// .charAt(0))); |
|
982 |
// } |
|
983 | 984 |
|
984 |
if (menu.getKey() != null) {
|
|
985 |
if ( menu.getKey() != null ) {
|
|
985 | 986 |
nuevoMenu.setAccelerator(KeyMapping.getKeyStroke(menu.getKey())); |
986 | 987 |
} |
987 | 988 |
|
988 | 989 |
nuevoMenu.setActionCommand(menu.getActionCommand()); |
989 | 990 |
|
990 |
if (menu.getTooltip() != null) { |
|
991 |
nuevoMenu.setToolTip(ps.getText(menu.getTooltip())); |
|
991 |
if ( menu.getTooltip() != null ) { |
|
992 |
nuevoMenu.setToolTip(i18nManager.getTranslation(menu.getTooltip())); |
|
993 |
nuevoMenu.setToolTipKey(menu.getTooltip()); |
|
992 | 994 |
} |
993 | 995 |
|
994 |
if (menu.getEnableText() != null) {
|
|
995 |
nuevoMenu.setEnableText(ps.getText(menu.getEnableText()));
|
|
996 |
if ( menu.getEnableText() != null ) {
|
|
997 |
nuevoMenu.setEnableText(i18nManager.getTranslation(menu.getEnableText()));
|
|
996 | 998 |
} |
997 | 999 |
|
998 | 1000 |
nuevoMenu.setEnabled(true); |
999 | 1001 |
nuevoMenu.setVisible(true); |
1000 | 1002 |
|
1001 |
if( menu.getName() != null ) { |
|
1002 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager();
|
|
1003 |
final ActionInfo actionInfo = actionManager.getAction(menu.getName());
|
|
1004 |
if( actionInfo != null ) {
|
|
1005 |
nuevoMenu.addActionListener(actionInfo);
|
|
1006 |
}
|
|
1003 |
if ( menu.getName() != null ) {
|
|
1004 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager();
|
|
1005 |
final ActionInfo actionInfo = actionManager.getAction(menu.getName());
|
|
1006 |
if ( actionInfo != null ) {
|
|
1007 |
nuevoMenu.addActionListener(actionInfo);
|
|
1008 |
}
|
|
1007 | 1009 |
} |
1008 | 1010 |
return nuevoMenu; |
1009 | 1011 |
} |
1010 | 1012 |
|
1011 | 1013 |
private JMenuItem createJMenuItem(ActionInfo action, String text) { |
1012 |
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
|
1014 |
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
|
1013 | 1015 |
JMenuItem nuevoMenu = null; |
1014 | 1016 |
String label = null; |
1015 |
|
|
1016 |
if( text == null ) { |
|
1017 |
label = action.getLabel();
|
|
1018 |
} else if( text.contains("/") ) { |
|
1019 |
String[] ss = text.split("/");
|
|
1020 |
label = ss[ss.length-1];
|
|
1017 |
|
|
1018 |
if ( text == null ) {
|
|
1019 |
label = action.getLabel();
|
|
1020 |
} else if ( text.contains("/") ) {
|
|
1021 |
String[] ss = text.split("/");
|
|
1022 |
label = ss[ss.length - 1];
|
|
1021 | 1023 |
} else { |
1022 |
label = text;
|
|
1024 |
label = text;
|
|
1023 | 1025 |
} |
1024 | 1026 |
String translatedText = i18nManager.getTranslation(label); |
1025 |
if( action.getIconName()!=null ) {
|
|
1026 |
ImageIcon image = action.getIcon();
|
|
1027 |
if ( image != null) {
|
|
1028 |
nuevoMenu = new JMenuItem(translatedText, image);
|
|
1029 |
} else {
|
|
1030 |
nuevoMenu = new JMenuItem(translatedText);
|
|
1031 |
}
|
|
1027 |
if ( action.getIconName() != null ) {
|
|
1028 |
ImageIcon image = action.getIcon();
|
|
1029 |
if ( image != null ) {
|
|
1030 |
nuevoMenu = new JMenuItem(translatedText, image);
|
|
1031 |
} else {
|
|
1032 |
nuevoMenu = new JMenuItem(translatedText);
|
|
1033 |
}
|
|
1032 | 1034 |
} else { |
1033 |
nuevoMenu = new JMenuItem(translatedText);
|
|
1035 |
nuevoMenu = new JMenuItem(translatedText);
|
|
1034 | 1036 |
} |
1035 | 1037 |
nuevoMenu.setName(action.getName()); |
1036 | 1038 |
KeyStroke key = action.getKeyStroke(); |
1037 |
if ( key!= null) {
|
|
1039 |
if ( key != null ) {
|
|
1038 | 1040 |
nuevoMenu.setAccelerator(key); |
1039 | 1041 |
} |
1040 | 1042 |
nuevoMenu.setActionCommand(action.getCommand()); |
1041 |
if (action.getTooltip() != null) {
|
|
1043 |
if ( action.getTooltip() != null ) {
|
|
1042 | 1044 |
nuevoMenu.setToolTip(i18nManager.getTranslation(action.getTooltip())); |
1043 | 1045 |
} |
1044 | 1046 |
nuevoMenu.setEnabled(true); |
1045 | 1047 |
nuevoMenu.setVisible(true); |
1046 |
nuevoMenu.addActionListener(action);
|
|
1048 |
nuevoMenu.addActionListener(action);
|
|
1047 | 1049 |
return nuevoMenu; |
1048 | 1050 |
} |
1049 | 1051 |
|
1050 | 1052 |
/** |
1051 | 1053 |
* Muestra u oculta el menu de nombre 'name' |
1052 |
*
|
|
1054 |
* |
|
1053 | 1055 |
* @param name |
1054 |
* Nombre del menu que se quiere mostrar
|
|
1056 |
* Nombre del menu que se quiere mostrar |
|
1055 | 1057 |
* @param x |
1056 |
* Evento de raton
|
|
1058 |
* Evento de raton |
|
1057 | 1059 |
* @param y |
1058 |
* DOCUMENT ME! |
|
1059 | 1060 |
* @param c |
1060 |
* DOCUMENT ME! |
|
1061 | 1061 |
*/ |
1062 | 1062 |
private void showPopupMenu(String name, int x, int y, Component c) { |
1063 | 1063 |
JPopupMenu menu = (JPopupMenu) popupMap.get(name); |
1064 | 1064 |
|
1065 |
if (menu != null) {
|
|
1065 |
if ( menu != null ) {
|
|
1066 | 1066 |
menu.show(c, x, y); |
1067 | 1067 |
} |
1068 | 1068 |
} |
1069 | 1069 |
|
1070 |
/** |
|
1071 |
* DOCUMENT ME! |
|
1072 |
* |
|
1073 |
* @param name |
|
1074 |
* DOCUMENT ME! |
|
1075 |
* @param listener |
|
1076 |
* DOCUMENT ME! |
|
1077 |
*/ |
|
1078 | 1070 |
public void removePopupMenuListener(String name, ActionListener listener) { |
1079 | 1071 |
JPopupMenu menu = (JPopupMenu) popupMap.get(name); |
1080 | 1072 |
|
1081 |
if (menu != null) {
|
|
1073 |
if ( menu != null ) {
|
|
1082 | 1074 |
Component[] jmenuitems = menu.getComponents(); |
1083 | 1075 |
|
1084 |
for (int i = 0; i < jmenuitems.length; i++) {
|
|
1085 |
if (jmenuitems[i] instanceof JMenuItem) {
|
|
1076 |
for ( int i = 0; i < jmenuitems.length; i++ ) {
|
|
1077 |
if ( jmenuitems[i] instanceof JMenuItem ) {
|
|
1086 | 1078 |
((JMenuItem) jmenuitems[i]).removeActionListener(listener); |
1087 | 1079 |
} |
1088 | 1080 |
} |
1089 | 1081 |
} |
1090 | 1082 |
} |
1091 | 1083 |
|
1092 |
/** |
|
1093 |
* DOCUMENT ME! |
|
1094 |
* |
|
1095 |
* @param popupName |
|
1096 |
* @param c |
|
1097 |
* DOCUMENT ME! |
|
1098 |
* @param listener |
|
1099 |
* @param loader |
|
1100 |
*/ |
|
1101 | 1084 |
public void addPopupMenuListener(String popupName, Component c, |
1102 |
ActionListener listener, PluginClassLoader loader) { |
|
1085 |
ActionListener listener, PluginClassLoader loader) {
|
|
1103 | 1086 |
final String name = getName(popupName, loader); |
1104 | 1087 |
|
1105 | 1088 |
JPopupMenu menu = (JPopupMenu) popupMap.get(name); |
1106 | 1089 |
|
1107 |
if (menu != null) {
|
|
1090 |
if ( menu != null ) {
|
|
1108 | 1091 |
Component[] jmenuitems = menu.getComponents(); |
1109 | 1092 |
|
1110 |
for (int i = 0; i < jmenuitems.length; i++) {
|
|
1111 |
if (jmenuitems[i] instanceof JMenuItem) {
|
|
1093 |
for ( int i = 0; i < jmenuitems.length; i++ ) {
|
|
1094 |
if ( jmenuitems[i] instanceof JMenuItem ) {
|
|
1112 | 1095 |
((JMenuItem) jmenuitems[i]).addActionListener(listener); |
1113 | 1096 |
} |
1114 | 1097 |
} |
... | ... | |
1118 | 1101 |
|
1119 | 1102 |
@Override |
1120 | 1103 |
public void mousePressed(MouseEvent e) { |
1121 |
if (e.isPopupTrigger()) {
|
|
1104 |
if ( e.isPopupTrigger() ) {
|
|
1122 | 1105 |
showPopupMenu(name, e.getX(), e.getY(), e.getComponent()); |
1123 | 1106 |
} |
1124 | 1107 |
} |
1125 | 1108 |
|
1126 | 1109 |
@Override |
1127 | 1110 |
public void mouseReleased(MouseEvent e) { |
1128 |
if (e.isPopupTrigger()) {
|
|
1111 |
if ( e.isPopupTrigger() ) {
|
|
1129 | 1112 |
showPopupMenu(name, e.getX(), e.getY(), e.getComponent()); |
1130 | 1113 |
} |
1131 | 1114 |
} |
... | ... | |
1134 | 1117 |
|
1135 | 1118 |
/** |
1136 | 1119 |
* Loop on the controls to enable/disable and show/hide them, according to |
1137 |
* its associated extension
|
|
1138 |
*
|
|
1120 |
* its associated action (ActionInfo)
|
|
1121 |
* |
|
1139 | 1122 |
* @throws RuntimeException |
1140 |
* DOCUMENT ME! |
|
1141 | 1123 |
*/ |
1142 | 1124 |
public void enableControls() { |
1143 |
if (!SwingUtilities.isEventDispatchThread()) {
|
|
1144 |
SwingUtilities.invokeLater(new Runnable() {
|
|
1145 |
public void run() {
|
|
1146 |
enableControls();
|
|
1147 |
}
|
|
1148 |
});
|
|
1149 |
return;
|
|
1125 |
if ( !SwingUtilities.isEventDispatchThread() ) {
|
|
1126 |
SwingUtilities.invokeLater(new Runnable() {
|
|
1127 |
public void run() {
|
|
1128 |
enableControls();
|
|
1129 |
}
|
|
1130 |
});
|
|
1131 |
return;
|
|
1150 | 1132 |
} |
1151 | 1133 |
|
1152 | 1134 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
1153 | 1135 |
ActionInfoStatusCache cache = actionManager.createActionStatusCache(); |
1154 |
|
|
1155 |
Iterator e = classesExtensions.values().iterator(); |
|
1156 | 1136 |
|
1157 |
// HashMap estadoExtensiones = new HashMap(); |
|
1158 |
// HashMap visibilidadExtensiones = new HashMap(); |
|
1159 |
// |
|
1160 |
// while (e.hasNext()) { |
|
1161 |
// ExtensionDecorator ext = (ExtensionDecorator) e.next(); |
|
1162 |
// |
|
1163 |
// try { |
|
1164 |
// if (estadoExtensiones.get(ext) == null) { |
|
1165 |
// boolean b; |
|
1166 |
// if (ext.getVisibility() == ExtensionDecorator.ALWAYS_VISIBLE) { |
|
1167 |
// b = true; |
|
1168 |
// } else |
|
1169 |
// if (ext.getVisibility() == ExtensionDecorator.ALWAYS_INVISIBLE) { |
|
1170 |
// b = false; |
|
1171 |
// } else { |
|
1172 |
// if (PluginServices.getExclusiveUIExtension() == null) { |
|
1173 |
// b = ext.isVisible(); |
|
1174 |
// } else { |
|
1175 |
// b = |
|
1176 |
// PluginServices.getExclusiveUIExtension() |
|
1177 |
// .isVisible(ext.getExtension()); |
|
1178 |
// } |
|
1179 |
// } |
|
1180 |
// Boolean visible = new Boolean(b); |
|
1181 |
// Boolean enabled = new Boolean(false); |
|
1182 |
// |
|
1183 |
// if (visible.booleanValue()) { |
|
1184 |
// if (PluginServices.getExclusiveUIExtension() == null) { |
|
1185 |
// enabled = new Boolean(ext.isEnabled()); |
|
1186 |
// } else { |
|
1187 |
// enabled = |
|
1188 |
// new Boolean(PluginServices |
Also available in: Unified diff