|
1 |
/**
|
|
2 |
*
|
|
3 |
*/
|
|
4 |
package com.iver.core.menus;
|
|
5 |
|
|
6 |
import java.awt.event.ActionEvent;
|
|
7 |
import java.awt.event.ActionListener;
|
|
8 |
import java.net.URL;
|
|
9 |
|
|
10 |
import javax.swing.ImageIcon;
|
|
11 |
|
|
12 |
import com.iver.andami.PluginServices;
|
|
13 |
import com.iver.andami.plugins.Extension;
|
|
14 |
import com.iver.andami.plugins.config.generate.Menu;
|
|
15 |
import com.iver.andami.ui.mdiFrame.SelectableToolBar;
|
|
16 |
|
|
17 |
/**
|
|
18 |
* @author cesar
|
|
19 |
*
|
|
20 |
*/
|
|
21 |
public class ToolbarMenus extends Extension implements ActionListener {
|
|
22 |
private final String ACTIONCOMMANDBASE = "CHANGE_VISIBILITY-";
|
|
23 |
private final String MENUBASE = "Ver/Toolbars/";
|
|
24 |
|
|
25 |
/* (non-Javadoc)
|
|
26 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
|
27 |
*/
|
|
28 |
public void execute(String actionCommand) {
|
|
29 |
// TODO Auto-generated method stub
|
|
30 |
|
|
31 |
}
|
|
32 |
|
|
33 |
/* (non-Javadoc)
|
|
34 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
|
35 |
*/
|
|
36 |
public void postinitialize() {
|
|
37 |
|
|
38 |
}
|
|
39 |
|
|
40 |
/* (non-Javadoc)
|
|
41 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
|
42 |
*/
|
|
43 |
public boolean isEnabled() {
|
|
44 |
return true;
|
|
45 |
}
|
|
46 |
|
|
47 |
/* (non-Javadoc)
|
|
48 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
|
49 |
*/
|
|
50 |
public boolean isVisible() {
|
|
51 |
// TODO Auto-generated method stub
|
|
52 |
return false;
|
|
53 |
}
|
|
54 |
|
|
55 |
public void actionPerformed(ActionEvent e) {
|
|
56 |
String toolbarName = e.getActionCommand().substring(ACTIONCOMMANDBASE.length());
|
|
57 |
javax.swing.JMenuItem menu = PluginServices.getMainFrame().getMenuEntry((MENUBASE+toolbarName).split("/"));
|
|
58 |
|
|
59 |
if (!toolbarName.equals("")) {
|
|
60 |
boolean oldVisibility = PluginServices.getMainFrame().getToolbarVisibility(toolbarName);
|
|
61 |
if (oldVisibility==false) {
|
|
62 |
URL icon = PluginServices.getPluginServices(this).getClassLoader().getResource("images/gtk-apply.png");
|
|
63 |
menu.setIcon(new ImageIcon(icon));
|
|
64 |
}
|
|
65 |
else {
|
|
66 |
menu.setIcon(null);
|
|
67 |
}
|
|
68 |
PluginServices.getMainFrame().setToolbarVisibility(toolbarName, !oldVisibility);
|
|
69 |
}
|
|
70 |
}
|
|
71 |
|
|
72 |
public void initialize() {
|
|
73 |
SelectableToolBar[] toolBars = PluginServices.getMainFrame().getToolbars();
|
|
74 |
for (int i=toolBars.length-1; i>0; i--) {
|
|
75 |
Menu menu = new Menu();
|
|
76 |
menu.setActionCommand(ACTIONCOMMANDBASE+toolBars[i].getName());
|
|
77 |
menu.setTooltip(PluginServices.getText(this, "muestra_oculta_la_toolbar"));
|
|
78 |
menu.setText(MENUBASE+toolBars[i].getName());
|
|
79 |
if (toolBars[i].getAndamiVisibility())
|
|
80 |
menu.setIcon("images/gtk-apply.png");
|
|
81 |
PluginServices.getMainFrame().addMenu(menu, this, PluginServices.getPluginServices(this).getClassLoader());
|
|
82 |
}
|
|
83 |
|
|
84 |
}
|
|
85 |
|
|
86 |
}
|
0 |
87 |
|