1 22 23 package org.gjt.sp.jedit; 24 25 import java.awt.event.ActionEvent ; 27 import java.awt.event.ActionListener ; 28 import java.awt.Component ; 29 30 import org.gjt.sp.util.Log; 31 33 46 public abstract class EditAction 47 { 48 private String name; 50 51 protected Object [] args; 52 53 55 60 public EditAction(String name) 61 { 62 this.name = name; 63 } 64 65 public EditAction(String name, Object [] newArgs) { 66 this.name = name; 67 this.args = newArgs; 68 } 69 70 74 public String getName() 75 { 76 return name; 77 } 79 84 public void setName(String newName) { 85 name = newName; 86 } 87 88 95 public String getLabel() 96 { 97 if (args != null) { 98 return jEdit.getProperty(name + ".label", args); 99 } 100 return jEdit.getProperty(name + ".label"); 101 } 103 109 public final String getMouseOverText() 110 { 111 return jEdit.getProperty(name + ".mouse-over"); 112 } 114 123 abstract public void invoke(View view); 124 125 131 final public void invoke(View view, Object [] newArgs) { 132 args = newArgs; 133 invoke(view); 134 } 135 136 140 public static View getView(Component comp) 141 { 142 return GUIUtilities.getView(comp); 144 } 146 155 public final boolean isToggle() 156 { 157 return jEdit.getBooleanProperty(name + ".toggle"); 158 } 160 166 public boolean isSelected(Component comp) 167 { 168 return false; 169 } 171 177 public boolean noRepeat() 178 { 179 return false; 180 } 182 188 public boolean noRecord() 189 { 190 return false; 191 } 193 199 public boolean noRememberLast() 200 { 201 return false; 202 } 204 216 public String getCode() 217 { 218 return "jEdit.getAction(" + name + ").invoke(view); "; 219 } 220 222 public String toString() 224 { 225 return name; 226 } 228 233 public static class Wrapper implements ActionListener 234 { 235 236 private ActionContext context; 237 private String actionName; 238 239 243 public Wrapper(ActionContext context, String actionName) 244 { 245 this.context = context; 246 this.actionName = actionName; 247 } 248 249 257 public void actionPerformed(ActionEvent evt) 258 { 259 EditAction action = context.getAction(actionName); 260 if(action == null) 261 { 262 Log.log(Log.WARNING,this,"Unknown action: " 263 + actionName); 264 } 265 else 266 context.invokeAction(evt,action); 267 } 268 269 270 } } 272 | Popular Tags |