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.

CustomWindow.java 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (c) 2006-2011 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;
  23. import com.dmdirc.config.IdentityManager;
  24. import com.dmdirc.ui.WindowManager;
  25. import com.dmdirc.ui.core.components.WindowComponent;
  26. import com.dmdirc.ui.interfaces.Window;
  27. import java.util.Arrays;
  28. /**
  29. * A generic custom window implementation.
  30. */
  31. public class CustomWindow extends FrameContainer {
  32. /**
  33. * Creates a new custom window as a child of the specified window.
  34. *
  35. * @param name The name of this custom window
  36. * @param title The title of this custom window
  37. * @param parent The parent of this custom window
  38. */
  39. public CustomWindow(final String name, final String title,
  40. final FrameContainer parent) {
  41. super("custom", name, title, Window.class, parent.getConfigManager(),
  42. Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
  43. WindowManager.getWindowManager().addWindow(parent, this);
  44. }
  45. /**
  46. * Creates a new custom window as a top-level window.
  47. *
  48. * @param name The name of this custom window
  49. * @param title The parent of this custom window
  50. */
  51. public CustomWindow(final String name, final String title) {
  52. super("custom", name, title, Window.class,
  53. IdentityManager.getGlobalConfig(),
  54. Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
  55. WindowManager.getWindowManager().addWindow(this);
  56. }
  57. /** {@inheritDoc} */
  58. @Override
  59. public void windowClosing() {
  60. // 2: Remove any callbacks or listeners
  61. // 3: Trigger any actions neccessary
  62. // 4: Trigger action for the window closing
  63. // 5: Inform any parents that the window is closing
  64. }
  65. /** {@inheritDoc} */
  66. @Override
  67. public void windowClosed() {
  68. // 7: Remove any references to the window and parents
  69. parent = null; // NOPMD
  70. }
  71. /** {@inheritDoc} */
  72. @Override
  73. public Server getServer() {
  74. return parent == null ? null : parent.getServer();
  75. }
  76. }