Search in sources :

Example 26 with Status

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) {
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) InputStreamReader(java.io.InputStreamReader) CoreException(org.eclipse.core.runtime.CoreException) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException)

Example 27 with Status

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];
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) ASTParser(org.eclipse.jdt.core.dom.ASTParser)

Example 28 with Status

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));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Example 29 with Status

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();
    }
}
Also used : Status(org.eclipse.core.runtime.Status) AntRunner(org.eclipse.ant.core.AntRunner) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) File(java.io.File)

Example 30 with Status

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);
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Status (org.eclipse.core.runtime.Status)305 IStatus (org.eclipse.core.runtime.IStatus)282 CoreException (org.eclipse.core.runtime.CoreException)132 IOException (java.io.IOException)66 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)64 InvocationTargetException (java.lang.reflect.InvocationTargetException)40 File (java.io.File)38 ArrayList (java.util.ArrayList)37 IFile (org.eclipse.core.resources.IFile)37 MultiStatus (org.eclipse.core.runtime.MultiStatus)30 IResource (org.eclipse.core.resources.IResource)27 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)26 IProject (org.eclipse.core.resources.IProject)24 IPath (org.eclipse.core.runtime.IPath)24 ITask (com.cubrid.common.core.task.ITask)23 PartInitException (org.eclipse.ui.PartInitException)23 InputStream (java.io.InputStream)18 GridData (org.eclipse.swt.layout.GridData)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 Composite (org.eclipse.swt.widgets.Composite)16