コード例 #1
0
  /**
   * @param project
   * @param destinationPath
   * @param classpathToMigrate
   */
  private void migrateSourceFiles(
      IProject project, IPath destinationPath, IClasspathEntry[] classpathToMigrate) {
    IPath relativeDestinationPath =
        ((IPath) destinationPath.clone()).makeRelativeTo(newProject.getFullPath());
    System.out.println(
        "migrate source destination: " + destinationPath + " relative: " + relativeDestinationPath);
    IFolder destination = newProject.getFolder(relativeDestinationPath);

    for (IClasspathEntry entry : classpathToMigrate) {
      if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
        try {
          IPath relativeSourcePath = entry.getPath().makeRelativeTo(project.getFullPath());
          IFolder source = project.getFolder(relativeSourcePath);

          SPLMigrationUtils.recursiveCopyFiles(source, destination);

          newProject.refreshLocal(IProject.DEPTH_INFINITE, null);

        } catch (CoreException e) {
          CorePlugin.getDefault().logError(e);
          e.printStackTrace();
        }
      }
    }
  }
コード例 #2
0
  private void init(IStructuredSelection selection) {
    project = null;

    Object selected = (selection.isEmpty() ? project : selection.getFirstElement());

    if (selected instanceof IArchiveNode) {
      IArchiveNode node = (IArchiveNode) selected;
      if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE
          || node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
        initialDestinationNode = (IArchiveNode) selected;
      }
      project = ResourcesPlugin.getWorkspace().getRoot().getProject(node.getProjectName());
    } else if (selected instanceof IContainer) {
      project = ((IContainer) selected).getProject();
      initialDestinationPath = ((IContainer) selected).getFullPath().toString();
      isPathWorkspaceRelative = true;
    } else if (selected instanceof WrappedProject) {
      project = ((WrappedProject) selected).getElement();
      initialDestinationPath = project.getFullPath().toString();
      isPathWorkspaceRelative = true;
    } else {
      project = ProjectArchivesCommonView.getInstance().getCurrentProject();
      if (project != null) {
        initialDestinationPath = project.getFullPath().toString();
        isPathWorkspaceRelative = true;
      }
    }
  }
コード例 #3
0
  private void validateFolders() {
    boolean useFolders = fFoldersAsSourceFolder.getSelection();

    fSrcFolderNameText.setEnabled(useFolders);
    fBinFolderNameText.setEnabled(useFolders);
    fSrcFolderNameLabel.setEnabled(useFolders);
    fBinFolderNameLabel.setEnabled(useFolders);
    if (useFolders) {
      String srcName = fSrcFolderNameText.getText();
      String binName = fBinFolderNameText.getText();
      if (srcName.length() + binName.length() == 0) {
        updateStatus(
            new StatusInfo(
                IStatus.ERROR,
                PreferencesMessages.NewJavaProjectPreferencePage_folders_error_namesempty));
        return;
      }
      IWorkspace workspace = JavaPlugin.getWorkspace();
      IProject dmy = workspace.getRoot().getProject("project"); // $NON-NLS-1$

      IStatus status;
      IPath srcPath = dmy.getFullPath().append(srcName);
      if (srcName.length() != 0) {
        status = workspace.validatePath(srcPath.toString(), IResource.FOLDER);
        if (!status.isOK()) {
          String message =
              Messages.format(
                  PreferencesMessages.NewJavaProjectPreferencePage_folders_error_invalidsrcname,
                  status.getMessage());
          updateStatus(new StatusInfo(IStatus.ERROR, message));
          return;
        }
      }
      IPath binPath = dmy.getFullPath().append(binName);
      if (binName.length() != 0) {
        status = workspace.validatePath(binPath.toString(), IResource.FOLDER);
        if (!status.isOK()) {
          String message =
              Messages.format(
                  PreferencesMessages.NewJavaProjectPreferencePage_folders_error_invalidbinname,
                  status.getMessage());
          updateStatus(new StatusInfo(IStatus.ERROR, message));
          return;
        }
      }
      IClasspathEntry entry = JavaCore.newSourceEntry(srcPath);
      status =
          JavaConventions.validateClasspath(
              JavaCore.create(dmy), new IClasspathEntry[] {entry}, binPath);
      if (!status.isOK()) {
        String message = PreferencesMessages.NewJavaProjectPreferencePage_folders_error_invalidcp;
        updateStatus(new StatusInfo(IStatus.ERROR, message));
        return;
      }
    }
    updateStatus(new StatusInfo()); // set to OK
  }
コード例 #4
0
  public void testCPathEntriesForOldStyle() throws Exception {
    p2 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "b", null, IPDOMManager.ID_NO_INDEXER);
    ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
    IProject project = p2.getProject();
    ICProjectDescription des = mngr.getProjectDescription(project, false);
    assertNotNull(des);
    assertEquals(1, des.getConfigurations().length);
    assertFalse(mngr.isNewStyleProject(des));
    assertFalse(mngr.isNewStyleProject(project));

    IPathEntry[] entries = CoreModel.getRawPathEntries(p2);
    entries =
        concatEntries(
            entries,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    CoreModel.setRawPathEntries(p2, entries, null);

    ICSourceEntry[] expectedSourceEntries =
        new ICSourceEntry[] {
          new CSourceEntry(
              project.getFullPath(), new IPath[] {new Path("test_src")}, ICSettingEntry.RESOLVED),
          new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED),
        };

    ICOutputEntry[] expectedOutputEntries =
        new ICOutputEntry[] {
          new COutputEntry(
              project.getFullPath(),
              null,
              ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
          new COutputEntry(
              project.getFullPath().append("test_out"),
              null,
              ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
        };

    des = mngr.getProjectDescription(project, false);
    ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
    ICSourceEntry[] sEntries = cfg.getSourceEntries();
    ICOutputEntry[] oEntries = cfg.getBuildSetting().getOutputDirectories();

    checkCEntriesMatch(expectedSourceEntries, sEntries);
    checkCEntriesMatch(expectedOutputEntries, oEntries);

    des = mngr.getProjectDescription(project, true);
    cfg = des.getDefaultSettingConfiguration();
    sEntries = cfg.getSourceEntries();
    oEntries = cfg.getBuildSetting().getOutputDirectories();

    checkCEntriesMatch(expectedSourceEntries, sEntries);
    checkCEntriesMatch(expectedOutputEntries, oEntries);
  }
コード例 #5
0
 /*
  * Reads the Mindpath file entries of this project's .Mindpath file.
  * This includes the output entry.
  * As a side effect, unknown elements are stored in the given map (if not null)
  */
 private static EList<MindPathEntry> readFileEntries(IProject p, MindLibOrProject mp) {
   try {
     return readFileEntriesWithException(p, mp);
   } catch (CoreException e) {
     MindIdeCore.log(
         e, "Exception while reading " + p.getFullPath().append(MINDPATH_FILENAME)); // $NON-NLS-1$
     return INVALID_MINDPATH;
   } catch (IOException e) {
     MindIdeCore.log(
         e, "Exception while reading " + p.getFullPath().append(MINDPATH_FILENAME)); // $NON-NLS-1$
     return INVALID_MINDPATH;
   }
 }
コード例 #6
0
    @Override
    protected IStatus run(IProgressMonitor monitor) {
      try {
        writeFileEntries(p, getRawMinpath(), mp);
      } catch (CoreException e) {
        return new Status(
            Status.ERROR, MindActivator.ID, "Exception while write " + p.getFullPath(), e);

      } catch (IOException e) {
        return new Status(
            Status.ERROR, MindActivator.ID, "Exception while write " + p.getFullPath(), e);
      }
      return Status.OK_STATUS;
    }
コード例 #7
0
  @Test
  public void testDownloadedSourcesShouldAttachToPackageFragmentRoot() throws Exception {
    String pom =
        "<groupId>test</groupId>"
            + "<artifactId>testArtifact</artifactId>"
            + "<version>42</version>"
            + "<dependencies>"
            + "    <dependency>"
            + "        <groupId>junit</groupId>"
            + "        <artifactId>junit</artifactId>"
            + "        <version>4.12</version>"
            + "    </dependency>"
            + "</dependencies>";
    createTestProject("test2", pom);

    IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test2");
    mavenWorkspace.update(Collections.singletonList(test));
    mavenWorkspace.waitForUpdate();
    IJavaProject javaProject = JavaCore.create(test);
    IType type = javaProject.findType("org.junit.Test");
    assertNull(type.getClassFile().getSourceRange());
    boolean downloadSources =
        classpathManager.downloadSources(test.getFullPath().toOSString(), "org.junit.Test");
    assertTrue(downloadSources);
    IType type2 = javaProject.findType("org.junit.Test");
    assertNotNull(type2.getClassFile().getSourceRange());
  }
コード例 #8
0
 protected void mergeEncodingPreferences(IProject project) {
   Preferences projectRegularPrefs = null;
   Preferences projectDerivedPrefs = getPreferences(project, false, true, true);
   if (projectDerivedPrefs == null) return;
   try {
     boolean prefsChanged = false;
     String[] affectedResources;
     affectedResources = projectDerivedPrefs.keys();
     for (int i = 0; i < affectedResources.length; i++) {
       String path = affectedResources[i];
       String value = projectDerivedPrefs.get(path, null);
       projectDerivedPrefs.remove(path);
       // lazy creation of non-derived preferences
       if (projectRegularPrefs == null)
         projectRegularPrefs = getPreferences(project, true, false, false);
       projectRegularPrefs.put(path, value);
       prefsChanged = true;
     }
     if (prefsChanged) {
       Map<IProject, Boolean> projectsToSave = new HashMap<>();
       // this is internal change so do not notify charset delta job
       projectsToSave.put(project, Boolean.TRUE);
       job.addChanges(projectsToSave);
     }
   } catch (BackingStoreException e) {
     // problems with the project scope... we will miss the changes (but will log)
     String message = Messages.resources_readingEncoding;
     Policy.log(
         new ResourceStatus(
             IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e));
   }
 }
コード例 #9
0
 private boolean isDerivedEncodingStoredSeparately(IProject project) {
   // be careful looking up for our node so not to create any nodes as side effect
   Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
   try {
     // TODO once bug 90500 is fixed, should be as simple as this:
     //			String path = project.getName() + IPath.SEPARATOR + ResourcesPlugin.PI_RESOURCES;
     //			return node.nodeExists(path) ?
     // node.node(path).getBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, false) : false;
     // for now, take the long way
     if (!node.nodeExists(project.getName()))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(project.getName());
     if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(ResourcesPlugin.PI_RESOURCES);
     return node.getBoolean(
         ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS,
         ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS);
   } catch (BackingStoreException e) {
     // nodeExists failed
     String message = Messages.resources_readingEncoding;
     Policy.log(
         new ResourceStatus(
             IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e));
     return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
   }
 }
コード例 #10
0
 private void doCreateProject(ProjectCandidate pc, IProgressMonitor monitor)
     throws CoreException, InterruptedException, InvocationTargetException {
   HybridProjectCreator projectCreator = new HybridProjectCreator();
   Widget w = pc.getWidget();
   String projectName = pc.getProjectName();
   URI location = null;
   if (!copyFiles) {
     location = pc.wwwLocation.getParentFile().toURI();
   }
   IProject project =
       projectCreator.createProject(
           projectName,
           location,
           w.getName(),
           w.getId(),
           HybridMobileEngineManager.getDefaultEngine(),
           monitor);
   if (copyFiles) {
     ImportOperation operation =
         new ImportOperation(
             project.getFullPath(),
             pc.wwwLocation.getParentFile(),
             FileSystemStructureProvider.INSTANCE,
             this);
     operation.setContext(getShell());
     operation.setOverwriteResources(true);
     operation.setCreateContainerStructure(false);
     operation.run(monitor);
     IStatus status = operation.getStatus();
     if (!status.isOK()) throw new InvocationTargetException(new CoreException(status));
   }
 }
コード例 #11
0
 public IFile getFile() {
   String fileName = unitName;
   if (!fileName.endsWith(".ceylon")) fileName += ".ceylon";
   IPath path = packageFragment.getPath().append(fileName);
   IProject project = sourceDir.getJavaProject().getProject();
   return project.getFile(path.makeRelativeTo(project.getFullPath()));
 }
コード例 #12
0
  public void testRegion() throws Exception {
    IJavaProject jproj = createJavaProject("RegionTest");
    IProject proj = jproj.getProject();
    IPath projPath = proj.getFullPath();
    IPath root = projPath.append("src");

    for (int idx = 0; idx < 1000; idx++) {
      this.env.addClass(
          root, "test", "Foo" + idx, "package test;\n\n" + "public class Foo" + idx + " {\n" + "}");
    }

    this.env.fullBuild();

    for (int idx = 0; idx < 10; idx++) {
      startMeasuring();
      Region region = new Region();
      IPackageFragment[] fragments = jproj.getPackageFragments();

      for (IPackageFragment next : fragments) {
        IJavaElement[] children = next.getChildren();

        for (IJavaElement nextChild : children) {
          region.add(nextChild);
        }
      }
      stopMeasuring();
    }

    // Commit
    commitMeasurements();
    assertPerformance();
  }
コード例 #13
0
  public void test000_removeClosed() throws Exception {
    IProject p1 = createExisting("t000-p1");
    waitForJobsToComplete();

    IMavenProjectFacade f1 = manager.create(p1, monitor);

    MavenProjectChangedEvent event;
    //    assertEquals(1, events.size());
    //    event = events.get(0);
    //    assertEquals(MavenProjectChangedEvent.KIND_ADDED, event.getKind());
    //    assertNull(event.getOldMavenProject());
    //    assertSame(f1, event.getMavenProject());

    assertEquals(p1.getFullPath(), f1.getFullPath());

    events.clear();

    p1.close(monitor);
    waitForJobsToComplete();

    assertNull(manager.create(p1, monitor));

    assertEquals(1, events.size());
    event = events.get(0);
    assertEquals(MavenProjectChangedEvent.KIND_REMOVED, event.getKind());
    assertSame(f1, event.getOldMavenProject());
    assertNull(event.getMavenProject());
  }
  /** Handle browse source folder. */
  private void handleBrowseSourceFolder() {

    ContainerSelectionDialog dialog =
        new ContainerSelectionDialog(
            getShell(), project, false, Messages.WizardPageChooseSourceFolderAndPackage_27);
    dialog.showClosedProjects(false);

    if (dialog.open() == Window.OK) {

      Object[] result = dialog.getResult();
      if (result.length == 1) {

        txtJavaSourceFolder.setText(((Path) result[0]).toString());
        // String fullPathWorkspace = GeneratorUtil.replaceAll(project.getLocation().toString(),
        // project.getFullPath().toString(), "");
        String fullPathWorkspace =
            project
                .getLocation()
                .toString()
                .replaceAll(project.getFullPath().toString(), ""); // $NON-NLS-1$
        EclipseGeneratorUtil.fullPathProject = project.getLocation().toString();
        EclipseGeneratorUtil.project = project;
        EclipseGeneratorUtil.projectName = EclipseGeneratorUtil.project.getName();
        EclipseGeneratorUtil.workspaceFolderPath = fullPathWorkspace;

        EclipseGeneratorUtil.javaSourceFolderPath =
            EclipseGeneratorUtil.workspaceFolderPath
                + txtJavaSourceFolder.getText()
                + GeneratorUtil.slash;
        btnPackage.setEnabled(true);
        btnNewPackage.setEnabled(true);
      }
    }
  }
コード例 #15
0
ファイル: Util.java プロジェクト: dargoner/fuseide
 public static String getCamelVersion(IProject project) {
   IPath pomPathValue =
       project.getProject().getRawLocation() != null
           ? project.getProject().getRawLocation().append("pom.xml")
           : ResourcesPlugin.getWorkspace()
               .getRoot()
               .getLocation()
               .append(project.getFullPath().append("pom.xml"));
   String pomPath = pomPathValue.toOSString();
   final File pomFile = new File(pomPath);
   try {
     final org.apache.maven.model.Model model = MavenPlugin.getMaven().readModel(pomFile);
     List<org.apache.maven.model.Dependency> deps = model.getDependencies();
     for (Iterator<org.apache.maven.model.Dependency> iterator = deps.iterator();
         iterator.hasNext(); ) {
       org.apache.maven.model.Dependency dependency = iterator.next();
       if (dependency.getArtifactId().equals("camel-core")) {
         return dependency.getVersion();
       }
     }
   } catch (CoreException e) {
     // not found, go with default
   }
   return org.fusesource.ide.camel.editor.Activator.getDefault().getCamelVersion();
 }
コード例 #16
0
  protected void checkIfPathValid() {
    fFolder = null;
    IContainer folder = null;
    if (fUseFolderButton.isSelected()) {
      String pathStr = fContainerDialogField.getText();
      if (pathStr.length() == 0) {
        fContainerFieldStatus.setError(NewWizardMessages.NewSourceFolderDialog_error_enterpath);
        return;
      }
      IPath path = fCurrProject.getFullPath().append(pathStr);
      IWorkspace workspace = fCurrProject.getWorkspace();

      IStatus pathValidation = workspace.validatePath(path.toString(), IResource.FOLDER);
      if (!pathValidation.isOK()) {
        fContainerFieldStatus.setError(
            Messages.format(
                NewWizardMessages.NewSourceFolderDialog_error_invalidpath,
                pathValidation.getMessage()));
        return;
      }
      folder = fCurrProject.getFolder(pathStr);
    } else {
      folder = fCurrProject;
    }
    if (isExisting(folder)) {
      fContainerFieldStatus.setError(NewWizardMessages.NewSourceFolderDialog_error_pathexists);
      return;
    }
    fContainerFieldStatus.setOK();
    fFolder = folder;
  }
コード例 #17
0
  public void search(
      ISearchRequestor requestor, QuerySpecification querySpecification, IProgressMonitor monitor)
      throws CoreException {

    if (querySpecification.getLimitTo() != S_LIMIT_REF
        && querySpecification.getLimitTo() != S_LIMIT_ALL) return;

    String search;
    if (querySpecification instanceof ElementQuerySpecification) {
      IJavaElement element = ((ElementQuerySpecification) querySpecification).getElement();
      if (element instanceof IType) search = ((IType) element).getFullyQualifiedName('.');
      else search = element.getElementName();
      int type = element.getElementType();
      if (type == IJavaElement.TYPE) fSearchFor = S_FOR_TYPES;
      else if (type == IJavaElement.PACKAGE_FRAGMENT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT)
        fSearchFor = S_FOR_PACKAGES;
    } else {
      fSearchFor = ((PatternQuerySpecification) querySpecification).getSearchFor();
      search = ((PatternQuerySpecification) querySpecification).getPattern();
    }
    if (fSearchFor != S_FOR_TYPES && fSearchFor != S_FOR_PACKAGES) return;
    fSearchPattern = PatternConstructor.createPattern(search, true);
    fSearchRequestor = requestor;

    IPath[] enclosingPaths = querySpecification.getScope().enclosingProjectsAndJars();
    IPluginModelBase[] pluginModels = PluginRegistry.getWorkspaceModels();
    monitor.beginTask(PDEUIMessages.ClassSearchParticipant_taskMessage, pluginModels.length);
    for (int i = 0; i < pluginModels.length; i++) {
      IProject project = pluginModels[i].getUnderlyingResource().getProject();
      if (!monitor.isCanceled() && encloses(enclosingPaths, project.getFullPath()))
        searchProject(project, monitor);
    }
  }
コード例 #18
0
ファイル: SVNUpdater.java プロジェクト: juancadavid/papyrus
  @Override
  public IStatus update() {
    IFile[] resourcesToProcess = getTargetFiles(getTargetResources());
    // The all project of each file shall be updated (In order to see if new files appeared (New
    // control))
    Set<IProject> projects = new HashSet<IProject>();
    for (IFile f : resourcesToProcess) {
      projects.add(f.getProject());
    }

    IProject[] projectsToUpdate = new IProject[projects.size()];
    projects.toArray(projectsToUpdate);
    if (ITracingConstant.UPDATE_TRACING) {
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("Updating projects: ").append("\n");
      for (IProject p : projectsToUpdate) {
        stringBuilder.append(p.getFullPath()).append("\n");
      }
      Tracer.logInfo(stringBuilder.toString());
    }
    CompositeOperation op = UpdateAction.getUpdateOperation(projectsToUpdate, SVNRevision.HEAD);
    ICancellableOperationWrapper runnable = UIMonitorUtility.doTaskNowDefault(op, false);
    IActionOperation resultStatus = runnable.getOperation();

    return resultStatus.getStatus();
  }
コード例 #19
0
  /** Returns the root directories to scan. */
  @Override
  protected Set<IPath> getRootDirectories(IProject project) {
    this.project = project;

    Set<IPath> rootDirectories = new LinkedHashSet<IPath>();
    rootDirectories.add(project.getFullPath());
    return rootDirectories;
  }
コード例 #20
0
ファイル: MavenProject.java プロジェクト: raphsoft/che
 public boolean containsAsModule(IPath modulePath) {
   if (!project.getFullPath().equals(modulePath)) {
     return false;
   }
   String moduleName = modulePath.lastSegment();
   List<String> modules = getModules();
   return modules.contains(moduleName);
 }
コード例 #21
0
  private boolean initProject(IResource selection) {
    IProject project = selection.getProject();
    if (project != null && GWTNature.isGWTProject(project)) {
      projectField.setText(project.getFullPath().makeRelative().toString());
      return true;
    }

    return false;
  }
コード例 #22
0
 public void syncMindPathFile() {
   IProject p = getProject();
   try {
     File f = getMindPathFile(getProject());
     if (f.exists()) {
       EList<MindPathEntry> mindPath = readFileEntries(getProject(), this);
       setMindpath(mindPath);
     } else {
       saveMPE();
     }
   } catch (IOException e) {
     MindIdeCore.log(
         e, "Exception while sync " + p.getFullPath().append(MINDPATH_FILENAME)); // $NON-NLS-1$
   } catch (CoreException e) {
     MindIdeCore.log(
         e, "Exception while sync " + p.getFullPath().append(MINDPATH_FILENAME)); // $NON-NLS-1$
   }
 }
コード例 #23
0
  protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
    Class<?>[] acceptedClasses =
        new Class[] {ICProject.class, IProject.class, IContainer.class, ICContainer.class};
    TypedElementSelectionValidator validator =
        new TypedElementSelectionValidator(acceptedClasses, existing == null);
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses);

    String title =
        (existing == null)
            ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_title
            : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title;
    String message =
        (existing == null)
            ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_description
            : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description;

    ElementTreeSelectionDialog dialog =
        new ElementTreeSelectionDialog(
            getShell(), new WorkbenchLabelProvider(), new CElementContentProvider());
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(CoreModel.getDefault().getCModel());
    if (existing == null) {
      dialog.setInitialSelection(fCurrCProject);
    } else {
      dialog.setInitialSelection(existing.getCProject());
    }

    if (dialog.open() == Window.OK) {
      Object[] elements = dialog.getResult();
      CPElement[] res = new CPElement[elements.length];
      for (int i = 0; i < res.length; i++) {
        IProject project;
        IPath includePath;
        if (elements[i] instanceof IResource) {
          project = ((IResource) elements[i]).getProject();
          includePath = ((IResource) elements[i]).getProjectRelativePath();
        } else {
          project = ((ICElement) elements[i]).getCProject().getProject();
          includePath = ((ICElement) elements[i]).getResource().getProjectRelativePath();
        }
        CPElementGroup group = getSelectedGroup();
        res[i] =
            new CPElement(
                fCurrCProject,
                IPathEntry.CDT_INCLUDE,
                group.getResource().getFullPath(),
                group.getResource());
        res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
        res[i].setAttribute(CPElement.INCLUDE, includePath);
      }
      return res;
    }
    return null;
  }
コード例 #24
0
 public void populateChildren() {
   IPath p =
       ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(project.getFullPath());
   try {
     findFiles(p.toFile());
   } catch (CoreException ex) {
     // ignore
   }
 }
コード例 #25
0
 @Override
 protected IStatus run(IProgressMonitor monitor) {
   MultiStatus result =
       new MultiStatus(
           ResourcesPlugin.PI_RESOURCES,
           IResourceStatus.FAILED_SETTING_CHARSET,
           Messages.resources_updatingEncoding,
           null);
   monitor = Policy.monitorFor(monitor);
   try {
     monitor.beginTask(Messages.resources_charsetUpdating, Policy.totalWork);
     final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(workspace.getRoot());
     try {
       workspace.prepareOperation(rule, monitor);
       workspace.beginOperation(true);
       Map.Entry<IProject, Boolean> next;
       while ((next = getNextChange()) != null) {
         // just exit if the system is shutting down or has been shut down
         // it is too late to change the workspace at this point anyway
         if (systemBundle.getState() != Bundle.ACTIVE) return Status.OK_STATUS;
         IProject project = next.getKey();
         try {
           if (project.isAccessible()) {
             boolean shouldDisableCharsetDeltaJob = next.getValue().booleanValue();
             // flush preferences for non-derived resources
             flushPreferences(
                 getPreferences(project, false, false, true), shouldDisableCharsetDeltaJob);
             // flush preferences for derived resources
             flushPreferences(
                 getPreferences(project, false, true, true), shouldDisableCharsetDeltaJob);
           }
         } catch (BackingStoreException e) {
           // we got an error saving
           String detailMessage = Messages.resources_savingEncoding;
           result.add(
               new ResourceStatus(
                   IResourceStatus.FAILED_SETTING_CHARSET,
                   project.getFullPath(),
                   detailMessage,
                   e));
         }
       }
       monitor.worked(Policy.opWork);
     } catch (OperationCanceledException e) {
       workspace.getWorkManager().operationCanceled();
       throw e;
     } finally {
       workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork));
     }
   } catch (CoreException ce) {
     return ce.getStatus();
   } finally {
     monitor.done();
   }
   return result;
 }
コード例 #26
0
  private static IClasspathContainer allocateLibraryContainer(IJavaProject javaProject) {
    final IProject iProject = javaProject.getProject();

    // check if the project has a valid target.
    ProjectState state = Sdk.getProjectState(iProject);
    if (state == null) {
      // getProjectState should already have logged an error. Just bail out.
      return null;
    }

    /*
     * At this point we're going to gather a list of all that need to go in the
     * dependency container.
     * - Library project outputs (direct and indirect)
     * - Java project output (those can be indirectly referenced through library projects
     *   or other other Java projects)
     * - Jar files:
     *    + inside this project's libs/
     *    + inside the library projects' libs/
     *    + inside the referenced Java projects' classpath
     */
    List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();

    // list of java project dependencies and jar files that will be built while
    // going through the library projects.
    Set<File> jarFiles = new HashSet<File>();
    Set<IProject> refProjects = new HashSet<IProject>();

    // process all the libraries

    List<IProject> libProjects = state.getFullLibraryProjects();
    for (IProject libProject : libProjects) {
      // process all of the library project's dependencies
      getDependencyListFromClasspath(libProject, refProjects, jarFiles, true);
    }

    // now process this projects' referenced projects only.
    processReferencedProjects(iProject, refProjects, jarFiles);

    // and the content of its libs folder
    getJarListFromLibsFolder(iProject, jarFiles);

    // now add a classpath entry for each Java project (this is a set so dups are already
    // removed)
    for (IProject p : refProjects) {
      entries.add(JavaCore.newProjectEntry(p.getFullPath(), true /*isExported*/));
    }

    entries.addAll(convertJarsToClasspathEntries(iProject, jarFiles));

    return allocateContainer(
        javaProject,
        entries,
        new Path(AndmoreAndroidConstants.CONTAINER_PRIVATE_LIBRARIES),
        "Android Private Libraries");
  }
コード例 #27
0
  public void testMoveProjectWithVirtualFolder() {
    IPath fileLocation = getRandomLocation();
    IPath folderLocation = getRandomLocation();

    IFile file = existingVirtualFolderInExistingProject.getFile(getUniqueString());
    IFolder folder = existingVirtualFolderInExistingProject.getFolder(getUniqueString());
    IFile childFile = folder.getFile(getUniqueString());
    IResource[] oldResources = new IResource[] {existingProject, file, folder, childFile};

    try {
      assertDoesNotExistInWorkspace("1.0", new IResource[] {folder, file, childFile});

      try {
        createFileInFileSystem(fileLocation);
        folderLocation.toFile().mkdir();

        folder.createLink(folderLocation, IResource.NONE, getMonitor());
        file.createLink(fileLocation, IResource.NONE, getMonitor());

        childFile.create(getRandomContents(), true, getMonitor());
      } catch (CoreException e) {
        fail("2.0", e);
      }

      // move the project
      IProject destinationProject = getWorkspace().getRoot().getProject("MoveTargetProject");
      assertDoesNotExistInWorkspace("3.0", destinationProject);

      try {
        existingProject.move(destinationProject.getFullPath(), IResource.SHALLOW, getMonitor());
      } catch (CoreException e) {
        fail("4.0", e);
      }

      IFile newFile = destinationProject.getFile(file.getProjectRelativePath());
      IFolder newFolder = destinationProject.getFolder(folder.getProjectRelativePath());
      IFile newChildFile = newFolder.getFile(childFile.getName());
      IResource[] newResources =
          new IResource[] {destinationProject, newFile, newFolder, newChildFile};

      assertExistsInWorkspace("5.0", newResources);
      assertDoesNotExistInWorkspace("6.1", oldResources);
      assertTrue("7.0", existingProject.isSynchronized(IResource.DEPTH_INFINITE));
      assertTrue("8.0", destinationProject.isSynchronized(IResource.DEPTH_INFINITE));

      assertTrue("9.0", newFile.getParent().isVirtual());
      assertTrue("10.0", newFile.isLinked());

      assertTrue("11.0", newFolder.isLinked());
      assertTrue("12.0", newFolder.getParent().isVirtual());
    } finally {
      Workspace.clear(fileLocation.toFile());
      Workspace.clear(folderLocation.toFile());
    }
  }
コード例 #28
0
ファイル: PHPCorePlugin.java プロジェクト: KopjeKoffie/pdt
    public void resourceChanged(IResourceChangeEvent event) {
      if (event.getBuildKind() == IncrementalProjectBuilder.CLEAN_BUILD) {
        Object source = event.getSource();
        try {
          if (source instanceof IProject) {
            IProject project = (IProject) source;
            ProjectIndexerManager.removeProject(project.getFullPath());
            ProjectIndexerManager.indexProject(project);

          } else if (source instanceof IWorkspace) {
            IWorkspace workspace = (IWorkspace) source;
            IProject[] projects = workspace.getRoot().getProjects();

            // remove from index:
            for (IProject project : projects) {
              if (!project.isAccessible()) {
                continue;
              }
              IScriptProject scriptProject = DLTKCore.create(project);
              if (scriptProject.isOpen()) {
                IProjectFragment[] projectFragments = scriptProject.getProjectFragments();
                for (IProjectFragment projectFragment : projectFragments) {
                  ProjectIndexerManager.removeProjectFragment(
                      scriptProject, projectFragment.getPath());
                }
                ProjectIndexerManager.removeProject(project.getFullPath());
              }
            }

            // add to index:
            for (IProject project : projects) {
              if (!project.isAccessible()) {
                continue;
              }
              ProjectIndexerManager.indexProject(project);
            }
          }
        } catch (CoreException e) {
          Logger.logException(e);
        }
      }
    }
コード例 #29
0
  private String getHiddenProjectPath() {
    String result = null;
    IProject hiddenProj =
        ProductCustomizerMgr.getInstance().getProductCharacteristics().getHiddenProject(false);

    if (hiddenProj != null) {
      result = hiddenProj.getFullPath().makeRelative().toString();
    }

    return result;
  }
コード例 #30
0
  public void test000_simple() throws Exception {
    IProject p1 = createExisting("t000-p1");
    waitForJobsToComplete();

    IMavenProjectFacade f1 = manager.create(p1, monitor);
    assertEquals(p1.getFullPath(), f1.getFullPath());

    assertEquals("t000", f1.getMavenProject(monitor).getGroupId());
    assertEquals("t000-p1", f1.getMavenProject(monitor).getArtifactId());
    assertEquals("0.0.1-SNAPSHOT", f1.getMavenProject(monitor).getVersion());
  }