Example usage for org.eclipse.jface.operation IRunnableWithProgress run

List of usage examples for org.eclipse.jface.operation IRunnableWithProgress run

Introduction

In this page you can find the example usage for org.eclipse.jface.operation IRunnableWithProgress run.

Prototype

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException;

Source Link

Document

Runs this operation.

Usage

From source file:org.eclipse.jdt.ui.tests.wizardapi.NewJavaProjectWizardTest.java

License:Open Source License

public void testUserCreate() throws Exception {
    IProject project = fWizardPage.getProjectHandle();

    IPath folderPath = project.getFolder("dbin").getFullPath();

    IClasspathEntry[] entries = new IClasspathEntry[] {
            JavaCore.newSourceEntry(project.getFolder("dsrc1").getFullPath()),
            JavaCore.newSourceEntry(project.getFolder("dsrc2").getFullPath()) };

    fWizardPage.setDefaultOutputFolder(folderPath);
    fWizardPage.setDefaultClassPath(entries, true);

    IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(fWizardPage.getRunnable());
    op.run(null);

    IJavaProject jproj = fWizardPage.getNewJavaProject();

    assertEquals("a", jproj.getProject(), project);

    IPath outputLocation = jproj.getOutputLocation();
    IClasspathEntry[] classpath = jproj.getRawClasspath();
    assertUserBuildPath(jproj.getProject(), outputLocation, classpath);
}

From source file:org.eclipse.jdt.ui.tests.wizardapi.NewJavaProjectWizardTest.java

License:Open Source License

public void testReadExisting() throws Exception {
    IProject project = fWizardPage.getProjectHandle();

    IPath folderPath = project.getFolder("dbin").getFullPath();
    IClasspathEntry[] entries = new IClasspathEntry[] {
            JavaCore.newSourceEntry(project.getFolder("dsrc1").getFullPath()),
            JavaCore.newSourceEntry(project.getFolder("dsrc2").getFullPath()) };

    fWizardPage.setDefaultOutputFolder(folderPath);
    fWizardPage.setDefaultClassPath(entries, true);

    IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(fWizardPage.getRunnable());
    op.run(null);

    IProject proj = fWizardPage.getNewJavaProject().getProject();

    fWizardPage.setDefaultClassPath(null, false);
    fWizardPage.setDefaultOutputFolder(null);
    fWizardPage.setProjectHandle(proj);//  ww w  .j  a  v  a2 s  .c om

    // reads from existing
    fWizardPage.initBuildPath();

    IPath outputLocation1 = fWizardPage.getOutputLocation();
    IClasspathEntry[] classpath1 = fWizardPage.getRawClassPath();
    assertUserBuildPath(project, outputLocation1, classpath1);
}

From source file:org.eclipse.jdt.ui.tests.wizardapi.NewJavaProjectWizardTest.java

License:Open Source License

public void testExistingOverwrite() throws Exception {
    IProject project = fWizardPage.getProjectHandle();

    IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(fWizardPage.getRunnable());
    op.run(null);

    IPath folderPath = project.getFolder("dbin").getFullPath();
    IClasspathEntry[] entries = new IClasspathEntry[] {
            JavaCore.newSourceEntry(project.getFolder("dsrc1").getFullPath()),
            JavaCore.newSourceEntry(project.getFolder("dsrc2").getFullPath()) };

    fWizardPage.setDefaultOutputFolder(folderPath);
    fWizardPage.setDefaultClassPath(entries, true);

    // should overwrite existing
    IRunnableWithProgress op1 = new WorkspaceModifyDelegatingOperation(fWizardPage.getRunnable());
    op1.run(null);//from   w  w  w .  ja va  2 s. co  m

    IJavaProject jproj = fWizardPage.getNewJavaProject();

    IPath outputLocation1 = jproj.getOutputLocation();
    IClasspathEntry[] classpath1 = jproj.getRawClasspath();
    assertUserBuildPath(project, outputLocation1, classpath1);
}

From source file:org.eclipse.jst.j2ee.internal.wizard.ServerTargetUIHelper.java

License:Open Source License

/**
 * @param project//  w  ww  .j  a  va  2s  .c  om
 */
public static void runEarValidation(IProject project) {
    try {
        IRunnableWithProgress runnable = EARValidationHelper.createValidationRunnable(project);
        runnable.run(null);
    } catch (InterruptedException ie) {
        Logger.getLogger().logError(ie);
    } catch (InvocationTargetException ite) {
        Logger.getLogger().logError(ite);
    }
}

From source file:org.eclipse.jst.ws.internal.consumption.ui.command.StartServerCommand.java

License:Open Source License

private IStatus publish(final IServer server, final int kind, IProgressMonitor monitor) {
    IStatus status = Status.OK_STATUS;//ww w . jav  a  2 s .  c o m
    final IStatus[] istatus = new IStatus[1];
    monitor.subTask(ConsumptionMessages.PROGRESS_INFO_PUBLISHING_SERVER);
    IRunnableWithProgress runnable = new IRunnableWithProgress() {
        public void run(IProgressMonitor shellMonitor) throws InvocationTargetException, InterruptedException {
            ServerPublishOperationListener publishListener = new ServerPublishOperationListener();
            server.publish(IServer.PUBLISH_INCREMENTAL, null, null, publishListener);
            istatus[0] = publishListener.getPublishStatus();
        }
    };

    try {
        if (doAsyncPublish_) {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
            dialog.run(true, true, runnable);
        } else {
            runnable.run(monitor);
        }

    } catch (InvocationTargetException ite) {
        istatus[0] = new org.eclipse.core.runtime.Status(IStatus.ERROR, "id", 0, ite.getMessage(), ite);
        ite.printStackTrace();
    } catch (InterruptedException ie) {
        istatus[0] = new org.eclipse.core.runtime.Status(IStatus.ERROR, "id", 0, ie.getMessage(), ie);
        ie.printStackTrace();
    }

    if (istatus[0].getSeverity() != IStatus.OK) {
        status = istatus[0];
        if (status.getSeverity() == IStatus.CANCEL)
            status = StatusUtils.errorStatus("");
        return status;
    }

    log.log(ILog.INFO, 5051, this, "publishProject", "IServer=" + server + ", Publish command completed");
    return status;
}

From source file:org.eclipse.linuxtools.internal.oprofile.core.Oprofile.java

License:Open Source License

/**
 * Checks the requested counter, event, and unit mask for validity.
 * @param ctr    the counter// w w  w  .j  a  v  a2 s. c  o m
 * @param event    the event name
 * @param um    the unit mask
 * @return whether the requested event is valid
 */
public static Boolean checkEvent(int ctr, String event, int um) {
    int[] validResult = new int[1];
    try {
        IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().checkEvents(ctr, event,
                um, validResult);
        opxml.run(null);
    } catch (InvocationTargetException | InterruptedException e) {
    }

    return (validResult[0] == CheckEventsProcessor.EVENT_OK);
}

From source file:org.eclipse.linuxtools.internal.oprofile.core.Oprofile.java

License:Open Source License

/**
 * Returns a list of all the session collected on the system, as well as
 * the event under each of them.//from ww w.  j  a v  a2s  .  co m
 * @since 3.0
 * @returns a list of all collected events
 */
public static OpModelSession[] getSessions() {
    OpModelSession[] events = null;

    ArrayList<OpModelSession> sessionList = new ArrayList<>();
    try {
        IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().sessions(sessionList);
        opxml.run(null);
        events = new OpModelSession[sessionList.size()];
        sessionList.toArray(events);
    } catch (InvocationTargetException | InterruptedException e) {
    }
    return events;
}

From source file:org.eclipse.linuxtools.internal.oprofile.core.Oprofile.java

License:Open Source License

/**
 * Return a list of all the Samples in the given session.
 * @param session the session for which to get samples
 * @param shell the composite shell to use for the progress dialog
 *///from   ww w .java 2s.co  m
public static OpModelImage getModelData(String eventName, String sessionName) {
    OpModelImage image = new OpModelImage();

    final IRunnableWithProgress opxml;
    try {
        opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().modelData(eventName, sessionName, image);
        opxml.run(null);
    } catch (InvocationTargetException | InterruptedException e) {
    }

    return image;
}

From source file:org.eclipse.linuxtools.oprofile.core.Oprofile.java

License:Open Source License

/**
 * Checks the requested counter, event, and unit mask for vailidity.
 * @param ctr   the counter//  w ww . j  av a  2 s. c  o m
 * @param event   the event number
 * @param um   the unit mask
 * @return whether the requested event is valid
 */
public static Boolean checkEvent(int ctr, int event, int um) {
    int[] validResult = new int[1];
    try {
        IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().checkEvents(ctr, event,
                um, validResult);
        opxml.run(null);
    } catch (InvocationTargetException e) {
    } catch (InterruptedException e) {
    } catch (OpxmlException e) {
        OprofileCorePlugin.showErrorDialog("opxmlProvider", e); //$NON-NLS-1$
        return null;
    }

    return (validResult[0] == CheckEventsProcessor.EVENT_OK);
}

From source file:org.eclipse.linuxtools.oprofile.core.Oprofile.java

License:Open Source License

/**
 * Returns a list of all the events collected on the system, as well as
 * the sessions under each of them.//from   w w w  . j a v a2  s.  co  m
 * @returns a list of all collected events
 */
public static OpModelEvent[] getEvents() {
    OpModelEvent[] events = null;

    ArrayList<OpModelEvent> sessionList = new ArrayList<OpModelEvent>();
    try {
        IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().sessions(sessionList);
        opxml.run(null);
        events = new OpModelEvent[sessionList.size()];
        sessionList.toArray(events);
    } catch (InvocationTargetException e) {
    } catch (InterruptedException e) {
    } catch (OpxmlException e) {
        OprofileCorePlugin.showErrorDialog("opxmlProvider", e); //$NON-NLS-1$
    }
    return events;
}