1 package net.suberic.util.thread; 2 import net.suberic.util.DynamicAbstractAction; 3 import javax.swing.Action ; 4 import javax.swing.Icon ; 5 import javax.swing.AbstractAction ; 6 import java.beans.PropertyChangeListener ; 7 import java.awt.event.ActionEvent ; 8 9 15 public class ActionWrapper extends net.suberic.util.DynamicAbstractAction { 16 Action wrappedAction; 17 ActionThread thread; 18 19 22 public ActionWrapper(Action newWrappedAction, ActionThread newThread) { 23 super(); 24 wrappedAction=newWrappedAction; 25 thread=newThread; 26 } 27 28 31 public void actionPerformed(ActionEvent e) { 32 thread.addToQueue(wrappedAction, e); 33 } 34 35 38 public void addPropertyChangeListener(PropertyChangeListener listener) { 39 wrappedAction.addPropertyChangeListener(listener); 40 } 41 42 45 public Object getValue(String key) { 46 return wrappedAction.getValue(key); 47 } 48 49 52 public boolean isEnabled() { 53 return wrappedAction.isEnabled(); 54 } 55 56 59 public void putValue(String key, Object newValue) { 60 wrappedAction.putValue(key, newValue); 61 super.putValue(key, newValue); 64 } 65 66 69 public void removePropertyChangeListener(PropertyChangeListener listener) { 70 wrappedAction.removePropertyChangeListener(listener); 71 } 72 73 76 public void setEnabled(boolean newValue) { 77 wrappedAction.setEnabled(newValue); 78 } 79 80 public Action getWrappedAction() { 81 return wrappedAction; 82 } 83 84 public void setWrappedAction(Action newValue) { 85 wrappedAction = newValue; 86 } 87 88 public ActionThread getThread() { 89 return thread; 90 } 91 92 public void setThread(ActionThread newValue) { 93 thread=newValue; 94 } 95 96 public Action cloneDynamicAction() throws CloneNotSupportedException { 97 if (wrappedAction instanceof DynamicAbstractAction) { 98 this.putValue("bugWorkaround", "true"); 99 ActionWrapper newAction = (ActionWrapper)this.clone(); 100 newAction.setWrappedAction(((DynamicAbstractAction) wrappedAction).cloneDynamicAction()); 101 return newAction; 102 } else { 103 throw new CloneNotSupportedException (); 104 } 105 } 106 107 } 108 | Popular Tags |