Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ServerFrameFactory.java 3.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.SwingWindowFactory;
  24. import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
  25. import com.dmdirc.addons.ui_swing.dialogs.serversetting.ServerSettingsDialog;
  26. import com.dmdirc.addons.ui_swing.dialogs.sslcertificate.SSLCertificateDialogFactory;
  27. import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider;
  28. import com.dmdirc.interfaces.Connection;
  29. import com.dmdirc.interfaces.EventBus;
  30. import com.dmdirc.interfaces.WindowModel;
  31. import com.dmdirc.ui.core.components.WindowComponent;
  32. import java.util.Arrays;
  33. import java.util.HashSet;
  34. import java.util.Set;
  35. import javax.inject.Inject;
  36. import javax.inject.Provider;
  37. import javax.inject.Singleton;
  38. import static com.dmdirc.addons.ui_swing.components.frames.TextFrame.TextFrameDependencies;
  39. /**
  40. * Factory for {@link ServerFrame}s
  41. */
  42. @Singleton
  43. public class ServerFrameFactory implements SwingWindowFactory.WindowProvider {
  44. private final Provider<TextFrameDependencies> dependencies;
  45. private final Provider<SwingInputField> inputFieldProvider;
  46. private final Provider<KeyedDialogProvider<Connection, ServerSettingsDialog>> dialogProvider;
  47. private final EventBus eventBus;
  48. private final InputTextFramePasteActionFactory inputTextFramePasteActionFactory;
  49. private final SSLCertificateDialogFactory sslCertificateDialogFactory;
  50. @Inject
  51. public ServerFrameFactory(
  52. final EventBus eventBus,
  53. final Provider<TextFrameDependencies> dependencies,
  54. final Provider<SwingInputField> inputFieldProvider,
  55. final InputTextFramePasteActionFactory inputTextFramePasteActionFactory,
  56. final Provider<KeyedDialogProvider<Connection, ServerSettingsDialog>> dialogProvider,
  57. final SSLCertificateDialogFactory sslCertificateDialogFactory) {
  58. this.eventBus = eventBus;
  59. this.dependencies = dependencies;
  60. this.inputFieldProvider = inputFieldProvider;
  61. this.dialogProvider = dialogProvider;
  62. this.inputTextFramePasteActionFactory = inputTextFramePasteActionFactory;
  63. this.sslCertificateDialogFactory = sslCertificateDialogFactory;
  64. }
  65. @Override
  66. public TextFrame getWindow(final WindowModel container) {
  67. final ServerFrame frame = new ServerFrame(dependencies.get(), inputFieldProvider,
  68. inputTextFramePasteActionFactory, dialogProvider.get(),
  69. sslCertificateDialogFactory, container.getConnection().get());
  70. eventBus.subscribe(frame);
  71. return frame;
  72. }
  73. @Override
  74. public Set<String> getComponents() {
  75. return new HashSet<>(Arrays.asList(
  76. WindowComponent.TEXTAREA.getIdentifier(),
  77. WindowComponent.INPUTFIELD.getIdentifier(),
  78. WindowComponent.CERTIFICATE_VIEWER.getIdentifier()));
  79. }
  80. }