use of org.eclipse.equinox.app.IApplication in project eclipse.platform.releng by eclipse.
the class UITestApplication method getApplication.
/*
* return the application to run, or null if not even the default application
* is found.
*/
private Object getApplication(String[] args) throws CoreException {
// Assume we are in 3.0 mode.
// Find the name of the application as specified by the PDE JUnit launcher.
// If no application is specified, the 3.0 default workbench application
// is returned.
IExtension extension = Platform.getExtensionRegistry().getExtension(Platform.PI_RUNTIME, Platform.PT_APPLICATIONS, getApplicationToRun(args));
// Set the deprecated flag to true
if (extension == null) {
extension = Platform.getExtensionRegistry().getExtension(Platform.PI_RUNTIME, Platform.PT_APPLICATIONS, DEFAULT_APP_PRE_3_0);
fInDeprecatedMode = true;
}
Assert.assertNotNull(extension);
// If the extension does not have the correct grammar, return null.
// Otherwise, return the application object.
IConfigurationElement[] elements = extension.getConfigurationElements();
if (elements.length > 0) {
// $NON-NLS-1$
IConfigurationElement[] runs = elements[0].getChildren("run");
if (runs.length > 0) {
// $NON-NLS-1$
Object runnable = runs[0].createExecutableExtension("class");
if (runnable instanceof IPlatformRunnable)
return runnable;
if (runnable instanceof IApplication)
return runnable;
}
}
return null;
}
use of org.eclipse.equinox.app.IApplication in project equinox.bundles by eclipse-equinox.
the class EclipseAppHandle method run.
@Override
public Object run(Object context) throws Exception {
if (context != null) {
// always force the use of the context if it is not null
arguments.put(IApplicationContext.APPLICATION_ARGS, context);
} else {
// get the context from the arguments
context = arguments.get(IApplicationContext.APPLICATION_ARGS);
if (context == null) {
// if context is null then use the args from CommandLineArgs
context = CommandLineArgs.getApplicationArgs();
arguments.put(IApplicationContext.APPLICATION_ARGS, context);
}
}
Object tempResult = null;
try {
Object app;
synchronized (this) {
if ((status & (EclipseAppHandle.FLAG_STARTING | EclipseAppHandle.FLAG_STOPPING)) == 0)
throw new ApplicationException(ApplicationException.APPLICATION_INTERNAL_ERROR, NLS.bind(Messages.application_instance_stopped, getInstanceId()));
// $NON-NLS-1$
application = getConfiguration().createExecutableExtension("run");
app = application;
notifyAll();
}
if (app instanceof IApplication)
tempResult = ((IApplication) app).start(this);
else
// $NON-NLS-1$
tempResult = EclipseAppContainer.callMethodWithException(app, "run", new Class[] { Object.class }, new Object[] { context });
if (tempResult == null)
tempResult = NULL_RESULT;
} finally {
tempResult = setInternalResult(tempResult, false, null);
}
if (Activator.DEBUG)
// $NON-NLS-1$
System.out.println(NLS.bind(Messages.application_returned, (new String[] { getApplicationDescriptor().getApplicationId(), tempResult == null ? "null" : tempResult.toString() })));
return tempResult;
}
use of org.eclipse.equinox.app.IApplication in project reddeer by eclipse.
the class UITestApplication method getApplication.
/*
* return the application to run, or null if not even the default application is
* found.
*/
private Object getApplication(String[] args) throws CoreException {
// Find the name of the application as specified by the PDE JUnit
// launcher.
// If no application is specified, the 3.0 default workbench application
// is returned.
String applicationToRun = getApplicationToRun(args);
IExtension extension = Platform.getExtensionRegistry().getExtension(Platform.PI_RUNTIME, Platform.PT_APPLICATIONS, applicationToRun);
Assert.isNotNull(extension, "Could not find IExtension for application: " + applicationToRun);
// If the extension does not have the correct grammar, return null.
// Otherwise, return the application object.
IConfigurationElement[] elements = extension.getConfigurationElements();
if (elements.length > 0) {
// $NON-NLS-1$
IConfigurationElement[] runs = elements[0].getChildren("run");
if (runs.length > 0) {
// $NON-NLS-1$
Object runnable = runs[0].createExecutableExtension("class");
if (runnable instanceof IApplication)
return runnable;
}
}
return null;
}
use of org.eclipse.equinox.app.IApplication in project hale by halestudio.
the class ApplicationUtil method launchSyncApplication.
/**
* Launch an application.
*
* @param application the application instance
* @param argList the application arguments
* @return the application return code
* @throws Exception if the application exits with an exception
*/
public static Object launchSyncApplication(IApplication application, final List<String> argList) throws Exception {
String[] args = argList.size() == 0 ? null : (String[]) argList.toArray(new String[argList.size()]);
final Map<String, Object> launchArgs = new HashMap<>(1);
if (args != null) {
launchArgs.put(IApplicationContext.APPLICATION_ARGS, args);
}
IApplicationContext context = new IApplicationContext() {
@Override
public void setResult(Object result, IApplication application) {
throw new UnsupportedOperationException();
}
@Override
public String getBrandingProperty(String key) {
return null;
}
@Override
public String getBrandingName() {
return null;
}
@Override
public String getBrandingId() {
return null;
}
@Override
public String getBrandingDescription() {
return null;
}
@Override
public Bundle getBrandingBundle() {
return null;
}
@Override
public String getBrandingApplication() {
return null;
}
@SuppressWarnings("rawtypes")
@Override
public Map getArguments() {
return launchArgs;
}
@Override
public void applicationRunning() {
// anything to do?
}
};
return application.start(context);
}
use of org.eclipse.equinox.app.IApplication in project rt.equinox.framework by eclipse.
the class ExitValueApp method run.
public synchronized void run() {
if (active) {
try {
// only run for 5 seconds at most
wait(5000);
} catch (InterruptedException e) {
// do nothing
}
}
stopped = true;
if (useAsync) {
IApplication app = this;
Object result = returnNull ? null : exitValue;
if (setWrongApp) {
result = "failed";
app = new IApplication() {
public void stop() {
// nothing
}
public Object start(IApplicationContext context) throws Exception {
return null;
}
};
}
try {
appContext.setResult(result, app);
// failed
} catch (IllegalArgumentException e) {
// passed
appContext.setResult(returnNull ? null : exitValue, this);
}
}
notifyAll();
}
Aggregations