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);
}
use of org.eclipse.core.runtime.Status in project che by eclipse.
the class JavaSearchResult method addMatch.
boolean addMatch(Match match, IMatchPresentation participant) {
Object element = match.getElement();
if (fElementsToParticipants.get(element) != null) {
// TODO must access the participant id / label to properly report the error.
JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), 0, "A second search participant was found for an element", //$NON-NLS-1$
null));
return false;
}
fElementsToParticipants.put(element, participant);
addMatch(match);
return true;
}
use of org.eclipse.core.runtime.Status in project che by eclipse.
the class RefactoringSessionReader method readSession.
/**
* Reads a refactoring history descriptor from the specified input object.
*
* @param source
* the input source
* @return a corresponding refactoring history descriptor, or
* <code>null</code>
* @throws CoreException
* if an error occurs while reading form the input source
*/
public RefactoringSessionDescriptor readSession(final InputSource source) throws CoreException {
fSessionFound = false;
try {
//$NON-NLS-1$
source.setSystemId("/");
createParser(SAXParserFactory.newInstance()).parse(source, this);
if (!fSessionFound)
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, RefactoringCoreMessages.RefactoringSessionReader_no_session, null));
if (fRefactoringDescriptors != null) {
if (//$NON-NLS-1$
fVersion == null || "".equals(fVersion))
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.MISSING_REFACTORING_HISTORY_VERSION, RefactoringCoreMessages.RefactoringSessionReader_missing_version_information, null));
if (!IRefactoringSerializationConstants.CURRENT_VERSION.equals(fVersion))
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.UNSUPPORTED_REFACTORING_HISTORY_VERSION, RefactoringCoreMessages.RefactoringSessionReader_unsupported_version_information, null));
return new RefactoringSessionDescriptor((RefactoringDescriptor[]) fRefactoringDescriptors.toArray(new RefactoringDescriptor[fRefactoringDescriptors.size()]), fVersion, fComment);
}
} catch (IOException exception) {
throwCoreException(exception, exception.getLocalizedMessage());
} catch (ParserConfigurationException exception) {
throwCoreException(exception, exception.getLocalizedMessage());
} catch (SAXParseException exception) {
String message = Messages.format(RefactoringCoreMessages.RefactoringSessionReader_invalid_contents_at, new Object[] { Integer.toString(exception.getLineNumber()), Integer.toString(exception.getColumnNumber()) });
throwCoreException(exception, message);
} catch (SAXException exception) {
throwCoreException(exception, exception.getLocalizedMessage());
} finally {
fRefactoringDescriptors = null;
fVersion = null;
fComment = null;
fLocator = null;
}
return null;
}
use of org.eclipse.core.runtime.Status in project che by eclipse.
the class RefactoringSessionTransformer method createArgument.
/**
* Creates a refactoring argument with the specified name and value.
* <p>
* If no refactoring is currently processed, this call has no effect.
* </p>
*
* @param name
* the non-empty name of the argument
* @param value
* the value of the argument
*
* @throws CoreException
* if an error occurs while creating a new argument
*/
public void createArgument(final String name, final String value) throws CoreException {
Assert.isNotNull(name);
//$NON-NLS-1$
Assert.isTrue(!"".equals(name));
Assert.isNotNull(value);
if (fDocument != null && fRefactoringArguments != null && value != null) {
try {
final Attr attribute = fDocument.createAttribute(name);
attribute.setValue(value);
fRefactoringArguments.add(attribute);
} catch (DOMException exception) {
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, exception.getLocalizedMessage(), null));
}
}
}
Aggregations