KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > client > grapheditor > WFContextMenu


1 package hero.client.grapheditor;
2
3 import java.awt.Color JavaDoc;
4 import java.awt.Point JavaDoc;
5 import java.awt.event.ActionEvent JavaDoc;
6 import java.awt.event.ActionListener JavaDoc;
7
8 import javax.swing.ImageIcon JavaDoc;
9 import javax.swing.JFrame JavaDoc;
10 import javax.swing.JMenu JavaDoc;
11 import javax.swing.JMenuItem JavaDoc;
12 import javax.swing.JPopupMenu JavaDoc;
13
14 public class WFContextMenu {
15     
16     static java.util.ResourceBundle JavaDoc resource = java.util.ResourceBundle.getBundle("resources.Traduction")/*#BundleType=List*/;
17     
18     public static JPopupMenu JavaDoc popupMenu(final JFrame JavaDoc frame, final Point JavaDoc p,final String JavaDoc nodeName,final WFManager manager){
19
20     JPopupMenu JavaDoc menu = new JPopupMenu JavaDoc();
21     JMenuItem JavaDoc mi;
22     ClassLoader JavaDoc cl = frame.getClass().getClassLoader();
23
24     if(nodeName!=null){ //BnNode Options
25

26         JMenu JavaDoc order = (JMenu JavaDoc) menu.add(new JMenu JavaDoc(resource.getString("wfcontextmenu.order")));
27         order.setBackground(new Color JavaDoc(177,177,251));
28         
29         mi =(JMenuItem JavaDoc) order.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.front")));
30         mi.setBackground(new Color JavaDoc(177,177,251));
31         mi.setIcon(new ImageIcon JavaDoc(cl.getResource("images/Forward.gif")));
32         mi.addActionListener (new ActionListener JavaDoc () {
33             public void actionPerformed (ActionEvent JavaDoc e) {
34                 manager.getGraph().toFront(nodeName);
35             }
36         });
37         
38         mi = (JMenuItem JavaDoc) order.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.back")));
39         mi.setBackground(new Color JavaDoc(177,177,251));
40         mi.setIcon(new ImageIcon JavaDoc(cl.getResource("images/Backward.gif")));
41         mi.addActionListener (new ActionListener JavaDoc () {
42             public void actionPerformed (ActionEvent JavaDoc e) {
43             manager.getGraph().toBack(nodeName);
44             }
45         });
46        
47         menu.addSeparator();
48
49         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.addprop")));
50         mi.setBackground(new Color JavaDoc(177,177,251));
51         mi.setEnabled(manager.getPersistence().hasPermission());
52         mi.addActionListener(new ActionListener JavaDoc() {
53             public void actionPerformed(ActionEvent JavaDoc e) {
54             manager.addNodeProperty(nodeName);
55             }
56         });
57         
58         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.newhook")));
59         mi.setBackground(new Color JavaDoc(177,177,251));
60                 mi.setEnabled(manager.getPersistence().hasPermission());
61                 mi.addActionListener(new ActionListener JavaDoc() {
62                     public void actionPerformed(ActionEvent JavaDoc e) {
63                     manager.setNodeHook(nodeName);
64                     }
65         });
66         
67         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.additer")));
68         mi.setBackground(new Color JavaDoc(177,177,251));
69         mi.setEnabled(manager.getPersistence().hasPermission());
70         mi.addActionListener(new ActionListener JavaDoc() {
71             public void actionPerformed(ActionEvent JavaDoc e) {
72             manager.iterate(nodeName);
73             }
74         });
75     
76         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.addperf")));
77         mi.setBackground(new Color JavaDoc(177,177,251));
78         mi.setEnabled(manager.getPersistence().hasPermission());
79         mi.addActionListener(new ActionListener JavaDoc() {
80             public void actionPerformed(ActionEvent JavaDoc e) {
81             manager.addPerformerAssigment(nodeName);
82             }
83         });
84     
85         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.editact")));
86         mi.setBackground(new Color JavaDoc(177,177,251));
87         mi.setEnabled(manager.getPersistence().hasPermission());
88         mi.addActionListener(new ActionListener JavaDoc() {
89             public void actionPerformed(ActionEvent JavaDoc e) {
90             manager.editNode(nodeName);
91             }
92         });
93     
94     } else {
95
96         JMenu JavaDoc project = (JMenu JavaDoc) menu.add(new JMenu JavaDoc(resource.getString("wfcontextmenu.configproj")));
97         project.setBackground(new Color JavaDoc(177, 177, 251));
98
99         mi = (JMenuItem JavaDoc) project.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.addprop")));
100         mi.setBackground(new Color JavaDoc(177, 177, 251));
101         mi.setEnabled(manager.getPersistence().hasPermission());
102         mi.addActionListener(new ActionListener JavaDoc() {
103             public void actionPerformed(ActionEvent JavaDoc e) {
104                 manager.addProjectProperty();
105             }
106         });
107
108         mi = (JMenuItem JavaDoc) project.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.newhook")));
109         mi.setBackground(new Color JavaDoc(177, 177, 251));
110         mi.setEnabled(manager.getPersistence().hasPermission());
111         mi.addActionListener(new ActionListener JavaDoc() {
112             public void actionPerformed(ActionEvent JavaDoc e) {
113                 manager.setProjectHook();
114             }
115         });
116         
117         menu.addSeparator();
118                     
119         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.newuser")));
120         mi.setBackground(new Color JavaDoc(177,177,251));
121         mi.setIcon(new ImageIcon JavaDoc(cl.getResource("images/User.gif")));
122         mi.setEnabled(manager.getPersistence().hasPermission());
123         mi.addActionListener(new ActionListener JavaDoc() {
124             public void actionPerformed(ActionEvent JavaDoc e) {
125             manager.newUser();
126             }
127         });
128         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.userproj")));
129         mi.setBackground(new Color JavaDoc(177,177,251));
130         mi.setIcon(new ImageIcon JavaDoc(cl.getResource("images/User2.gif")));
131         mi.setEnabled(manager.getPersistence().hasPermission());
132         mi.addActionListener(new ActionListener JavaDoc() {
133             public void actionPerformed(ActionEvent JavaDoc e) {
134             manager.usersInProject();
135             }
136         });
137         
138         
139         menu.addSeparator();
140          
141         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.addrole")));
142         mi.setBackground(new Color JavaDoc(177,177,251));
143         mi.setIcon(new ImageIcon JavaDoc(cl.getResource("images/Role2.gif")));
144         mi.setEnabled(manager.getPersistence().hasPermission());
145         mi.addActionListener(new ActionListener JavaDoc() {
146             public void actionPerformed(ActionEvent JavaDoc e) {
147             manager.newRole();
148             }
149         });
150         
151         mi = (JMenuItem JavaDoc) menu.add(new JMenuItem JavaDoc(resource.getString("wfcontextmenu.adduserrole")));
152         mi.setBackground(new Color JavaDoc(177,177,251));
153         mi.setIcon(new ImageIcon JavaDoc(cl.getResource("images/Role.gif")));
154         mi.setEnabled(manager.getPersistence().hasPermission());
155         mi.addActionListener(new ActionListener JavaDoc() {
156             public void actionPerformed(ActionEvent JavaDoc e) {
157             manager.addUserToRole();
158             }
159         });
160         
161     }
162     return menu;
163     
164
165     }
166     
167 }
168
169
Popular Tags