DBInstallerGUI.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (C) 2004-2014 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.tools.dbinstaller.gui;
  20. import java.awt.BorderLayout;
  21. import java.awt.Dimension;
  22. import java.awt.Toolkit;
  23. import java.sql.Connection;
  24. import javax.swing.JFrame;
  25. import javax.swing.JOptionPane;
  26. import javax.swing.JProgressBar;
  27. import javax.swing.JScrollPane;
  28. import javax.swing.JTextArea;
  29. import com.l2jserver.tools.dbinstaller.DBOutputInterface;
  30. import com.l2jserver.tools.images.ImagesTable;
  31. /**
  32. * @author mrTJO
  33. */
  34. public class DBInstallerGUI extends JFrame implements DBOutputInterface
  35. {
  36. private static final long serialVersionUID = -1005504757826370170L;
  37. private final JProgressBar _progBar;
  38. private final JTextArea _progArea;
  39. private final Connection _con;
  40. public DBInstallerGUI(Connection con)
  41. {
  42. super("L2J Database Installer");
  43. setLayout(new BorderLayout());
  44. setDefaultLookAndFeelDecorated(true);
  45. setIconImage(ImagesTable.getImage("l2j.png").getImage());
  46. _con = con;
  47. int width = 480;
  48. int height = 360;
  49. Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
  50. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  51. setBounds((resolution.width - width) / 2, (resolution.height - height) / 2, width, height);
  52. setResizable(false);
  53. _progBar = new JProgressBar();
  54. _progBar.setIndeterminate(true);
  55. add(_progBar, BorderLayout.PAGE_START);
  56. _progArea = new JTextArea();
  57. JScrollPane scrollPane = new JScrollPane(_progArea);
  58. _progArea.setEditable(false);
  59. appendToProgressArea("Connected");
  60. add(scrollPane, BorderLayout.CENTER);
  61. }
  62. @Override
  63. public void setProgressIndeterminate(boolean value)
  64. {
  65. _progBar.setIndeterminate(value);
  66. }
  67. @Override
  68. public void setProgressMaximum(int maxValue)
  69. {
  70. _progBar.setMaximum(maxValue);
  71. }
  72. @Override
  73. public void setProgressValue(int value)
  74. {
  75. _progBar.setValue(value);
  76. }
  77. @Override
  78. public void appendToProgressArea(String text)
  79. {
  80. _progArea.append(text + System.getProperty("line.separator"));
  81. _progArea.setCaretPosition(_progArea.getDocument().getLength());
  82. }
  83. @Override
  84. public Connection getConnection()
  85. {
  86. return _con;
  87. }
  88. @Override
  89. public void setFrameVisible(boolean value)
  90. {
  91. setVisible(value);
  92. }
  93. @Override
  94. public int requestConfirm(String title, String message, int type)
  95. {
  96. return JOptionPane.showConfirmDialog(null, message, title, type);
  97. }
  98. @Override
  99. public void showMessage(String title, String message, int type)
  100. {
  101. JOptionPane.showMessageDialog(null, message, title, type);
  102. }
  103. }