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.

WindowModel.java 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.interfaces;
  23. import com.dmdirc.DMDircMBassador;
  24. import com.dmdirc.commandparser.parsers.CommandParser;
  25. import com.dmdirc.events.FrameIconChangedEvent;
  26. import com.dmdirc.events.FrameTitleChangedEvent;
  27. import com.dmdirc.interfaces.config.AggregateConfigProvider;
  28. import com.dmdirc.ui.input.TabCompleter;
  29. import com.dmdirc.ui.messages.BackBuffer;
  30. import com.dmdirc.ui.messages.UnreadStatusManager;
  31. import java.util.Collection;
  32. import java.util.Date;
  33. import java.util.Optional;
  34. import java.util.Set;
  35. /**
  36. * Models the state of a window.
  37. */
  38. public interface WindowModel {
  39. Optional<WindowModel> getParent();
  40. String getIcon();
  41. String getName();
  42. String getTitle();
  43. AggregateConfigProvider getConfigManager();
  44. DMDircMBassador getEventBus();
  45. boolean isWritable();
  46. /**
  47. * Returns a collection of direct children of this frame.
  48. *
  49. * @return This frame's children
  50. *
  51. * @since 0.6.4
  52. */
  53. Collection<WindowModel> getChildren();
  54. /**
  55. * Adds a new child window to this frame.
  56. *
  57. * @param child The window to be added
  58. *
  59. * @since 0.6.4
  60. */
  61. void addChild(WindowModel child);
  62. /**
  63. * Removes a child window from this frame.
  64. *
  65. * @param child The window to be removed
  66. *
  67. * @since 0.6.4
  68. */
  69. void removeChild(WindowModel child);
  70. /**
  71. * Changes the title of this container, and fires a {@link FrameTitleChangedEvent}.
  72. *
  73. * @param title The new title for this frame.
  74. */
  75. void setTitle(String title);
  76. /**
  77. * Returns the collection of UI component identifiers that this frame container requires for its
  78. * display.
  79. *
  80. * @since 0.6.6
  81. * @return Collection of UI component identifiers
  82. */
  83. Set<String> getComponents();
  84. /**
  85. * Adds a new component to this container.
  86. *
  87. * @since 0.6.6
  88. * @param component The component to be added
  89. */
  90. void addComponent(String component);
  91. /**
  92. * Removes a component from this container.
  93. *
  94. * @since 0.6.6
  95. * @param component The component to be removed
  96. */
  97. void removeComponent(String component);
  98. /**
  99. * Closes this container (and its associated frame).
  100. */
  101. void close();
  102. /**
  103. * Returns the connection that this container is associated with.
  104. *
  105. * @return the associated connection.
  106. */
  107. Optional<Connection> getConnection();
  108. /**
  109. * Sets the icon to be used by this frame container and fires a {@link FrameIconChangedEvent}.
  110. *
  111. * @param icon The new icon to be used
  112. */
  113. void setIcon(String icon);
  114. /**
  115. * Gets the back buffer for this container.
  116. *
  117. * @return This container's back buffer.
  118. */
  119. BackBuffer getBackBuffer();
  120. /**
  121. * Adds a line to this container's window. If the window is null for some reason, the line is
  122. * silently discarded.
  123. *
  124. * @param type The message type to use
  125. * @param timestamp The timestamp to use for this line
  126. * @param args The message's arguments
  127. *
  128. * @since 0.6.4
  129. */
  130. void addLine(String type, Date timestamp, Object... args);
  131. /**
  132. * Adds a line to this container's window. If the window is null for some reason, the line is
  133. * silently discarded.
  134. *
  135. * @param type The message type to use
  136. * @param args The message's arguments
  137. */
  138. void addLine(String type, Object... args);
  139. /**
  140. * Adds the specified raw line to the window, without using a formatter, and using the specified
  141. * timestamp. If the timestamp is <code>null</code>, no timestamp is added.
  142. *
  143. * @param line The line to be added
  144. * @param timestamp The timestamp to use for the line
  145. *
  146. * @since 0.6.4
  147. */
  148. void addLine(String line, Date timestamp);
  149. /**
  150. * Sends a line of text to this container's source.
  151. *
  152. * @param line The line to be sent
  153. */
  154. void sendLine(String line);
  155. /**
  156. * Retrieves the command parser to be used for this container.
  157. *
  158. * @return This container's command parser
  159. */
  160. CommandParser getCommandParser();
  161. /**
  162. * Retrieves the tab completer which should be used for this container.
  163. *
  164. * @return This container's tab completer
  165. */
  166. TabCompleter getTabCompleter();
  167. /**
  168. * Returns the maximum length that a line passed to sendLine() should be, in order to prevent it
  169. * being truncated or causing protocol violations.
  170. *
  171. * @return The maximum line length for this container
  172. */
  173. int getMaxLineLength();
  174. /**
  175. * Returns the number of lines that the specified string would be sent as.
  176. *
  177. * @param line The string to be split and sent
  178. *
  179. * @return The number of lines required to send the specified string
  180. */
  181. int getNumLines(String line);
  182. UnreadStatusManager getUnreadStatusManager();
  183. }