Example #1
0
 protected static void checkIfModifiable(RefactoringStatus result, IResource resource, int flags) {
   checkExistence(result, resource);
   if (result.hasFatalError()) return;
   if (flags == NONE) return;
   ValidationState state = new ValidationState(resource);
   if ((flags & READ_ONLY) != 0) {
     state.checkReadOnly(result);
     if (result.hasFatalError()) return;
   }
   if ((flags & DIRTY) != 0) {
     state.checkDirty(result);
   }
 }
Example #2
0
 // protected final RefactoringStatus isValid(IProgressMonitor pm, boolean checkReadOnly, boolean
 // checkDirty) throws CoreException {
 protected final RefactoringStatus isValid(IProgressMonitor pm, int flags) throws CoreException {
   pm.beginTask("", 2); // $NON-NLS-1$
   try {
     RefactoringStatus result = new RefactoringStatus();
     Object modifiedElement = getModifiedElement();
     checkExistence(result, modifiedElement);
     if (result.hasFatalError()) return result;
     if (flags == NONE) return result;
     IResource resource = getResource(modifiedElement);
     if (resource != null) {
       ValidationState state = new ValidationState(resource);
       state.checkModificationStamp(result, fModificationStamp);
       if (result.hasFatalError()) return result;
       state.checkSameReadOnly(result, fReadOnly);
       if (result.hasFatalError()) return result;
       if ((flags & READ_ONLY) != 0) {
         state.checkReadOnly(result);
         if (result.hasFatalError()) return result;
       }
       if ((flags & DIRTY) != 0) {
         if ((flags & SAVE) != 0) {
           state.checkDirty(result, fModificationStamp, new SubProgressMonitor(pm, 1));
         } else {
           state.checkDirty(result);
         }
       }
     }
     return result;
   } finally {
     pm.done();
   }
 }