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.

DummyInputWindow.java 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.addons.ui_dummy;
  23. import com.dmdirc.WritableFrameContainer;
  24. import com.dmdirc.commandparser.parsers.CommandParser;
  25. import com.dmdirc.config.ConfigManager;
  26. import com.dmdirc.config.IdentityManager;
  27. import com.dmdirc.ui.input.InputHandler;
  28. import com.dmdirc.ui.interfaces.InputWindow;
  29. import com.dmdirc.util.StringTranscoder;
  30. import java.nio.charset.Charset;
  31. import java.util.Arrays;
  32. /**
  33. * Dummy input window, used for testing.
  34. */
  35. public class DummyInputWindow implements InputWindow {
  36. /** Window title. */
  37. private String title;
  38. /** Are we visible? */
  39. private boolean visible;
  40. /** are we maximised? */
  41. private boolean maximised;
  42. /** Our container. */
  43. private final WritableFrameContainer container;
  44. /** Our command parser. */
  45. private final CommandParser commandParser;
  46. /**
  47. * Instantiates a new DummyInputWindow.
  48. *
  49. * @param owner Parent window
  50. * @param commandParser Parent command parser
  51. */
  52. public DummyInputWindow(final WritableFrameContainer owner,
  53. final CommandParser commandParser) {
  54. this.container = owner;
  55. this.commandParser = commandParser;
  56. }
  57. /** {@inheritDoc} */
  58. @Override
  59. public CommandParser getCommandParser() {
  60. return commandParser;
  61. }
  62. /** {@inheritDoc} */
  63. @Override
  64. public InputHandler getInputHandler() {
  65. return new DummyInputHandler(new DummyInputField(), null, this);
  66. }
  67. /** {@inheritDoc} */
  68. @Override
  69. public void setAwayIndicator(final boolean isAway) {
  70. // Do nothing
  71. }
  72. /** {@inheritDoc} */
  73. @Override
  74. public void addLine(final String messageType, final Object... args) {
  75. System.out.println("DummyInputWindow.addLine(" + messageType + ", " + Arrays.toString(args) + ")");
  76. }
  77. /** {@inheritDoc} */
  78. @Override
  79. public void addLine(final StringBuffer messageType, final Object... args) {
  80. addLine(messageType.toString(), args);
  81. }
  82. /** {@inheritDoc} */
  83. @Override
  84. public void addLine(final String line, final boolean timestamp) {
  85. throw new UnsupportedOperationException("Not supported yet.");
  86. }
  87. /** {@inheritDoc} */
  88. @Override
  89. public void clear() {
  90. throw new UnsupportedOperationException("Not supported yet.");
  91. }
  92. /** {@inheritDoc} */
  93. @Override
  94. public ConfigManager getConfigManager() {
  95. return IdentityManager.getGlobalConfig();
  96. }
  97. /** {@inheritDoc} */
  98. @Override
  99. public WritableFrameContainer getContainer() {
  100. return container;
  101. }
  102. /** {@inheritDoc} */
  103. @Override
  104. public boolean isVisible() {
  105. return visible;
  106. }
  107. /** {@inheritDoc} */
  108. @Override
  109. public void setVisible(final boolean isVisible) {
  110. visible = isVisible;
  111. }
  112. /** {@inheritDoc} */
  113. @Override
  114. public String getTitle() {
  115. return title;
  116. }
  117. /** {@inheritDoc} */
  118. @Override
  119. public boolean isMaximum() {
  120. return maximised;
  121. }
  122. /**
  123. * {@inheritDoc}
  124. *
  125. * @param b maximised or not
  126. */
  127. public void setMaximum(final boolean b) {
  128. maximised = b;
  129. }
  130. /** {@inheritDoc} */
  131. @Override
  132. public void setTitle(final String title) {
  133. this.title = title;
  134. }
  135. /** {@inheritDoc} */
  136. @Override
  137. public void open() {
  138. // Do nothing
  139. }
  140. /** {@inheritDoc} */
  141. @Override
  142. public StringTranscoder getTranscoder() {
  143. return new StringTranscoder(Charset.defaultCharset());
  144. }
  145. /** {@inheritDoc} */
  146. @Override
  147. public void close() {
  148. container.windowClosing();
  149. }
  150. /** {@inheritDoc} */
  151. @Override
  152. public void restore() {
  153. // Do nothing
  154. }
  155. /** {@inheritDoc} */
  156. @Override
  157. public void maximise() {
  158. // Do nothing
  159. }
  160. /** {@inheritDoc} */
  161. @Override
  162. public void toggleMaximise() {
  163. // Do nothing
  164. }
  165. /** {@inheritDoc} */
  166. @Override
  167. public void minimise() {
  168. // Do nothing
  169. }
  170. /** {@inheritDoc} */
  171. @Override
  172. public void activateFrame() {
  173. // Do nothing
  174. }
  175. }