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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.FrameContainer;
  24. import com.dmdirc.util.StringTranscoder;
  25. import com.dmdirc.WritableFrameContainer;
  26. import com.dmdirc.commandparser.CommandParser;
  27. import com.dmdirc.commandparser.GlobalCommandParser;
  28. import com.dmdirc.config.ConfigManager;
  29. import com.dmdirc.ui.input.InputHandler;
  30. import com.dmdirc.ui.interfaces.InputWindow;
  31. import java.beans.PropertyVetoException;
  32. import java.nio.charset.Charset;
  33. import java.util.Arrays;
  34. import javax.swing.Icon;
  35. import javax.swing.JTextField;
  36. /**
  37. * Dummy input window, used for testing.
  38. */
  39. public final class DummyInputWindow implements InputWindow {
  40. /** Window title. */
  41. private String title;
  42. /** Are we visible? */
  43. private boolean visible;
  44. /** are we maximised? */
  45. private boolean maximised;
  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. //Do nothing.
  55. }
  56. /** {@inheritDoc} */
  57. public CommandParser getCommandParser() {
  58. return GlobalCommandParser.getGlobalCommandParser();
  59. }
  60. /** {@inheritDoc} */
  61. public InputHandler getInputHandler() {
  62. return new InputHandler(new JTextField(), null, this);
  63. }
  64. /** {@inheritDoc} */
  65. public void setAwayIndicator(final boolean isAway) {
  66. // Do nothing
  67. }
  68. /** {@inheritDoc} */
  69. public void addLine(final String messageType, final Object... args) {
  70. System.out.println("DummyInputWindow.addLine(" + messageType + ", " + Arrays.toString(args) + ")");
  71. }
  72. /** {@inheritDoc} */
  73. public void addLine(final StringBuffer messageType, final Object... args) {
  74. addLine(messageType.toString(), args);
  75. }
  76. /** {@inheritDoc} */
  77. public void addLine(final String line, final boolean timestamp) {
  78. throw new UnsupportedOperationException("Not supported yet.");
  79. }
  80. /** {@inheritDoc} */
  81. public void clear() {
  82. throw new UnsupportedOperationException("Not supported yet.");
  83. }
  84. /** {@inheritDoc} */
  85. public ConfigManager getConfigManager() {
  86. return new ConfigManager("dummy", "dummy", "dummy");
  87. }
  88. /** {@inheritDoc} */
  89. public FrameContainer getContainer() {
  90. throw new UnsupportedOperationException("Not supported yet.");
  91. }
  92. /** {@inheritDoc} */
  93. public boolean isVisible() {
  94. return visible;
  95. }
  96. /** {@inheritDoc} */
  97. public void setVisible(final boolean isVisible) {
  98. visible = isVisible;
  99. }
  100. /** {@inheritDoc} */
  101. public String getTitle() {
  102. return title;
  103. }
  104. /** {@inheritDoc} */
  105. public boolean isMaximum() {
  106. return maximised;
  107. }
  108. /** {@inheritDoc} */
  109. public void setMaximum(final boolean b) throws PropertyVetoException {
  110. maximised = b;
  111. }
  112. /** {@inheritDoc} */
  113. public void setTitle(final String title) {
  114. this.title = title;
  115. }
  116. /** {@inheritDoc} */
  117. public void open() {
  118. // Do nothing
  119. }
  120. /** {@inheritDoc} */
  121. public void setFrameIcon(final Icon icon) {
  122. // Do nothing
  123. }
  124. /** {@inheritDoc} */
  125. public StringTranscoder getTranscoder() {
  126. return new StringTranscoder(Charset.defaultCharset());
  127. }
  128. }