/** * Method createStateValidator. * * @return ResourceStateValidator */ private ResourceStateValidator createStateValidator() { return new ResourceStateValidatorImpl(this); }
/** * This method should be called whenever <code>aListener</code> is activated (becomes active). * This will check the timestamps of the underlying files to see if they are different from the * last cached modified value. <code>aListener</code> should be prepared to prompt the user if * they would like to refresh with the contents on disk if we are dirty. */ public void checkActivation(ResourceStateValidatorPresenter presenter) throws CoreException { checkConsistency(presenter); }
/** * @see ResourceStateValidator#checkReadOnly() */ public boolean checkReadOnly() { boolean result = checkReadOnlyResources(); if (!result) result = checkReadOnlyNonResourceFiles(); return result; }
protected void checkConsistency(ResourceStateValidatorPresenter presenter) throws CoreException { if (isCheckingConsistency || presenter == null) return; isCheckingConsistency = true; try { List inconsistentResources = getInconsistentResources(); List inconsistentFiles = getFiles(inconsistentResources); inconsistentFiles = addOtherInconsistentFiles(inconsistentFiles); if (inconsistentFiles == null || inconsistentFiles.isEmpty()) return; boolean shouldRefreshFiles = true; //Defect 208654 & 209631 want prompt no matter what. if (anyFileChangedSinceLastRefreshPrompt(inconsistentFiles)) { clearLastNonRefreshStateMap(); shouldRefreshFiles = presenter.promptForInconsistentFileRefresh(inconsistentFiles); } else return; if (shouldRefreshFiles) refreshFiles(inconsistentFiles, inconsistentResources); else cacheLastNonRefreshFileStamps(inconsistentFiles); } finally { isCheckingConsistency = false; } }
/** * This method should be called at least the first time a ResourceStateValidatorPresenter * becomes active and is about to edit its contents. The returned IStatus may have an ERROR * status which should be presented to the user. */ public IStatus validateState(ResourceStateValidatorPresenter presenter) throws CoreException { List roResources, nonResROFiles, roFiles = null; List[] readOnly = selectReadOnlyResources(provider.getResources()); roResources = readOnly[0]; roFiles = readOnly[1]; nonResROFiles = selectReadOnlyFiles(provider.getNonResourceFiles()); if (nonResROFiles != null) { if (roFiles == null) roFiles = nonResROFiles; else roFiles.addAll(nonResROFiles); } if (roFiles == null || roFiles.isEmpty()) return OK_STATUS; IFile[] files = new IFile[roFiles.size()]; roFiles.toArray(files); Object ctx = presenter != null ? presenter.getValidateEditContext() : null; IStatus result = ResourcesPlugin.getWorkspace().validateEdit(files, ctx); cacheValidateState(result, roResources, nonResROFiles); if (!result.isOK()) checkConsistency(presenter); return result; }
public boolean checkSave(ResourceStateValidatorPresenter presenter) throws CoreException { if (presenter == null) return false; if (!provider.isDirty()) return false; List inconsistentResources = getInconsistentResources(); List inconsistentFiles = getFiles(inconsistentResources); inconsistentFiles = addOtherInconsistentFiles(inconsistentFiles); if (inconsistentFiles == null || inconsistentFiles.isEmpty()) return true; return presenter.promptForInconsistentFileOverwrite(inconsistentFiles); }
/** * Method createStateValidator. * * @return ResourceStateValidator */ private ResourceStateValidator createStateValidator() { return new ResourceStateValidatorImpl(this); }
public void lostActivation(ResourceStateValidatorPresenter presenter) throws CoreException { checkConsistency(presenter); }
/** * Method createStateValidator. * * @return ResourceStateValidator */ private ResourceStateValidator createStateValidator() { return new ResourceStateValidatorImpl(this); }