Ejemplo n.º 1
0
 protected static Object newInstance(String name) {
   try {
     Class clazz = Class.forName(name);
     return clazz.newInstance();
   } catch (Exception e) {
     Logger().severe("Cannot extatiate class " + name + ": " + e.getMessage());
     return null;
   }
 }
Ejemplo n.º 2
0
 public static void quit() {
   try {
     if (instance.onQuit()) {
       System.exit(0);
     }
   } catch (Exception e) {
     Logger().severe("Error when quiting: " + e.getMessage());
   }
 }
Ejemplo n.º 3
0
 public static void closeActiveWindow() {
   for (int i = 0; i < windows.size(); i++) {
     try {
       AbstractWindow window = (AbstractWindow) windows.get(i);
       if (window != null && window.isActive()) {
         closeWindow(window);
       }
     } catch (Exception e) {
       logger.warning("Cannot close window: " + e.getMessage());
     }
   }
 }
Ejemplo n.º 4
0
 public static ImageIcon AboutImage() {
   ImageIcon image = null;
   String imagename = Settings().getAboutImage();
   if ((imagename != null) && "".compareTo(imagename) != 0) {
     image = new ImageIcon();
     try {
       image.setImage(ImageIO.read(Settings().getResourceAsStream(imagename)));
     } catch (Exception e) {
       Logger().warning("About image not found " + imagename + ": " + e.getMessage());
     }
   }
   return image;
 }
Ejemplo n.º 5
0
 public void cancelUpdate(String window_name) {
   try {
     saveUpdateSettings();
     if (!cmd.getQuiet()) {
       if (window_name == null) {
         window = new MainWindow();
       } else {
         window = (AbstractWindow) newInstance(window_name);
       }
       addWindow(window);
       window.setVisible(window.getWindowSettings().getVisible());
       window.postLoad();
     }
   } catch (Exception ex) {
     ex.printStackTrace();
     logger.severe("Could not start application: " + ex.getMessage());
   }
 }
Ejemplo n.º 6
0
  public static Logger initLogger() {
    Logger initlogger = Logger.getLogger(settings.getMainClass());
    initlogger.setLevel(settings.getLogLevel());
    boolean addconsole = false;
    if (settings.getLogToFile()) {
      try {
        Handler handler = new FileHandler(settings.getLogFile(), true);
        handler.setFormatter(new SimpleFormatter());
        initlogger.addHandler(handler);
      } catch (Exception e) {
        Logger().warning("Could not set logfile " + settings.getLogFile() + ": " + e.getMessage());
        addconsole = true;
      }
    }
    addconsole = settings.getLogToConsole() || addconsole;
    if (addconsole) {
      initlogger.addHandler(new ConsoleHandler());
    }
    // restore original log state
    logger.setLevel(templevel);
    templevel = null;

    return initlogger;
  }
Ejemplo n.º 7
0
 public static void showLogError(String msg, String title, Exception e, Component comp) {
   JOptionPane.showMessageDialog(comp, msg, title, JOptionPane.WARNING_MESSAGE);
   Main.Logger().warning(msg + (e == null ? "" : ": " + e.getMessage()));
 }