Exemplo n.º 1
0
 /**
  * Sets the attribute of this IMarker with the given name. <br>
  *
  * @see IMarker#setAttribute(String, Object)
  * @param marker The concerned marker
  * @param attributeName the name of the attribute
  * @param value the value, or <code>null</code> if the attribute is to be undefined
  */
 public static void setAttribute(IMarker marker, String attributeName, Object value) {
   try {
     if (marker != null) {
       marker.setAttribute(attributeName, value);
     }
   } catch (final CoreException e) {
     DslCommonPlugin.getDefault().getLog().log(e.getStatus());
   }
 }
Exemplo n.º 2
0
 /**
  * Deletes all markers on this resource of the given type.
  *
  * @param resource An IResource for which this markers must be removed
  * @param type the type of the marker to create
  */
 public static void removeMarkerFor(IResource resource, String type) {
   try {
     if (resource != null && resource.exists()) {
       resource.deleteMarkers(type, false, IResource.DEPTH_ZERO);
     }
   } catch (final CoreException e) {
     DslCommonPlugin.getDefault().getLog().log(e.getStatus());
   }
 }
Exemplo n.º 3
0
 /**
  * Creates a marker with the specified type on this resource. Marker type ids are the id of an
  * extension installed in the <code>org.eclipse.core.resources.markers</code> extension point. The
  * specified type string must not be <code>null</code>.
  *
  * @param resource An IResource for which a marker must be added
  * @param message The message of the marker we want to display in the Problem View.
  * @param severity The severity of the marker
  * @param type the type of the marker to create
  * @return an optional Marker (none if problem during creation).
  */
 public static Option<IMarker> addMarkerFor(
     final IResource resource, final String message, final int severity, String type) {
   try {
     if (resource != null) {
       final IMarker marker = resource.createMarker(type);
       marker.setAttribute(IMarker.SEVERITY, severity);
       marker.setAttribute(IMarker.MESSAGE, message);
       return Options.newSome(marker);
     }
   } catch (final CoreException e) {
     DslCommonPlugin.getDefault().getLog().log(e.getStatus());
   }
   return Options.newNone();
 }
  /**
   * return the list of EPackage declared in the given list of bundles.
   *
   * @param bundles a collection of bundles.
   * @return the list of EPackage declarations made through the plugin.xml of those bundles.
   */
  protected Collection<EPackageLoadingCallback.EPackageDeclarationSource>
      getEPackagesDeclaredInBundles(Collection<String> bundles) {
    Collection<EPackageLoadingCallback.EPackageDeclarationSource> result = Lists.newArrayList();
    if (EMFPlugin.IS_ECLIPSE_RUNNING) {
      final IExtensionRegistry reg = Platform.getExtensionRegistry();
      Multimap<String, EPackageDeclaration> contributions = HashMultimap.create();
      final IExtensionPoint ep = reg.getExtensionPoint(EMF_GENERATED_PACKAGE_EXTENSIONPOINT);
      for (final IExtension ext : ep.getExtensions()) {
        final IConfigurationElement[] ce = ext.getConfigurationElements();
        String contributorName = ext.getContributor().getName();
        if (bundles.contains(contributorName)) {
          for (IConfigurationElement element : ce) {

            String nsURI = element.getAttribute("uri"); // $NON-NLS-1$
            String className = element.getAttribute("class"); // $NON-NLS-1$
            String genModel = element.getAttribute("genModel"); // $NON-NLS-1$

            if (nsURI != null && className != null) {
              contributions.put(
                  contributorName, new EPackageDeclaration(nsURI, className, genModel));
            } else {
              DslCommonPlugin.getDefault()
                  .warning(
                      MessageFormat.format(
                          Messages.BundleClassLoading_ignoredEPackageDeclaration, contributorName),
                      new IllegalArgumentException());
            }
          }
        }
      }

      for (String contributor : contributions.keySet()) {
        Collection<EPackageDeclaration> declarations = contributions.get(contributor);
        if (declarations.size() > 0) {
          result.add(
              new EPackageLoadingCallback.EPackageDeclarationSource(
                  contributor, declarations, true));
        }
      }
    }
    return result;
  }
 @Override
 public IEditingDomainFactory getEditingDomainFactory() {
   if (extension == null) {
     if (Platform.isRunning()) {
       try {
         extension =
             (IEditingDomainFactory)
                 element.createExecutableExtension(EDITING_DOMAIN_FACTORY_CLASS_ATTRIBUTE);
       } catch (CoreException e) {
         DslCommonPlugin.getDefault()
             .getLog()
             .log(
                 new Status(
                     IStatus.ERROR,
                     DslCommonPlugin.PLUGIN_ID,
                     MessageFormat.format(
                         Messages.EclipseEditingDomainFactoryDescriptor_errorLoadingExtension,
                         element.getDeclaringExtension().getUniqueIdentifier()),
                     e));
       }
     }
   }
   return extension;
 }