本文整理匯總了Java中org.eclipse.core.resources.IResource.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java IResource.getLocation方法的具體用法?Java IResource.getLocation怎麽用?Java IResource.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IResource
的用法示例。
在下文中一共展示了IResource.getLocation方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getResourcesWithExtension
import org.eclipse.core.resources.IResource; //導入方法依賴的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: getFinalAssemblyDefinition
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
public CompositeNode getFinalAssemblyDefinition(String name, String containerName) {
CompositeNode ret = null;
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 file = new File(loc.toOSString() + File.separator + name + ".fassmbl");
try {
ret = ParseUtil.getFinalAssemblyNodeFromText(FileUtils.readFileToString(file));
} catch (IOException e) {
EclipseUtil.writeStactTraceToConsole(e);
}
}
return ret;
}
示例3: getLogicalSystemDefinition
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
public LogicalSystemNode getLogicalSystemDefinition(String name, String containerName) {
LogicalSystemNode ret = null;
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 file = new File(loc.toOSString() + File.separator + name + ".lsys");
try {
ret = ParseUtil.getLogicalSystemNodeFromText(FileUtils.readFileToString(file));
} catch (IOException e) {
EclipseUtil.writeStactTraceToConsole(e);
}
}
return ret;
}
示例4: getComponentImplementationDefinition
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
public ComponentImplementationNode getComponentImplementationDefinition(String name, String containerName) {
ComponentImplementationNode ret = null;
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 file = new File(loc.toOSString() + File.separator + name + ".cimpl");
try {
ret = ParseUtil.getComponentImplementationNodeFromText(FileUtils.readFileToString(file));
} catch (IOException e) {
EclipseUtil.writeStactTraceToConsole(e);
}
}
return ret;
}
示例5: validate
import org.eclipse.core.resources.IResource; //導入方法依賴的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;
}
示例6: addBreakpointToMap
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
private void addBreakpointToMap(IBreakpoint breakpoint) throws CoreException {
Assert.isTrue(supportsBreakpoint(breakpoint) && breakpoint instanceof ILineBreakpoint);
if (breakpoint instanceof ILineBreakpoint) {
ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
IResource resource = lineBreakpoint.getMarker().getResource();
IPath location = resource.getLocation();
String path = location.toOSString();
String name = location.lastSegment();
int lineNumber = lineBreakpoint.getLineNumber();
Source source = new Source().setName(name).setPath(path);
List<SourceBreakpoint> sourceBreakpoints = targetBreakpoints.computeIfAbsent(source,
s -> new ArrayList<>());
sourceBreakpoints.add(new SourceBreakpoint().setLine(lineNumber));
}
}
示例7: deleteBreakpointFromMap
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
private void deleteBreakpointFromMap(IBreakpoint breakpoint) throws CoreException {
Assert.isTrue(supportsBreakpoint(breakpoint) && breakpoint instanceof ILineBreakpoint);
if (breakpoint instanceof ILineBreakpoint) {
ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
IResource resource = lineBreakpoint.getMarker().getResource();
IPath location = resource.getLocation();
String path = location.toOSString();
String name = location.lastSegment();
int lineNumber = lineBreakpoint.getLineNumber();
for (Entry<Source, List<SourceBreakpoint>> entry : targetBreakpoints.entrySet()) {
Source source = entry.getKey();
if (Objects.equals(name, source.name) && Objects.equals(path, source.path)) {
List<SourceBreakpoint> bps = entry.getValue();
for (Iterator<SourceBreakpoint> iterator = bps.iterator(); iterator.hasNext();) {
SourceBreakpoint sourceBreakpoint = (SourceBreakpoint) iterator.next();
if (Objects.equals(lineNumber, sourceBreakpoint.line)) {
iterator.remove();
}
}
}
}
}
}
示例8: getProjectLocation
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
public static File getProjectLocation(String project) throws FileNotFoundException {
if ( project == null)
throw new FileNotFoundException("");
IResource resource = getWorkspaceRoot().findMember(project);
if (resource == null)
throw new FileNotFoundException(project.toString());
IPath path = resource.getRawLocation();
if (path == null) {
path = resource.getLocation();
}
String file = path.makeAbsolute().toString();
return new File(file);
}
示例9: visit
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
/**
* Answers whether children should be visited.
* <p>
* If the associated resource is a class file which has been changed, record it.
* </p>
*/
@Override
public boolean visit(IResourceDelta delta) {
if (delta == null || 0 == (delta.getKind() & IResourceDelta.CHANGED)) {
return false;
}
IResource resource = delta.getResource();
if (resource != null) {
switch (resource.getType()) {
case IResource.FILE:
if (0 == (delta.getFlags() & IResourceDelta.CONTENT)) {
return false;
}
if (CLASS_FILE_EXTENSION.equals(resource.getFullPath().getFileExtension())) {
IPath localLocation = resource.getLocation();
if (localLocation != null) {
String path = localLocation.toOSString();
IClassFileReader reader = ToolFactory.createDefaultClassFileReader(path,
IClassFileReader.CLASSFILE_ATTRIBUTES);
if (reader != null) {
// this name is slash-delimited
String qualifiedName = new String(reader.getClassName());
boolean hasBlockingErrors = false;
try {
// If the user doesn't want to replace
// classfiles containing
// compilation errors, get the source
// file associated with
// the class file and query it for
// compilation errors
IJavaProject pro = JavaCore.create(resource.getProject());
ISourceAttribute sourceAttribute = reader.getSourceFileAttribute();
String sourceName = null;
if (sourceAttribute != null) {
sourceName = new String(sourceAttribute.getSourceFileName());
}
IResource sourceFile = getSourceFile(pro, qualifiedName, sourceName);
if (sourceFile != null) {
IMarker[] problemMarkers = null;
problemMarkers = sourceFile.findMarkers(
IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true,
IResource.DEPTH_INFINITE);
for (IMarker problemMarker : problemMarkers) {
if (problemMarker.getAttribute(IMarker.SEVERITY,
-1) == IMarker.SEVERITY_ERROR) {
hasBlockingErrors = true;
break;
}
}
}
} catch (CoreException e) {
logger.log(Level.SEVERE, "Failed to visit classes: " + e.getMessage(), e);
}
if (!hasBlockingErrors) {
changedFiles.add(resource);
// dot-delimit the name
fullyQualifiedNames.add(qualifiedName.replace('/', '.'));
}
}
}
}
return false;
default:
return true;
}
}
return true;
}