當前位置: 首頁>>代碼示例>>Java>>正文


Java PyStructureConfigHelpers.convertToProjectRelativePath方法代碼示例

本文整理匯總了Java中org.python.pydev.plugin.PyStructureConfigHelpers.convertToProjectRelativePath方法的典型用法代碼示例。如果您正苦於以下問題:Java PyStructureConfigHelpers.convertToProjectRelativePath方法的具體用法?Java PyStructureConfigHelpers.convertToProjectRelativePath怎麽用?Java PyStructureConfigHelpers.convertToProjectRelativePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.python.pydev.plugin.PyStructureConfigHelpers的用法示例。


在下文中一共展示了PyStructureConfigHelpers.convertToProjectRelativePath方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doActionOnContainer

import org.python.pydev.plugin.PyStructureConfigHelpers; //導入方法依賴的package包/類
@Override
protected int doActionOnContainer(IContainer container, IProgressMonitor monitor) {
    try {
        IProject project = container.getProject();
        IPythonPathNature pythonPathNature = PythonNature.getPythonPathNature(project);
        if (pythonPathNature == null) {
            Log.log("Unable to get PythonNature on project: " + project);
            return 0;
        }
        OrderedMap<String, String> projectSourcePathMap = pythonPathNature
                .getProjectSourcePathResolvedToUnresolvedMap();
        String pathToAdd = container.getFullPath().toString();
        if (projectSourcePathMap.containsKey(pathToAdd)) {
            return 0;
        }

        pathToAdd = PyStructureConfigHelpers.convertToProjectRelativePath(project.getFullPath().toString(),
                pathToAdd);

        Collection<String> values = new ArrayList<String>(projectSourcePathMap.values());
        values.add(pathToAdd);
        pythonPathNature.setProjectSourcePath(StringUtils.join("|", values));
        PythonNature.getPythonNature(project).rebuildPath();
        return 1;
    } catch (CoreException e) {
        Log.log(IStatus.ERROR, "Unexpected error setting project properties", e);
    }
    return 0;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:30,代碼來源:PyAddSrcFolder.java

示例2: getPathAsString

import org.python.pydev.plugin.PyStructureConfigHelpers; //導入方法依賴的package包/類
/**
 * @param project 
 * @return The passed path as a string (used for the selection dialog, as things come relative to the workspace).
 */
private String getPathAsString(IPath p, IProject project) {
    String ret = p.toString();
    if (ret.startsWith("/") == false) {
        ret = "/" + ret;
    }
    return PyStructureConfigHelpers.convertToProjectRelativePath(project.getFullPath().toString(), ret);
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:12,代碼來源:TreeWithAddRemove.java

示例3: doCreateNew

import org.python.pydev.plugin.PyStructureConfigHelpers; //導入方法依賴的package包/類
@Override
protected IFile doCreateNew(IProgressMonitor monitor) throws CoreException {
    IProject project = filePage.getValidatedProject();
    String name = filePage.getValidatedName();
    IPath source = filePage.getSourceToLink();
    if (project == null || !project.exists()) {
        throw new RuntimeException("The project selected does not exist in the workspace.");
    }
    IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
    if (pathNature == null) {
        IPythonNature nature = PythonNature.addNature(project, monitor, null, null, null, null, null);
        pathNature = nature.getPythonPathNature();
        if (pathNature == null) {
            throw new RuntimeException("Unable to add the nature to the seleted project.");
        }
    }
    if (source == null || !source.toFile().exists()) {
        throw new RuntimeException("The source to link to, " + source.toString() + ", does not exist.");
    }
    IFolder folder = project.getFolder(name);
    if (!folder.exists()) {
        folder.createLink(source, IResource.BACKGROUND_REFRESH, monitor);
    }
    String newPath = folder.getFullPath().toString();

    String curr = pathNature.getProjectSourcePath(true);
    if (curr == null) {
        curr = "";
    }
    if (curr.endsWith("|")) {
        curr = curr.substring(0, curr.length() - 1);
    }
    String newPathRel = PyStructureConfigHelpers.convertToProjectRelativePath(
            project.getFullPath().toString(), newPath);
    if (curr.length() > 0) {
        //there is already some path
        Set<String> projectSourcePathSet = pathNature.getProjectSourcePathSet(true);
        if (!projectSourcePathSet.contains(newPath)) {
            //only add to the path if it doesn't already contain the new path
            curr += "|" + newPathRel;
        }
    } else {
        //there is still no other path
        curr = newPathRel;
    }
    pathNature.setProjectSourcePath(curr);
    PythonNature.getPythonNature(project).rebuildPath();
    return null;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:50,代碼來源:PythonExistingSourceFolderWizard.java

示例4: doCreateNew

import org.python.pydev.plugin.PyStructureConfigHelpers; //導入方法依賴的package包/類
@Override
protected IFile doCreateNew(IProgressMonitor monitor) throws CoreException {
    IProject project = filePage.getValidatedProject();
    String name = filePage.getValidatedName();
    if (project == null || !project.exists()) {
        throw new RuntimeException("The project selected does not exist in the workspace.");
    }
    IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
    if (pathNature == null) {
        IPythonNature nature = PythonNature.addNature(project, monitor, null, null, null, null, null);
        pathNature = nature.getPythonPathNature();
        if (pathNature == null) {
            throw new RuntimeException("Unable to add the nature to the seleted project.");
        }
    }
    IFolder folder = project.getFolder(name);
    if (folder.exists()) {
        Log.log("Source folder already exists. Nothing new was created");
        return null;
    }
    folder.create(true, true, monitor);
    String newPath = folder.getFullPath().toString();

    String curr = pathNature.getProjectSourcePath(false);
    if (curr == null) {
        curr = "";
    }
    if (curr.endsWith("|")) {
        curr = curr.substring(0, curr.length() - 1);
    }
    String newPathRel = PyStructureConfigHelpers.convertToProjectRelativePath(
            project.getFullPath().toString(), newPath);
    if (curr.length() > 0) {
        //there is already some path
        Set<String> projectSourcePathSet = pathNature.getProjectSourcePathSet(true);
        if (!projectSourcePathSet.contains(newPath)) {
            //only add to the path if it doesn't already contain the new path
            curr += "|" + newPathRel;
        }
    } else {
        //there is still no other path
        curr = newPathRel;
    }
    pathNature.setProjectSourcePath(curr);
    PythonNature.getPythonNature(project).rebuildPath();
    return null;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:48,代碼來源:PythonSourceFolderWizard.java


注:本文中的org.python.pydev.plugin.PyStructureConfigHelpers.convertToProjectRelativePath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。