public IProduct getProduct() { if (product != null) return product; EclipseAppContainer container = Activator.getContainer(); IBranding branding = container == null ? null : container.getBranding(); if (branding == null) return null; Object brandingProduct = branding.getProduct(); if (!(brandingProduct instanceof IProduct)) brandingProduct = new Product(branding); product = (IProduct) brandingProduct; return product; }
@Override public String getApplication() { return (String) EclipseAppContainer.callMethod(product, "getApplication", null, null); //$NON-NLS-1$ }
private void registerAppDescriptors() { IExtension[] availableApps = getAvailableAppExtensions(); for (int i = 0; i < availableApps.length; i++) createAppDescriptor(availableApps[i]); }
private void registerAppDescriptor(String applicationId) { IExtension appExtension = getAppExtension(applicationId); if (appExtension != null) createAppDescriptor(appExtension); }
void startDefaultApp(boolean delayError) throws ApplicationException { // find the default application String applicationId = getDefaultAppId(); EclipseAppDescriptor defaultDesc = null; Map args = new HashMap(2); args.put(EclipseAppDescriptor.APP_DEFAULT, Boolean.TRUE); if (applicationId == null && !delayError) { // the application id is not set; use a descriptor that will throw an exception args.put(ErrorApplication.ERROR_EXCEPTION, new RuntimeException(Messages.application_noIdFound)); defaultDesc = getAppDescriptor(EXT_ERROR_APP); } else { defaultDesc = getAppDescriptor(applicationId); if (defaultDesc == null && !delayError) { // the application id is not available in the registry; use a descriptor that will throw an exception args.put(ErrorApplication.ERROR_EXCEPTION, new RuntimeException(NLS.bind(Messages.application_notFound, applicationId, getAvailableAppsMsg()))); defaultDesc = getAppDescriptor(EXT_ERROR_APP); } } if (delayError && defaultDesc == null) { // could not find the application; but we want to delay the error. // another bundle may get installed that provides the application // before we actually try to launch it. missingApp = true; return; } if (defaultDesc != null) defaultDesc.launch(args); else throw new ApplicationException(ApplicationException.APPLICATION_INTERNAL_ERROR, Messages.application_noIdFound); }
private IConfigurationElement getConfiguration() { IExtension applicationExtension = ((EclipseAppDescriptor) getApplicationDescriptor()).getContainerManager().getAppExtension(getApplicationDescriptor().getApplicationId()); if (applicationExtension == null) throw new RuntimeException(NLS.bind(Messages.application_notFound, getApplicationDescriptor().getApplicationId(), ((EclipseAppDescriptor) getApplicationDescriptor()).getContainerManager().getAvailableAppsMsg())); IConfigurationElement[] configs = applicationExtension.getConfigurationElements(); if (configs.length == 0) throw new RuntimeException(NLS.bind(Messages.application_invalidExtension, getApplicationDescriptor().getApplicationId())); return configs[0]; }
public Object addingService(ServiceReference reference) { BundleContext context = _context; if (context == null) return null; // really should never happen since we close the tracker before nulling out context Object service = null; EclipseAppContainer startContainer = null; synchronized (this) { if (container != null) return null; // container is already started; do nothing service = context.getService(reference); if (registry == null && service instanceof IExtensionRegistry) { registry = (IExtensionRegistry) service; // create and start the app container container = new EclipseAppContainer(context, registry); startContainer = container; } } // must not start the container while holding a lock because this will register additional services if (startContainer != null) { startContainer.start(); return service; } // this means there is more than one registry; we don't need a second one if (service != null) context.ungetService(reference); return null; }
static Object callMethod(Object obj, String methodName, Class[] argTypes, Object[] args) { try { return callMethodWithException(obj, methodName, argTypes, args); } catch (Throwable t) { Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.ERROR, 0, "Error in invoking method.", 0, t, null)); //$NON-NLS-1$ } return null; }
String getAvailableAppsMsg() { IExtension[] availableApps = getAvailableAppExtensions(); String availableAppsMsg = "<NONE>"; //$NON-NLS-1$ if (availableApps.length != 0) { availableAppsMsg = availableApps[0].getUniqueIdentifier(); for (int i = 1; i < availableApps.length; i++) availableAppsMsg = availableAppsMsg + ", " + availableApps[i].getUniqueIdentifier(); //$NON-NLS-1$ } return availableAppsMsg; }
@Override public void added(IExtension[] extensions) { for (int i = 0; i < extensions.length; i++) createAppDescriptor(extensions[i]); }
String defaultApp = getDefaultAppId(); if (defaultApp != null && defaultApp.equals(appExtension.getUniqueIdentifier())) flags |= EclipseAppDescriptor.FLAG_DEFAULT_APP;
void startDefaultApp(boolean delayError) throws ApplicationException { // find the default application String applicationId = getDefaultAppId(); EclipseAppDescriptor defaultDesc = null; Map args = new HashMap(2); args.put(EclipseAppDescriptor.APP_DEFAULT, Boolean.TRUE); if (applicationId == null && !delayError) { // the application id is not set; use a descriptor that will throw an exception args.put(ErrorApplication.ERROR_EXCEPTION, new RuntimeException(Messages.application_noIdFound)); defaultDesc = getAppDescriptor(EXT_ERROR_APP); } else { defaultDesc = getAppDescriptor(applicationId); if (defaultDesc == null && !delayError) { // the application id is not available in the registry; use a descriptor that will throw an exception args.put(ErrorApplication.ERROR_EXCEPTION, new RuntimeException(NLS.bind(Messages.application_notFound, applicationId, getAvailableAppsMsg()))); defaultDesc = getAppDescriptor(EXT_ERROR_APP); } } if (delayError && defaultDesc == null) { // could not find the application; but we want to delay the error. // another bundle may get installed that provides the application // before we actually try to launch it. missingApp = true; return; } if (defaultDesc != null) defaultDesc.launch(args); else throw new ApplicationException(ApplicationException.APPLICATION_INTERNAL_ERROR, Messages.application_noIdFound); }
private IConfigurationElement getConfiguration() { IExtension applicationExtension = ((EclipseAppDescriptor) getApplicationDescriptor()).getContainerManager().getAppExtension(getApplicationDescriptor().getApplicationId()); if (applicationExtension == null) throw new RuntimeException(NLS.bind(Messages.application_notFound, getApplicationDescriptor().getApplicationId(), ((EclipseAppDescriptor) getApplicationDescriptor()).getContainerManager().getAvailableAppsMsg())); IConfigurationElement[] configs = applicationExtension.getConfigurationElements(); if (configs.length == 0) throw new RuntimeException(NLS.bind(Messages.application_invalidExtension, getApplicationDescriptor().getApplicationId())); return configs[0]; }
private void registerAppDescriptor(String applicationId) { IExtension appExtension = getAppExtension(applicationId); if (appExtension != null) createAppDescriptor(appExtension); }
public Object addingService(ServiceReference reference) { BundleContext context = _context; if (context == null) return null; // really should never happen since we close the tracker before nulling out context Object service = null; EclipseAppContainer startContainer = null; synchronized (this) { if (container != null) return null; // container is already started; do nothing service = context.getService(reference); if (registry == null && service instanceof IExtensionRegistry) { registry = (IExtensionRegistry) service; // create and start the app container container = new EclipseAppContainer(context, registry); startContainer = container; } } // must not start the container while holding a lock because this will register additional services if (startContainer != null) { startContainer.start(); return service; } // this means there is more than one registry; we don't need a second one if (service != null) context.ungetService(reference); return null; }
static Object callMethod(Object obj, String methodName, Class[] argTypes, Object[] args) { try { return callMethodWithException(obj, methodName, argTypes, args); } catch (Throwable t) { Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.ERROR, 0, "Error in invoking method.", 0, t, null)); //$NON-NLS-1$ } return null; }
String getAvailableAppsMsg() { IExtension[] availableApps = getAvailableAppExtensions(); String availableAppsMsg = "<NONE>"; //$NON-NLS-1$ if (availableApps.length != 0) { availableAppsMsg = availableApps[0].getUniqueIdentifier(); for (int i = 1; i < availableApps.length; i++) availableAppsMsg = availableAppsMsg + ", " + availableApps[i].getUniqueIdentifier(); //$NON-NLS-1$ } return availableAppsMsg; }
public void added(IExtension[] extensions) { for (int i = 0; i < extensions.length; i++) createAppDescriptor(extensions[i]); }
String defaultApp = getDefaultAppId(); if (defaultApp != null && defaultApp.equals(appExtension.getUniqueIdentifier())) flags |= EclipseAppDescriptor.FLAG_DEFAULT_APP;
private String getDefaultAppId() { if (defaultAppId != null) return defaultAppId; // try commandLineProperties defaultAppId = CommandLineArgs.getApplication(); if (defaultAppId != null) return defaultAppId; // try bundleContext properties defaultAppId = context.getProperty(EclipseAppContainer.PROP_ECLIPSE_APPLICATION); if (defaultAppId != null) return defaultAppId; //Derive the application from the product information defaultAppId = getBranding() == null ? null : getBranding().getApplication(); return defaultAppId; }