Example usage for java.lang.reflect InvocationTargetException InvocationTargetException

List of usage examples for java.lang.reflect InvocationTargetException InvocationTargetException

Introduction

In this page you can find the example usage for java.lang.reflect InvocationTargetException InvocationTargetException.

Prototype

public InvocationTargetException(Throwable target) 

Source Link

Document

Constructs a InvocationTargetException with a target exception.

Usage

From source file:Main.java

/**
 * In EDT just runs the runnable (so in that thread the pending AWT events
 * are _not_ dispatched before running the runnable).
 *//*from w  w w . ja v a2  s.c om*/
public static void invokeAndWaitFromAnyThread(Runnable r)
        throws InterruptedException, InvocationTargetException {
    if (SwingUtilities.isEventDispatchThread()) {
        try {
            r.run();
        } catch (RuntimeException e) {
            throw new InvocationTargetException(e);
        }
    } else {
        SwingUtilities.invokeAndWait(r);
    }
}

From source file:org.ff4j.aop.test.goodbye.GoodbyeServiceEnglishImpl.java

@Override
public void sayGoodbyeInvocationTargetExceptionNull() throws InvocationTargetException {
    throw new InvocationTargetException(null);
}

From source file:org.ff4j.aop.test.goodbye.GoodbyeServiceEnglishImpl.java

@Override
public void sayGoodbyeWithClassInvocationTargetExceptionNull() throws InvocationTargetException {
    throw new InvocationTargetException(null);
}

From source file:de.jcup.egradle.eclipse.ide.execution.GradleRunnableWithProgress.java

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

    try {// www  .  j a v a2 s  . c  o  m
        execution.execute(monitor);
        ProcessExecutionResult result = execution.getResult();
        if (result.isCanceledByuser()) {
            return;
        }
        if (!result.isOkay()) {
            getDialogSupport().showWarning("Result was not okay:" + result.getResultCode());
        }
    } catch (Exception e) {
        throw new InvocationTargetException(e);
    }

}

From source file:com.bluexml.side.Integration.eclipse.branding.enterprise.wizards.migration.ModelMigrationWizard.java

@Override
public boolean performFinish() {
    System.out.println("ModelMigrationWizard.performFinish()");
    final GeneralProjectMigration page = (GeneralProjectMigration) getContainer().getCurrentPage();
    final String libraryId = page.getFieldValueString(GeneralProjectMigration.Fields.library.toString());
    // import library if project do not exists in workspace

    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                execute(page, libraryId, monitor);
            } catch (Exception e) {

                throw new InvocationTargetException(e);
            }/*from  www.ja v  a2s .co m*/
        }
    };

    try {
        this.getContainer().run(true, true, runnable);
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        Activator.getDefault().getLog()
                .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, cause.toString(), cause));
        MessageDialog.openError(getShell(), "Error", NLS.bind("Internal error {0}", cause.getMessage())); //$NON-NLS-1$
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return true;
}

From source file:com.parasoft.xtest.reports.jenkins.parser.ParasoftParser.java

@Override
public Collection<FileAnnotation> parse(File file, String sModuleName) throws InvocationTargetException {
    FileInputStream input = null;
    try {//from  w w  w  . ja v a2s .  c  o  m
        input = new FileInputStream(file);
        return intern(importResults(file, sModuleName));
    } catch (FileNotFoundException exception) {
        throw new InvocationTargetException(exception);
    } finally {
        IOUtils.closeQuietly(input);
    }
}

From source file:com.bmw.spdxeditor.wizards.NewSPDXFileWizard.java

/**
 * This method is called when 'Finish' button is pressed in
 * the wizard. We will create an operation and run it
 * using wizard as execution context./* w w  w. ja va  2  s  .co m*/
 */
public boolean performFinish() {
    final String containerName = page.getContainerName();
    final String fileName = page.getFileName();
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                doFinish(containerName, fileName, monitor);
            } catch (CoreException e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    };
    try {
        getContainer().run(true, false, op);
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        Throwable realException = e.getTargetException();
        MessageDialog.openError(getShell(), "Error", realException.getMessage());
        return false;
    }
    return true;
}

From source file:ca.uvic.cs.tagsea.research.GetIDWithProgress.java

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    GetMethod getUidMethod = new GetMethod(uidScript);
    getUidMethod.setQueryString(new NameValuePair[] { first, last, email, job, size, buisness, anon });
    monitor.beginTask("Get User Id", 1);
    HttpClient client = new HttpClient();
    try {/*from w  w  w.j  a  v  a  2 s.c  o  m*/
        status = client.executeMethod(getUidMethod);

        resp = getData(getUidMethod.getResponseBodyAsStream());

        // release the connection to the server
        getUidMethod.releaseConnection();
    } catch (Exception e) {
        // there was a problem with the file upload so throw up
        // an error
        // dialog to inform the user and log the exception
        failed = true;
        throw new InvocationTargetException(e);
    }

    if (status != 200) {
        // there was a problem with the file upload so throw up an error
        // dialog to inform the user

        failed = true;

        // there was a problem with the file upload so throw up an error
        // dialog to inform the user
        MessageDialog.openError(null, "Error Getting User ID", "There was an error getting a user id: \n"
                + "HTTP Response Code " + status + "\n" + "Please try again later");
    } else {
        resp = resp.substring(resp.indexOf(":") + 1).trim();
        uid = Integer.parseInt(resp);
    }

    monitor.worked(1);
    monitor.done();
}

From source file:ca.uvic.chisel.logging.eclipse.internal.network.LogUploadRunnable.java

public void run(IProgressMonitor sendMonitor) throws InterruptedException, InvocationTargetException {
    File[] filesToUpload = log.getCategory().getFilesToUpload();
    sendMonitor.beginTask("Uploading Log " + log.getCategory().getName(), filesToUpload.length);
    LoggingCategory category = log.getCategory();
    IMemento memento = category.getMemento();
    for (File file : filesToUpload) {
        if (sendMonitor.isCanceled()) {
            throw new InterruptedException();
        }/*from   w w  w.  ja  v a  2s. c o m*/
        PostMethod post = new PostMethod(category.getURL().toString());

        try {
            Part[] parts = { new StringPart("KIND", "workbench-log"),
                    new StringPart("CATEGORY", category.getCategoryID()),
                    new StringPart("USER", WorkbenchLoggingPlugin.getDefault().getLocalUser()),
                    new FilePart("WorkbenchLogger", file.getName(), file, "application/zip", null) };
            post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
            HttpClient client = new HttpClient();
            int status = client.executeMethod(post);
            String resp = getData(post.getResponseBodyAsStream());
            if (status != 200 || !resp.startsWith("Status: 200 Success")) {
                IOException ex = new IOException(resp);
                throw (ex);
            }
            memento.putString("lastUpload", file.getName());
            file.delete();
        } catch (IOException e) {
            throw new InvocationTargetException(e);
        } finally {
            sendMonitor.worked(1);
        }
    }
    sendMonitor.done();
}

From source file:hudson.plugins.ccm.parser.CcmParser.java

@Override
public Collection<FileAnnotation> parse(InputStream file, String moduleName) throws InvocationTargetException {
    try {//from w  ww .  j  a  v a2 s  .c  o m
        Digester digester = new Digester();
        digester.setValidating(false);
        digester.setClassLoader(CcmParser.class.getClassLoader());

        String rootXPath = "ccm";
        digester.addObjectCreate(rootXPath, Ccm.class);
        digester.addSetProperties(rootXPath);

        String fileMetric = "ccm/metric";
        digester.addObjectCreate(fileMetric, Metric.class);
        digester.addSetProperties(fileMetric);
        digester.addBeanPropertySetter("ccm/metric/complexity");
        digester.addBeanPropertySetter("ccm/metric/unit");
        digester.addBeanPropertySetter("ccm/metric/classification");
        digester.addBeanPropertySetter("ccm/metric/file");
        digester.addBeanPropertySetter("ccm/metric/startLineNumber");
        digester.addBeanPropertySetter("ccm/metric/endLineNumber");
        digester.addSetNext(fileMetric, "addMetric", Metric.class.getName());

        Ccm module = (Ccm) digester.parse(file);
        if (module == null) {
            throw new SAXException("Input stream is not a CCM file.");
        }

        return convert(module, moduleName);
    } catch (IOException exception) {
        throw new InvocationTargetException(exception);
    } catch (SAXException exception) {
        throw new InvocationTargetException(exception);
    }
}