1 19 package org.netbeans.modules.diff.builtin.visualizer; 20 21 import java.awt.event.ActionEvent ; 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.beans.PropertyChangeSupport ; 25 import javax.swing.Action ; 26 27 28 33 public class SourceTranslatorAction implements Action , PropertyChangeListener { 34 35 final Action scrollAction; 36 final Object source; 37 final PropertyChangeSupport support; 38 39 public SourceTranslatorAction(Action action, Object source) { 40 scrollAction = action; 41 this.source = source; 42 support = new PropertyChangeSupport (action); 43 } 44 45 public Object getValue(String key) { 46 return scrollAction.getValue(key); 47 } 48 49 public void putValue(String key, Object value) { 50 scrollAction.putValue(key, value); 51 } 52 53 public void setEnabled(boolean b) { 54 scrollAction.setEnabled(b); 55 } 56 57 public boolean isEnabled() { 58 return scrollAction.isEnabled(); 59 } 60 61 public void addPropertyChangeListener(PropertyChangeListener listener) { 62 if (support.hasListeners(null) == false) { 63 scrollAction.addPropertyChangeListener(this); 64 } 65 support.addPropertyChangeListener(listener); 66 } 67 68 public void removePropertyChangeListener(PropertyChangeListener listener) { 69 support.removePropertyChangeListener(listener); 70 if (support.hasListeners(null) == false) { 71 scrollAction.removePropertyChangeListener(this); 72 } 73 } 74 75 public void actionPerformed(ActionEvent e) { 76 ActionEvent event = new ActionEvent (source, e.getID(), e.getActionCommand(), e.getWhen(), e.getModifiers()); 77 scrollAction.actionPerformed(event); 78 } 79 80 public void propertyChange(PropertyChangeEvent evt) { 81 support.firePropertyChange(evt); 82 } 83 } | Popular Tags |