Desktop tool for browsing account info from EVE-Online
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.

Main.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2009 Chris Smith
  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 uk.co.md87.evetool;
  23. import java.io.BufferedReader;
  24. import java.io.IOException;
  25. import java.io.InputStreamReader;
  26. import java.util.logging.Handler;
  27. import java.util.logging.Level;
  28. import java.util.logging.Logger;
  29. import uk.co.md87.evetool.api.util.TableCreator;
  30. import uk.co.md87.evetool.ui.MainWindow;
  31. /**
  32. * Main class for the program. Handles initialisation of the core assets
  33. * and UI.
  34. *
  35. * @author chris
  36. */
  37. public class Main {
  38. /** The version of this instance of EVE Tool. */
  39. public static String version;
  40. /** Tables that are needed by the application. */
  41. private static final String[] TABLES
  42. = new String[]{"Accounts", "PageConfigElements", "PageConfigs"};
  43. /**
  44. * Main program entry point.
  45. *
  46. * @param args the command line arguments
  47. */
  48. public static void main(final String[] args) {
  49. initLogging();
  50. final ConfigManager config = new ConfigManager();
  51. final ApiFactory factory = new ApiFactory(config);
  52. config.checkDatabase(factory.getConnection());
  53. readVersion();
  54. initTables(factory);
  55. final AccountManager manager = new AccountManager(factory.getConnection());
  56. new MainWindow(manager, factory, config).setVisible(true);
  57. }
  58. /**
  59. * Initialises the logging system.
  60. */
  61. protected static void initLogging() {
  62. Logger.getLogger("uk").setLevel(Level.ALL);
  63. for (Handler handler : Logger.getLogger("").getHandlers()) {
  64. handler.setLevel(Level.ALL);
  65. }
  66. }
  67. /**
  68. * Initialises tables used by the program.
  69. *
  70. * @param factory The ApiFactory to use for the database connection
  71. */
  72. protected static void initTables(final ApiFactory factory) {
  73. new TableCreator(factory.getConnection(), "/uk/co/md87/evetool/sql/",
  74. TABLES).checkTables();
  75. }
  76. /**
  77. * Reads the version string from the bundled version.txt file.
  78. */
  79. protected static void readVersion() {
  80. try {
  81. final BufferedReader br = new BufferedReader(new InputStreamReader(
  82. Main.class.getResourceAsStream("version.txt")));
  83. version = br.readLine();
  84. } catch (IOException ex) {
  85. Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  86. }
  87. }
  88. }