001: package hero.client.grapheditor;
002:
003: import java.awt.Color;
004: import java.awt.Point;
005: import java.awt.event.ActionEvent;
006: import java.awt.event.ActionListener;
007:
008: import javax.swing.ImageIcon;
009: import javax.swing.JFrame;
010: import javax.swing.JMenu;
011: import javax.swing.JMenuItem;
012: import javax.swing.JPopupMenu;
013:
014: public class WFContextMenu {
015:
016: static java.util.ResourceBundle resource = java.util.ResourceBundle
017: .getBundle("resources.Traduction")/*#BundleType=List*/;
018:
019: public static JPopupMenu popupMenu(final JFrame frame,
020: final Point p, final String nodeName,
021: final WFManager manager) {
022:
023: JPopupMenu menu = new JPopupMenu();
024: JMenuItem mi;
025: ClassLoader cl = frame.getClass().getClassLoader();
026:
027: if (nodeName != null) { //BnNode Options
028:
029: JMenu order = (JMenu) menu.add(new JMenu(resource
030: .getString("wfcontextmenu.order")));
031: order.setBackground(new Color(177, 177, 251));
032:
033: mi = (JMenuItem) order.add(new JMenuItem(resource
034: .getString("wfcontextmenu.front")));
035: mi.setBackground(new Color(177, 177, 251));
036: mi.setIcon(new ImageIcon(cl
037: .getResource("images/Forward.gif")));
038: mi.addActionListener(new ActionListener() {
039: public void actionPerformed(ActionEvent e) {
040: manager.getGraph().toFront(nodeName);
041: }
042: });
043:
044: mi = (JMenuItem) order.add(new JMenuItem(resource
045: .getString("wfcontextmenu.back")));
046: mi.setBackground(new Color(177, 177, 251));
047: mi.setIcon(new ImageIcon(cl
048: .getResource("images/Backward.gif")));
049: mi.addActionListener(new ActionListener() {
050: public void actionPerformed(ActionEvent e) {
051: manager.getGraph().toBack(nodeName);
052: }
053: });
054:
055: menu.addSeparator();
056:
057: mi = (JMenuItem) menu.add(new JMenuItem(resource
058: .getString("wfcontextmenu.addprop")));
059: mi.setBackground(new Color(177, 177, 251));
060: mi.setEnabled(manager.getPersistence().hasPermission());
061: mi.addActionListener(new ActionListener() {
062: public void actionPerformed(ActionEvent e) {
063: manager.addNodeProperty(nodeName);
064: }
065: });
066:
067: mi = (JMenuItem) menu.add(new JMenuItem(resource
068: .getString("wfcontextmenu.newhook")));
069: mi.setBackground(new Color(177, 177, 251));
070: mi.setEnabled(manager.getPersistence().hasPermission());
071: mi.addActionListener(new ActionListener() {
072: public void actionPerformed(ActionEvent e) {
073: manager.setNodeHook(nodeName);
074: }
075: });
076:
077: mi = (JMenuItem) menu.add(new JMenuItem(resource
078: .getString("wfcontextmenu.additer")));
079: mi.setBackground(new Color(177, 177, 251));
080: mi.setEnabled(manager.getPersistence().hasPermission());
081: mi.addActionListener(new ActionListener() {
082: public void actionPerformed(ActionEvent e) {
083: manager.iterate(nodeName);
084: }
085: });
086:
087: mi = (JMenuItem) menu.add(new JMenuItem(resource
088: .getString("wfcontextmenu.addperf")));
089: mi.setBackground(new Color(177, 177, 251));
090: mi.setEnabled(manager.getPersistence().hasPermission());
091: mi.addActionListener(new ActionListener() {
092: public void actionPerformed(ActionEvent e) {
093: manager.addPerformerAssigment(nodeName);
094: }
095: });
096:
097: mi = (JMenuItem) menu.add(new JMenuItem(resource
098: .getString("wfcontextmenu.editact")));
099: mi.setBackground(new Color(177, 177, 251));
100: mi.setEnabled(manager.getPersistence().hasPermission());
101: mi.addActionListener(new ActionListener() {
102: public void actionPerformed(ActionEvent e) {
103: manager.editNode(nodeName);
104: }
105: });
106:
107: } else {
108:
109: JMenu project = (JMenu) menu.add(new JMenu(resource
110: .getString("wfcontextmenu.configproj")));
111: project.setBackground(new Color(177, 177, 251));
112:
113: mi = (JMenuItem) project.add(new JMenuItem(resource
114: .getString("wfcontextmenu.addprop")));
115: mi.setBackground(new Color(177, 177, 251));
116: mi.setEnabled(manager.getPersistence().hasPermission());
117: mi.addActionListener(new ActionListener() {
118: public void actionPerformed(ActionEvent e) {
119: manager.addProjectProperty();
120: }
121: });
122:
123: mi = (JMenuItem) project.add(new JMenuItem(resource
124: .getString("wfcontextmenu.newhook")));
125: mi.setBackground(new Color(177, 177, 251));
126: mi.setEnabled(manager.getPersistence().hasPermission());
127: mi.addActionListener(new ActionListener() {
128: public void actionPerformed(ActionEvent e) {
129: manager.setProjectHook();
130: }
131: });
132:
133: menu.addSeparator();
134:
135: mi = (JMenuItem) menu.add(new JMenuItem(resource
136: .getString("wfcontextmenu.newuser")));
137: mi.setBackground(new Color(177, 177, 251));
138: mi
139: .setIcon(new ImageIcon(cl
140: .getResource("images/User.gif")));
141: mi.setEnabled(manager.getPersistence().hasPermission());
142: mi.addActionListener(new ActionListener() {
143: public void actionPerformed(ActionEvent e) {
144: manager.newUser();
145: }
146: });
147: mi = (JMenuItem) menu.add(new JMenuItem(resource
148: .getString("wfcontextmenu.userproj")));
149: mi.setBackground(new Color(177, 177, 251));
150: mi
151: .setIcon(new ImageIcon(cl
152: .getResource("images/User2.gif")));
153: mi.setEnabled(manager.getPersistence().hasPermission());
154: mi.addActionListener(new ActionListener() {
155: public void actionPerformed(ActionEvent e) {
156: manager.usersInProject();
157: }
158: });
159:
160: menu.addSeparator();
161:
162: mi = (JMenuItem) menu.add(new JMenuItem(resource
163: .getString("wfcontextmenu.addrole")));
164: mi.setBackground(new Color(177, 177, 251));
165: mi
166: .setIcon(new ImageIcon(cl
167: .getResource("images/Role2.gif")));
168: mi.setEnabled(manager.getPersistence().hasPermission());
169: mi.addActionListener(new ActionListener() {
170: public void actionPerformed(ActionEvent e) {
171: manager.newRole();
172: }
173: });
174:
175: mi = (JMenuItem) menu.add(new JMenuItem(resource
176: .getString("wfcontextmenu.adduserrole")));
177: mi.setBackground(new Color(177, 177, 251));
178: mi
179: .setIcon(new ImageIcon(cl
180: .getResource("images/Role.gif")));
181: mi.setEnabled(manager.getPersistence().hasPermission());
182: mi.addActionListener(new ActionListener() {
183: public void actionPerformed(ActionEvent e) {
184: manager.addUserToRole();
185: }
186: });
187:
188: }
189: return menu;
190:
191: }
192:
193: }
|