<commit_before>/**
 * This program and the accompanying materials
 * are made available under the terms of the License
 * which accompanies this distribution in the file LICENSE.txt
 */
package com.archimatetool.editor;

import java.io.IOException;
import java.net.URL;

import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;

import com.archimatetool.editor.utils.PlatformUtils;




/**
 * The main application class for standalone RCP operation.
 * 
 * @author <NAME>
 */
public class Application
implements IApplication {

    /**
     * ID of the Application
     */
    public static String ID = ArchiPlugin.PLUGIN_ID + ".app"; //$NON-NLS-1$
    
	/**
	 * Constructor
	 */
	public Application() {
	}
	
	@Override
    public Object start(IApplicationContext context) throws Exception {
        // If running on Linux lock the instance location so we can only launch Archi once
        if(PlatformUtils.isLinux() && Platform.getInstanceLocation() != null) {
            if(Platform.getInstanceLocation().isLocked()) {
                return EXIT_OK;
            }
            
            Platform.getInstanceLocation().lock();
        }

        // Platform specific launcher check
        IPlatformLauncher launcher = ArchiPlugin.INSTANCE.getPlatformLauncher();
        if(launcher != null) {
            launcher.startup();
            
            // If the application is already open (Windows), exit
            if(launcher.shouldApplicationExitEarly()) {
                return EXIT_OK;
            }
	    }
	    
	    // Create Main Display
	    Display display = PlatformUI.createDisplay();
	    
	    // Tell the Launcher that the display has been created
	    if(launcher != null) {
	        launcher.displayCreated(display);
	    }
	    
	    // Hook into opening documents from the desktop<commit_msg>Lock instance location on startup on Linux to avoid multiple launches of app part 2<commit_after>/**
 * This program and the accompanying materials
 * are made available under the terms of the License
 * which accompanies this distribution in the file LICENSE.txt
 */
package com.archimatetool.editor;

import java.io.IOException;
import java.net.URL;

import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;

import com.archimatetool.editor.utils.PlatformUtils;




/**
 * The main application class for standalone RCP operation.
 * 
 * @author <NAME>
 */
public class Application
implements IApplication {

    /**
     * ID of the Application
     */
    public static String ID = ArchiPlugin.PLUGIN_ID + ".app"; //$NON-NLS-1$
    
	/**
	 * Constructor
	 */
	public Application() {
	}
	
	@Override
    public Object start(IApplicationContext context) throws Exception {
        // If running on Linux lock the instance location so we can only launch Archi once
        if(PlatformUtils.isLinux()) {
            Location loc = Platform.getInstanceLocation();
            
            if(loc.isLocked()) {
                return EXIT_OK;
            }            
            
            if(loc.isSet()) { // Ensure it's set to avoid IOException
                loc.lock(); // Lock it
            }
        }

        // Platform specific launcher check
        IPlatformLauncher launcher = ArchiPlugin.INSTANCE.getPlatformLauncher();
        if(launcher != null) {
            launcher.startup();
            
            // If the application is already open (Windows), exit
            if(launcher.shouldApplicationExitEarly()) {
                return EXIT_OK;
            }
	    }
	    
	    // Create Main Display
	    Display display = PlatformUI.createDisplay();
	    
	    // Tell the Launcher that the display has been created
	    if(launcher != null) {
	        launcher.displayCreated(display);
	    }
	    
	    // Hook into opening documents from the desktop
{'fraction_non_alphanumeric': 0.09011145364002845, 'fraction_numerical': 0.0007114062129475931, 'mean_word_length': 2.407108239095315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6988615', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1091, 'n_words': 319}