PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/bundles/plugins-trunk/CommonControls/common/gui/actions/CustomAction.java

#
Java | 81 lines | 50 code | 16 blank | 15 comment | 0 complexity | b6078092df3d0ff9346b78dd958a7ffe MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. package common.gui.actions;
  2. import java.awt.event.*;
  3. import java.net.*;
  4. import javax.swing.*;
  5. /**
  6. * An old class that probably should not be used anymore.
  7. *
  8. * @author mace
  9. * @created October 24, 2002
  10. * @modified $Date: 2012-03-13 17:07:11 +0100 (Tue, 13 Mar 2012) $ by $Author: ezust $
  11. * @version $Revision: 21349 $
  12. * @deprecated
  13. */
  14. @Deprecated
  15. public abstract class CustomAction extends AbstractAction {
  16. public final static int CTRL = KeyEvent.CTRL_MASK;
  17. public final static int ALT = KeyEvent.ALT_MASK;
  18. public final static int SHIFT = KeyEvent.SHIFT_MASK;
  19. public final static int META = KeyEvent.META_MASK;
  20. /**
  21. * The Action's tool tip text is set to it's name by default.
  22. *
  23. * @param name Description of the Parameter
  24. */
  25. public CustomAction(String name) {
  26. super(name);
  27. setActionCommand(name);
  28. setToolTipText(name);
  29. }
  30. public CustomAction(String name, Icon icon) {
  31. super(name, icon);
  32. setActionCommand(name);
  33. setToolTipText(name);
  34. }
  35. public void setToolTipText(String text) {
  36. putValue(SHORT_DESCRIPTION, text);
  37. }
  38. public void setContextualHelp(String text) {
  39. putValue(LONG_DESCRIPTION, text);
  40. }
  41. public void setAccelerator(KeyStroke ks) {
  42. putValue(ACCELERATOR_KEY, ks);
  43. }
  44. public void setAccelerator(int key, int modifiers) {
  45. KeyStroke ks = KeyStroke.getKeyStroke(key, modifiers);
  46. setAccelerator(ks);
  47. }
  48. public void setMnemonic(int key) {
  49. putValue(MNEMONIC_KEY, new Integer(key));
  50. }
  51. public void setName(String name) {
  52. putValue(NAME, name);
  53. }
  54. public void setIcon(String file) {
  55. //URL iconURL = ClassLoader.getSystemResource(file);
  56. ImageIcon icon = new ImageIcon(file);
  57. setIcon(icon);
  58. }
  59. public void setIcon(Icon i) {
  60. putValue(SMALL_ICON, i);
  61. }
  62. public void setActionCommand(String command) {
  63. putValue(ACTION_COMMAND_KEY, command);
  64. }
  65. }