1 19 20 package org.netbeans.modules.versioning.util; 21 22 import org.openide.util.actions.SystemAction; 23 import org.openide.util.Lookup; 24 import org.openide.util.ContextAwareAction; 25 26 import javax.swing.*; 27 import java.awt.event.ActionEvent ; 28 29 34 public class SystemActionBridge extends AbstractAction { 35 36 private Action action; 37 38 public static SystemActionBridge createAction(Action action, String name, Lookup context) { 39 if (context != null && action instanceof ContextAwareAction) { 40 action = ((ContextAwareAction) action).createContextAwareInstance(context); 41 } 42 return new SystemActionBridge(action, name); 43 } 44 45 public SystemActionBridge(Action action, String name) { 46 super(name, null); 47 putValue("noIconInMenu", Boolean.TRUE); this.action = action; 49 } 50 51 public void actionPerformed(ActionEvent e) { 52 action.actionPerformed(e); 53 } 54 55 public boolean isEnabled() { 56 return action.isEnabled(); 57 } 58 } 59 | Popular Tags |