1 11 package org.eclipse.jface.action; 12 13 import org.eclipse.jface.resource.ImageDescriptor; 14 import org.eclipse.swt.events.HelpListener; 15 import org.eclipse.swt.widgets.Control; 16 import org.eclipse.swt.widgets.Event; 17 import org.eclipse.swt.widgets.Menu; 18 19 26 public abstract class Action extends AbstractAction implements IAction { 27 28 private static final IMenuCreator VAL_DROP_DOWN_MENU = new IMenuCreator() { 29 public void dispose() { 30 } 32 33 public Menu getMenu(Control parent) { 34 return null; 36 } 37 38 public Menu getMenu(Menu parent) { 39 return null; 41 } 42 }; 43 44 48 private static final String VAL_PUSH_BTN = "PUSH_BTN"; 50 private static final Integer VAL_RADIO_BTN_OFF = new Integer (0); 51 52 private static final Integer VAL_RADIO_BTN_ON = new Integer (1); 53 54 private static final Boolean VAL_TOGGLE_BTN_OFF = Boolean.FALSE; 55 56 private static final Boolean VAL_TOGGLE_BTN_ON = Boolean.TRUE; 57 58 65 public static String convertAccelerator(int keyCode) { 66 return LegacyActionTools.convertAccelerator(keyCode); 67 } 68 69 77 public static int convertAccelerator(String acceleratorText) { 78 return LegacyActionTools.convertAccelerator(acceleratorText); 79 } 80 81 111 public static int findKeyCode(String token) { 112 return LegacyActionTools.findKeyCode(token); 113 } 114 115 128 public static String findKeyString(int keyCode) { 129 return LegacyActionTools.findKeyString(keyCode); 130 } 131 132 144 public static int findModifier(String token) { 145 return LegacyActionTools.findModifier(token); 146 } 147 148 160 public static String findModifierString(int keyCode) { 161 return LegacyActionTools.findModifierString(keyCode); 162 } 163 164 173 public static String removeAcceleratorText(String text) { 174 return LegacyActionTools.removeAcceleratorText(text); 175 } 176 177 188 public static String removeMnemonics(String text) { 189 return LegacyActionTools.removeMnemonics(text); 190 } 191 192 195 private int accelerator = 0; 196 197 200 private String actionDefinitionId; 201 202 205 private String description; 206 207 210 private ImageDescriptor disabledImage; 211 212 215 private boolean enabled = true; 216 217 220 private HelpListener helpListener; 221 222 225 private ImageDescriptor hoverImage; 226 227 230 private String id; 231 232 235 private ImageDescriptor image; 236 237 240 private String text; 241 242 245 private String toolTipText; 246 247 255 private Object value = null; 256 257 263 protected Action() { 264 } 266 267 276 protected Action(String text) { 277 this(); 278 setText(text); 279 } 280 281 294 protected Action(String text, ImageDescriptor image) { 295 this(text); 296 setImageDescriptor(image); 297 } 298 299 310 protected Action(String text, int style) { 311 this(text); 312 switch (style) { 313 case AS_PUSH_BUTTON: 314 value = VAL_PUSH_BTN; 315 break; 316 case AS_CHECK_BOX: 317 value = VAL_TOGGLE_BTN_OFF; 318 break; 319 case AS_DROP_DOWN_MENU: 320 value = VAL_DROP_DOWN_MENU; 321 break; 322 case AS_RADIO_BUTTON: 323 value = VAL_RADIO_BTN_OFF; 324 break; 325 } 326 } 327 328 331 public int getAccelerator() { 332 return accelerator; 333 } 334 335 339 public String getActionDefinitionId() { 340 return actionDefinitionId; 341 } 342 343 346 public String getDescription() { 347 if (description != null) { 348 return description; 349 &nb
|