選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

FakeWriteableFrameContainer.java 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.addons.redirect;
  23. import com.dmdirc.DMDircMBassador;
  24. import com.dmdirc.FrameContainer;
  25. import com.dmdirc.interfaces.Connection;
  26. import com.dmdirc.interfaces.WindowModel;
  27. import com.dmdirc.ui.messages.BackBufferFactory;
  28. import com.dmdirc.ui.messages.Formatter;
  29. import java.util.Collections;
  30. import java.util.Date;
  31. import java.util.Optional;
  32. /**
  33. * Implements a fake input window, which sends echoed text to the specified chat window instead.
  34. */
  35. public class FakeWriteableFrameContainer extends FrameContainer {
  36. /** The target for this window. */
  37. private final WindowModel target;
  38. /**
  39. * Creates a new instance of FakeInputWindow.
  40. */
  41. public FakeWriteableFrameContainer(
  42. final WindowModel target,
  43. final DMDircMBassador eventBus,
  44. final BackBufferFactory backBufferFactory) {
  45. super(target, target.getIcon(), target.getName(), target.getTitle(),
  46. target.getConfigManager(), backBufferFactory,
  47. target.getTabCompleter(), eventBus, Collections.<String>emptyList());
  48. this.target = target;
  49. initBackBuffer();
  50. setCommandParser(target.getCommandParser());
  51. }
  52. @Override
  53. public void sendLine(final String line) {
  54. target.sendLine(line);
  55. }
  56. @Override
  57. public void addLine(final String type, final Date timestamp, final Object... args) {
  58. addLine(type, args);
  59. }
  60. @Override
  61. public void addLine(final String type, final Object... args) {
  62. sendLine(Formatter.formatMessage(getConfigManager(), type, args));
  63. }
  64. @Override
  65. public void addLine(final String line, final Date timestamp) {
  66. addLine(line);
  67. }
  68. @Override
  69. public int getMaxLineLength() {
  70. return target.getMaxLineLength();
  71. }
  72. @Override
  73. public Optional<Connection> getConnection() {
  74. return target.getConnection();
  75. }
  76. }