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 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.dialogs.about;
  23. import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
  24. import com.dmdirc.addons.ui_swing.injection.MainWindow;
  25. import com.dmdirc.config.GlobalConfig;
  26. import com.dmdirc.interfaces.config.AggregateConfigProvider;
  27. import com.dmdirc.interfaces.ui.AboutDialogModel;
  28. import com.dmdirc.ui.core.util.URLHandler;
  29. import java.awt.Window;
  30. import javax.inject.Inject;
  31. import javax.swing.JButton;
  32. import javax.swing.JTabbedPane;
  33. import javax.swing.WindowConstants;
  34. import net.miginfocom.swing.MigLayout;
  35. /**
  36. * About dialog.
  37. */
  38. public class AboutDialog extends StandardDialog {
  39. private static final long serialVersionUID = 5;
  40. private final URLHandler urlHandler;
  41. private final AboutDialogModel model;
  42. private final AggregateConfigProvider config;
  43. @Inject
  44. public AboutDialog(
  45. @GlobalConfig final AggregateConfigProvider config,
  46. @MainWindow final Window parentWindow,
  47. final AboutDialogModel model,
  48. final URLHandler urlHandler) {
  49. super(parentWindow, ModalityType.MODELESS);
  50. this.urlHandler = urlHandler;
  51. this.model = model;
  52. this.config = config;
  53. model.load();
  54. initComponents();
  55. }
  56. /** Initialises the main UI components. */
  57. private void initComponents() {
  58. final JTabbedPane tabbedPane = new JTabbedPane();
  59. setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  60. setTitle("About");
  61. setResizable(false);
  62. orderButtons(new JButton(), new JButton());
  63. getOkButton().addActionListener(e -> dispose());
  64. getCancelButton().addActionListener(e -> dispose());
  65. tabbedPane.add("About", new AboutPanel(urlHandler, model));
  66. tabbedPane.add("Credits", new CreditsPanel(urlHandler, model));
  67. tabbedPane.add("Licences", new LicencesPanel(model, config));
  68. tabbedPane.add("Information", new InfoPanel(model));
  69. getContentPane().setLayout(new MigLayout("ins rel, wrap 1, fill, "
  70. + "wmin 600, wmax 600, hmin 400, hmax 400"));
  71. getContentPane().add(tabbedPane, "grow, push");
  72. getContentPane().add(getOkButton(), "right");
  73. }
  74. }