use of org.eclipse.core.runtime.IStatus in project generator by mybatis.
the class RunGeneratorAction method handleException.
private void handleException(Exception exception, Shell shell) {
IStatus status;
Throwable exceptionToHandle;
if (exception instanceof InvocationTargetException) {
exceptionToHandle = ((InvocationTargetException) exception).getCause();
} else {
exceptionToHandle = exception;
}
if (exceptionToHandle instanceof InterruptedException) {
status = new Status(IStatus.CANCEL, Activator.PLUGIN_ID, IStatus.CANCEL, "Cancelled by User", exceptionToHandle);
} else if (exceptionToHandle instanceof CoreException) {
status = ((CoreException) exceptionToHandle).getStatus();
} else {
String message = "Unexpected error while running MyBatis Generator.";
status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, message, exceptionToHandle);
Activator.getDefault().getLog().log(status);
}
ErrorDialog.openError(shell, "MyBatis Generator", "Generation Failed", status, IStatus.ERROR | IStatus.CANCEL);
}
use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class Resources method makeCommittable.
/**
* Makes the given resources committable. Committable means that all
* resources are writeable and that the content of the resources hasn't
* changed by calling <code>validateEdit</code> for a given file on
* <tt>IWorkspace</tt>.
*
* @param resources the resources to be checked
* @param context the context passed to <code>validateEdit</code>
* @return IStatus status describing the method's result. If <code>status.
* isOK()</code> returns <code>true</code> then the add resources are
* committable
*
* @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], Object)
*/
public static IStatus makeCommittable(IResource[] resources, Object context) {
List<IResource> readOnlyFiles = new ArrayList<IResource>();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (resource.getType() == IResource.FILE && isReadOnly(resource))
readOnlyFiles.add(resource);
}
if (readOnlyFiles.size() == 0)
return Status.OK_STATUS;
Map<IFile, Long> oldTimeStamps = createModificationStampMap(readOnlyFiles);
IStatus status = ResourcesPlugin.getWorkspace().validateEdit(readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
if (!status.isOK())
return status;
IStatus modified = null;
Map<IFile, Long> newTimeStamps = createModificationStampMap(readOnlyFiles);
for (Iterator<IFile> iter = oldTimeStamps.keySet().iterator(); iter.hasNext(); ) {
IFile file = iter.next();
if (!oldTimeStamps.get(file).equals(newTimeStamps.get(file)))
modified = addModified(modified, file);
}
if (modified != null)
return modified;
return Status.OK_STATUS;
}
use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class Resources method makeCommittable.
/**
* Makes the given resources committable. Committable means that all
* resources are writeable and that the content of the resources hasn't
* changed by calling <code>validateEdit</code> for a given file on
* <tt>IWorkspace</tt>.
*
* @param resources the resources to be checked
* @param context the context passed to <code>validateEdit</code>
* @return IStatus status describing the method's result. If <code>status.
* isOK()</code> returns <code>true</code> then the add resources are
* committable
*
* @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
*/
public static IStatus makeCommittable(IResource[] resources, Object context) {
List readOnlyFiles = new ArrayList();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (resource.getType() == IResource.FILE && isReadOnly(resource))
readOnlyFiles.add(resource);
}
if (readOnlyFiles.size() == 0)
return Status.OK_STATUS;
Map oldTimeStamps = createModificationStampMap(readOnlyFiles);
IStatus status = ResourcesPlugin.getWorkspace().validateEdit((IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
if (!status.isOK())
return status;
IStatus modified = null;
Map newTimeStamps = createModificationStampMap(readOnlyFiles);
for (Iterator iter = oldTimeStamps.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Entry) iter.next();
if (!entry.getValue().equals(newTimeStamps.get(entry.getKey())))
modified = addModified(modified, (IFile) entry.getKey());
}
if (modified != null)
return modified;
return Status.OK_STATUS;
}
use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class ResourceChangeChecker method createFrom.
private static RefactoringStatus createFrom(IStatus status) {
if (status.isOK())
return new RefactoringStatus();
if (!status.isMultiStatus()) {
switch(status.getSeverity()) {
case IStatus.OK:
return new RefactoringStatus();
case IStatus.INFO:
return RefactoringStatus.createInfoStatus(status.getMessage());
case IStatus.WARNING:
return RefactoringStatus.createWarningStatus(status.getMessage());
case IStatus.ERROR:
return RefactoringStatus.createErrorStatus(status.getMessage());
case IStatus.CANCEL:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
default:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
}
} else {
IStatus[] children = status.getChildren();
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < children.length; i++) {
result.merge(createFrom(children[i]));
}
return result;
}
}
use of org.eclipse.core.runtime.IStatus in project che by eclipse.
the class ValidateEditChecker method check.
/**
* {@inheritDoc}
*/
public RefactoringStatus check(IProgressMonitor monitor) throws CoreException {
IResource[] resources = (IResource[]) fFiles.toArray(new IResource[fFiles.size()]);
RefactoringStatus result = new RefactoringStatus();
IStatus status = Resources.checkInSync(resources);
if (!status.isOK())
result.merge(RefactoringStatus.create(status));
status = Resources.makeCommittable(resources, fContext);
if (!status.isOK()) {
result.merge(RefactoringStatus.create(status));
if (!result.hasFatalError()) {
result.addFatalError(RefactoringCoreMessages.ValidateEditChecker_failed);
}
}
return result;
}
Aggregations