public ModificationStampValidationState(IFile file) { super(file); fModificationStamp= getModificationStamp(); }
public RefactoringStatus isValid(boolean needsSaving, boolean resilientForDerived) throws CoreException { RefactoringStatus result= super.isValid(needsSaving, resilientForDerived); if (result.hasFatalError()) return result; ModificationStamp currentStamp= getModificationStamp(); // we don't need to check the kind here since the document stamp // and file stamp are in sync for documents implementing // IDocumentExtension4. If both are file stamps the file must // not be dirty if (fModificationStamp.getValue() != currentStamp.getValue() // we know here that the stamp value are equal. However, if // the stamp is a null stamp then the king must be equal as well. || (fModificationStamp.isFileStamp() && fModificationStamp.getValue() == IResource.NULL_STAMP && !currentStamp.isFileStamp()) || (fModificationStamp.isDocumentStamp() && fModificationStamp.getValue() == IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && !currentStamp.isDocumentStamp()) || (fModificationStamp.isFileStamp() && currentStamp.isFileStamp() && isDirty(fFile))) { result.addFatalError(Messages.format( RefactoringCoreMessages.TextChanges_error_content_changed, fFile.getFullPath().toString() )); } return result; } }
public static BufferValidationState create(IFile file) { ITextFileBuffer buffer= getBuffer(file); if (buffer == null) { return new ModificationStampValidationState(file); } else { IDocument document= buffer.getDocument(); if (document instanceof IDocumentExtension4) { return new ModificationStampValidationState(file); } else { if (buffer.isDirty()) { return new NoStampValidationState(file); } else { return new ModificationStampValidationState(file); } } } }
@Override public RefactoringStatus isValid(boolean needsSaving, boolean resilientForDerived) throws CoreException { RefactoringStatus result= super.isValid(needsSaving, resilientForDerived); if (result.hasFatalError()) return result; ModificationStamp currentStamp= getModificationStamp(); // we don't need to check the kind here since the document stamp // and file stamp are in sync for documents implementing // IDocumentExtension4. If both are file stamps the file must // not be dirty if (fModificationStamp.getValue() != currentStamp.getValue() // we know here that the stamp value are equal. However, if // the stamp is a null stamp then the king must be equal as well. || (fModificationStamp.isFileStamp() && fModificationStamp.getValue() == IResource.NULL_STAMP && !currentStamp.isFileStamp()) || (fModificationStamp.isDocumentStamp() && fModificationStamp.getValue() == IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && !currentStamp.isDocumentStamp()) || (fModificationStamp.isFileStamp() && currentStamp.isFileStamp() && isDirty(fFile))) { result.addFatalError(Messages.format( RefactoringCoreMessages.TextChanges_error_content_changed, BasicElementLabels.getPathLabel(fFile.getFullPath(), false) )); } return result; } }
public static BufferValidationState create(IFile file) { ITextFileBuffer buffer= getBuffer(file); if (buffer == null) { return new ModificationStampValidationState(file); } else { IDocument document= buffer.getDocument(); if (document instanceof IDocumentExtension4) { return new ModificationStampValidationState(file); } else { if (buffer.isDirty()) { return new NoStampValidationState(file); } else { return new ModificationStampValidationState(file); } } } }
@Override public RefactoringStatus isValid(boolean needsSaving, boolean resilientForDerived) throws CoreException { RefactoringStatus result= super.isValid(needsSaving, resilientForDerived); if (result.hasFatalError()) return result; ModificationStamp currentStamp= getModificationStamp(); // we don't need to check the kind here since the document stamp // and file stamp are in sync for documents implementing // IDocumentExtension4. If both are file stamps the file must // not be dirty if (fModificationStamp.getValue() != currentStamp.getValue() // we know here that the stamp value are equal. However, if // the stamp is a null stamp then the king must be equal as well. || (fModificationStamp.isFileStamp() && fModificationStamp.getValue() == IResource.NULL_STAMP && !currentStamp.isFileStamp()) || (fModificationStamp.isDocumentStamp() && fModificationStamp.getValue() == IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && !currentStamp.isDocumentStamp()) || (fModificationStamp.isFileStamp() && currentStamp.isFileStamp() && isDirty(fFile))) { result.addFatalError(Messages.format( RefactoringCoreMessages.TextChanges_error_content_changed, BasicElementLabels.getPathLabel(fFile.getFullPath(), false) )); } return result; } }
public ModificationStampValidationState(IFile file) { super(file); fModificationStamp= getModificationStamp(); }
public static BufferValidationState create(IFile file) { ITextFileBuffer buffer= getBuffer(file); if (buffer == null) { return new ModificationStampValidationState(file); } else { IDocument document= buffer.getDocument(); if (document instanceof IDocumentExtension4) { return new ModificationStampValidationState(file); } else { if (buffer.isDirty()) { return new NoStampValidationState(file); } else { return new ModificationStampValidationState(file); } } } }
public ModificationStampValidationState(IFile file) { super(file); fModificationStamp= getModificationStamp(); }