Search in sources :

Example 1 with ICoreRunnable

use of org.springsource.ide.eclipse.commons.ui.ICoreRunnable in project eclipse-integration-commons by spring-projects.

the class ConfiguratorPreferencesPage method doInstall.

protected void doInstall(final ConfigurableExtension extension) {
    // FIXME use directory where extension is installed
    final File installDirectory = new File(userLocationText.getText());
    if (!installDirectory.canWrite()) {
        UiStatusHandler.logAndDisplay(new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind("Installation failed. The directory ''{0}'' is not writeable.", userLocationText.getText())));
        return;
    }
    try {
        final IStatus[] status = new IStatus[1];
        UiUtil.busyCursorWhile(new ICoreRunnable() {

            public void run(IProgressMonitor monitor) throws CoreException {
                status[0] = extension.install(installDirectory, monitor);
                if (status[0].getSeverity() != IStatus.ERROR) {
                    IStatus configurationStatus = extension.configure(monitor);
                    if (status[0].getSeverity() != IStatus.OK) {
                        MultiStatus result = new MultiStatus(Activator.PLUGIN_ID, 0, NLS.bind("The installation of {0} generated warning. See error log for details.", extension.getLabel()), null);
                        result.add(status[0]);
                        result.add(configurationStatus);
                        status[0] = result;
                    } else {
                        status[0] = configurationStatus;
                    }
                }
            }
        });
        handleResult(extension, status);
        doRefresh();
    } catch (OperationCanceledException ignored) {
    // cancelled
    } catch (CoreException e) {
        UiStatusHandler.logAndDisplay(e.getStatus());
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ICoreRunnable(org.springsource.ide.eclipse.commons.ui.ICoreRunnable) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) MultiStatus(org.eclipse.core.runtime.MultiStatus) File(java.io.File)

Example 2 with ICoreRunnable

use of org.springsource.ide.eclipse.commons.ui.ICoreRunnable in project eclipse-integration-commons by spring-projects.

the class ConfiguratorPreferencesPage method doConfigure.

protected void doConfigure(final ConfigurableExtension extension) {
    try {
        final IStatus[] status = new IStatus[1];
        UiUtil.busyCursorWhile(new ICoreRunnable() {

            public void run(IProgressMonitor monitor) throws CoreException {
                status[0] = extension.configure(monitor);
            }
        });
        handleResult(extension, status);
        doRefresh();
    } catch (OperationCanceledException ignored) {
    // cancelled
    } catch (CoreException e) {
        UiStatusHandler.logAndDisplay(e.getStatus());
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ICoreRunnable(org.springsource.ide.eclipse.commons.ui.ICoreRunnable) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException)

Example 3 with ICoreRunnable

use of org.springsource.ide.eclipse.commons.ui.ICoreRunnable in project eclipse-integration-commons by spring-projects.

the class IdeUiUtils method createTaskData.

private static TaskData createTaskData(final TaskRepository taskRepository, final String projectKey) throws CoreException {
    AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(JIRA_CONNECTOR_KIND);
    final AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
    final TaskData taskData = new TaskData(taskDataHandler.getAttributeMapper(taskRepository), JIRA_CONNECTOR_KIND, taskRepository.getRepositoryUrl(), "");
    ICoreRunnable runner = new ICoreRunnable() {

        public void run(IProgressMonitor monitor) throws CoreException {
            TaskMapping mapping = new TaskMapping() {

                @Override
                public String getProduct() {
                    return projectKey;
                }
            };
            if (!taskDataHandler.initializeTaskData(taskRepository, taskData, mapping, monitor)) {
                throw new CoreException(new Status(Status.ERROR, IdeUiPlugin.PLUGIN_ID, "The repository does not have a project with key: " + projectKey));
            }
        }
    };
    UiUtil.busyCursorWhile(runner);
    return taskData;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ICoreRunnable(org.springsource.ide.eclipse.commons.ui.ICoreRunnable) AbstractRepositoryConnector(org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector) TaskMapping(org.eclipse.mylyn.tasks.core.TaskMapping) AbstractTaskDataHandler(org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IStatus (org.eclipse.core.runtime.IStatus)3 ICoreRunnable (org.springsource.ide.eclipse.commons.ui.ICoreRunnable)3 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 Status (org.eclipse.core.runtime.Status)2 File (java.io.File)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 AbstractRepositoryConnector (org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector)1 TaskMapping (org.eclipse.mylyn.tasks.core.TaskMapping)1 AbstractTaskDataHandler (org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler)1 TaskData (org.eclipse.mylyn.tasks.core.data.TaskData)1