Java Code Examples for org.eclipse.core.resources.IResource#ROOT
The following examples show how to use
org.eclipse.core.resources.IResource#ROOT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaModel.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public boolean contains(IResource resource) { switch (resource.getType()) { case IResource.ROOT: case IResource.PROJECT: return true; } // file or folder IJavaProject[] projects; try { projects = getJavaProjects(); } catch (JavaModelException e) { return false; } for (int i = 0, length = projects.length; i < length; i++) { JavaProject project = (JavaProject)projects[i]; if (!project.contains(resource)) { return false; } } return true; }
Example 2
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected RefactoringStatus verifyDestination(IResource resource) throws JavaModelException { Assert.isNotNull(resource); if (!resource.exists() || resource.isPhantom()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_phantom); if (!resource.isAccessible()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_inaccessible); if (resource.getType() == IResource.ROOT) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource); if (isChildOfOrEqualToAnyFolder(resource)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource); if (containsLinkedResources() && !ReorgUtils.canBeDestinationForLinkedResources(resource)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_linked); return new RefactoringStatus(); }
Example 3
Source File: SVNHistoryPageSource.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public boolean canShowHistoryFor(Object object) { if (object instanceof IResource) { IResource resource = (IResource)object; ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource); if (localResource != null) { try { if (!localResource.isManaged()) { return false; } if (localResource.isAdded() && !localResource.getStatus().isCopied()) { return false; } } catch (Exception e) { SVNUIPlugin.log(Status.ERROR, e.getMessage(), e); } } } return (object instanceof IResource && ((IResource) object).getType() != IResource.ROOT) || (object instanceof ISVNRemoteResource); }
Example 4
Source File: NewEntryPointWizardPage.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public void init(IStructuredSelection selection) { IJavaElement initialJavaElement = getInitialJavaElement(selection); initContainerPage(initialJavaElement); initTypePage(initialJavaElement); // Set the initial resource, based either on the selection or on the // initial Java element returned by NewContainerWizardPage IResource initialResource = AbstractNewFileWizard.getSelectedResource(selection); if (initialResource.getType() == IResource.ROOT && initialJavaElement != null) { initialResource = initialJavaElement.getResource(); } initEntryPointPage(initialResource); doStatusUpdate(); setMethodStubSelection(false, true); }
Example 5
Source File: BuilderParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.9 */ protected boolean canClean(IContainer container, OutputConfiguration config) { if (container.getType() == IResource.PROJECT) return false; if (container.getType() == IResource.ROOT) return false; return config.isCanClearOutputDirectory(); }
Example 6
Source File: ProblemMarkerManager.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private void checkInvalidate(IResourceDelta delta, IResource resource) { int kind = delta.getKind(); if (kind == IResourceDelta.REMOVED || kind == IResourceDelta.ADDED || (kind == IResourceDelta.CHANGED && isErrorDelta(delta))) { // invalidate the resource and all parents while (resource.getType() != IResource.ROOT && fChangedElements.add(resource)) { resource = resource.getParent(); } } }
Example 7
Source File: FieldInitializerUtil.java From sarl with Apache License 2.0 | 5 votes |
private static IJavaElement getPackage(IAdaptable adaptable) { IJavaElement elem = null; IResource resource = adaptable.getAdapter(IResource.class); if (resource != null && resource.getType() != IResource.ROOT) { while (elem == null && resource.getType() != IResource.PROJECT) { resource = resource.getParent(); elem = resource.getAdapter(IJavaElement.class); } } if (elem == null) { elem = JavaCore.create(resource); } return elem; }
Example 8
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean isDeleteAvailable(final IResource resource) { if (!resource.exists() || resource.isPhantom()) return false; if (resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT) return false; return true; }
Example 9
Source File: ProblemMarkerManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void checkInvalidate(IResourceDelta delta, IResource resource) { int kind= delta.getKind(); if (kind == IResourceDelta.REMOVED || kind == IResourceDelta.ADDED || (kind == IResourceDelta.CHANGED && isErrorDelta(delta))) { // invalidate the resource and all parents while (resource.getType() != IResource.ROOT && fChangedElements.add(resource)) { resource= resource.getParent(); } } }
Example 10
Source File: StatusBarUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String formatResourceMessage(IResource element) { IContainer parent= element.getParent(); if (parent != null && parent.getType() != IResource.ROOT) return BasicElementLabels.getResourceName(element.getName()) + JavaElementLabels.CONCAT_STRING + BasicElementLabels.getPathLabel(parent.getFullPath(), false); else return BasicElementLabels.getResourceName(element.getName()); }
Example 11
Source File: NewEntryPointWizardPage.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private void initEntryPointPage(IResource resource) { if (resource.getType() == IResource.ROOT || !resource.isAccessible()) { return; } if (moduleField.init(resource)) { // Initialize the package based on the module's client source path if (moduleStatus.isOK()) { initPackageFromModule(); } else { // If initializing the module caused an error, reset it moduleField.setText(""); } } }
Example 12
Source File: WorkbenchResourceUtil.java From typescript.java with MIT License | 5 votes |
public static IFile findFileInContainerOrParent(IContainer container, IPath name) throws CoreException { if (container == null || container.getType() == IResource.ROOT) { // container is null, or it's workspace root. return null; } IFile file = container.getFile(name); if (file != null && file.exists()) { return file; } return findFileInContainerOrParent(container.getParent(), name); }
Example 13
Source File: FieldInitializerUtil.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private IJavaElement getPackage(Object o) { IJavaElement elem = null; IResource resource = Adapters.adapt(o, IResource.class); if (resource != null && resource.getType() != IResource.ROOT) { while(elem == null && resource.getType() != IResource.PROJECT){ resource = resource.getParent(); elem = Adapters.adapt(resource, IJavaElement.class); } } if (elem == null) { elem = JavaCore.create(resource); } return elem; }
Example 14
Source File: ProblemMarkerManager.java From goclipse with Eclipse Public License 1.0 | 5 votes |
private void checkInvalidate(IResourceDelta delta, IResource resource) { int kind= delta.getKind(); if (kind == IResourceDelta.REMOVED || kind == IResourceDelta.ADDED || (kind == IResourceDelta.CHANGED && isErrorDelta(delta))) { // invalidate the resource and all parents while (resource.getType() != IResource.ROOT && fChangedElements.add(resource)) { resource= resource.getParent(); } } }
Example 15
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override protected RefactoringStatus verifyDestination(IResource resource) { Assert.isNotNull(resource); if (!resource.exists() || resource.isPhantom()) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_phantom); } if (!resource.isAccessible()) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_inaccessible); } if (!(resource instanceof IContainer)) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource); } if (resource.getType() == IResource.ROOT) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource); } if (isChildOfOrEqualToAnyFolder(resource)) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource); } if (containsLinkedResources() && !ReorgUtils.canBeDestinationForLinkedResources(resource)) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_linked); } return new RefactoringStatus(); }
Example 16
Source File: RefactoringAvailabilityTester.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static boolean isDeleteAvailable(final IResource resource) { if (!resource.exists() || resource.isPhantom()) { return false; } if (resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT) { return false; } return true; }
Example 17
Source File: ResourceDeltaVisitor.java From saros with GNU General Public License v2.0 | 4 votes |
@Override public boolean visit(final IResourceDelta delta) throws CoreException { final IResource resource = delta.getResource(); if (resource.getType() == IResource.ROOT) return true; if (!session.isShared(ResourceAdapterFactory.create(resource))) return true; if (resource.getType() != IResource.PROJECT) { isModifyingResources = true; return false; } if (delta.getKind() == IResourceDelta.REMOVED) { if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) isMovingProject = true; else isDeletingProject = true; return false; } return true; }
Example 18
Source File: LocalResource.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") public boolean isIgnored() throws SVNException { // If the resource is a team private or linked resource, it is ignored if (resource.isTeamPrivateMember() || resource.isLinked() ) { return true; } // always ignore .svn folder if ((resource.getType() == IResource.FOLDER) && SVNProviderPlugin.getPlugin().isAdminDirectory(getName())) { //$NON-NLS-1$ return true; } if(resource.getType()==IResource.ROOT || resource.getType()==IResource.PROJECT ) { return false; } if (isParentInSvnIgnore()) { return true; } LocalResourceStatus status = getStatusFromCache(); // If resource is derived, it is ignored if it is unmanaged, or if preference is to ignore managed derived resources. if (resource.isDerived()) { if (SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_IGNORE_MANAGED_DERIVED_RESOURCES) || !status.isManaged()) { return true; } } // a managed resource is never ignored if (status.isManaged()) { return false; } // check ignore patterns from the .cvsignore file. if (status.isIgnored()) { return true; } // check the global ignores from Team if (Team.isIgnoredHint(resource)) { return true; } // check the parent, if the parent is ignored // then this resource is ignored also ISVNLocalFolder parent = getParent(); if (parent==null) { return false; } if (parent.isIgnored()) { return true; } return false; }
Example 19
Source File: ResourceUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private static boolean canSync(IResource resource) { return resource.getType() != IResource.PROJECT && resource.getType() != IResource.ROOT; }
Example 20
Source File: CopyToClipboardAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static boolean canCopyToClipboard(IResource resource) { return resource != null && resource.exists() && ! resource.isPhantom() && resource.getType() != IResource.ROOT; }