1 23 24 package org.apache.slide.event; 25 26 import org.apache.slide.common.Namespace; 27 import org.apache.slide.common.SlideToken; 28 29 import java.util.EventListener ; 30 import java.util.EventObject ; 31 32 37 public class MacroEvent extends EventObject implements RemoteInformation { 38 public final static Move MOVE = new Move(); 39 public final static Copy COPY = new Copy(); 40 public final static Delete DELETE = new Delete(); 41 42 public final static String GROUP = "macro"; 43 public final static AbstractEventMethod[] methods = new AbstractEventMethod[] { MOVE, COPY, DELETE }; 44 45 protected final static String SOURCE_URI_KEY = "source-uri"; 46 protected final static String TARGET_URI_KEY = "target-uri"; 47 private String sourceURI, targetURI; 48 private SlideToken token; 49 private Namespace namespace; 50 51 public MacroEvent(Object source, SlideToken token, Namespace namespace, String tagetURI) { 52 this(source, token, namespace, null, tagetURI); 53 } 54 55 public MacroEvent(Object source, SlideToken token, Namespace namespace, String sourceURI, String targetURI) { 56 super(source); 57 this.sourceURI = sourceURI; 58 this.targetURI = targetURI; 59 this.token = token; 60 this.namespace = namespace; 61 } 62 63 public SlideToken getToken() { 64 return token; 65 } 66 67 public Namespace getNamespace() { 68 return namespace; 69 } 70 71 public String getSourceURI() { 72 return sourceURI; 73 } 74 75 public String getTargetURI() { 76 return targetURI; 77 } 78 79 public String toString() { 80 StringBuffer buffer = new StringBuffer (256); 81 buffer.append(getClass().getName()).append("[source-uri=").append(sourceURI); 82 buffer.append(", target-uri=").append(targetURI); 83 buffer.append("]"); 84 return buffer.toString(); 85 } 86 87 public String [][] getInformation() { 88 return new String [][] { { SOURCE_URI_KEY, sourceURI }, 89 { TARGET_URI_KEY, targetURI }}; 90 } 91 92 public final static class Copy extends VetoableEventMethod { 93 public Copy() { 94 super(GROUP, "copy"); 95 } 96 97 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 98 if ( listener instanceof MacroListener ) ((MacroListener)listener).copy((MacroEvent)event); 99 } 100 } 101 102 public final static class Move extends VetoableEventMethod { 103 public Move() { 104 super(GROUP, "move"); 105 } 106 107 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 108 if ( listener instanceof MacroListener ) ((MacroListener)listener).move((MacroEvent)event); 109 } 110 } 111 112 public final static class Delete extends VetoableEventMethod { 113 public Delete() { 114 super(GROUP, "delete"); 115 } 116 117 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 118 if ( listener instanceof MacroListener ) ((MacroListener)listener).delete((MacroEvent)event); 119 } 120 } 121 } | Popular Tags |