[6821] | 1 | package fr.mael.jiwigo; |
---|
| 2 | |
---|
| 3 | import java.io.File; |
---|
| 4 | import java.io.IOException; |
---|
[8838] | 5 | |
---|
[6821] | 6 | import javax.swing.UIManager; |
---|
[8838] | 7 | |
---|
[6821] | 8 | import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel; |
---|
[8838] | 9 | |
---|
[6821] | 10 | import fr.mael.jiwigo.transverse.session.SessionManager; |
---|
[9393] | 11 | import fr.mael.jiwigo.transverse.util.Tools; |
---|
[6821] | 12 | import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement; |
---|
| 13 | import fr.mael.jiwigo.ui.ConnexionDialog; |
---|
| 14 | import fr.mael.jiwigo.ui.mainframe.MainFrame; |
---|
| 15 | |
---|
| 16 | /** |
---|
| 17 | Copyright (c) 2010, Mael |
---|
| 18 | All rights reserved. |
---|
| 19 | |
---|
| 20 | Redistribution and use in source and binary forms, with or without |
---|
| 21 | modification, are permitted provided that the following conditions are met: |
---|
| 22 | * Redistributions of source code must retain the above copyright |
---|
| 23 | notice, this list of conditions and the following disclaimer. |
---|
| 24 | * Redistributions in binary form must reproduce the above copyright |
---|
| 25 | notice, this list of conditions and the following disclaimer in the |
---|
| 26 | documentation and/or other materials provided with the distribution. |
---|
| 27 | * Neither the name of jiwigo nor the |
---|
| 28 | names of its contributors may be used to endorse or promote products |
---|
| 29 | derived from this software without specific prior written permission. |
---|
| 30 | |
---|
| 31 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
---|
| 32 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
---|
| 33 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
---|
| 34 | DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY |
---|
| 35 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
---|
| 36 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
---|
| 37 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
---|
| 38 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
| 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
| 40 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 41 | |
---|
[8838] | 42 | * Main class |
---|
[6821] | 43 | * @author mael |
---|
| 44 | * |
---|
| 45 | */ |
---|
| 46 | public class Main { |
---|
| 47 | |
---|
[8838] | 48 | /** |
---|
| 49 | * Logger |
---|
| 50 | */ |
---|
| 51 | public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(Main.class); |
---|
| 52 | /** |
---|
| 53 | * The login and session manager that allows to connect to |
---|
| 54 | * the webservice and to query it |
---|
| 55 | */ |
---|
| 56 | public static SessionManager sessionManager; |
---|
[6821] | 57 | |
---|
[8838] | 58 | /** |
---|
| 59 | * the main window |
---|
| 60 | */ |
---|
| 61 | private static MainFrame mainFrame; |
---|
[7221] | 62 | |
---|
[8838] | 63 | public static void main(String[] args) { |
---|
| 64 | try { |
---|
| 65 | UIManager.setLookAndFeel(new NimbusLookAndFeel()); |
---|
| 66 | } catch (Exception e) { |
---|
[6821] | 67 | } |
---|
[8838] | 68 | File dossierConfig = new File(System.getProperty("user.home") + "/.jiwigo"); |
---|
| 69 | if (!dossierConfig.exists()) { |
---|
| 70 | dossierConfig.mkdir(); |
---|
| 71 | } |
---|
| 72 | try { |
---|
| 73 | PreferencesManagement.creerFichierParDefaut(); |
---|
| 74 | //dialog de connexion |
---|
| 75 | ConnexionDialog dialog = new ConnexionDialog(); |
---|
| 76 | dialog.showDialog(); |
---|
| 77 | } catch (IOException e) { |
---|
[9393] | 78 | LOG.error(Tools.getStackTrace(e)); |
---|
[8838] | 79 | } |
---|
[6821] | 80 | |
---|
[8838] | 81 | } |
---|
[6821] | 82 | |
---|
[8838] | 83 | public static void showFrame() { |
---|
[6821] | 84 | |
---|
[8838] | 85 | if (mainFrame == null) { |
---|
| 86 | mainFrame = MainFrame.getInstance(); |
---|
[6821] | 87 | } |
---|
[8838] | 88 | if (!mainFrame.isVisible()) { |
---|
| 89 | mainFrame.showUi(); |
---|
| 90 | } |
---|
| 91 | } |
---|
[6821] | 92 | } |
---|