use of org.eclipse.core.runtime.Status in project che by eclipse.
the class DeletePackageFragmentRootChange method getFileLength.
private static int getFileLength(IFile file) throws CoreException {
// Cannot use file buffers here, since they are not yet in sync at this point.
InputStream contents = file.getContents();
InputStreamReader reader;
try {
reader = new InputStreamReader(contents, file.getCharset());
} catch (UnsupportedEncodingException e) {
JavaPlugin.log(e);
reader = new InputStreamReader(contents);
}
try {
return (int) reader.skip(Integer.MAX_VALUE);
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, Corext.getPluginId(), e.getMessage(), e));
} finally {
try {
reader.close();
} catch (IOException e) {
}
}
}
use of org.eclipse.core.runtime.Status in project flux by eclipse.
the class ASTProvider method createAST.
private static CompilationUnit createAST(final ITypeRoot input, final IProgressMonitor progressMonitor) {
if (progressMonitor != null && progressMonitor.isCanceled())
return null;
final ASTParser parser = ASTParser.newParser(SHARED_AST_LEVEL);
parser.setResolveBindings(true);
parser.setStatementsRecovery(SHARED_AST_STATEMENT_RECOVERY);
parser.setBindingsRecovery(SHARED_BINDING_RECOVERY);
parser.setSource(input);
if (progressMonitor != null && progressMonitor.isCanceled())
return null;
final CompilationUnit[] root = new CompilationUnit[1];
SafeRunner.run(new ISafeRunnable() {
public void run() {
try {
if (progressMonitor != null && progressMonitor.isCanceled())
return;
root[0] = (CompilationUnit) parser.createAST(progressMonitor);
//mark as unmodifiable
ASTNodes.setFlagsToAST(root[0], ASTNode.PROTECT);
} catch (OperationCanceledException ex) {
return;
}
}
public void handleException(Throwable ex) {
//$NON-NLS-1$
IStatus status = new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "Error in JDT Core during AST creation", ex);
JavaPlugin.getDefault().getLog().log(status);
}
});
return root[0];
}
use of org.eclipse.core.runtime.Status in project flux by eclipse.
the class ContributionContextTypeRegistry method createContextType.
private static TemplateContextType createContextType(IConfigurationElement element) throws CoreException {
String id = element.getAttribute(ID);
try {
TemplateContextType contextType = (TemplateContextType) element.createExecutableExtension(CLASS);
String name = element.getAttribute(NAME);
if (name == null)
name = id;
if (contextType.getId() == null)
contextType.setId(id);
if (contextType.getName() == null)
contextType.setName(name);
return contextType;
} catch (ClassCastException e) {
//$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "extension does not implement " + TemplateContextType.class.getName(), e));
}
}
use of org.eclipse.core.runtime.Status in project generator by mybatis.
the class GeneratorLaunchConfigurationDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
AntRunner antRunner = new AntRunner();
String buildFile;
try {
buildFile = generateAntScript(configuration);
} catch (IOException e) {
Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.LAUNCH_ERROR_ERROR_GENERATING_ANT_FILE, e);
throw new CoreException(status);
}
antRunner.setBuildFileLocation(buildFile);
//$NON-NLS-1$
antRunner.addBuildLogger("org.mybatis.generator.eclipse.ui.ant.GeneratorBuildLogger");
modifyAntClasspathIfNecessary(configuration, antRunner);
if (ILaunchManager.DEBUG_MODE.equals(mode)) {
antRunner.setMessageOutputLevel(Project.MSG_DEBUG);
//$NON-NLS-1$
antRunner.setArguments("-debug");
} else {
antRunner.setMessageOutputLevel(Project.MSG_WARN);
}
antRunner.run(monitor);
if (LauncherUtils.getBooleanOrFalse(configuration, GeneratorLaunchConstants.ATTR_SQL_SCRIPT_SECURE_CREDENTIALS)) {
File file = new File(buildFile);
file.delete();
}
}
use of org.eclipse.core.runtime.Status 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);
}
Aggregations