本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}