Search in sources :

Example 1 with ConfigurableExtension

use of org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension in project eclipse-integration-commons by spring-projects.

the class ConfiguratorPreferencesPage method updateSelection.

protected void updateSelection(ISelection selection) {
    configureButton.setEnabled(!selection.isEmpty());
    ConfigurableExtension extension = getSelectedExtension(selection);
    installButton.setEnabled(extension != null && extension.isInstallable() && isInstallEnabled());
}
Also used : ConfigurableExtension(org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension)

Example 2 with ConfigurableExtension

use of org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension in project eclipse-integration-commons by spring-projects.

the class ConfiguratorPreferencesPage method updateElements.

private void updateElements() {
    elements = new ArrayList<ConfigurableExtension>();
    importer = new ConfiguratorImporter();
    importer.setFirstMatchOnly(false);
    try {
        PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                elements.addAll(importer.detectExtensions(monitor));
            }
        });
    } catch (InvocationTargetException e) {
        StatusHandler.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "An error occurred loading configurable items", e));
    } catch (InterruptedException e) {
    // ignore
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConfigurableExtension(org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension) ConfiguratorImporter(org.springsource.ide.eclipse.commons.internal.configurator.ConfiguratorImporter) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 3 with ConfigurableExtension

use of org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension in project eclipse-integration-commons by spring-projects.

the class ConfiguratorImporterTest method testDetectExtensions.

@Test
public void testDetectExtensions() throws Exception {
    Assume.assumeTrue(isStsDistribution());
    ConfiguratorImporter importer = new ConfiguratorImporter();
    List<ConfigurableExtension> extensions = importer.detectExtensions(new NullProgressMonitor());
    // assertContains("grails-", extensions);
    assertContains("apache-maven-", extensions);
    assertContains("spring-roo-", extensions);
    assertContains("vfabric-tc-server-developer-", extensions);
// assertContains("com.springsource.cloudfoundryserver.runtime.10",
// extensions);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ConfigurableExtension(org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension) Test(org.junit.Test)

Example 4 with ConfigurableExtension

use of org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension in project eclipse-integration-commons by spring-projects.

the class ConfiguratorImporter method getInstalledBundles.

public Set<String> getInstalledBundles() {
    final Set<String> installedBundles = new HashSet<String>();
    Set<WorkspaceConfiguratorParticipant> participants = ParticipantExtensionPointReader.getParticipants();
    for (final WorkspaceConfiguratorParticipant configurator : participants) {
        SafeRunner.run(new ISafeRunnable() {

            public void handleException(Throwable exception) {
            // logged by super class
            }

            public void run() throws Exception {
                List<ConfigurableExtension> extensions = configurator.detectExtensions(ConfiguratorImporter.this, new NullProgressMonitor());
                for (ConfigurableExtension extension : extensions) {
                    if (extension.getBundleId() != null) {
                        installedBundles.add(extension.getBundleId() + ".feature.group");
                    }
                }
            }
        });
    }
    return installedBundles;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) WorkspaceConfiguratorParticipant(org.springsource.ide.eclipse.commons.configurator.WorkspaceConfiguratorParticipant) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) ArrayList(java.util.ArrayList) List(java.util.List) ConfigurableExtension(org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension) CoreException(org.eclipse.core.runtime.CoreException) HashSet(java.util.HashSet)

Example 5 with ConfigurableExtension

use of org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension in project eclipse-integration-commons by spring-projects.

the class ConfiguratorImporter method detectExtensions.

public List<ConfigurableExtension> detectExtensions(final IProgressMonitor monitor) {
    final List<ConfigurableExtension> result = new ArrayList<ConfigurableExtension>();
    Set<WorkspaceConfiguratorParticipant> participants = ParticipantExtensionPointReader.getParticipants();
    for (final WorkspaceConfiguratorParticipant participant : participants) {
        SafeRunner.run(new ISafeRunnable() {

            public void handleException(Throwable exception) {
            // logged by super class
            }

            public void run() throws Exception {
                List<ConfigurableExtension> extensions = participant.detectExtensions(ConfiguratorImporter.this, monitor);
                result.addAll(extensions);
            }
        });
    }
    Set<InstallableItem> installableItems = ParticipantExtensionPointReader.getInstallableItems();
    for (final InstallableItem item : installableItems) {
        boolean found = false;
        for (ConfigurableExtension extension : result) {
            if (extension.getId().equals(item.getId())) {
                extension.setInstallableItem(item);
                found = true;
            }
        }
        if (!found) {
            for (final WorkspaceConfiguratorParticipant participant : participants) {
                if (participant.getId().equals(item.getConfiguratorId())) {
                    final AtomicBoolean added = new AtomicBoolean(false);
                    SafeRunner.run(new ISafeRunnable() {

                        public void handleException(Throwable exception) {
                        // logged by super class
                        }

                        public void run() throws Exception {
                            ConfigurableExtension extension = participant.createExtension(item, monitor);
                            if (extension != null) {
                                result.add(extension);
                                added.set(true);
                            }
                        }
                    });
                    if (added.get()) {
                        break;
                    }
                }
            }
        }
    }
    return result;
}
Also used : WorkspaceConfiguratorParticipant(org.springsource.ide.eclipse.commons.configurator.WorkspaceConfiguratorParticipant) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) ArrayList(java.util.ArrayList) List(java.util.List) ConfigurableExtension(org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension)

Aggregations

ConfigurableExtension (org.springsource.ide.eclipse.commons.configurator.ConfigurableExtension)9 CoreException (org.eclipse.core.runtime.CoreException)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 WorkspaceConfiguratorParticipant (org.springsource.ide.eclipse.commons.configurator.WorkspaceConfiguratorParticipant)2 HashSet (java.util.HashSet)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 Job (org.eclipse.core.runtime.jobs.Job)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1