Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

HistoryWindow.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.addons.logging;
  23. import com.dmdirc.FrameContainer;
  24. import com.dmdirc.IconManager;
  25. import com.dmdirc.Main;
  26. import com.dmdirc.Server;
  27. import com.dmdirc.config.ConfigManager;
  28. import com.dmdirc.config.IdentityManager;
  29. import com.dmdirc.ui.WindowManager;
  30. import com.dmdirc.ui.interfaces.Window;
  31. import java.util.Stack;
  32. /**
  33. * Displays an extended history of a window.
  34. *
  35. * @author Chris
  36. */
  37. public class HistoryWindow extends FrameContainer {
  38. /** The title of our window. */
  39. private final String title;
  40. /** The window we're using. */
  41. private final Window myWindow;
  42. /** Our parent window. */
  43. private final Window parent;
  44. /**
  45. * Creates a new HistoryWindow.
  46. *
  47. * @param title The title of the window
  48. * @param reader The reader to use to get the history
  49. * @param parent The window this history window was opened from
  50. */
  51. public HistoryWindow(final String title, final ReverseFileReader reader, final Window parent) {
  52. super();
  53. this.title = title;
  54. this.parent = parent;
  55. icon = IconManager.getIconManager().getIcon("raw");
  56. myWindow = Main.getUI().getWindow(this);
  57. WindowManager.addWindow(parent, myWindow);
  58. myWindow.setTitle(title);
  59. myWindow.setFrameIcon(icon);
  60. myWindow.setVisible(true);
  61. final Stack<String> lines = reader.getLines(
  62. IdentityManager.getGlobalConfig().getOptionInt("plugin-Logging", "history.lines", 50000));
  63. while (lines.size() > 0) {
  64. myWindow.addLine(lines.pop(), false);
  65. }
  66. }
  67. /** {@inheritDoc} */
  68. public Window getFrame() {
  69. return myWindow;
  70. }
  71. /** {@inheritDoc} */
  72. public String toString() {
  73. return title;
  74. }
  75. /** {@inheritDoc} */
  76. public void close() {
  77. myWindow.setVisible(false);
  78. Main.getUI().getMainWindow().delChild(myWindow);
  79. WindowManager.removeWindow(myWindow);
  80. }
  81. /** {@inheritDoc} */
  82. public Server getServer() {
  83. return parent.getContainer().getServer();
  84. }
  85. /** {@inheritDoc} */
  86. @Override
  87. public ConfigManager getConfigManager() {
  88. return parent.getConfigManager();
  89. }
  90. }