本文整理汇总了Java中org.eclipse.core.runtime.IPath.toString方法的典型用法代码示例。如果您正苦于以下问题:Java IPath.toString方法的具体用法?Java IPath.toString怎么用?Java IPath.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.IPath
的用法示例。
在下文中一共展示了IPath.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResourcesWithExtension
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public ArrayList<String> getResourcesWithExtension(String ext, String containerName) {
ArrayList<String> ret = new ArrayList<String>();
if (containerName != null) {
String[] names = StringUtils.split(containerName, "/");
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = wsRoot.findMember(new Path("/" + names[0]));
IPath loc = resource.getLocation();
File prjLoc = new File(loc.toString());
Collection<File> res = FileUtils.listFiles(prjLoc, FileFilterUtils.suffixFileFilter(ext, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
for (File file : res)
ret.add(file.getAbsolutePath());
}
return ret;
}
示例2: createFromPath
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* Creates a module specifier proposal from a given path and type
*
* @param path
* The path of the proposal
* @param moduleType
* The type of the proposal
* @return The proposal
*/
static ModuleSpecifierProposal createFromPath(IPath path, ModuleProposalType moduleType) {
String content, label;
if (moduleType == ModuleProposalType.FOLDER) {
content = path.removeFileExtension().addTrailingSeparator().toString();
} else {
content = path.removeFileExtension().toString();
}
if (moduleType == ModuleProposalType.FOLDER) {
label = path.addTrailingSeparator().toString();
} else {
label = path.toString();
}
return new ModuleSpecifierProposal(content, label, moduleType);
}
示例3: isFileInFolders
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* Return whether the resource is in of the passed folders
*
* @param resource
* @param folders
* @return
*/
public static boolean isFileInFolders(IFile resource, String[] folders) {
if (resource == null)
return false;
IProject p = resource.getProject();
IJavaProject javaProject = JavaCore.create(p);
for (int i = 0; i < folders.length; i++) {
IPath folderPath = javaProject.getPath().append(folders[i]);
String allowedPAth = folderPath.toString();
String resourcePath = resource.getFullPath().toString();
if (resourcePath.startsWith(allowedPAth)) {
return true;
}
}
return false;
}
示例4: validate
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public static boolean validate(String container) {
if (container != null) {
String[] names = StringUtils.split(container, "/");
IResource resource = wsRoot.findMember(new Path("/" + names[0]));
IPath loc = resource.getLocation();
File prjLoc = new File(loc.toString());
File[] res = prjLoc.listFiles();
HashMap<String, ArrayList<File>> fileGroups = new HashMap<String, ArrayList<File>>();
HashMap<String, Integer> groupCnt = new HashMap<String, Integer>();
for (File file : res) {
String extension = FilenameUtils.getExtension(file.getName());
ArrayList<File> list = fileGroups.get(extension);
int cnt = (groupCnt.get(extension) == null) ? 0 : groupCnt.get(extension).intValue();
if (list == null)
list = new ArrayList<File>();
list.add(file);
cnt++;
groupCnt.put(extension, new Integer(cnt));
fileGroups.put(extension, list);
}
return !validate(groupCnt);
}
return false;
}
示例5: getFilteredSourceFolders
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* @param projectName
* @return the direct child folders of the project
* @throws CoreException
*/
public static List<String> getFilteredSourceFolders(String projectName, String[] excludes) throws CoreException {
List<String> ret = new ArrayList<String>();
IJavaProject javaProject = (IJavaProject) JavaCore.create(getProject(projectName));
IClasspathEntry[] entries = javaProject.getRawClasspath();
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IPath path = entry.getPath().makeRelativeTo(new Path(projectName));
boolean isExcluded = false;
for (int j = 0; j < excludes.length; j++) {
if (excludes[j].equalsIgnoreCase(path.toString())) {
isExcluded = true;
break;
}
}
if (!isExcluded) {
String p = path.toString();
ret.add(p);
}
}
}
return ret;
}
示例6: validateIsExistingProjectPath
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* Checks whether the specified project path points to an existing project and sets an according error message.
*
* Returns <code>true</code> otherwise.
*
* This method assumes that {@link #getProjectName()} returns a valid project name.
*/
private boolean validateIsExistingProjectPath() {
IPath projectLocation = getLocationPath();
final String projectName = getProjectName();
// if workspace is project location (default location)
if (projectLocation.equals(Platform.getLocation())) {
// add project name since #getLocationPath does not return the full project location
projectLocation = projectLocation.append(projectName);
}
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
boolean workspaceProjectExists = root.getProject(projectName).exists();
// check for an existing manifest
IPath manifestPath = projectLocation.append("manifest.n4mf");
File existingManifest = new File(manifestPath.toString());
// check for an existing file with the path of the project folder
File existingFileAtProjectDirectory = new File(projectLocation.toString());
boolean projectDirectoryIsExistingFile = existingFileAtProjectDirectory.exists()
&& existingFileAtProjectDirectory.isFile();
boolean isExistingNonWorkspaceProject = existingManifest.exists() && !workspaceProjectExists;
if (projectDirectoryIsExistingFile) {
// set error message if there is already at the specified project location
setErrorMessage("There already exists a file at the location '" + projectLocation.toString() + "'.");
return false;
} else if (isExistingNonWorkspaceProject) {
// set error message if the specified directory already represents an N4JS project
setErrorMessage(
"There already exists an N4JS project at the specified location. Please use 'File > Import...' to add it to the workspace.");
return false;
} else {
// otherwise the project location does not exist yet
return true;
}
}
示例7: editorChanged
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
@Override
public void editorChanged() {
IPath path = new Path(editor.getStringValue());
filePath = path.toString();
File f = new File(filePath);
if(f.exists()) {
try {
addToCombo(FileUtils.toUriString(f));
} catch (MalformedURLException e) {}
} else {
editor.setStringValue(null);
setTextStatus("Please select an existing file");
}
}
示例8: RefreshAction
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public RefreshAction(IWorkbenchPart part, IPath iPath, IFile file) {
super(part);
setText("Refresh Implementation");
this.part = part;
this.containerName = iPath.toString();
this.file = file;
}
示例9: RefreshAction
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public RefreshAction(IWorkbenchPart part, IPath iPath, IFile file) {
super(part);
setText("Refresh Deployment");
this.part = part;
this.containerName = iPath.toString();
this.file = file;
}
示例10: getFullyQualifiedName
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* @param elt
* @return
* @throws JavaModelException
*/
public static String getFullyQualifiedName(IJavaElement elt) throws JavaModelException {
IPackageFragmentRoot[] roots = elt.getJavaProject().getPackageFragmentRoots();
for (int i = 0; i < roots.length; i++) {
if (roots[i].getPath().isPrefixOf(elt.getPath())) {
IPath p = elt.getPath().makeRelativeTo(roots[i].getPath());
return p.toString();
}
}
return elt.getElementName();
}
示例11: toFile
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* Return the OS File
*
* @param in
* @return
* @throws FileNotFoundException
*/
public static File toFile(IPath ipath) throws FileNotFoundException {
if (ipath == null)
throw new FileNotFoundException("");
IResource resource = getWorkspaceRoot().findMember(ipath);
if (resource == null)
throw new FileNotFoundException(ipath.toString());
IPath path = resource.getRawLocation();
String file = path.makeAbsolute().toString();
return new File(file);
}
示例12: getPathUsageRegExp
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public static String getPathUsageRegExp (IPath path) {
String regex = "([P]aths\\.get)\\s*\\(\\s*\"" + path.toString() + "\"\\s*\\)" ;
return regex;
}
示例13: ClearTargetAction
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public ClearTargetAction(IWorkbenchPart part, IPath iPath) {
super(part);
setText("Clear Generated Code");
this.part = part;
this.containerName = iPath.toString();
}
示例14: GenerateUIDAction
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public GenerateUIDAction(IWorkbenchPart part, IPath iPath) {
super(part);
setText("Generate UID");
this.part = part;
this.containerName = iPath.toString();
}
示例15: ExportImageAction
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
public ExportImageAction(IWorkbenchPart part, IPath iPath) {
super(part);
setText("Export As Image");
this.part = part;
this.containerName = iPath.toString();
}