private IPluginModelBase findModel(IAdaptable object) {
   if (object instanceof IJavaProject) object = ((IJavaProject) object).getProject();
   if (object instanceof IProject) return PluginRegistry.findModel((IProject) object);
   if (object instanceof PersistablePluginObject) {
     return PluginRegistry.findModel(((PersistablePluginObject) object).getPluginID());
   }
   return null;
 }
 private void loadManifestAndIntroIds(boolean onlyLoadManifest) {
   TreeSet<String> result = new TreeSet<String>();
   String introId;
   IExtension[] extensions =
       PDECore.getDefault()
           .getExtensionsRegistry()
           .findExtensions("org.eclipse.ui.intro", true); // $NON-NLS-1$
   for (int i = 0; i < extensions.length; i++) {
     IConfigurationElement[] children = extensions[i].getConfigurationElements();
     for (int j = 0; j < children.length; j++) {
       if ("introProductBinding".equals(children[j].getName())) { // $NON-NLS-1$
         String attribute = children[j].getAttribute("productId"); // $NON-NLS-1$
         if (attribute != null && attribute.equals(getProduct().getProductId())) {
           if (fManifest == null) {
             IPluginModelBase base =
                 PluginRegistry.findModel(extensions[i].getContributor().getName());
             if (base == null) continue;
             fManifest = (IFile) base.getUnderlyingResource();
           }
           if (onlyLoadManifest) return;
           introId = children[j].getAttribute("introId"); // $NON-NLS-1$
           if (introId != null) result.add(introId);
         }
       }
     }
   }
   fAvailableIntroIds = result.toArray(new String[result.size()]);
 }
 protected void collectSuites(IPluginModelBase model, Set<String> visited) {
   if (!model.isEnabled()) return;
   BundleDescription description = model.getBundleDescription();
   if (!visited.add(description.getSymbolicName())) return;
   model.addModelChangedListener(this);
   listentingTo.add(model);
   for (IPluginExtension ext : model.getExtensions(true).getExtensions())
     if ("org.xpect.testSuite".equals(ext.getPoint())) {
       for (IPluginObject child : ext.getChildren()) {
         if (child instanceof IPluginElement) {
           IPluginElement pluginElement = (IPluginElement) child;
           IPluginAttribute clazz = pluginElement.getAttribute("class");
           IPluginAttribute fileExtension = pluginElement.getAttribute("fileExtension");
           if (clazz != null && fileExtension != null) {
             LazyClass<Object> lazyClass =
                 LazyClass.create(
                     Object.class, clazz.getValue(), (Function<String, Class<?>>) null);
             TestSuiteInfo info =
                 new TestSuiteInfo(lazyClass, Collections.singleton(fileExtension.getValue()));
             this.extToInfo.put(fileExtension.getValue(), info);
           }
         }
       }
     }
   for (BundleDescription desc : description.getDependents()) {
     collectSuites(PluginRegistry.findModel(desc), visited);
   }
 }
 private void initializePluginModel() {
   IPluginModelBase base = PluginRegistry.findModel(getPluginProject());
   // should never happen
   if (base == null) return;
   if (base instanceof IBundlePluginModelBase)
     fExtensionsModel = ((IBundlePluginModelBase) base).getExtensionsModel();
   else fExtensionsModel = base;
 }
 protected void collectSuites() {
   if (this.extToInfo == null) {
     for (IModelChangeProvider provider : listentingTo) provider.removeModelChangedListener(this);
     listentingTo.clear();
     this.extToInfo = Maps.newHashMap();
     IPluginModelBase xpect = PluginRegistry.findModel("org.xpect");
     collectSuites(xpect, Sets.<String>newHashSet());
   }
 }
Esempio n. 6
0
 private void initializeModel(IStructuredSelection selection) {
   Object selected = selection.getFirstElement();
   if (selected instanceof IAdaptable) {
     IResource resource = (IResource) ((IAdaptable) selected).getAdapter(IResource.class);
     if (resource != null) {
       IProject project = resource.getProject();
       fModel = PluginRegistry.findModel(project);
     }
   }
 }
Esempio n. 7
0
 /**
  * This will install or refresh the given workspace contribution if needed, then search through it
  * for a class corresponding to <code>qualifiedName</code>.
  *
  * @param project The project that is to be dynamically installed when Acceleo searches for
  *     workspace contributions.
  * @param qualifiedName The qualified name of the class we seek to load.
  * @return An instance of the class <code>qualifiedName</code> if it could be found in the
  *     workspace bundles, <code>null</code> otherwise.
  */
 public synchronized Class<?> getClass(IProject project, String qualifiedName) {
   Class<?> instance = null;
   addWorkspaceContribution(project);
   refreshContributions();
   final IPluginModelBase model = PluginRegistry.findModel(project);
   final Bundle installedBundle = workspaceInstalledBundles.get(model);
   if (installedBundle != null) {
     instance = internalLoadClass(installedBundle, qualifiedName);
   }
   return instance;
 }
 // Copied from PDEClasspathContainer#resolveLibraryInFragments
 protected static IPluginModelBase resolveLibraryInFragments(
     IPluginModelBase model, String libraryName) {
   BundleDescription desc = model.getBundleDescription();
   if (desc != null) {
     BundleDescription[] fragments = desc.getFragments();
     for (int i = 0; i < fragments.length; i++) {
       if (new File(fragments[i].getLocation(), libraryName).exists())
         return PluginRegistry.findModel(fragments[i]);
     }
   }
   return null;
 }
  // Adapted from RequiredPluginsClassPathContainer#addPlugin and
  // PDEClasspathContainer#addExternalPlugin
  private void createEntry(BundleDescription desc, LinkedList<IClasspathEntry> entries) {
    IPluginModelBase model = PluginRegistry.findModel(desc);
    IResource resource = model.getUnderlyingResource();
    // Rule[] rules = useInclusions ? getInclusions(map, model) : null;
    if (resource != null) {
      entries.add(JavaCore.newProjectEntry(resource.getProject().getFullPath()));
      // addProjectEntry(resource.getProject(), rules, entries);
    } else {
      if (new File(model.getInstallLocation()).isFile()) {
        String installLocation = model.getInstallLocation();
        // This is to make it work in windows...
        if (!installLocation.startsWith("/")) {
          installLocation = "/" + installLocation;
        }
        IPath libraryLocation_ = Path.fromOSString(installLocation);
        entries.add(JavaCore.newLibraryEntry(libraryLocation_, null, null));

        // IPath libraryLocation_ = Path.fromPortableString(model.getInstallLocation());
        // entries.add( JavaCore.newLibraryEntry(libraryLocation_, null, null) );
      } else {
        IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
        for (int i = 0; i < libraries.length; i++) {
          if (IPluginLibrary.RESOURCE.equals(libraries[i].getType())) continue;
          model = (IPluginModelBase) libraries[i].getModel();

          String name = libraries[i].getName();
          String expandedName = ClasspathUtilCore.expandLibraryName(name);
          IPath path = getPath(model, expandedName);
          if (path == null
              && !model.isFragmentModel()
              && ClasspathUtilCore.containsVariables(name)) {
            model = resolveLibraryInFragments(model, expandedName);
            if (model != null && model.isEnabled()) path = getPath(model, expandedName);
          }
          if (path != null && !path.toFile().isDirectory()) {
            entries.add(
                JavaCore.newLibraryEntry(
                    path, ClasspathUtilCore.getSourceAnnotation(model, expandedName), null));
            // addLibraryEntry(path, ClasspathUtilCore.getSourceAnnotation(model, expandedName),
            // rules, getClasspathAttributes(model), entries);
          } else if (path != null) {
            // is a directory
            entries.add(
                JavaCore.newLibraryEntry(
                    path, ClasspathUtilCore.getSourceAnnotation(model, expandedName), null));
          }
        }
      }
    }
  }
  private void validateUnpack(Element parent) {
    int severity = CompilerFlags.getFlag(fProject, CompilerFlags.F_UNRESOLVED_PLUGINS);
    if (severity == CompilerFlags.IGNORE) {
      return;
    }
    if (severity == CompilerFlags.ERROR) {
      // this might not be an error, so max the flag at WARNING level.
      severity = CompilerFlags.WARNING;
    }
    String unpack = parent.getAttribute("unpack"); // $NON-NLS-1$
    IPluginModelBase pModel = PluginRegistry.findModel(parent.getAttribute("id")); // $NON-NLS-1$
    if (pModel == null) {
      return;
    }

    if (pModel instanceof IBundlePluginModel) {
      IBundlePluginModel bModel = (IBundlePluginModel) pModel;
      IManifestHeader header =
          bModel
              .getBundleModel()
              .getBundle()
              .getManifestHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE);
      if (header != null) {
        String value = header.getValue();
        String unpackValue =
            "true".equals(unpack) ? "jar" : "dir"; // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        if (value != null && !value.equalsIgnoreCase(unpackValue)) {
          String message =
              NLS.bind(
                  PDECoreMessages.Builders_Feature_mismatchUnpackBundleShape,
                  (new String[] {
                    "unpack=" + unpack, parent.getAttribute("id"), "Eclipse-BundleShape: " + value
                  })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          report(message, getLine(parent), severity, PDEMarkerFactory.CAT_OTHER);
        }
      }
    }

    if ("true".equals(unpack)
        && !CoreUtility.guessUnpack(pModel.getBundleDescription())) { // $NON-NLS-1$
      String message =
          NLS.bind(
              PDECoreMessages.Builders_Feature_missingUnpackFalse,
              (new String[] {
                parent.getAttribute("id"), "unpack=\"false\""
              })); //$NON-NLS-1$ //$NON-NLS-2$
      report(message, getLine(parent), severity, PDEMarkerFactory.CAT_OTHER);
    }
  }
 private void computeSelected(Collection<?> initialSelection) {
   if (initialSelection == null || initialSelection.size() == 0) return;
   Set<IPluginModelBase> selected = new HashSet<IPluginModelBase>();
   Iterator<?> iter = initialSelection.iterator();
   while (iter.hasNext()) {
     Object obj = iter.next();
     if (obj instanceof IProject) {
       IPluginModelBase model = PluginRegistry.findModel((IProject) obj);
       if (model != null) {
         selected.add(model);
       }
     }
   }
   fSelected = selected.toArray(new IPluginModelBase[selected.size()]);
 }
Esempio n. 12
0
 protected void validatePluginIDRef(Element element, Attr attr) {
   if (!validatePluginID(element, attr)) {
     return;
   }
   int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNRESOLVED_IMPORTS);
   if ("true".equals(element.getAttribute("optional"))
       && severity == CompilerFlags.ERROR) // $NON-NLS-1$ //$NON-NLS-2$
   severity = CompilerFlags.WARNING;
   if (severity != CompilerFlags.IGNORE) {
     IPluginModelBase model = PluginRegistry.findModel(attr.getValue());
     if (model == null || !model.isEnabled()) {
       report(
           NLS.bind(PDECoreMessages.Builders_Manifest_dependency, attr.getValue()),
           getLine(element, attr.getName()),
           severity,
           PDEMarkerFactory.CAT_FATAL);
     }
   }
 }
 private void validatePluginID(Element element, Attr attr, boolean isFragment) {
   String id = attr.getValue();
   if (!validatePluginID(element, attr)) {
     return;
   }
   int severity = CompilerFlags.getFlag(fProject, CompilerFlags.F_UNRESOLVED_PLUGINS);
   if (severity != CompilerFlags.IGNORE) {
     IPluginModelBase model = PluginRegistry.findModel(id);
     if (model == null
         || !model.isEnabled()
         || (isFragment && !model.isFragmentModel())
         || (!isFragment && model.isFragmentModel())) {
       report(
           NLS.bind(PDECoreMessages.Builders_Feature_reference, id),
           getLine(element, attr.getName()),
           severity,
           PDEMarkerFactory.CAT_OTHER);
     }
   }
 }
Esempio n. 14
0
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
  */
 public void resourceChanged(IResourceChangeEvent event) {
   switch (event.getType()) {
       /*
        * Closing and deleting projects trigger the same actions : we must remove the model listener and
        * uninstall the bundle.
        */
     case IResourceChangeEvent.PRE_CLOSE:
     case IResourceChangeEvent.PRE_DELETE:
       if (event.getResource() instanceof IProject) {
         final IProject project = (IProject) event.getResource();
         final IPluginModelBase model = PluginRegistry.findModel(project);
         if (model != null) {
           final Bundle bundle = workspaceInstalledBundles.remove(model);
           changedContributions.remove(model);
           if (bundle != null) {
             try {
               uninstallBundle(bundle);
             } catch (BundleException e) {
               AcceleoCommonPlugin.log(
                   new Status(
                       IStatus.ERROR,
                       AcceleoCommonPlugin.PLUGIN_ID,
                       AcceleoCommonMessages.getString(
                           UNINSTALLATION_FAILURE_KEY, bundle.getSymbolicName()),
                       e));
             }
           }
         }
       }
       break;
     case IResourceChangeEvent.POST_BUILD:
       processBuildEvent(event);
       break;
     case IResourceChangeEvent.POST_CHANGE:
     default:
       // no default action
   }
 }
Esempio n. 15
0
 /**
  * Adds a given project to the set of projects that are to be dynamically installed.
  *
  * @param project The project that is to be dynamically installed when Acceleo searches for
  *     workspace contributions.
  */
 public synchronized void addWorkspaceContribution(IProject project) {
   final IPluginModelBase model = PluginRegistry.findModel(project);
   if (model != null && !workspaceInstalledBundles.containsKey(model)) {
     changedContributions.add(model);
   }
 }
Esempio n. 16
0
    /**
     * This will process IResourceChangeEvent.POST_BUILD events so that we can react to builds of
     * our workspace loaded services.
     *
     * @param event The event that is to be processed. Assumes that <code>
     *     event.getType() == IResourceChangeEvent.POST_BUILD</code>.
     */
    private void processBuildEvent(IResourceChangeEvent event) {
      final IResourceDelta delta = event.getDelta();
      switch (event.getBuildKind()) {
        case IncrementalProjectBuilder.AUTO_BUILD:
          // Nothing built in such cases
          if (!ResourcesPlugin.getWorkspace().isAutoBuilding()) {
            break;
          }
          // Fall through to the incremental build handling otherwise
          // $FALL-THROUGH$
        case IncrementalProjectBuilder.INCREMENTAL_BUILD:
          final AcceleoDeltaVisitor visitor = new AcceleoDeltaVisitor();
          try {
            delta.accept(visitor);
          } catch (CoreException e) {
            AcceleoCommonPlugin.log(e, false);
          }
          for (IProject changed : visitor.getChangedProjects()) {
            IPluginModelBase model = PluginRegistry.findModel(changed);
            if (model != null) {
              changedContributions.add(model);
            }
          }
          for (String changedClass : visitor.getChangedClasses()) {
            final WorkspaceClassInstance workspaceInstance =
                workspaceLoadedClasses.get(changedClass);
            if (workspaceInstance != null) {
              workspaceInstance.setStale(true);
            }
          }
          break;
        case IncrementalProjectBuilder.FULL_BUILD:
          for (Map.Entry<IPluginModelBase, Bundle> entry : workspaceInstalledBundles.entrySet()) {
            IPluginModelBase model = entry.getKey();
            if (model != null) {
              changedContributions.add(model);
            }
          }
          for (WorkspaceClassInstance workspaceInstance : workspaceLoadedClasses.values()) {
            workspaceInstance.setStale(true);
          }
          break;
        case IncrementalProjectBuilder.CLEAN_BUILD:
          // workspace has been cleaned. Unload every service until next they're built
          final Iterator<Map.Entry<IPluginModelBase, Bundle>> workspaceBundleIterator =
              workspaceInstalledBundles.entrySet().iterator();
          while (workspaceBundleIterator.hasNext()) {
            Map.Entry<IPluginModelBase, Bundle> entry = workspaceBundleIterator.next();
            final Bundle bundle = entry.getValue();

            try {
              uninstallBundle(bundle);
            } catch (BundleException e) {
              AcceleoCommonPlugin.log(
                  new Status(
                      IStatus.ERROR,
                      AcceleoCommonPlugin.PLUGIN_ID,
                      AcceleoCommonMessages.getString(
                          UNINSTALLATION_FAILURE_KEY, bundle.getSymbolicName()),
                      e));
            }

            workspaceBundleIterator.remove();
          }
          for (WorkspaceClassInstance workspaceInstance : workspaceLoadedClasses.values()) {
            workspaceInstance.setStale(true);
          }
          break;
        default:
          // no default action
      }
    }
Esempio n. 17
0
 public DependencyExtentOperation(IProject project, String importID, ISearchResult searchResult) {
   fSearchResult = (DependencyExtentSearchResult) searchResult;
   fProject = project;
   fImportID = importID;
   fModel = PluginRegistry.findModel(project);
 }
  // see
  // http://www.devdaily.com/java/jwarehouse/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerInitializer.java.shtml
  // see
  // http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.6.1/org.eclipse.jdt.junit/core/3.6.1/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java#BuildPathSupport.JUnitPluginDescription.getLibraryEntry
  private EclecticContainerInternal getNewContainer(IPath containerPath) {
    // IPath bundleLocation  = new Path(org.eclectic.idc.Activator.getBundle().getLocation());
    // IClasspathEntry entry = JavaCore.newLibraryEntry(
    //		bundleLocation.append("eclectic-runtime.jar"), null, null);

    // I may need to touch raw classpath according to the clojure example, but i don't know why

    // Eclectic-runtime
    /*
    File libFile = getJarInsidePlugin(org.eclectic.idc.Activator.getBundle().getSymbolicName(), "eclectic-runtime");
    IPath libraryLocation = Path.fromOSString(libFile.getAbsolutePath());

    IPluginModelBase srcPlugin = PluginRegistry.findModel(org.eclectic.idc.Activator.getBundle().getSymbolicName());
    IClasspathEntry entryEclecticRuntime = JavaCore.newLibraryEntry(libraryLocation,
    		Path.fromPortableString(srcPlugin.getInstallLocation()), null);

    // Eclectic-modelhandling
    File libFile2 = getJarInsidePlugin(org.eclectic.idc.Activator.getBundle().getSymbolicName(), "eclectic-modeling");
    IPath libraryLocation2 = Path.fromOSString(libFile2.getAbsolutePath());
    IClasspathEntry entryEclecticModeling = JavaCore.newLibraryEntry(libraryLocation2, null, null);
    */

    // Bundle bundle = Platform.getBundle("org.eclipse.emf.ecore");
    // Path path = new Path("icons/sample.gif");
    //   URL fileURL = FileLocator.find(bundle, path, null);
    //   InputStream in = fileURL.openStream();

    LinkedList<BundleDescription> bundleDescriptions = new LinkedList<BundleDescription>();
    bundleDescriptions.add(
        PluginRegistry.findModel("org.eclipse.emf.ecore").getBundleDescription());
    bundleDescriptions.add(
        PluginRegistry.findModel("org.eclipse.emf.ecore.xmi").getBundleDescription());
    bundleDescriptions.add(PluginRegistry.findModel("org.eclectic.idc").getBundleDescription());
    bundleDescriptions.add(
        PluginRegistry.findModel("org.eclectic.modeling").getBundleDescription());
    bundleDescriptions.add(
        PluginRegistry.findModel("org.eclectic.javaflow").getBundleDescription());
    // To allow loading a description to create an ApiModel -> maybe it could be removed in the
    // future
    bundleDescriptions.add(
        PluginRegistry.findModel("org.eclectic.apidesc.language").getBundleDescription());
    bundleDescriptions.add(
        PluginRegistry.findModel("org.eclectic.streamdesc.language").getBundleDescription());
    bundleDescriptions.add(PluginRegistry.findModel("com.google.inject").getBundleDescription());
    bundleDescriptions.add(PluginRegistry.findModel("javax.inject").getBundleDescription());
    bundleDescriptions.add(PluginRegistry.findModel("com.google.guava").getBundleDescription());

    fillWithDependent(bundleDescriptions);

    LinkedList<IClasspathEntry> entries = new LinkedList<IClasspathEntry>();
    for (int i = 0; i < bundleDescriptions.size(); i++) {
      BundleDescription bundleDescription = bundleDescriptions.get(i);

      // IPluginModelBase plugin = PluginRegistry.findModel(bundleDescription);
      // IPath libraryLocation_ = Path.fromPortableString(plugin.getInstallLocation());
      // IClasspathEntry entry_ = JavaCore.newLibraryEntry(libraryLocation_, null, null);

      createEntry(bundleDescription, entries);
    }

    // entries.add( entryEclecticRuntime );
    // entries.add( entryEclecticModeling );

    File libFile2 =
        getJarInsidePlugin(
            org.eclectic.idc.Activator.getBundle().getSymbolicName(),
            "lib-instrumented/idc-instrumented");
    IPath libraryLocation2 = Path.fromOSString(libFile2.getAbsolutePath());
    IClasspathEntry entryIdcInstrumentedClasses =
        JavaCore.newLibraryEntry(libraryLocation2, null, null);
    entries.add(entryIdcInstrumentedClasses);

    String javaflow =
        PluginRegistry.findModel("org.eclectic.javaflow").getBundleDescription().getSymbolicName();
    File libFile3 = getJarInsidePlugin(javaflow, "lib/commons-logging-api-1.1.1");
    IPath libraryLocation3 = Path.fromOSString(libFile3.getAbsolutePath());
    IClasspathEntry javaflow3 = JavaCore.newLibraryEntry(libraryLocation3, null, null);
    entries.add(javaflow3);

    File libFile4 = getJarInsidePlugin(javaflow, "lib/commons-logging-1.1.1");
    IPath libraryLocation4 = Path.fromOSString(libFile4.getAbsolutePath());
    IClasspathEntry javaflow4 = JavaCore.newLibraryEntry(libraryLocation4, null, null);
    entries.add(javaflow4);

    IClasspathEntry[] entriesAsArray = new IClasspathEntry[entries.size()];
    entries.toArray(entriesAsArray);
    return new EclecticContainerInternal(containerPath, entriesAsArray);
  }
  /**
   * Creates a URL describing the location of a included schema. First looks up the plug-in in the
   * schema registry, then tries additional source locations, then looks for a co-located plug-in,
   * then looks in the additional search path locations.
   *
   * @param pluginID ID of the plug-in owning the schema
   * @param path the path to the schema inside the plug-in
   * @param parentURL url of the parent schema file
   * @param additionalSearchPath list of additional locations to search; only used with the <code>
   *     pde.convertSchemaToHTML</code> Ant task
   * @return a url location of the included schema or <code>null</code>
   */
  private static URL getPluginRelativePath(
      String pluginID, IPath path, URL parentURL, List<IPath> additionalSearchPath) {
    // Start by looking in the schema registry
    URL url = SchemaRegistry.getSchemaURL(pluginID, path.toString());

    // Next search source locations
    if (url == null) {
      IPluginModelBase model = PluginRegistry.findModel(pluginID);
      if (model != null)
        url = SchemaRegistry.getSchemaFromSourceExtension(model.getPluginBase(), path);
    }

    File parentFile = null;
    if (url == null && parentURL != null) {
      try {
        parentFile = URIUtil.toFile(URIUtil.toURI(parentURL));
      } catch (URISyntaxException e) {
      }
    }

    // If we are running the ant task, see if another project co-located with the parent contains
    // the schema file
    // The project folder must have the plug-in ID as its file name
    if (url == null && parentFile != null) {
      try {
        // assuming schemas are located in: pluginId/schema/schemaFile.exsd (need to go up to parent
        // of plug-in directory)
        File pluginFile = new File(parentFile + "/../../../" + pluginID); // $NON-NLS-1$
        if (pluginFile.isDirectory()) {
          File schemaFile = new File(pluginFile, path.toOSString());
          if (schemaFile.exists()) {
            url = schemaFile.toURL();
          }
          // This is how we would extract the schema from a jar, but in practice this will never be
          // the case
          // because when a bundle is built, the schema files are moved to the source bundle, not
          // the bundle we are checking
          //					} else if (CoreUtility.jarContainsResource(pluginFile, path.toPortableString(),
          // false)) {
          //						url = new URL("jar:file:" + pluginFile.getAbsolutePath() + "!/" + path);
          // //$NON-NLS-1$ //$NON-NLS-2$
        }
      } catch (MalformedURLException e) {
      }
    }

    // If we are running the ant task, additional search locations may be provided
    // The project folder must have the plug-in ID as its file name
    if (url == null && additionalSearchPath != null) {
      for (IPath searchPath : additionalSearchPath) {
        File pluginFile = null;
        if (searchPath.isAbsolute()) {
          // Append plug-in id directly to absolute paths
          pluginFile = new File(searchPath.toFile(), pluginID);
        } else if (parentFile != null) {
          // Append relative path to parent file location
          File file = new File(parentFile, searchPath.toOSString());
          pluginFile = new File(file, pluginID);
        }

        if (pluginFile != null && pluginFile.isDirectory()) {
          try {
            File schemaFile = new File(pluginFile, path.toOSString());
            if (schemaFile.exists()) {
              url = schemaFile.toURL();
              break;
            }
          } catch (MalformedURLException e) {
          }
        }
      }
    }
    return url;
  }
Esempio n. 20
0
 public IPluginModelBase getReferencedModel(IFeaturePlugin reference) {
   IPluginModelBase model = PluginRegistry.findModel(reference.getId());
   return (model != null && model.isEnabled()) ? model : null;
 }