Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 11 package org.eclipse.core.commands.operations; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 25 public final class ObjectUndoContext extends UndoContext { 26 27 private Object object; 28 29 private String label; 30 31 private List children = new ArrayList (); 32 33 39 public ObjectUndoContext(Object object) { 40 this(object, null); 41 } 42 43 52 public ObjectUndoContext(Object object, String label) { 53 super(); 54 this.object = object; 55 this.label = label; 56 } 57 58 63 public String getLabel() { 64 if (label != null) { 65 return label; 66 } 67 if (object != null) { 68 return object.toString(); 69 } 70 return super.getLabel(); 71 } 72 73 78 public Object getObject() { 79 return object; 80 } 81 82 93 public void addMatch(IUndoContext context) { 94 children.add(context); 95 } 96 97 107 public void removeMatch(IUndoContext context) { 108 children.remove(context); 109 } 110 111 117 public boolean matches(IUndoContext context) { 118 if (children.contains(context)) { 120 return true; 121 } 122 if (context instanceof ObjectUndoContext && getObject() != null) { 124 return getObject().equals(((ObjectUndoContext)context).getObject()); 125 } 126 return super.matches(context); 128 } 129 130 136 public String toString() { 137 return getLabel(); 138 } 139 140 141 } 142
| Popular Tags
|