1 19 package org.openide.actions; 20 21 import org.openide.util.Lookup; 22 import org.openide.util.actions.SystemAction; 23 24 import java.awt.event.ActionEvent ; 25 26 import java.beans.*; 27 28 import javax.swing.Action ; 29 30 31 36 public abstract class ActionManager extends Object { 37 40 public static final String PROP_CONTEXT_ACTIONS = "contextActions"; 42 43 private PropertyChangeSupport supp = null; 44 45 50 public static ActionManager getDefault() { 51 ActionManager am = (ActionManager) Lookup.getDefault().lookup(ActionManager.class); 52 53 if (am == null) { 54 am = new Trivial(); 55 } 56 57 return am; 58 } 59 60 66 public abstract SystemAction[] getContextActions(); 67 68 73 public void invokeAction(Action a, ActionEvent e) { 74 a.actionPerformed(e); 75 } 76 77 80 public final void addPropertyChangeListener(PropertyChangeListener listener) { 81 if (supp == null) { 82 supp = new PropertyChangeSupport(this); 83 } 84 85 supp.addPropertyChangeListener(listener); 86 } 87 88 91 public final void removePropertyChangeListener(PropertyChangeListener listener) { 92 if (supp != null) { 93 supp.removePropertyChangeListener(listener); 94 } 95 } 96 97 102 protected final void firePropertyChange(String name, Object o, Object n) { 103 if (supp != null) { 104 supp.firePropertyChange(name, o, n); 105 } 106 } 107 108 112 private static final class Trivial extends ActionManager { 113 public SystemAction[] getContextActions() { 114 return new SystemAction[0]; 115 } 116 } 117 } 118 | Popular Tags |