コード例 #1
0
ファイル: EMFNature.java プロジェクト: nitind/webtools.common
 /**
  * Return if the project has the given nature.
  *
  * @param project
  * @param natureId
  * @return <code>true</code> if project has given nature
  * @since 1.0.0
  */
 public static boolean hasRuntime(IProject project, String natureId) {
   if (project == null || !project.isAccessible()) return false;
   try {
     return project.hasNature(natureId);
   } catch (CoreException e) {
     return false;
   }
 }
コード例 #2
0
ファイル: SharpenProject.java プロジェクト: Galigator/db4o
 public static ISharpenProject create(IProject project, IProgressMonitor monitor)
     throws CoreException {
   if (!project.hasNature(SharpenNature.NATURE_ID)) {
     return null;
   }
   ISharpenProject cached = (ISharpenProject) project.getSessionProperty(PROJECT_SESSION_KEY);
   if (null == cached) {
     cached = new SharpenProject(project);
     project.setSessionProperty(PROJECT_SESSION_KEY, cached);
   }
   return cached;
 }
コード例 #3
0
  private void addProjectSourceContainers(IProject project, ArrayList result) throws CoreException {
    if (project == null || !project.hasNature(JavaCore.NATURE_ID)) return;

    IJavaProject jProject = JavaCore.create(project);
    result.add(JavaRuntime.newProjectRuntimeClasspathEntry(jProject));

    IClasspathEntry[] entries = jProject.getRawClasspath();
    for (int i = 0; i < entries.length; i++) {
      IClasspathEntry entry = entries[i];
      if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
        IRuntimeClasspathEntry rte = convertClasspathEntry(entry);
        if (rte != null) result.add(rte);
      }
    }
  }
コード例 #4
0
ファイル: EMFNature.java プロジェクト: nitind/webtools.common
 /**
  * Return a list of nature ids based on the natures that have been configured for this project.
  *
  * @return list of configured nature ids.
  * @param project
  */
 public static List getRegisteredRuntimeIDs(IProject project) {
   List result = null;
   String natureID = null;
   if (project != null && project.isAccessible()) {
     Iterator it = EMFNatureRegistry.singleton().REGISTERED_NATURE_IDS.iterator();
     while (it.hasNext()) {
       natureID = (String) it.next();
       try {
         if (project.hasNature(natureID)) {
           if (result == null) result = new ArrayList(2);
           result.add(natureID);
         }
       } catch (CoreException e) {
       }
     }
   }
   return result == null ? Collections.EMPTY_LIST : result;
 }
コード例 #5
0
  private void createProject(IFeatureModel model, IProgressMonitor monitor) throws CoreException {
    String name = model.getFeature().getId();

    IFeaturePlugin[] plugins = model.getFeature().getPlugins();
    for (int i = 0; i < plugins.length; i++) {
      if (name.equals(plugins[i].getId())) {
        name += "-feature"; // $NON-NLS-1$
        break;
      }
    }

    String task = NLS.bind(MDEUIMessages.FeatureImportWizard_operation_creating2, name);
    monitor.beginTask(task, 9);
    try {
      IProject project = fRoot.getProject(name);

      if (project.exists() || new File(project.getParent().getLocation().toFile(), name).exists()) {
        if (queryReplace(project)) {
          if (!project.exists()) project.create(new SubProgressMonitor(monitor, 1));
          project.delete(true, true, new SubProgressMonitor(monitor, 1));
          try {
            RepositoryProvider.unmap(project);
          } catch (TeamException e) {
          }
        } else {
          return;
        }
      } else {
        monitor.worked(1);
      }

      IProjectDescription description = MDEPlugin.getWorkspace().newProjectDescription(name);
      if (fTargetPath != null) description.setLocation(fTargetPath.append(name));

      project.create(description, new SubProgressMonitor(monitor, 1));
      if (!project.isOpen()) {
        project.open(null);
      }
      File featureDir = new File(model.getInstallLocation());

      importContent(
          featureDir,
          project.getFullPath(),
          FileSystemStructureProvider.INSTANCE,
          null,
          new SubProgressMonitor(monitor, 1));
      IFolder folder = project.getFolder("META-INF"); // $NON-NLS-1$
      if (folder.exists()) {
        folder.delete(true, null);
      }
      if (fBinary) {
        // Mark this project so that we can show image overlay
        // using the label decorator
        project.setPersistentProperty(
            MDECore.EXTERNAL_PROJECT_PROPERTY, MDECore.BINARY_PROJECT_VALUE);
      }
      createBuildProperties(project);
      setProjectNatures(project, model, monitor);
      if (project.hasNature(JavaCore.NATURE_ID)) setClasspath(project, model, monitor);

    } finally {
      monitor.done();
    }
  }