Coverage details for base.jdbs.JDBS

LineHitsSource
1 /*******************************************************************************
2  *InternetCafe is a software solution that helps the management of Cybercafes
3  * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4  * Copyright (C) 2006 Guido Angelo Ingenito
5  
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  
11  * This program 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
14  * GNU 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, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *******************************************************************************/
20 package base.jdbs;
21  
22 import java.awt.BorderLayout;
23 import java.io.File;
24  
25 import org.apache.log4j.Logger;
26 import org.apache.log4j.xml.DOMConfigurator;
27  
28 import ui.dialog.UserDialog;
29 import ui.util.GeneralUtil;
30 import base.InternetCafe;
31 import base.jdbs.ui.JDBSMainFrame;
32 import base.jdbs.ui.JDBSMenuBar;
33 import base.jdbs.ui.dialog.RepositorySetupDialog;
34 import base.user.User;
35 import base.user.UserFactory;
36  
370public class JDBS {
38  
390    private static final transient Logger logger = Logger.getLogger(JDBS.class
400            .getName());
41  
420    /**
43      * @param args
44      */
45     public static void main(String[] args) {
46  
470        initJDBS();
48  
490        JDBSMainFrame mainFrame = new JDBSMainFrame();
500        mainFrame.setSize(1024, 768);
510        mainFrame.setJMenuBar(new JDBSMenuBar());
520        mainFrame.add(InternetCafe.getStatusBar(), BorderLayout.SOUTH);
530        GeneralUtil.centerComponent(mainFrame);
540        mainFrame.setVisible(true);
550        // NetworkManager.getInstance();
560    }
57  
580    protected static void initJDBS() {
59         // This call enables the log4j logs for JDBS.
600        DOMConfigurator.configure("log4jConfiguration.xml");
61         try {
620            // First of all we must load the JDBS configurations.
630            File configurationFile = new File(
64                     JDBSConstant.JDBS_CONFIGURATION_FILE);
650 
660            if (configurationFile.exists()) { // Read It!
670                logger.info("Configuration file : " + configurationFile
680                        + " found. Loading configurations from it...");
690                ConfigurationManager.loadConfiguration();
700            } else {
710                logger.info("Setting up the JDBS's user...");
720                User user = UserFactory.newUser();
730                UserDialog dialog = new UserDialog(user);
740                dialog.setModal(true);
750                dialog.setTitle("New User");
760                dialog.setVisible(true);
770                ConfigurationManager.getInstance().setUser(dialog.getUser());
780                logger.info(dialog.getUser());
790 
800                logger.info("Setting up the JDBS's repository...");
810                RepositorySetupDialog repositorySetupDialog = new RepositorySetupDialog();
820                repositorySetupDialog.setModal(true);
830                GeneralUtil.centerComponent(repositorySetupDialog);
840                repositorySetupDialog.setVisible(true);
85  
860                ConfigurationManager.saveConfiguration();
870            }
880        } catch (Exception e) {
890            logger.error(e.getMessage());
900            e.printStackTrace();
910        }
920 
930        if (ConfigurationManager.getInstance().getRepository().getLocation()
940                .exists()) {
950            logger.info("Indexing the JDBS's repository...");
960            ConfigurationManager.getInstance().getRepository()
970                    .indexRepository();
980        }
990    }
100 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.