1 11 12 package org.eclipse.core.commands; 13 14 import org.eclipse.core.commands.common.EventManager; 15 import org.eclipse.core.internal.commands.util.Util; 16 17 35 public class State extends EventManager { 36 37 41 private String id; 42 43 46 private Object value; 47 48 54 public void addListener(final IStateListener listener) { 55 addListenerObject(listener); 56 } 57 58 62 public void dispose() { 63 } 65 66 72 protected final void fireStateChanged(final Object oldValue) { 73 final Object [] listeners = getListeners(); 74 for (int i = 0; i < listeners.length; i++) { 75 final IStateListener listener = (IStateListener) listeners[i]; 76 listener.handleStateChange(this, oldValue); 77 } 78 } 79 80 85 public final String getId() { 86 return id; 87 } 88 89 96 97 public Object getValue() { 98 return value; 99 } 100 101 107 108 public void removeListener(final IStateListener listener) { 109 removeListenerObject(listener); 110 } 111 112 119 public void setId(final String id) { 120 this.id = id; 121 } 122 123 129 public void setValue(final Object value) { 130 if (!Util.equals(this.value, value)) { 131 final Object oldValue = this.value; 132 this.value = value; 133 fireStateChanged(oldValue); 134 } 135 } 136 } 137 | Popular Tags |