Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ChannelFrameFactory.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.ui_swing.components.frames;
  23. import com.dmdirc.addons.ui_swing.SwingController;
  24. import com.dmdirc.addons.ui_swing.SwingWindowFactory;
  25. import com.dmdirc.addons.ui_swing.components.TopicBarFactory;
  26. import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
  27. import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
  28. import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider;
  29. import com.dmdirc.interfaces.EventBus;
  30. import com.dmdirc.interfaces.GroupChat;
  31. import com.dmdirc.interfaces.WindowModel;
  32. import com.dmdirc.interfaces.config.IdentityFactory;
  33. import com.dmdirc.plugins.PluginDomain;
  34. import com.dmdirc.ui.core.components.WindowComponent;
  35. import java.util.Arrays;
  36. import java.util.HashSet;
  37. import java.util.Set;
  38. import javax.inject.Inject;
  39. import javax.inject.Provider;
  40. import javax.inject.Singleton;
  41. import static com.dmdirc.addons.ui_swing.components.frames.TextFrame.TextFrameDependencies;
  42. /**
  43. * Factory for {@link ChannelFrame}s.
  44. */
  45. @Singleton
  46. public class ChannelFrameFactory implements SwingWindowFactory.WindowProvider {
  47. private final String domain;
  48. private final Provider<TextFrameDependencies> dependencies;
  49. private final Provider<SwingInputField> inputFieldProvider;
  50. private final IdentityFactory identityFactory;
  51. private final InputTextFramePasteActionFactory inputTextFramePasteActionFactory;
  52. private final Provider<KeyedDialogProvider<GroupChat, ChannelSettingsDialog>> dialogProvider;
  53. private final TopicBarFactory topicBarFactory;
  54. private final EventBus eventBus;
  55. @Inject
  56. public ChannelFrameFactory(
  57. final EventBus eventBus,
  58. @PluginDomain(SwingController.class) final String domain,
  59. final Provider<TextFrameDependencies> dependencies,
  60. final Provider<SwingInputField> inputFieldProvider,
  61. final InputTextFramePasteActionFactory inputTextFramePasteActionFactory,
  62. final IdentityFactory identityFactory,
  63. final Provider<KeyedDialogProvider<GroupChat, ChannelSettingsDialog>> dialogProvider,
  64. final TopicBarFactory topicBarFactory) {
  65. this.eventBus = eventBus;
  66. this.domain = domain;
  67. this.dependencies = dependencies;
  68. this.inputFieldProvider = inputFieldProvider;
  69. this.identityFactory = identityFactory;
  70. this.dialogProvider = dialogProvider;
  71. this.topicBarFactory = topicBarFactory;
  72. this.inputTextFramePasteActionFactory = inputTextFramePasteActionFactory;
  73. }
  74. @Override
  75. public TextFrame getWindow(final WindowModel container) {
  76. final ChannelFrame frame = new ChannelFrame(domain, dependencies.get(), inputFieldProvider,
  77. identityFactory, dialogProvider.get(), inputTextFramePasteActionFactory,
  78. topicBarFactory, (GroupChat) container);
  79. // TODO: Can't assume containers are GroupChats...
  80. eventBus.subscribe(frame);
  81. return frame;
  82. }
  83. @Override
  84. public Set<String> getComponents() {
  85. return new HashSet<>(Arrays.asList(
  86. WindowComponent.TEXTAREA.getIdentifier(),
  87. WindowComponent.INPUTFIELD.getIdentifier(),
  88. WindowComponent.TOPICBAR.getIdentifier(),
  89. WindowComponent.USERLIST.getIdentifier()));
  90. }
  91. }