You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ClientEvents.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.actions.metatypes;
  23. import com.dmdirc.FrameContainer;
  24. import com.dmdirc.actions.interfaces.ActionMetaType;
  25. import com.dmdirc.commandparser.PopupMenu;
  26. import com.dmdirc.commandparser.PopupType;
  27. import com.dmdirc.config.ConfigManager;
  28. import com.dmdirc.config.prefs.PreferencesManager;
  29. import javax.swing.KeyStroke;
  30. import javax.swing.text.StyledDocument;
  31. /**
  32. * Defines client-wide events.
  33. *
  34. * @author Chris
  35. */
  36. public enum ClientEvents implements ActionMetaType {
  37. /** Client event type. */
  38. CLIENT_EVENT(new String[]{}),
  39. /** Client event type, with a frame argument. */
  40. WINDOW_EVENT(new String[]{"window"}, FrameContainer.class),
  41. /** Client event with frame and message. */
  42. WINDOW_EVENT_WITH_MESSAGE(new String[]{"window", "message"}, FrameContainer.class, String.class),
  43. /** A popup-related event. */
  44. POPUP_EVENT(new String[]{"popup type", "popup", "configuration manager"}, PopupType.class, PopupMenu.class, ConfigManager.class),
  45. /** Client event type, with a key argument. */
  46. CLIENT_EVENT_WITH_KEY(new String[]{"key event"}, KeyStroke.class),
  47. /** Client event with an origin and editable buffer. */
  48. CLIENT_EVENT_WITH_BUFFER(new String[]{"origin", "buffer"}, FrameContainer.class, StringBuffer.class),
  49. /** Client event with preferences manager. */
  50. CLIENT_EVENT_WITH_PREFS(new String[]{"preferences manager"}, PreferencesManager.class),
  51. /** Client event with a styled doc. */
  52. CLIENT_EVENT_WITH_STYLE(new String[]{"styled document", "start offset", "length"}, StyledDocument.class, Integer.class, Integer.class),
  53. /** Unknown command event type. */
  54. UNKNOWN_COMMAND(new String[]{"source", "command", "arguments"}, FrameContainer.class, String.class, String[].class);
  55. /** The names of the arguments for this meta type. */
  56. private String[] argNames;
  57. /** The classes of the arguments for this meta type. */
  58. private Class[] argTypes;
  59. /**
  60. * Creates a new instance of this meta-type.
  61. *
  62. * @param argNames The names of the meta-type's arguments
  63. * @param argTypes The types of the meta-type's arguments
  64. */
  65. ClientEvents(final String[] argNames, final Class ... argTypes) {
  66. this.argNames = argNames;
  67. this.argTypes = argTypes;
  68. }
  69. /** {@inheritDoc} */
  70. @Override
  71. public int getArity() {
  72. return argNames.length;
  73. }
  74. /** {@inheritDoc} */
  75. @Override
  76. public Class[] getArgTypes() {
  77. return argTypes;
  78. }
  79. /** {@inheritDoc} */
  80. @Override
  81. public String[] getArgNames() {
  82. return argNames;
  83. }
  84. /** {@inheritDoc} */
  85. @Override
  86. public String getGroup() {
  87. return "General Events";
  88. }
  89. }