use of org.eclipse.core.runtime.MultiStatus in project generator by mybatis.
the class RunGeneratorAction method run.
public void run(IAction action) {
Shell shell = new Shell();
if (!MessageDialog.openConfirm(shell, "Deprecated Funtionality", DEPRECATION_MESSAGE)) {
return;
}
try {
List<String> warnings = new ArrayList<String>();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
IRunnableWithProgress thread = new GeneratorRunner(warnings);
dialog.run(true, true, thread);
if (warnings.size() > 0) {
MultiStatus ms = new MultiStatus(Activator.PLUGIN_ID, Status.WARNING, "Generation Warnings Occured", null);
Iterator<String> iter = warnings.iterator();
while (iter.hasNext()) {
Status status = new Status(Status.WARNING, Activator.PLUGIN_ID, Status.WARNING, iter.next(), null);
ms.add(status);
}
ErrorDialog.openError(shell, "MyBatis Generator", "Run Complete With Warnings", ms, Status.WARNING);
}
} catch (Exception e) {
handleException(e, shell);
}
}
use of org.eclipse.core.runtime.MultiStatus in project generator by mybatis.
the class RunGeneratorThread method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws CoreException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 1000);
subMonitor.beginTask("Generating MyBatis/iBATIS Artifacts:", 1000);
setClassLoader();
try {
subMonitor.subTask("Parsing Configuration");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(inputFile.getLocation().toFile());
subMonitor.worked(50);
MyBatisGenerator mybatisGenerator = new MyBatisGenerator(config, new EclipseShellCallback(), warnings);
monitor.subTask("Generating Files from Database Tables");
SubMonitor spm = subMonitor.newChild(950);
mybatisGenerator.generate(new EclipseProgressCallback(spm));
} catch (InterruptedException e) {
throw new OperationCanceledException();
} catch (SQLException e) {
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
Activator.getDefault().getLog().log(status);
throw new CoreException(status);
} catch (IOException e) {
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
Activator.getDefault().getLog().log(status);
throw new CoreException(status);
} catch (XMLParserException e) {
List<String> errors = e.getErrors();
MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR, "XML Parser Errors\n See Details for more Information", null);
Iterator<String> iter = errors.iterator();
while (iter.hasNext()) {
Status message = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, iter.next(), null);
multiStatus.add(message);
}
throw new CoreException(multiStatus);
} catch (InvalidConfigurationException e) {
List<String> errors = e.getErrors();
MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR, "Invalid Configuration\n See Details for more Information", null);
Iterator<String> iter = errors.iterator();
while (iter.hasNext()) {
Status message = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, iter.next(), null);
multiStatus.add(message);
}
throw new CoreException(multiStatus);
} finally {
monitor.done();
restoreClassLoader();
}
}
use of org.eclipse.core.runtime.MultiStatus in project sling by apache.
the class ServerBehaviourDelegateWithModulePublishSupport method publish.
// from WST's ServerBehavior
public IStatus publish(int kind, IProgressMonitor monitor) {
Activator.getDefault().getPluginLogger().trace("-->-- Publishing to server: " + getServer().toString() + " -->--");
if (getServer().getServerType().hasRuntime() && getServer().getRuntime() == null)
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "No runtime available", null);
//getAllModules();
final List<IModule[]> moduleList = modules3 == null ? getAllModules() : new LinkedList<>(modules3);
List<Integer> deltaKindList = computeDelta(moduleList);
PublishOperation[] tasks = getTasks(kind, moduleList, deltaKindList);
int size = 2000 + 3500 * moduleList.size() + 500 * tasks.length;
// monitor = ProgressUtil.getMonitorFor(monitor); //TODO
//NLS.bind(Messages.publishing, getServer().getName());
String mainTaskMsg = "Publishing to " + getServer().getName();
monitor.beginTask(mainTaskMsg, size);
MultiStatus tempMulti = new MultiStatus(Activator.PLUGIN_ID, 0, "", null);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
try {
Activator.getDefault().getPluginLogger().trace("Starting publish");
//ProgressUtil.getSubMonitorFor(monitor, 1000)); //TODO
publishStart(monitor);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
// execute tasks
MultiStatus taskStatus = performTasks(tasks, monitor);
monitor.setTaskName(mainTaskMsg);
if (taskStatus != null && !taskStatus.isOK())
tempMulti.addAll(taskStatus);
// execute publishers
taskStatus = executePublishers(kind, moduleList, deltaKindList, monitor, info3);
monitor.setTaskName(mainTaskMsg);
if (taskStatus != null && !taskStatus.isOK())
tempMulti.addAll(taskStatus);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
// publish the server
//ProgressUtil.getSubMonitorFor(monitor, 1000));//TODO
publishServer(kind, monitor);
monitor.setTaskName(mainTaskMsg);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
// publish modules
publishModules(kind, moduleList, deltaKindList, tempMulti, monitor);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
monitor.done();
} catch (CoreException ce) {
Activator.getDefault().getPluginLogger().error("CoreException publishing to " + toString(), ce);
return ce.getStatus();
} catch (Exception e) {
Activator.getDefault().getPluginLogger().error("Error publishing to " + toString(), e);
tempMulti.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "Error publishing", e));
} finally {
// end the publishing
try {
//ProgressUtil.getSubMonitorFor(monitor, 500));
publishFinish(monitor);
} catch (CoreException ce) {
Activator.getDefault().getPluginLogger().error("CoreException publishing to " + toString(), ce);
tempMulti.add(ce.getStatus());
} catch (Exception e) {
Activator.getDefault().getPluginLogger().error("Error stopping publish to " + toString(), e);
tempMulti.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "Error publishing", e));
}
}
Activator.getDefault().getPluginLogger().trace("--<-- Done publishing --<--");
if (tempMulti.getChildren().length == 1)
return tempMulti.getChildren()[0];
MultiStatus multi = null;
if (tempMulti.getSeverity() == IStatus.OK)
return Status.OK_STATUS;
else if (tempMulti.getSeverity() == IStatus.INFO)
multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing completed with information", null);
else if (tempMulti.getSeverity() == IStatus.WARNING)
multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing completed with a warning", null);
else if (tempMulti.getSeverity() == IStatus.ERROR)
multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing failed", null);
if (multi != null)
multi.addAll(tempMulti);
return multi;
}
use of org.eclipse.core.runtime.MultiStatus in project eclipse.platform.text by eclipse.
the class ResourceFileBuffer method validateState.
@Override
public void validateState(IProgressMonitor monitor, Object computationContext) throws CoreException {
if (!isDisconnected() && !fIsStateValidated) {
fStatus = null;
fManager.fireStateChanging(this);
try {
if (fFile.isReadOnly()) {
IWorkspace workspace = fFile.getWorkspace();
fStatus = workspace.validateEdit(new IFile[] { fFile }, computationContext);
if (fStatus.isOK())
handleFileContentChanged(false, false);
}
if (fFile.isDerived(IResource.CHECK_ANCESTORS)) {
IStatus status = new Status(IStatus.WARNING, FileBuffersPlugin.PLUGIN_ID, IFileBufferStatusCodes.DERIVED_FILE, FileBuffersMessages.ResourceFileBuffer_warning_fileIsDerived, null);
if (fStatus == null || fStatus.isOK())
fStatus = status;
else
fStatus = new MultiStatus(FileBuffersPlugin.PLUGIN_ID, IFileBufferStatusCodes.STATE_VALIDATION_FAILED, new IStatus[] { fStatus, status }, FileBuffersMessages.ResourceFileBuffer_stateValidationFailed, null);
}
} catch (RuntimeException x) {
fManager.fireStateChangeFailed(this);
throw x;
}
fIsStateValidated = fStatus == null || fStatus.getSeverity() != IStatus.CANCEL;
fManager.fireStateValidationChanged(this, fIsStateValidated);
}
}
use of org.eclipse.core.runtime.MultiStatus in project linuxtools by eclipse.
the class SRPMImportOperation method getStatus.
/**
* @return The result of the operation.
*/
public MultiStatus getStatus() {
IStatus[] errors = new IStatus[rpmErrorTable.size()];
int iCount = 0;
for (CoreException ex : rpmErrorTable) {
errors[iCount] = ex.getStatus();
iCount++;
}
return new // $NON-NLS-1$
MultiStatus(// $NON-NLS-1$
PlatformUI.PLUGIN_ID, // $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
errors, // $NON-NLS-1$
Messages.getString("SRPMImportOperation.3"), null);
}
Aggregations