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 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2006-2015 DMDirc Developers
  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.commandparser.PopupMenu;
  25. import com.dmdirc.commandparser.PopupType;
  26. import com.dmdirc.config.prefs.PreferencesCategory;
  27. import com.dmdirc.config.prefs.PreferencesDialogModel;
  28. import com.dmdirc.interfaces.actions.ActionMetaType;
  29. import com.dmdirc.interfaces.config.AggregateConfigProvider;
  30. import javax.swing.KeyStroke;
  31. import javax.swing.text.StyledDocument;
  32. /**
  33. * Defines client-wide events.
  34. */
  35. public enum ClientEvents implements ActionMetaType {
  36. /** Client event type. */
  37. CLIENT_EVENT(new String[]{}),
  38. /** Client event type, with a frame argument. */
  39. WINDOW_EVENT(new String[]{"window"}, FrameContainer.class),
  40. /** Client event with frame and message. */
  41. WINDOW_EVENT_WITH_MESSAGE(new String[]{"window", "message"}, FrameContainer.class, String.class),
  42. /** A popup-related event. */
  43. POPUP_EVENT(new String[]{"popup type", "popup", "configuration provider"}, PopupType.class,
  44. PopupMenu.class, AggregateConfigProvider.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
  48. * editable buffer. */
  49. CLIENT_EVENT_WITH_BUFFER(new String[]{"origin", "buffer"}, FrameContainer.class,
  50. StringBuffer.class),
  51. /** Client event with preferences manager. */
  52. CLIENT_EVENT_WITH_PREFS(new String[]{"preferences manager"}, PreferencesDialogModel.class),
  53. /** Client event with preferences category. */
  54. CLIENT_EVENT_WITH_PREFS_CAT(new String[]{"preferences category", "is server"},
  55. PreferencesCategory.class, Boolean.class),
  56. /** Client event with a styled doc. */
  57. CLIENT_EVENT_WITH_STYLE(new String[]{"styled document", "start offset", "length"},
  58. StyledDocument.class, Integer.class, Integer.class),
  59. /** Unknown command event type. */
  60. UNKNOWN_COMMAND(new String[]{"source", "command", "arguments"}, FrameContainer.class,
  61. String.class, String[].class);
  62. /** The names of the arguments for this meta type. */
  63. private final String[] argNames;
  64. /** The classes of the arguments for this meta type. */
  65. private final Class<?>[] argTypes;
  66. /**
  67. * Creates a new instance of this meta-type.
  68. *
  69. * @param argNames The names of the meta-type's arguments
  70. * @param argTypes The types of the meta-type's arguments
  71. */
  72. ClientEvents(final String[] argNames, final Class<?>... argTypes) {
  73. this.argNames = argNames;
  74. this.argTypes = argTypes;
  75. }
  76. @Override
  77. public int getArity() {
  78. return argNames.length;
  79. }
  80. @Override
  81. public Class<?>[] getArgTypes() {
  82. return argTypes;
  83. }
  84. @Override
  85. public String[] getArgNames() {
  86. return argNames;
  87. }
  88. @Override
  89. public String getGroup() {
  90. return "General Events";
  91. }
  92. }