Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ClientEvents.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (c) 2006-2014 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, PopupMenu.class, AggregateConfigProvider.class),
  44. /** Client event type, with a key argument. */
  45. CLIENT_EVENT_WITH_KEY(new String[]{"key event"}, KeyStroke.class),
  46. /** Client event with an origin and editable buffer. */
  47. CLIENT_EVENT_WITH_BUFFER(new String[]{"origin", "buffer"}, FrameContainer.class, StringBuffer.class),
  48. /** Client event with preferences manager. */
  49. CLIENT_EVENT_WITH_PREFS(new String[]{"preferences manager"}, PreferencesDialogModel.class),
  50. /** Client event with preferences category. */
  51. CLIENT_EVENT_WITH_PREFS_CAT(new String[]{"preferences category", "is server"}, PreferencesCategory.class, Boolean.class),
  52. /** Client event with a styled doc. */
  53. CLIENT_EVENT_WITH_STYLE(new String[]{"styled document", "start offset", "length"}, StyledDocument.class, Integer.class, Integer.class),
  54. /** Unknown command event type. */
  55. UNKNOWN_COMMAND(new String[]{"source", "command", "arguments"}, FrameContainer.class, String.class, String[].class);
  56. /** The names of the arguments for this meta type. */
  57. private String[] argNames;
  58. /** The classes of the arguments for this meta type. */
  59. private Class[] argTypes;
  60. /**
  61. * Creates a new instance of this meta-type.
  62. *
  63. * @param argNames The names of the meta-type's arguments
  64. * @param argTypes The types of the meta-type's arguments
  65. */
  66. ClientEvents(final String[] argNames, final Class ... argTypes) {
  67. this.argNames = argNames;
  68. this.argTypes = argTypes;
  69. }
  70. /** {@inheritDoc} */
  71. @Override
  72. public int getArity() {
  73. return argNames.length;
  74. }
  75. /** {@inheritDoc} */
  76. @Override
  77. public Class[] getArgTypes() {
  78. return argTypes;
  79. }
  80. /** {@inheritDoc} */
  81. @Override
  82. public String[] getArgNames() {
  83. return argNames;
  84. }
  85. /** {@inheritDoc} */
  86. @Override
  87. public String getGroup() {
  88. return "General Events";
  89. }
  90. }