Java Code Examples for org.osgi.framework.Bundle

The following examples show how to use org.osgi.framework.Bundle. These examples are extracted from open source projects. 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
/**
 * Load a MetaTypeProvider from an XML file.
 */
public static MTP loadMTPFromURL(Bundle bundle, URL url) throws IOException {
  InputStream in = null;

  try {
    in = url.openStream();
    final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
    final IXMLReader reader = new StdXMLReader(in);
    parser.setReader(reader);
    final XMLElement el = (XMLElement) parser.parse();
    return loadMTP(bundle, url, el);
  } catch (final Throwable t) {
    throw (IOException) new IOException("Failed to load " + url + " " + t)
        .initCause(t);
  } finally {
    try {
      in.close();
    } catch (final Exception ignored) {
    }
  }

}
 
Example 2
/**
 * Creates a new XML Parser Factory object.
 * 
 * <p>
 * A unique XML Parser Factory object is returned for each call to this
 * method.
 * 
 * <p>
 * The returned XML Parser Factory object will be configured for validating
 * and namespace aware support as specified in the service properties of the
 * specified ServiceRegistration object.
 * 
 * This method can be overridden to configure additional features in the
 * returned XML Parser Factory object.
 * 
 * @param bundle The bundle using the service.
 * @param registration The <code>ServiceRegistration</code> object for the
 *        service.
 * @return A new, configured XML Parser Factory object or null if a
 *         configuration error was encountered
 */
public Object getService(Bundle bundle, ServiceRegistration registration) {
	ServiceReference sref = registration.getReference();
	String parserFactoryClassName = (String) sref
			.getProperty(FACTORYNAMEKEY);
	// need to set factory properties
	Object factory = getFactory(parserFactoryClassName);
	if (factory instanceof SAXParserFactory) {
		((SAXParserFactory) factory).setValidating(((Boolean) sref
				.getProperty(PARSER_VALIDATING)).booleanValue());
		((SAXParserFactory) factory).setNamespaceAware(((Boolean) sref
				.getProperty(PARSER_NAMESPACEAWARE)).booleanValue());
	}
	else {
		if (factory instanceof DocumentBuilderFactory) {
			((DocumentBuilderFactory) factory)
					.setValidating(((Boolean) sref
							.getProperty(PARSER_VALIDATING)).booleanValue());
			((DocumentBuilderFactory) factory)
					.setNamespaceAware(((Boolean) sref
							.getProperty(PARSER_NAMESPACEAWARE))
							.booleanValue());
		}
	}
	return factory;
}
 
Example 3
/**
 * DOCUMENT ME!
 *
 * @param name DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
public URL getResource(String name) {
    name = name.substring(1);

    String temp = name.substring(0, name.lastIndexOf("/"));
    String packageName = temp.replace('/', '.');

    for (int i = 0; i < exportedPackages.size(); i++) {
        Bundle b = ((Bundle) exportedPackages.get(i));
        ExportedPackage[] exp = packageAdmin.getExportedPackages(b);

        if (exp != null) {
            for (int j = 0; j < exp.length; j++) {
                if (exp[j].getName().equals(packageName)) {
                    return b.getResource(name);
                }
            }
        }
    }

    return null;
}
 
Example 4
/**
 * Get the specified header name from a bundle and parse the value as package
 * names (ignoring all parameters and directives).
 *
 * @return a collection of strings
 */
protected Collection<String> getPackageNames(final Bundle b,
                                             final String headerName)
{
  final Set<String> res = new TreeSet<String>();
  final String v = b.getHeaders().get(headerName);

  if (v != null && v.length() > 0) {
    // Uses the manifest entry parser from the KF-framework
    try {
      for (final HeaderEntry he : org.knopflerfish.framework.Util
          .parseManifestHeader(headerName, v, false, false, false)) {
        res.addAll(he.getKeys());
      }
    } catch (final IllegalArgumentException iae) {
    }
  }
  return res;
}
 
Example 5
/**
 * Get the RequiredBundle object for this bundle.
 *
 * @param rbl
 *          List of required bundles as returend by package admin.
 * @param bundle
 *          The bundle to get requiring bundles for.
 * @return The RequiredBundle object for the given bundle or <tt>null</tt> if
 *         the bundle is not required.
 */
public RequiredBundle getRequiredBundle(final RequiredBundle[] rbl,
                                        final Bundle b)
{
  final RequiredBundle rb = requiredBundleMap.get(b);
  if (rb != null) {
    return rb;
  }
  for (int i = 0; rbl != null && i < rbl.length; i++) {
    final Bundle rbb = rbl[i].getBundle();
    if (rbb != null && rbb.getBundleId() == b.getBundleId()) {
      requiredBundleMap.put(b, rbl[i]);
      return rbl[i];
    }
  }
  requiredBundleMap.put(b, null);
  return null;
}
 
Example 6
Source Project: carbon-kernel   Source File: StartupOrderResolver.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Process supported manifest headers (Startup-Component and Provide-Capability).
 * <p>
 * Process Startup-Component headers and create StartupComponent instances.
 * <p>
 * Process Provide-Capability headers to calculate the expected number of required capabilities.
 * <p>
 * Process Provide-Capability headers to get a list of CapabilityProviders and RequiredCapabilityListeners.
 *
 * @param bundleList list of bundles to be scanned for Provide-Capability headers.
 */
private void processManifestHeaders(List<Bundle> bundleList) {
    Map<String, List<ManifestElement>> groupedManifestElements =
            bundleList.stream()
                    // Filter out all the bundles with the Carbon-Component manifest header.
                    .filter(StartupOrderResolverUtils::isCarbonComponentHeaderPresent)
                    // Process filtered manifest headers and get a list of ManifestElements.
                    .map(StartupOrderResolverUtils::getManifestElements)
                    // Merge all the manifest elements lists into a single list.
                    .flatMap(Collection::stream)
                    // Partition all the ManifestElements with the manifest header name.
                    .collect(Collectors.groupingBy(ManifestElement::getValue));

    if (groupedManifestElements.get(STARTUP_LISTENER_COMPONENT) != null) {
        processServiceComponents(groupedManifestElements);
    }

    if (groupedManifestElements.get(OSGI_SERVICE_COMPONENT) != null) {
        processCapabilityProviders(groupedManifestElements.get(OSGI_SERVICE_COMPONENT));
        processOSGiServices(groupedManifestElements.get(OSGI_SERVICE_COMPONENT));
    }

    // You can add logic to handle other types of provide capabilities here.
    // e.g. custom manifest headers, config files etc.
}
 
Example 7
Source Project: KaiZen-OpenAPI-Editor   Source File: Activator.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    if (Display.getCurrent() != null && PlatformUI.isWorkbenchRunning()) {
        Bundle bundle = Platform.getBundle(PLUGIN_ID);
  
        // for quick outline, add icons from YEdit
        bundle = Platform.getBundle(org.dadacoalition.yedit.Activator.PLUGIN_ID);
        addImage(bundle, Icons.outline_document.name(), "icons/outline_document.gif");
        addImage(bundle, Icons.outline_mapping.name(), "icons/outline_mapping.gif");
        addImage(bundle, Icons.outline_scalar.name(), "icons/outline_scalar.gif");
        addImage(bundle, Icons.outline_mapping_scalar.name(), "icons/outline_mappingscalar.gif");
        addImage(bundle, Icons.outline_sequence.name(), "icons/outline_sequence.png");
    }
}
 
Example 8
private static ImageDescriptor findIconImageDescriptor(String iconPath) {
    String pluginId = "org.eclipse.gmf.runtime.diagram.ui.providers";
    Bundle bundle = Platform.getBundle(pluginId);
    try
    {
        if (iconPath != null) {
            URL fullPathString = FileLocator.find(bundle, new Path(iconPath), null);
            fullPathString = fullPathString != null ? fullPathString : new URL(iconPath);
            if (fullPathString != null) {
                return ImageDescriptor.createFromURL(fullPathString);
            }
        }
    }
    catch (MalformedURLException e)
    {
        Trace.catching(DiagramUIPlugin.getInstance(),
            DiagramUIDebugOptions.EXCEPTIONS_CATCHING,
            DefaultPaletteProvider.class, e.getLocalizedMessage(), e); 
        Log.error(DiagramUIPlugin.getInstance(),
            DiagramUIStatusCodes.RESOURCE_FAILURE, e.getMessage(), e);
    }
    
    return null;
}
 
Example 9
Source Project: smarthome   Source File: BindingInfoXmlProvider.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public BindingInfoXmlProvider(Bundle bundle, XmlBindingInfoProvider bindingInfoProvider,
        AbstractXmlConfigDescriptionProvider configDescriptionProvider) throws IllegalArgumentException {
    if (bundle == null) {
        throw new IllegalArgumentException("The Bundle must not be null!");
    }

    if (bindingInfoProvider == null) {
        throw new IllegalArgumentException("The XmlBindingInfoProvider must not be null!");
    }

    if (configDescriptionProvider == null) {
        throw new IllegalArgumentException("The XmlConfigDescriptionProvider must not be null!");
    }

    this.bundle = bundle;

    this.bindingInfoProvider = bindingInfoProvider;
    this.configDescriptionProvider = configDescriptionProvider;
}
 
Example 10
@Override
public Representation put(final Representation value,
		final Variant variant) {
	try {
		final Bundle bundle = getBundleFromKeys(RestService.BUNDLE_ID_KEY);
		if (bundle == null) {
			return ERROR(Status.CLIENT_ERROR_NOT_FOUND);
		}
		final BundleStartLevelPojo sl = fromRepresentation(value, value.getMediaType());
		final BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
		bsl.setStartLevel(sl.getStartLevel());

		return getRepresentation(new BundleStartLevelPojo(bsl), variant);
	} catch (final Exception e) {
		return ERROR(e, variant);
	}
}
 
Example 11
Source Project: xds-ide   Source File: XdsResourcesUpdater.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param installedUpdatesRegistry 
 * @param dirWithUpdatesPath directory where updates are
 * @param updateDirSubdirWithResource relative path where update is
 * @param newResourceName update resource name
 * @throws IOException
 * @throws FileNotFoundException
 * @return true if the resource was updated
 */
private boolean updateResource(InstalledUpdatesRegistry installedUpdatesRegistry, Bundle resourcesBundle, String dirWithUpdatesPath, Update update) {
	String newResourceRelativePath = update.newResourceLocation;
	String existingResourceRelativePath = update.existingResourceLocation;
	String xmlSchemaRelativePath = update.xmlSchemaLocation;
	Version version = update.version;
	File resourceFolderFile = null;
	try {
		resourceFolderFile = FileLocator.getBundleFile(resourcesBundle);
	} catch (IOException e) {
		LogHelper.logError(e);
		return false;
	}
	
	return updateResource(installedUpdatesRegistry, dirWithUpdatesPath,
			newResourceRelativePath, resourceFolderFile,
			existingResourceRelativePath, xmlSchemaRelativePath, version, true);
}
 
Example 12
Source Project: vespa   Source File: Deconstructor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void deconstruct(Collection<Object> components, Collection<Bundle> bundles) {
    Collection<AbstractComponent> destructibleComponents = new ArrayList<>();
    for (var component : components) {
        if (component instanceof AbstractComponent) {
            AbstractComponent abstractComponent = (AbstractComponent) component;
            if (abstractComponent.isDeconstructable()) {
                destructibleComponents.add(abstractComponent);
            }
        } else if (component instanceof Provider) {
            // TODO Providers should most likely be deconstructed similarly to AbstractComponent
            log.log(FINE, () -> "Starting deconstruction of provider " + component);
            ((Provider<?>) component).deconstruct();
            log.log(FINE, () -> "Finished deconstruction of provider " + component);
        } else if (component instanceof SharedResource) {
            log.log(FINE, () -> "Releasing container reference to resource " + component);
            // No need to delay release, as jdisc does ref-counting
            ((SharedResource) component).release();
        }
    }
    if (! destructibleComponents.isEmpty() || ! bundles.isEmpty())
        executor.schedule(new DestructComponentTask(destructibleComponents, bundles),
                          delay.getSeconds(), TimeUnit.SECONDS);
}
 
Example 13
private static List<String> collectFilesFrom(Bundle bundle, String bundlePath, String bundleName,
        Set<String> extensionsToInclude) throws Exception {
    List<String> result = new ArrayList<>();
    URL url = getBaseURL(bundle, bundleName);
    if (url != null) {
        String path = url.getPath();
        URI baseURI = url.toURI();

        List<URL> list = collectEntries(bundle, path, extensionsToInclude);
        for (URL entryURL : list) {
            String fileEntry = convertToFileEntry(baseURI, entryURL);
            result.add(fileEntry);
        }
    }
    return result;
}
 
Example 14
Source Project: developer-studio   Source File: ResourceManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns an {@link URL} based on a {@link Bundle} and resource entry path.
 */
private static URL getPluginImageURL(String symbolicName, String path) {
	// try runtime plugins
	{
		Bundle bundle = Platform.getBundle(symbolicName);
		if (bundle != null) {
			return bundle.getEntry(path);
		}
	}
	// try design time provider
	if (m_designTimePluginResourceProvider != null) {
		return m_designTimePluginResourceProvider.getEntry(symbolicName, path);
	}
	// no such resource
	return null;
}
 
Example 15
public static Color getColor(int state) {
  switch(state) {
  case Bundle.INSTALLED:
    return installedColor;
  case Bundle.ACTIVE:
    return activeColor;
  case Bundle.RESOLVED:
    return resolvedColor;
  case Bundle.UNINSTALLED:
    return uninstalledColor;
  case Bundle.STARTING:
    return startingColor;
  case Bundle.STOPPING:
    return stoppingColor;
  }

  return Color.black;
}
 
Example 16
public Bundle[] getBundles(String symbolicName, String versionRange) {
  final VersionRange vr = versionRange != null ? new VersionRange(versionRange.trim()) :
      null;
  final List<BundleGeneration> bgs = fwCtx.bundles.getBundles(symbolicName, vr);
  final int size = bgs.size();
  if (size > 0) {
    final Bundle[] res = new Bundle[size];
    final Iterator<BundleGeneration> i = bgs.iterator();
    for (int pos = 0; pos < size;) {
      res[pos++] = i.next().bundle;
    }
    return res;
  } else {
    return null;
  }
}
 
Example 17
public void addBundle0(final Bundle[] bundles) {
  if (bundles != null) {
    for (final Bundle bundle : bundles) {
      if(null == getBundleComponent(bundle)) {
        final JLabel c = createJLabelForBundle(bundle);

        c.setToolTipText(Util.bundleInfo(bundle));
        c.setVerticalTextPosition(SwingConstants.BOTTOM);
        c.setHorizontalTextPosition(SwingConstants.CENTER);

        c.setPreferredSize(new Dimension(96, 64));
        c.setBorder(null);
        c.setFont(getFont());

        bundleMap.put(new Long(bundle.getBundleId()), c);

        updateBundleComp(bundle);
      }
    }
  }
  rebuildPanel();
}
 
Example 18
public RelationalActivator() {
    instance = this;
    //Make sure the JNDI plugin is active
    AccessController.doPrivileged( new PrivilegedAction<Void>() {
        public Void run() {
            try {
                Bundle bundle = Platform.getBundle( "com.ibm.pvc.jndi.provider.java"); // $NON-NLS-1$
                if(bundle!=null) { // Empty during the unit tests
                    bundle.start();
                }
            } catch (BundleException ex) {
                if(RelationalLogger.RELATIONAL.isErrorEnabled()) {
                    RelationalLogger.RELATIONAL.errorp(this, "RelationalActivator", ex, "Exception occured activating the JNDI plugin"); // $NON-NLS-1$ $NLE-RelationalActivator.ExceptionoccuredactivatingtheJNDI-2$
                }
            }
            return null;
        }
    });
}
 
Example 19
/**
 * Handle the section error when an issue is found loading from the
 * configuration element.
 *
 * @param exception
 *            an optional CoreException
 */
private void handleSectionError(CoreException exception) {
	String pluginId = getConfigurationElement().getDeclaringExtension()
			.getContributor().getName();
	String message = TabbedPropertyMessages.SectionDescriptor_Section_error;
	if (exception == null) {
		message = MessageFormat.format(TabbedPropertyMessages.SectionDescriptor_Section_error, pluginId);
	} else {
		message = MessageFormat.format(TabbedPropertyMessages.SectionDescriptor_class_not_found_error, pluginId);
	}
	IStatus status = new Status(IStatus.ERROR, pluginId,
			TabbedPropertyViewStatusCodes.SECTION_ERROR, message, exception);
	Bundle bundle = FrameworkUtil.getBundle(SectionDescriptor.class);
	Platform.getLog(bundle).log(status);
}
 
Example 20
/**
 * Get the gwt zip path.
 */
private static String getGwtTestSdkPath() {
  Bundle bundle = GwtTestingPlugin.getDefault().getBundle();

  // Maven compile uses a jar, and is in target
  String basePath = Paths.get("").toAbsolutePath().toString();
  if (basePath.endsWith("target")) {
    basePath = basePath.replace("target/", "");
  }

  String version = TestEnvironmentUtil.getMavenPropertyVersionFor("gwt.version");
  String pathToZip = basePath + "/../../resources/target/resources/gwt-" + version + ".zip";
  String gwtHomePath = TestEnvironmentUtil.installTestSdk(bundle, pathToZip).toOSString();
  return gwtHomePath;
}
 
Example 21
Source Project: brooklyn-server   Source File: Osgis.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Installs a bundle from the given URL, doing a check if already installed, and
 * using the {@link ResourceUtils} loader for this project (brooklyn core)
 */
public static Bundle install(Framework framework, String url) throws BundleException {
    boolean isLocal = isLocalUrl(url);
    String localUrl = url;
    if (!isLocal) {
        localUrl = cacheFile(url);
    }

    try {
        Bundle bundle = getInstalledBundle(framework, localUrl);
        if (bundle != null) {
            return bundle;
        }

        // use our URL resolution so we get classpath items
        LOG.debug("Installing bundle into {} from url: {}", framework, url);
        InputStream stream = getUrlStream(localUrl);
        Bundle installedBundle = framework.getBundleContext().installBundle(url, stream);
        
        return installedBundle;
    } finally {
        if (!isLocal) {
            try {
                new File(new URI(localUrl)).delete();
            } catch (URISyntaxException e) {
                throw Exceptions.propagate(e);
            }
        }
    }
}
 
Example 22
Source Project: depan   Source File: PluginClassLoader.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Try to load classes from the known list of bundles, in order.
 * If all of those fail, delegate to the super class.
 */
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
  for (Bundle bundle: pluginBundles) {
    // try to load the class one plugin after the other. stop on the first
    // plugin providing the corresponding class.
    try {
      return bundle.loadClass(name);
    } catch (ClassNotFoundException e) {
    }
  }
  return super.loadClass(name);
}
 
Example 23
Source Project: AtlasForAndroid   Source File: Package.java    License: MIT License 5 votes vote down vote up
public Bundle[] getImportingBundles() {
    if (this.importingBundles == null) {
        return new Bundle[]{this.classloader.bundle};
    }
    Bundle[] bundleArr = new Bundle[(this.importingBundles.size() + 1)];
    this.importingBundles.toArray(bundleArr);
    bundleArr[this.importingBundles.size()] = this.classloader.bundle;
    return bundleArr;
}
 
Example 24
Source Project: vespa   Source File: ClassLoaderOsgiFramework.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<Bundle> installBundle(String bundleLocation) {
    if (bundleLocation != null && ! bundleLocation.isEmpty()) {
        try {
            URL url = new URL(bundleLocation);
            bundleLocations.add(url);
            bundleList.add(new JarBundleImpl(url));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    return bundles();
}
 
Example 25
ConfigurationImpl(Bundle callingBundle, String bundleLocation,
                  String factoryPid, String servicePid,
                  ConfigurationDictionary properties)
{
  this.callingBundle = callingBundle;
  this.factoryPid = factoryPid;
  this.servicePid = servicePid;

  if (properties == null) {
    this.properties = new ConfigurationDictionary();
  } else {
    this.properties = properties;
  }
  putLocation(bundleLocation);
}
 
Example 26
Source Project: EasyShell   Source File: Activator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected void addImageToRegistry(ImageRegistry registry, Bundle bundle, String imagePath, String image_id) {
    IPath path = new Path(imagePath);
    URL url = FileLocator.find(bundle, path, null);
    ImageDescriptor desc = ImageDescriptor.createFromURL(url);
    registry.put(image_id, desc);
    imageNames.add(image_id);
}
 
Example 27
Source Project: brooklyn-server   Source File: OsgiTestBase.java    License: Apache License 2.0 5 votes vote down vote up
protected Bundle install(String url) {
    try {
        return Osgis.install(framework, url);
    } catch (Exception e) {
        throw new IllegalStateException("test resources not available; may be an IDE issue, so try a mvn rebuild of this project", e);
    }
}
 
Example 28
Source Project: tracecompass   Source File: XmlUtils.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static synchronized @NonNull List<@NonNull URL> getUrlsFromConfiguration(String extensionName, String elementName, String attribName) {
    /* Get the XSD files advertised through the extension point */
    IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionName);
    List<@NonNull URL> list = new ArrayList<>();
    for (IConfigurationElement element : elements) {
        if (element.getName().equals(elementName)) {
            final String filename = element.getAttribute(attribName);
            final String name = element.getContributor().getName();
            // Run this in a safe runner in case there is an exception
            // (IOException, FileNotFoundException, NPE, etc).
            // This makes sure other extensions are not prevented from
            // working if one is faulty.
            SafeRunner.run(new ISafeRunnable() {

                @Override
                public void run() throws IOException {
                    if (name != null) {
                        Bundle bundle = Platform.getBundle(name);
                        if (bundle != null) {
                            URL xmlUrl = bundle.getResource(filename);
                            if (xmlUrl == null) {
                                throw new FileNotFoundException(filename);
                            }
                            URL locatedURL = FileLocator.toFileURL(xmlUrl);
                            list.add(NonNullUtils.checkNotNull(locatedURL));
                        }
                    }
                }

                @Override
                public void handleException(Throwable exception) {
                    // Handled sufficiently in SafeRunner
                }
            });
        }
    }
    return list;
}
 
Example 29
Source Project: gwt-eclipse-plugin   Source File: GdtPreferences.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Attempts to register the SDK from a bundle.
 */
private static void registerBundleSdk(Bundle bundle) throws CoreException {
  try {
    IPath propPath = new Path(SDK_REGISTRANT_PROPERTY_FILE);
    URL propUrl = FileLocator.find(bundle, propPath, (Map<String, String>) null);
    if (propUrl != null) {
      InputStream instream = propUrl.openStream();
      Properties props = new Properties();
      props.load(instream);
      String sdkType = props.getProperty(SDK_BUNDLE_MARKER_PROPERTY);
      String sdkPrefix = props.getProperty(SDK_PATH_PREFIX_PROPERTY);
      if (sdkType != null && sdkPrefix != null) {
        IPath sdkPrefixPath = new Path(sdkPrefix);
        URL sdkPathUrl = FileLocator.find(bundle, sdkPrefixPath, (Map<String, String>) null);
        if (sdkPathUrl == null) {
          // Automatic SDK registration failed. This is expected in dev mode.
          CorePluginLog.logWarning("Failed to register SDK: " + sdkPrefix);
          return;
        }
        // resolve needed to switch from bundleentry to file url
        sdkPathUrl = FileLocator.resolve(sdkPathUrl);
        if (sdkPathUrl != null) {
          if ("file".equals(sdkPathUrl.getProtocol())) {
            GWTSdkRegistrant.registerSdk(sdkPathUrl, sdkType);
          }
        }
      }
    }
  } catch (IOException e) {
    throw new CoreException(new Status(IStatus.WARNING, GdtPlugin.PLUGIN_ID, e.getLocalizedMessage(), e));
  }
}
 
Example 30
Source Project: ice   Source File: PlayAction.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * This function stops the timer and switches the button from a pause button
 * to a play button.
 * </p>
 */
public void stop() {
	// Stop the timer
	timer.stop();
	// Change the "hover" text
	this.setText("Play");
	// Change the button appearance
	Bundle bundle = FrameworkUtil.getBundle(getClass());
	Path imagePath = new Path(
			"icons" + System.getProperty("file.separator") + "play.gif");
	URL imageURL = FileLocator.find(bundle, imagePath, null);
	ImageDescriptor imageDescriptor = ImageDescriptor
			.createFromURL(imageURL);
	this.setImageDescriptor(imageDescriptor);
}