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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. readVersion();
  53. initTables(factory);
  54. final AccountManager manager = new AccountManager(factory.getConnection());
  55. new MainWindow(manager, factory, config).setVisible(true);
  56. }
  57. /**
  58. * Initialises the logging system.
  59. */
  60. protected static void initLogging() {
  61. Logger.getLogger("uk").setLevel(Level.ALL);
  62. for (Handler handler : Logger.getLogger("").getHandlers()) {
  63. handler.setLevel(Level.ALL);
  64. }
  65. }
  66. /**
  67. * Initialises tables used by the program.
  68. *
  69. * @param factory The ApiFactory to use for the database connection
  70. */
  71. protected static void initTables(final ApiFactory factory) {
  72. new TableCreator(factory.getConnection(), "/uk/co/md87/evetool/sql/",
  73. TABLES).checkTables();
  74. }
  75. /**
  76. * Reads the version string from the bundled version.txt file.
  77. */
  78. protected static void readVersion() {
  79. try {
  80. final BufferedReader br = new BufferedReader(new InputStreamReader(
  81. Main.class.getResourceAsStream("version.txt")));
  82. version = br.readLine();
  83. } catch (IOException ex) {
  84. Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  85. }
  86. }
  87. }