1 package hero.client.grapheditor; 2 3 import java.awt.Color ; 4 import java.awt.Point ; 5 import java.awt.event.ActionEvent ; 6 import java.awt.event.ActionListener ; 7 8 import javax.swing.ImageIcon ; 9 import javax.swing.JFrame ; 10 import javax.swing.JMenu ; 11 import javax.swing.JMenuItem ; 12 import javax.swing.JPopupMenu ; 13 14 public class WFContextMenu { 15 16 static java.util.ResourceBundle resource = java.util.ResourceBundle.getBundle("resources.Traduction"); 17 18 public static JPopupMenu popupMenu(final JFrame frame, final Point p,final String nodeName,final WFManager manager){ 19 20 JPopupMenu menu = new JPopupMenu (); 21 JMenuItem mi; 22 ClassLoader cl = frame.getClass().getClassLoader(); 23 24 if(nodeName!=null){ 26 JMenu order = (JMenu ) menu.add(new JMenu (resource.getString("wfcontextmenu.order"))); 27 order.setBackground(new Color (177,177,251)); 28 29 mi =(JMenuItem ) order.add(new JMenuItem (resource.getString("wfcontextmenu.front"))); 30 mi.setBackground(new Color (177,177,251)); 31 mi.setIcon(new ImageIcon (cl.getResource("images/Forward.gif"))); 32 mi.addActionListener (new ActionListener () { 33 public void actionPerformed (ActionEvent e) { 34 manager.getGraph().toFront(nodeName); 35 } 36 }); 37 38 mi = (JMenuItem ) order.add(new JMenuItem (resource.getString("wfcontextmenu.back"))); 39 mi.setBackground(new Color (177,177,251)); 40 mi.setIcon(new ImageIcon (cl.getResource("images/Backward.gif"))); 41 mi.addActionListener (new ActionListener () { 42 public void actionPerformed (ActionEvent e) { 43 manager.getGraph().toBack(nodeName); 44 } 45 }); 46 47 menu.addSeparator(); 48 49 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.addprop"))); 50 mi.setBackground(new Color (177,177,251)); 51 mi.setEnabled(manager.getPersistence().hasPermission()); 52 mi.addActionListener(new ActionListener () { 53 public void actionPerformed(ActionEvent e) { 54 manager.addNodeProperty(nodeName); 55 } 56 }); 57 58 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.newhook"))); 59 mi.setBackground(new Color (177,177,251)); 60 mi.setEnabled(manager.getPersistence().hasPermission()); 61 mi.addActionListener(new ActionListener () { 62 public void actionPerformed(ActionEvent e) { 63 manager.setNodeHook(nodeName); 64 } 65 }); 66 67 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.additer"))); 68 mi.setBackground(new Color (177,177,251)); 69 mi.setEnabled(manager.getPersistence().hasPermission()); 70 mi.addActionListener(new ActionListener () { 71 public void actionPerformed(ActionEvent e) { 72 manager.iterate(nodeName); 73 } 74 }); 75 76 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.addperf"))); 77 mi.setBackground(new Color (177,177,251)); 78 mi.setEnabled(manager.getPersistence().hasPermission()); 79 mi.addActionListener(new ActionListener () { 80 public void actionPerformed(ActionEvent e) { 81 manager.addPerformerAssigment(nodeName); 82 } 83 }); 84 85 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.editact"))); 86 mi.setBackground(new Color (177,177,251)); 87 mi.setEnabled(manager.getPersistence().hasPermission()); 88 mi.addActionListener(new ActionListener () { 89 public void actionPerformed(ActionEvent e) { 90 manager.editNode(nodeName); 91 } 92 }); 93 94 } else { 95 96 JMenu project = (JMenu ) menu.add(new JMenu (resource.getString("wfcontextmenu.configproj"))); 97 project.setBackground(new Color (177, 177, 251)); 98 99 mi = (JMenuItem ) project.add(new JMenuItem (resource.getString("wfcontextmenu.addprop"))); 100 mi.setBackground(new Color (177, 177, 251)); 101 mi.setEnabled(manager.getPersistence().hasPermission()); 102 mi.addActionListener(new ActionListener () { 103 public void actionPerformed(ActionEvent e) { 104 manager.addProjectProperty(); 105 } 106 }); 107 108 mi = (JMenuItem ) project.add(new JMenuItem (resource.getString("wfcontextmenu.newhook"))); 109 mi.setBackground(new Color (177, 177, 251)); 110 mi.setEnabled(manager.getPersistence().hasPermission()); 111 mi.addActionListener(new ActionListener () { 112 public void actionPerformed(ActionEvent e) { 113 manager.setProjectHook(); 114 } 115 }); 116 117 menu.addSeparator(); 118 119 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.newuser"))); 120 mi.setBackground(new Color (177,177,251)); 121 mi.setIcon(new ImageIcon (cl.getResource("images/User.gif"))); 122 mi.setEnabled(manager.getPersistence().hasPermission()); 123 mi.addActionListener(new ActionListener () { 124 public void actionPerformed(ActionEvent e) { 125 manager.newUser(); 126 } 127 }); 128 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.userproj"))); 129 mi.setBackground(new Color (177,177,251)); 130 mi.setIcon(new ImageIcon (cl.getResource("images/User2.gif"))); 131 mi.setEnabled(manager.getPersistence().hasPermission()); 132 mi.addActionListener(new ActionListener () { 133 public void actionPerformed(ActionEvent e) { 134 manager.usersInProject(); 135 } 136 }); 137 138 139 menu.addSeparator(); 140 141 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.addrole"))); 142 mi.setBackground(new Color (177,177,251)); 143 mi.setIcon(new ImageIcon (cl.getResource("images/Role2.gif"))); 144 mi.setEnabled(manager.getPersistence().hasPermission()); 145 mi.addActionListener(new ActionListener () { 146 public void actionPerformed(ActionEvent e) { 147 manager.newRole(); 148 } 149 }); 150 151 mi = (JMenuItem ) menu.add(new JMenuItem (resource.getString("wfcontextmenu.adduserrole"))); 152 mi.setBackground(new Color (177,177,251)); 153 mi.setIcon(new ImageIcon (cl.getResource("images/Role.gif"))); 154 mi.setEnabled(manager.getPersistence().hasPermission()); 155 mi.addActionListener(new ActionListener () { 156 public void actionPerformed(ActionEvent e) { 157 manager.addUserToRole(); 158 } 159 }); 160 161 } 162 return menu; 163 164 165 } 166 167 } 168 169 | Popular Tags |