Example usage for org.eclipse.jdt.core IJavaModelStatusConstants INVALID_RESOURCE

List of usage examples for org.eclipse.jdt.core IJavaModelStatusConstants INVALID_RESOURCE

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaModelStatusConstants INVALID_RESOURCE.

Prototype

int INVALID_RESOURCE

To view the source code for org.eclipse.jdt.core IJavaModelStatusConstants INVALID_RESOURCE.

Click Source Link

Document

Status indicating that a Java element could not be created because the underlying resource is invalid.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.CompilationUnit.java

License:Open Source License

protected void updateTimeStamp(CompilationUnit original) throws JavaModelException {
    long timeStamp = ((IFile) original.getResource()).getModificationStamp();
    if (timeStamp == IResource.NULL_STAMP) {
        throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE));
    }/*from   w  w w.  j  a  v  a 2  s  .  c  om*/
    ((CompilationUnitElementInfo) getElementInfo()).timestamp = timeStamp;
}

From source file:org.eclipse.jdt.internal.core.CopyResourceElementsOperation.java

License:Open Source License

/**
 * @see MultiOperation// w  w  w .j  ava  2  s .  c om
 */
protected void verify(IJavaElement element) throws JavaModelException {
    if (element == null || !element.exists())
        error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);

    if (element.isReadOnly() && (isRename() || isMove()))
        error(IJavaModelStatusConstants.READ_ONLY, element);

    IResource resource = ((JavaElement) element).resource();
    if (resource instanceof IFolder) {
        if (resource.isLinked()) {
            error(IJavaModelStatusConstants.INVALID_RESOURCE, element);
        }
    }

    int elementType = element.getElementType();

    if (elementType == IJavaElement.COMPILATION_UNIT) {
        org.eclipse.jdt.internal.core.CompilationUnit compilationUnit = (org.eclipse.jdt.internal.core.CompilationUnit) element;
        if (isMove() && compilationUnit.isWorkingCopy() && !compilationUnit.isPrimary())
            error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
    } else if (elementType != IJavaElement.PACKAGE_FRAGMENT) {
        error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
    }

    JavaElement dest = (JavaElement) getDestinationParent(element);
    verifyDestination(element, dest);
    if (this.renamings != null) {
        verifyRenaming(element);
    }
}