// -----BEGIN DISCLAIMER-----
/*******************************************************************************
 * Copyright (c) 2011, 2020 JCrypTool Team and Contributors
 * 
 * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
 * Public License v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
// -----END DISCLAIMER-----
package org.jcryptool.core;

import java.util.Locale;

import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

/**
 * This class controls all aspects of the application's execution.
 * 
 * @author Dominik Schadow
 * @version 1.0.0
 */
public class Application implements IApplication {

    /*
     * (non-Javadoc)
     * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
     */
    @Override
	public Object start(IApplicationContext context) throws Exception {
        try {
            if (!Locale.GERMAN.equals(Locale.getDefault()) && !Locale.ENGLISH.equals(Locale.getDefault())) {
                System.setProperty("osgi.nl", "en"); // fixes Platform.getNL()
                Locale.setDefault(Locale.ENGLISH);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        Display display = PlatformUI.createDisplay();
        try {
            int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
            if (returnCode == PlatformUI.RETURN_RESTART) {
                return IApplication.EXIT_RESTART;
            } else {
                return IApplication.EXIT_OK;
            }
        } finally {
            display.dispose();
        }

    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.equinox.app.IApplication#stop()
     */
    @Override
	public void stop() {
        final IWorkbench workbench = PlatformUI.getWorkbench();
        if (workbench == null) {
            return;
        }
        final Display display = workbench.getDisplay();
        display.syncExec(new Runnable() {
            @Override
			public void run() {
                if (!display.isDisposed()) {
                    workbench.close();
                }
            }
        });
    }
}

@@ -780,16 +780,65 @@
 tformUI;
+%0Aimport org.jcryptool.core.logging.utils.LogUtil;
 %0A%0A/**%0A *
@@ -1252,104 +1252,311 @@
     
-    if (!Locale.GERMAN.equals(Locale.getDefault()) && !Locale.ENGLISH.equals(Locale.getDefault()
+%09// Set English as default language if the operating system language is neither %0A        %09// German, English or French.%0A        %09if (!Locale.getDefault().getLanguage().equals(%22de%22) &&%0A        %09%09%09!Locale.getDefault().getLanguage().equals(%22en%22) &&%0A        %09%09%09!Locale.getDefault().getLanguage().equals(%22fr%22
 )) %7B
@@ -1570,18 +1570,16 @@
         
- 
- 
 System.s
@@ -1647,18 +1647,16 @@
         
-  
 Locale.s
@@ -1682,36 +1682,33 @@
 GLISH);%0A        
-  
-  
+%09
 %7D%0A        %7D catc
@@ -1741,26 +1741,48 @@
     
-e.printStackTrace(
+LogUtil.logError(CorePlugin.PLUGIN_ID, e
 );%0A 

Fix #2 for #178 (Any crypto operation fails ...)