本文整理汇总了Java中org.eclipse.core.resources.IResource类的典型用法代码示例。如果您正苦于以下问题:Java IResource类的具体用法?Java IResource怎么用?Java IResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IResource类属于org.eclipse.core.resources包,在下文中一共展示了IResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSeverity
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
private int getSeverity() {
IEditorInput editorInput = getEditorInput();
if (editorInput == null) {
return IMarker.SEVERITY_INFO;
}
try {
final IResource resource = ResourceUtil.getResource(editorInput);
if (resource == null) {
return IMarker.SEVERITY_INFO;
}
int severity = resource.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
return severity;
} catch (CoreException e) {
// Might be a project that is not open
}
return IMarker.SEVERITY_INFO;
}
示例3: fileNested
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
@Test
public void fileNested() throws Exception {
waitForWorkspaceChanges(() -> {
project.getFolder("/folder").create(true, true, null);
project.getFolder("/folder/deep/").create(true, true, null);
IFile file = project.getFile("/folder/deep/myFile.ext");
file.create(new NullInputStream(0), true, null);
});
URI uri = URI.createPlatformResourceURI("/myProject/folder/deep/myFile.ext", true);
IResource iResource = UriUtils.toIResource(uri);
assertTrue(iResource instanceof IFile);
assertTrue(iResource.exists());
assertEquals("/myProject/folder/deep/myFile.ext", iResource.getFullPath().toString());
}
示例4: deleteCache
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
/**
* @param projectName
* @param container
* @param monitor
*/
private static void deleteCache(String cachename, IContainer container, IProgressMonitor monitor) {
try {
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer) {
deleteCache(cachename, (IContainer) member, monitor);
} else if (member instanceof IFile) {
IFile file = (IFile) member;
if (cachename.equals(file.getName())) {
file.delete(true, monitor);
}
}
}
} catch (CoreException e) {
ResourceManager.logException(e);
}
}
示例5: browseXMLSelectionDialog
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
/**
* @param filterExtension
* @param fileName
* Open the dialog to browse .xml file for expression, operation or outputfields
*/
private void browseXMLSelectionDialog(String filterExtension, Text fileName) {
String externalSchemaTextBoxValue = "";
ExternalSchemaFileSelectionDialog dialog = new ExternalSchemaFileSelectionDialog("Project",
"Select Input File (.xml)", new String[]{filterExtension,Extensions.XML.toString()}, this);
if (dialog.open() == IDialogConstants.OK_ID) {
String file = fileNameTextBoxValue;
IResource resource = (IResource) dialog.getFirstResult();
String path[] = resource.getFullPath().toString().split("/");
if (file.isEmpty()) {
for (int i = 1; i < path.length; i++) {
externalSchemaTextBoxValue = externalSchemaTextBoxValue + path[i] + "/";
}
} else {
for (int i = 1; i < path.length; i++) {
if (!path[i].endsWith(".xml")) {
externalSchemaTextBoxValue = externalSchemaTextBoxValue + path[i] + "/";
}
}
externalSchemaTextBoxValue = externalSchemaTextBoxValue + file;
}
fileName.setText(externalSchemaTextBoxValue);
}
}
示例6: dialogChanged
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
/**
* This method ensures user select Target project and permissions
*/
private void dialogChanged() {
IResource container = ResourcesPlugin.getWorkspace().getRoot()
.findMember(new Path(getContainerName().get("TargetPath")));
if (getContainerName().get("TargetPath").length() == 0) {
updateStatus("File container must be specified");
return;
}
if (container == null
|| (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
updateStatus("File container must exist");
return;
}
if (!container.isAccessible()) {
updateStatus("Project must be writable");
return;
}
updateStatus(null);
}
示例7: getElements
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof IContainer) {
try {
List<IResource> projects = Arrays.asList(((IContainer) inputElement).members()).stream()
.filter(member -> member instanceof IProject)
.filter(project -> isN4JSProject((IProject) project))
.sorted(new ResourceComparator())
.collect(Collectors.toList());
return projects.toArray(new IResource[projects.size()]);
} catch (CoreException e) {
e.printStackTrace();
return null;
}
}
return null;
}
示例8: resourceExistsIn
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
/**
* Process recursively the containers until we found a resource with the
* specified path
*
* @param container
* @param path
* @return
* @throws CoreException
*/
private static boolean resourceExistsIn(IContainer container, IPath path) throws CoreException {
boolean found = false;
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer) {
found = resourceExistsIn((IContainer) member, path);
if (found)
break;
} else if (member instanceof IFile) {
IFile file = (IFile) member;
if (path.equals(file.getFullPath()))
return true;
}
}
return found;
}
示例9: compile
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
@Override
public void compile(List<URI> uris, IProgressMonitor progress) {
Set<IResource> filesToCompile = getFilesToCompile(uris);
if (filesToCompile.isEmpty() || progress.isCanceled()) {
return;
}
progress.beginTask("compiling ...", filesToCompile.size());
try {
Process process = new ProcessBuilder(getCompilerPath(), "--standard-json").start();
sendInput(process.getOutputStream(), filesToCompile);
handler.handleOutput(process.getInputStream(), filesToCompile);
if (process.waitFor(30, TimeUnit.SECONDS) && process.exitValue() != 0) {
throw new Exception("Solidity compiler invocation failed with exit code " + process.exitValue() + ".");
}
progress.done();
} catch (Exception e) {
e.printStackTrace();
progress.done();
}
}
示例10: visit
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
@Override
public boolean visit(IResourceDelta delta) throws CoreException
{
IResource resource = delta.getResource();
if( resource.isDerived() )
{
return false;
}
if( resource.getType() == IResource.FILE )
{
IFile file = (IFile) resource;
IProject project = resource.getProject();
if( file.equals(JPFProject.getManifest(project)) )
{
manifestChanged = true;
return false;
}
}
return true;
}
示例11: showInstruction
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
/**
* Show the given {@link EObject instruction}.
*
* @param editorPart
* the opened {@link DialectEditor}
* @param instruction
* the {@link EObject instruction} to show
*/
public static void showInstruction(DialectEditor editorPart, EObject instruction) {
final URI resourceURI = instruction.eResource().getURI();
if (resourceURI.isPlatformResource()) {
final String resourcePath = resourceURI.toPlatformString(true);
final IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
resourcePath));
try {
final IMarker marker = resource.createMarker(EValidator.MARKER);
marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(instruction).toString());
final TraceabilityMarkerNavigationProvider navigationProvider = new TraceabilityMarkerNavigationProvider(
(DialectEditor)editorPart);
navigationProvider.gotoMarker(marker);
marker.delete();
} catch (CoreException e) {
DebugSiriusIdeUiPlugin.INSTANCE.log(e);
}
}
}
示例12: setJobFileAndXmlFile
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
private void setJobFileAndXmlFile(IFolder jobsFolder) {
try {
IResource[] members = jobsFolder.members();
if (members != null) {
for (IResource jobFolderMember : members) {
if ((IFolder.class).isAssignableFrom(jobFolderMember.getClass())) {
setJobFileAndXmlFile((IFolder) jobFolderMember);
} else if ((IFile.class).isAssignableFrom(jobFolderMember.getClass())) {
String file = jobFolderMember.getFullPath().lastSegment();
if (StringUtils.equalsIgnoreCase(modifiedResource.getName().replace(Constants.PROPERTIES_EXTENSION,
Constants.JOB_EXTENSION), file)) {
jobIFile = jobsFolder.getFile(modifiedResource.getName()
.replace(Constants.PROPERTIES_EXTENSION, Constants.JOB_EXTENSION));
} else if (StringUtils.equalsIgnoreCase(modifiedResource.getName().replace(Constants.PROPERTIES_EXTENSION,
Constants.XML_EXTENSION), file)) {
xmlIFile = jobsFolder.getFile(modifiedResource.getName()
.replace(Constants.PROPERTIES_EXTENSION, Constants.XML_EXTENSION));
}
}
}
}
} catch (CoreException coreException) {
LOGGER.error("Error while setting job file and xml file for dependent deletion", coreException);
}
}
示例13: removeMarkerForAbstractContextUsed
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
/**
* @param project
* @param file
*/
public static void removeMarkerForAbstractContextUsed (IFile file) {
try {
IMarker[] markers = file.findMarkers(GW4EBuilder.MARKER_TYPE, true, IResource.DEPTH_INFINITE);
for (int i = 0; i < markers.length; i++) {
IMarker m = markers[i];
Integer pbId = (Integer)m.getAttribute(IJavaModelMarker.ID);
if (pbId!=null) {
if (GW4EParser.ABSTRACT_CONTEXT_USED==pbId.intValue()) {
m.delete();
}
}
}
} catch (CoreException ce) {
}
}
示例14: cleanOutput
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
private void cleanOutput(IProject aProject, OutputConfiguration config, IProgressMonitor monitor)
throws CoreException {
IContainer container = getContainer(aProject, config.getOutputDirectory());
if (!container.exists()) {
return;
}
if (config.isCanClearOutputDirectory()) {
for (IResource resource : container.members()) {
resource.delete(IResource.KEEP_HISTORY, monitor);
}
} else if (config.isCleanUpDerivedResources()) {
List<IFile> resources = derivedResourceMarkers.findDerivedResources(container, null);
for (IFile iFile : resources) {
iFile.delete(IResource.KEEP_HISTORY, monitor);
}
}
}
示例15: execute
import org.eclipse.core.resources.IResource; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = MarkerFactory.getSelection();
if (selection instanceof ITreeSelection) {
ITreeSelection treeSelection = (ITreeSelection) selection;
if (treeSelection.getFirstElement() instanceof IOpenable
|| treeSelection.getFirstElement() instanceof IFile) {
IResource resource =
((IAdaptable) treeSelection.getFirstElement()).getAdapter(IResource.class);
List<IMarker> markers = MarkerFactory.findMarkers(resource);
MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Marker Count", null,
markers.size() + " marker(s)", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
dialog.open();
}
}
return null;
}