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.

DummyChannelWindow.java 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (c) 2006-2007 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.ui.dummy;
  23. import com.dmdirc.Channel;
  24. import com.dmdirc.FrameContainer;
  25. import com.dmdirc.util.StringTranscoder;
  26. import com.dmdirc.commandparser.parsers.ChannelCommandParser;
  27. import com.dmdirc.commandparser.parsers.CommandParser;
  28. import com.dmdirc.config.ConfigManager;
  29. import com.dmdirc.parser.ChannelClientInfo;
  30. import com.dmdirc.ui.input.InputHandler;
  31. import com.dmdirc.ui.interfaces.ChannelWindow;
  32. import java.beans.PropertyVetoException;
  33. import java.nio.charset.Charset;
  34. import java.util.Arrays;
  35. import java.util.List;
  36. import javax.swing.Icon;
  37. import javax.swing.JTextField;
  38. /**
  39. * Dummy channel window, used for testing.
  40. */
  41. public final class DummyChannelWindow implements ChannelWindow {
  42. /** Parent channel. */
  43. private final Channel parent;
  44. /** Window title. */
  45. private String title;
  46. /** is maximised? */
  47. private boolean maximised;
  48. /** is visible? */
  49. private boolean visible;
  50. /**
  51. * Instantiates a new DummyChannelWindow.
  52. *
  53. * @param parent Parent channel
  54. */
  55. public DummyChannelWindow(final Channel parent) {
  56. this.parent = parent;
  57. }
  58. /** {@inheritDoc} */
  59. public void updateNames(final List<ChannelClientInfo> clients) {
  60. // Do nothing
  61. }
  62. /** {@inheritDoc} */
  63. public void addName(final ChannelClientInfo client) {
  64. // Do nothing
  65. }
  66. /** {@inheritDoc} */
  67. public void removeName(final ChannelClientInfo client) {
  68. // Do nothing
  69. }
  70. /** {@inheritDoc} */
  71. public void updateNames() {
  72. // Do nothing
  73. }
  74. /** {@inheritDoc} */
  75. public CommandParser getCommandParser() {
  76. return new ChannelCommandParser(parent.getServer(), parent);
  77. }
  78. /** {@inheritDoc} */
  79. public InputHandler getInputHandler() {
  80. return new InputHandler(new JTextField(), getCommandParser(), this);
  81. }
  82. /** {@inheritDoc} */
  83. public void setAwayIndicator(final boolean isAway) {
  84. throw new UnsupportedOperationException("Not supported yet.");
  85. }
  86. /** {@inheritDoc} */
  87. public void addLine(final String messageType, final Object... args) {
  88. System.out.println("DummyChannelWindow.addLine(" + messageType + ", " + Arrays.toString(args) + ")");
  89. }
  90. /** {@inheritDoc} */
  91. public void addLine(final StringBuffer messageType, final Object... args) {
  92. addLine(messageType.toString(), args);
  93. }
  94. /** {@inheritDoc} */
  95. public void addLine(final String line, final boolean timestamp) {
  96. throw new UnsupportedOperationException("Not supported yet.");
  97. }
  98. /** {@inheritDoc} */
  99. public void clear() {
  100. throw new UnsupportedOperationException("Not supported yet.");
  101. }
  102. /** {@inheritDoc} */
  103. public ConfigManager getConfigManager() {
  104. return parent.getConfigManager();
  105. }
  106. /** {@inheritDoc} */
  107. public FrameContainer getContainer() {
  108. return parent;
  109. }
  110. /** {@inheritDoc} */
  111. public boolean isVisible() {
  112. return visible;
  113. }
  114. /** {@inheritDoc} */
  115. public void setVisible(final boolean isVisible) {
  116. visible = isVisible;
  117. }
  118. /** {@inheritDoc} */
  119. public String getTitle() {
  120. return title;
  121. }
  122. /** {@inheritDoc} */
  123. public boolean isMaximum() {
  124. return maximised;
  125. }
  126. /** {@inheritDoc} */
  127. public void setMaximum(final boolean b) throws PropertyVetoException {
  128. maximised = b;
  129. }
  130. /** {@inheritDoc} */
  131. public void setTitle(final String title) {
  132. this.title = title;
  133. }
  134. /** {@inheritDoc} */
  135. public void open() {
  136. // Do nothing
  137. }
  138. /** {@inheritDoc} */
  139. public void setFrameIcon(final Icon icon) {
  140. // Do nothing
  141. }
  142. /** {@inheritDoc} */
  143. public StringTranscoder getTranscoder() {
  144. return new StringTranscoder(Charset.defaultCharset());
  145. }
  146. }