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.

AboutDialog.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2006-2014 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.dialogs.about;
  23. import com.dmdirc.ClientModule.GlobalConfig;
  24. import com.dmdirc.DMDircMBassador;
  25. import com.dmdirc.addons.ui_swing.SwingController;
  26. import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
  27. import com.dmdirc.addons.ui_swing.injection.MainWindow;
  28. import com.dmdirc.events.ClientInfoRequestEvent;
  29. import com.dmdirc.interfaces.config.AggregateConfigProvider;
  30. import com.dmdirc.interfaces.ui.AboutDialogModel;
  31. import com.dmdirc.ui.core.about.InfoItem;
  32. import com.dmdirc.ui.core.util.URLHandler;
  33. import java.awt.Window;
  34. import javax.inject.Inject;
  35. import javax.swing.JButton;
  36. import javax.swing.JTabbedPane;
  37. import javax.swing.WindowConstants;
  38. import net.miginfocom.layout.LayoutUtil;
  39. import net.miginfocom.swing.MigLayout;
  40. import net.engio.mbassy.listener.Handler;
  41. /**
  42. * About dialog.
  43. */
  44. public class AboutDialog extends StandardDialog {
  45. private static final long serialVersionUID = 5;
  46. private final URLHandler urlHandler;
  47. private final AboutDialogModel model;
  48. private final SwingController controller;
  49. private final DMDircMBassador eventBus;
  50. private final AggregateConfigProvider config;
  51. @Inject
  52. public AboutDialog(
  53. @GlobalConfig final AggregateConfigProvider config,
  54. @MainWindow final Window parentWindow,
  55. final AboutDialogModel model,
  56. final URLHandler urlHandler,
  57. final DMDircMBassador eventBus,
  58. final SwingController controller) {
  59. super(parentWindow, ModalityType.MODELESS);
  60. this.urlHandler = urlHandler;
  61. this.model = model;
  62. this.controller = controller;
  63. this.eventBus = eventBus;
  64. this.config = config;
  65. eventBus.subscribe(this);
  66. model.load();
  67. initComponents();
  68. }
  69. /** Initialises the main UI components. */
  70. private void initComponents() {
  71. final JTabbedPane tabbedPane = new JTabbedPane();
  72. setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  73. setTitle("About");
  74. setResizable(false);
  75. orderButtons(new JButton(), new JButton());
  76. getOkButton().addActionListener(e -> dispose());
  77. getCancelButton().addActionListener(e -> dispose());
  78. tabbedPane.add("About", new AboutPanel(urlHandler, model));
  79. tabbedPane.add("Credits", new CreditsPanel(urlHandler, model));
  80. tabbedPane.add("Licences", new LicencesPanel(model, config, eventBus));
  81. tabbedPane.add("Information", new InfoPanel(model));
  82. getContentPane().setLayout(new MigLayout("ins rel, wrap 1, fill, "
  83. + "wmin 600, wmax 600, hmin 400, hmax 400"));
  84. getContentPane().add(tabbedPane, "grow, push");
  85. getContentPane().add(getOkButton(), "right");
  86. }
  87. @Handler
  88. public void handleInfoRequest(final ClientInfoRequestEvent event) {
  89. event.addInfoItem(InfoItem.create("Swing UI Version", controller.getVersion().toString()),
  90. InfoItem.create("Look and Feel", SwingController.getLookAndFeel()),
  91. InfoItem.create("MiG Layout Version", LayoutUtil.getVersion())
  92. );
  93. }
  94. }