Java Code Examples for org.eclipse.equinox.app.IApplication#EXIT_OK

The following examples show how to use org.eclipse.equinox.app.IApplication#EXIT_OK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Application.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		PreferenceUtil.initProductEdition();
		if (!PreferenceUtil.checkEdition()) {
			MessageDialog.openInformation(display.getActiveShell(), Messages.getString("dialog.AboutDialog.msgTitle"),
					Messages.getString("dialog.AboutDialog.msg"));
			return IApplication.EXIT_OK;
		}
		initSystemLan();
		SystemResourceUtil.beforeload();
		PreferenceUtil.checkCleanValue();
		deleteErrorMemoryFile();
		int returnCode = PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 2
Source File: Application.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		PreferenceUtil.initProductEdition();

		deleteErrorMemoryInfo();

		initSystemLan();
		PreferenceUtil.checkCleanValue();
		int returnCode = PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 3
Source File: JavaIndexerApplication.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Object start(IApplicationContext context) throws Exception {
	boolean execute = processCommandLine((String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS));
	if (execute) {
		if (this.jarToIndex != null && this.indexFile != null) {
			File f = new File(this.jarToIndex);
			if (f.exists()) {
				if (this.verbose) {
					System.out.println(Messages.bind(Messages.CommandLineProcessing, this.indexFile, this.jarToIndex));
				}
				try {
					JavaIndexer.generateIndexForJar(this.jarToIndex, this.indexFile);
				} catch (IOException e) {
					System.out.println(Messages.bind(Messages.CaughtException, "IOException", e.getLocalizedMessage())); //$NON-NLS-1$
				}
			} else {
					System.out.println(Messages.bind(Messages.CommandLineJarFileNotExist, this.jarToIndex));
			}
		} else if (this.jarToIndex == null) {
			System.out.println(Messages.bind(Messages.CommandLineJarNotSpecified));
		} else if (this.indexFile == null) {
			System.out.println(Messages.bind(Messages.CommandLineIndexFileNotSpecified));
		}
	}
	return IApplication.EXIT_OK;
}
 
Example 4
Source File: GWTCodeFormatterApplication.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {

  String[] args = (String[]) context.getArguments().get(
      IApplicationContext.APPLICATION_ARGS);

  if (args.length < 3) {
    System.err.println("Usage: eclipse -application com.google.gwt.eclipse.core.formatter.GWTCodeFormatterApplication "
        + "<javaFormatterConfigFile> <jsFormatterConfigFile> <sourceFile1> [<sourceFile2>] ...");
    return IApplication.EXIT_OK;
  }

  javaConfig = getConfig(args[0]);
  jsConfig = getConfig(args[1]);

  // The JavaScriptCore plugin, which the JS formatter depends on, requires
  // the workbench, so start one manually
  startWorkbench();

  for (int i = 2; i < args.length; i++) {
    File f = new File(args[i]);
    format(f);
  }

  return IApplication.EXIT_OK;
}
 
Example 5
Source File: LanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {

   JavaLanguageServerPlugin.startLanguageServer(this);
   synchronized(waitLock){
         while (!shutdown) {
           try {
             context.applicationRunning();
             JavaLanguageServerPlugin.logInfo("Main thread is waiting");
             waitLock.wait();
           } catch (InterruptedException e) {
             JavaLanguageServerPlugin.logException(e.getMessage(), e);
           }
         }
   }
	return IApplication.EXIT_OK;
}
 
Example 6
Source File: Application.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
public Object start(IApplicationContext context) {

		Display display = PlatformUI.createDisplay();

		display.asyncExec(new Runnable() {
			public void run() {
				launchOrionApplication();
				new OSGiConsoleFactory().openConsole();
			}
		});
		try {
			int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
			if (returnCode == PlatformUI.RETURN_RESTART) {
				return IApplication.EXIT_RESTART;
			}
			return IApplication.EXIT_OK;
		} finally {
			display.dispose();
		}
	}
 
Example 7
Source File: Application.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object start ( final IApplicationContext context ) throws Exception
{
    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 ();
    }

}
 
Example 8
Source File: RcpApplication.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public Object start(final IApplicationContext context) throws Exception {
	Object result = null;
	Display display = PlatformUI.createDisplay();
	try {
		final int returnCode = PlatformUI.createAndRunWorkbench(display,
				new RcpWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			result = IApplication.EXIT_RESTART;
		} else {
			result = IApplication.EXIT_OK;
		}
	} finally {
		display.dispose();
	}
	return result;
}
 
Example 9
Source File: Application.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public Object start(IApplicationContext context) throws Exception {
	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();
	}
	
}
 
Example 10
Source File: ImportWorkspaceApplication.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {
    repositoryAccessor.init();
    final String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
    final Optional<String> scan = Stream.of(args).filter("-scan"::equals).findFirst();
    final Optional<String> export = Stream.of(args).filter(arg -> arg.startsWith("-export=")).findFirst();

    final File exportTargetFolder = new File(System.getProperty("java.io.tmpdir"), IMPORT_CACHE_FOLDER);
    if (export.isPresent()) {
        if (exportTargetFolder.exists()) {
            PlatformUtil.delete(exportTargetFolder, Repository.NULL_PROGRESS_MONITOR);
        }
        exportTargetFolder.mkdirs();
    }

    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    if (scan.isPresent() || export.isPresent()) {
        Stream.of(workspace.getRoot().getProjects())
                .filter(hasBonitaNature())
                .map(IProject::getName)
                .map(repositoryAccessor::getRepository)
                .forEach(repository -> {
                    System.out.println(
                            String.format("$SCAN_PROGRESS_%s:%s:%s:%s", repository.getName(),
                                    repository.getVersion(),
                                    findEdition(repository), connected(repository)));
                    export
                            .map(value -> value.split("=")[1])
                            .map(repositories -> repositories.split(":"))
                            .map(Stream::of)
                            .orElse(Stream.empty())
                            .filter(repository.getName()::equals)
                            .findFirst()
                            .ifPresent(repoToExport -> migrateAndExportRepository(exportTargetFolder, repository));

                });
    }
    return IApplication.EXIT_OK;
}
 
Example 11
Source File: Application.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {
  final Map<?, ?> args = context.getArguments();
  final String[] appArgs = (String[]) args.get("application.args");
  CommandDispatch cli = new CommandDispatch();
  cli.dispatch(Arrays.asList(appArgs));

  Object result = cli.getResult();
  if (IApplication.EXIT_OK != result) {
    CmdLogger.LOG.error("Depan Cmd failure with result: {}", result);
  }
  return result;
}
 
Example 12
Source File: Application.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 13
Source File: Application.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object start(IApplicationContext context) {
	Display display = PlatformUI.createDisplay();
	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART) {
			return IApplication.EXIT_RESTART;
		}
		return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}
}
 
Example 14
Source File: Application.java    From gradle-and-eclipse-rcp with Apache License 2.0 5 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {
	Display.setAppName("RCP Demo");
	Shells.builder(SWT.SHELL_TRIM, AppGui::new)
			.setTitle("RCP Demo")
			.setSize(SwtMisc.scaleByFontHeight(40, 30))
			.openOnDisplayBlocking();
	return IApplication.EXIT_OK;
}
 
Example 15
Source File: CodeFormatterApplication.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Runs the Java code formatter application
 */
public Object start(IApplicationContext context) throws Exception {
	File[] filesToFormat = processCommandLine((String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS));

	if (filesToFormat == null) {
		return IApplication.EXIT_OK;
	}

	if (!this.quiet) {
		if (this.configName != null) {
			System.out.println(Messages.bind(Messages.CommandLineConfigFile, this.configName));
		}
		System.out.println(Messages.bind(Messages.CommandLineStart));
	}

	final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(this.options);
	// format the list of files and/or directories
	for (int i = 0, max = filesToFormat.length; i < max; i++) {
		final File file = filesToFormat[i];
		if (file.isDirectory()) {
			formatDirTree(file, codeFormatter);
		} else if (Util.isJavaLikeFileName(file.getPath())) {
			formatFile(file, codeFormatter);
		}
	}
	if (!this.quiet) {
		System.out.println(Messages.bind(Messages.CommandLineDone));
	}

	return IApplication.EXIT_OK;
}
 
Example 16
Source File: Application.java    From jbt with Apache License 2.0 5 votes vote down vote up
public Object start(IApplicationContext context) throws Exception {
	Display display = PlatformUI.createDisplay();

	/*
	 * Before doing anything at all, standard nodes must be loaded. If they
	 * cannot be loaded, the application will not start.
	 */
	try {
		NodesLoader.loadStandardNodes();
		ApplicationIcons.loadIcons();
	} catch (Exception e) {
		StandardDialogs
				.exceptionDialog(
						"Could not start application",
						"There were errors while loading the set of standard nodes",
						e);
		return IApplication.EXIT_OK;
	}

	try {
		int returnCode = PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART)
			return IApplication.EXIT_RESTART;
		else
			return IApplication.EXIT_OK;
	} finally {
		/* Dispose loaded icons. */
		ApplicationIcons.disposeIcons();
		display.dispose();
	}

}
 
Example 17
Source File: OssmeterApplication.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {
	// Setup platform
	processArguments(context);
	
	prop = new Properties();
	prop.load(this.getClass().getResourceAsStream("/config/log4j.properties"));
	
	loggerOssmeter = (OssmeterLogger)OssmeterLogger.getLogger("OssmeterApplication");
	loggerOssmeter.info("Application initialising.");

	// Connect to Mongo - single instance per node
	mongo = Configuration.getInstance().getMongoConnection();
	Platform platform = Platform.getInstance();
	platform.setMongo(mongo);
	platform.initialize();
	
	// Ensure OSGi contributors are active
	PongoFactory.getInstance().getContributors().add(new OsgiPongoFactoryContributor());
	
	ExecutorService executorService = Executors.newFixedThreadPool(this.analysisThreadNumber);
	
	if (worker) {
		WorkerExecutor workerExecutor = new WorkerExecutor(platform,workerId);
		executorService.execute(workerExecutor);
	}
	
	// Start web servers
	if (apiServer) {		
		Activator.getContext().registerService(ApiStartServiceToken.class, new ApiStartServiceToken(), null);
	}
	
	// Launch supervisor daily checking
	TaskCheckExecutor checkerExecutor = new TaskCheckExecutor(platform);
	executorService.execute(checkerExecutor);
	
	try {
		executorService.shutdown();
		executorService.awaitTermination(24, TimeUnit.HOURS);
	} catch (InterruptedException e) {
		loggerOssmeter.error("Exception thrown when shutting down executor service.", e);
	}
	
	// Now, rest.
 		waitForDone();
 		stop();
	return IApplication.EXIT_OK;
}
 
Example 18
Source File: M2DocLauncher.java    From M2Doc with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Launcher logic.
 * 
 * @param args
 *            application parameters passed by the Equinox framework.
 * @return the return value of the application
 */
public Object doMain(String[] args) {
    CmdLineParser parser = new CmdLineParser(this);

    boolean somethingWentWrong = false;
    try {
        System.out.println(CLIUtils.getDecorator()
                .purple(" __          __  _                            _          __  __ ___     _            \n"
                    + " \\ \\        / / | |                          | |        |  \\/  |__ \\   | |           \n"
                    + "  \\ \\  /\\  / /__| | ___ ___  _ __ ___   ___  | |_ ___   | \\  / |  ) |__| | ___   ___ \n"
                    + "   \\ \\/  \\/ / _ \\ |/ __/ _ \\| '_ ` _ \\ / _ \\ | __/ _ \\  | |\\/| | / // _` |/ _ \\ / __|\n"
                    + "    \\  /\\  /  __/ | (_| (_) | | | | | |  __/ | || (_) | | |  | |/ /| (_| | (_) | (__ \n"
                    + "     \\/  \\/ \\___|_|\\___\\___/|_| |_| |_|\\___|  \\__\\___/  |_|  |_|____\\__,_|\\___/ \\___|"));
        System.out.println(
                CLIUtils.getDecorator().yellow("The command-line launcher to generate .docx from your models."));
        parser.parseArgument(args);
        System.out.println(CLIUtils.RESET);
        Collection<URI> genconfsURIs = validateArguments(parser);
        Collection<Generation> loadedGenConfs = new ArrayList<Generation>();

        ResourceSet s = new ResourceSetImpl();
        for (URI uri : genconfsURIs) {
            somethingWentWrong = loadGenerationConfigs(loadedGenConfs, s, uri) || somethingWentWrong;
        }

        final Monitor monitor = new CLIUtils.ColoredPrinting(System.out);
        monitor.beginTask("Generating .docx documents", loadedGenConfs.size());
        for (Generation generation : loadedGenConfs) {
            launchGenerationConfiguration(generation, monitor);
        }
    } catch (CmdLineException e) {
        // print the list of available options
        parser.printUsage(System.err);
        System.err.println();
        somethingWentWrong = true;
        // problem in the command line
        M2DocLauncherPlugin.INSTANCE
                .log(new Status(IStatus.ERROR, M2DocLauncherPlugin.INSTANCE.getSymbolicName(), e.getMessage(), e));
    }

    if (somethingWentWrong) {
        return APPLICATION_ERROR;
    }
    return IApplication.EXIT_OK;

}
 
Example 19
Source File: Application.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {
    Display display = PlatformUI.createDisplay();
    try {
        // fetch the Location that we will be modifying
        fInstanceLoc = Platform.getInstanceLocation();

        // -data @noDefault in <applName>.ini allows us to set the workspace here.
        // If the user wants to change the location then he has to change
        // @noDefault to a specific location or remove -data @noDefault for
        // default location
        if (!fInstanceLoc.allowsDefault() && !fInstanceLoc.isSet()) {
            File workspaceRoot = new File(TracingRcpPlugin.getWorkspaceRoot());

            if (!workspaceRoot.exists()) {
                MessageDialog.openError(display.getActiveShell(),
                        Messages.Application_WorkspaceCreationError,
                        MessageFormat.format(Messages.Application_WorkspaceRootNotExistError, new Object[] { TracingRcpPlugin.getWorkspaceRoot() }));
                return IApplication.EXIT_OK;
            }

            if (!workspaceRoot.canWrite()) {
                MessageDialog.openError(display.getActiveShell(),
                        Messages.Application_WorkspaceCreationError,
                        MessageFormat.format(Messages.Application_WorkspaceRootPermissionError, new Object[] { TracingRcpPlugin.getWorkspaceRoot() }));
                return IApplication.EXIT_OK;
            }

            String workspace = TracingRcpPlugin.getWorkspaceRoot() + File.separator + TracingRcpPlugin.WORKSPACE_NAME;
            // set location to workspace
            fInstanceLoc.set(new URL("file", null, workspace), false); //$NON-NLS-1$
        }

        /*
         * Execute the early command line options.
         */
        try {
            CliCommandLine cmdLine = CliParserManager.getInstance().parse(Platform.getCommandLineArgs());
            TracingRcpPlugin.getDefault().setCommandLine(cmdLine);
            if (cmdLine != null && CliParserManager.applicationStartup(cmdLine)) {
                return IApplication.EXIT_OK;
            }
        } catch (CliParserException e) {
            TracingRcpPlugin.getDefault().logError("Error parsing command line arguments", e); //$NON-NLS-1$
            return IApplication.EXIT_OK;
        }

        if (!fInstanceLoc.lock()) {
            MessageDialog.openError(display.getActiveShell(),
                    Messages.Application_WorkspaceCreationError,
                    MessageFormat.format(Messages.Application_WorkspaceInUseError, new Object[] { fInstanceLoc.getURL().getPath() }));
            return IApplication.EXIT_OK;
        }

        int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
        if (returnCode == PlatformUI.RETURN_RESTART) {
            return IApplication.EXIT_RESTART;
        }
        return IApplication.EXIT_OK;
    } finally {
        display.dispose();
    }
}
 
Example 20
Source File: HeadlessApp.java    From gradle-and-eclipse-rcp with Apache License 2.0 4 votes vote down vote up
@Override
public Object start(IApplicationContext context) throws Exception {
	String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
	System.out.println(Arrays.asList(args));
	return IApplication.EXIT_OK;
}