OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 49... Line 49...
49
import org.openconcerto.utils.CompareUtils;
49
import org.openconcerto.utils.CompareUtils;
50
import org.openconcerto.utils.ExceptionHandler;
50
import org.openconcerto.utils.ExceptionHandler;
51
import org.openconcerto.utils.FileUtils;
51
import org.openconcerto.utils.FileUtils;
52
import org.openconcerto.utils.ThrowableHandler;
52
import org.openconcerto.utils.ThrowableHandler;
53
import org.openconcerto.utils.protocol.Helper;
53
import org.openconcerto.utils.protocol.Helper;
-
 
54
import org.openconcerto.xml.FastXMLProperties;
54
 
55
 
55
import java.awt.AWTEvent;
56
import java.awt.AWTEvent;
56
import java.awt.Component;
57
import java.awt.Component;
57
import java.awt.Desktop;
58
import java.awt.Desktop;
58
import java.awt.Image;
59
import java.awt.Image;
Line 202... Line 203...
202
 
203
 
203
        System.setSecurityManager(new SecurityManager());
204
        System.setSecurityManager(new SecurityManager());
204
    }
205
    }
205
 
206
 
206
    public static void main(String[] args) {
207
    public static void main(String[] args) {
-
 
208
        System.setProperty("org.xml.sax.driver", "com.bluecast.xml.Piccolo");
-
 
209
        System.setProperty("org.xml.sax.parser", "com.bluecast.xml.Piccolo");
-
 
210
        System.setProperty("javax.xml.parsers.SAXParserFactory", "com.bluecast.xml.JAXPSAXParserFactory");
207
        ComptaPropsConfiguration.checkJava();
211
        ComptaPropsConfiguration.checkJava();
208
        // Check MacOS Sandbox
212
        // Check MacOS Sandbox
209
        String cwd = new File(getProperty("user.dir")).toURI().toString();
213
        String cwd = new File(getProperty("user.dir")).toURI().toString();
210
        if (cwd.startsWith("file:/private/var/folders")) {
214
        if (cwd.startsWith("file:/private/var/folders")) {
211
            JOptionPane.showMessageDialog(null,
215
            JOptionPane.showMessageDialog(null,
Line 408... Line 412...
408
        pTOS.setProperty("hasManual", "false");
412
        pTOS.setProperty("hasManual", "false");
409
        pTOS.setProperty("hasCloud", "false");
413
        pTOS.setProperty("hasCloud", "false");
410
 
414
 
411
        if (fTOS.exists()) {
415
        if (fTOS.exists()) {
412
            try {
416
            try {
413
                pTOS.loadFromXML(new FileInputStream(fTOS));
417
                FastXMLProperties.load(pTOS, new FileInputStream(fTOS));
414
            } catch (Exception e1) {
418
            } catch (Exception e1) {
415
                e1.printStackTrace();
419
                e1.printStackTrace();
416
            }
420
            }
417
        }
421
        }
418
        if (ComptaPropsConfiguration.getInstanceCompta().isOnCloud()) {
422
        if (ComptaPropsConfiguration.getInstanceCompta().isOnCloud()) {
Line 576... Line 580...
576
    }
580
    }
577
 
581
 
578
    private static void saveProperties(File fTOS, Properties pTOS) {
582
    private static void saveProperties(File fTOS, Properties pTOS) {
579
        try {
583
        try {
580
            final FileOutputStream outputStream = new FileOutputStream(fTOS);
584
            final FileOutputStream outputStream = new FileOutputStream(fTOS);
581
            pTOS.storeToXML(outputStream, "tos", "UTF-8");
585
            FastXMLProperties.store(pTOS, outputStream, "tos");
582
            outputStream.close();
586
            outputStream.close();
583
        } catch (Exception e) {
587
        } catch (Exception e) {
584
            e.printStackTrace();
588
            e.printStackTrace();
585
        }
589
        }
586
    }
590
    }
Line 591... Line 595...
591
 
595
 
592
            @Override
596
            @Override
593
            public boolean handle(String message, Throwable throwable) {
597
            public boolean handle(String message, Throwable throwable) {
594
                if (throwable == null)
598
                if (throwable == null)
595
                    return false;
599
                    return false;
596
 
-
 
-
 
600
                throwable.printStackTrace();
597
                final ByteArrayOutputStream out = new ByteArrayOutputStream();
601
                final ByteArrayOutputStream out = new ByteArrayOutputStream();
598
                throwable.printStackTrace(new PrintStream(out));
602
                throwable.printStackTrace(new PrintStream(out));
599
                String s = new String(out.toByteArray());
603
                String s = new String(out.toByteArray());
600
                if (s.contains("Database may be already in use")) {
604
                if (s.contains("Database may be already in use")) {
601
                    JOptionPane.showMessageDialog(null,
605
                    JOptionPane.showMessageDialog(null,
Line 632... Line 636...
632
                    // at sun.awt.windows.WInputMethod$1.run(Unknown Source)
636
                    // at sun.awt.windows.WInputMethod$1.run(Unknown Source)
633
                    // at java.awt.event.InvocationEvent.dispatch(Unknown Source)
637
                    // at java.awt.event.InvocationEvent.dispatch(Unknown Source)
634
                    return true;
638
                    return true;
635
                }
639
                }
636
 
640
 
637
                else if (s.contains("No application is associated with the specified file for this operation")) {
641
                else if (s.contains("No application is associated with the specified file for this operation") || s.contains("Error message: Package could not be registered")) {
638
                    JOptionPane.showMessageDialog(null, "Merci d'installer LibreOffice ou tout autre application succeptible d'ouvrir ce fichier");
642
                    JOptionPane.showMessageDialog(null, "Merci d'installer LibreOffice ou tout autre application succeptible d'ouvrir ce fichier");
639
                    return true;
643
                    return true;
640
                } else if (s.contains("java.net.SocketTimeoutException: connect timed out")) {
644
                } else if (s.contains("java.net.SocketTimeoutException: connect timed out")) {
641
                    JOptionPane.showMessageDialog(null, "Le serveur de base de données n'est pas joignable.\n" + message);
645
                    JOptionPane.showMessageDialog(null, "Le serveur de base de données n'est pas joignable.\n" + message);
642
                    return true;
646
                    return true;