diff options
author | Brian Bauman | 2006-08-31 21:32:00 +0000 |
---|---|---|
committer | Brian Bauman | 2006-08-31 21:32:00 +0000 |
commit | cf9420ba4598cfc897becd87266bf1cc9c7aa753 (patch) | |
tree | aa0e1edceb8009c2b44f5b4e3d5f05aec2984cee | |
parent | 2565e3addde0ce14ad9907fcdbae3e01e3ac909e (diff) | |
download | eclipse.pde.ui-OSGi_Launcher.tar.gz eclipse.pde.ui-OSGi_Launcher.tar.xz eclipse.pde.ui-OSGi_Launcher.zip |
error checking for OSGi LauncherOSGi_Launcher
Also renamed extension point based on Wassim's feedback
-rw-r--r-- | ui/org.eclipse.pde.ui/plugin.xml | 4 | ||||
-rw-r--r-- | ui/org.eclipse.pde.ui/schema/osgiLaunchers.exsd (renamed from ui/org.eclipse.pde.ui/schema/osgiLauncher.exsd) | 0 | ||||
-rw-r--r-- | ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java | 8 | ||||
-rw-r--r-- | ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java | 47 | ||||
-rw-r--r-- | ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourceLookupDirector.java | 6 | ||||
-rw-r--r-- | ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourcePathComputer.java | 15 | ||||
-rw-r--r-- | ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties | 5 | ||||
-rw-r--r-- | ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLaunchConfiguration.java | 28 |
8 files changed, 85 insertions, 28 deletions
diff --git a/ui/org.eclipse.pde.ui/plugin.xml b/ui/org.eclipse.pde.ui/plugin.xml index abd2d68009..b48a18dc29 100644 --- a/ui/org.eclipse.pde.ui/plugin.xml +++ b/ui/org.eclipse.pde.ui/plugin.xml @@ -8,7 +8,7 @@ <extension-point id="newExtension" name="%expoint.newExtension.name" schema="schema/newExtension.exsd"/>
<extension-point id="templates" name="%expoint.templates.name" schema="schema/templates.exsd"/>
<extension-point id="samples" name="%expoint.samples.name" schema="schema/samples.exsd"/>
- <extension-point id="osgiLauncher" name="%expoint.osgiLauncher.name" schema="schema/osgiLauncher.exsd"/>
+ <extension-point id="osgiLaunchers" name="%expoint.osgiLauncher.name" schema="schema/osgiLaunchers.exsd"/>
<!-- Extensions -->
<extension
@@ -1973,7 +1973,7 @@ </perspectiveExtension>
</extension>
<extension
- point="org.eclipse.pde.ui.osgiLauncher">
+ point="org.eclipse.pde.ui.osgiLaunchers">
<launcher
class="org.eclipse.pde.internal.ui.launcher.EquinoxLauncher"
id="org.eclipse.pde.ui.EquinoxLauncher"
diff --git a/ui/org.eclipse.pde.ui/schema/osgiLauncher.exsd b/ui/org.eclipse.pde.ui/schema/osgiLaunchers.exsd index a3e29199ed..a3e29199ed 100644 --- a/ui/org.eclipse.pde.ui/schema/osgiLauncher.exsd +++ b/ui/org.eclipse.pde.ui/schema/osgiLaunchers.exsd diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java index 90049135b9..312e99876d 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java @@ -59,6 +59,14 @@ public class PDEUIMessages extends NLS { public static String OSGiBundlesTab_frameworkLabel; + public static String OSGiFrameworkBlock_initializingErrorMessage; + + public static String OSGiFrameworkBlock_initializingErrorTitle; + + public static String OSGiLaunchConfiguration_cannotFindLaunchConfiguration; + + public static String OSGiLaunchConfiguration_selected; + public static String RemoveUnknownExecEnvironments_label; public static String RevertUnsupportSingletonResolution_desc; diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java index c82cb44962..309e385fab 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.launcher; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -19,6 +20,7 @@ import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.ui.launcher.AbstractLauncherTab; import org.eclipse.pde.ui.launcher.AbstractOSGiLaunchConfiguration; @@ -58,7 +60,7 @@ public class OSGiFrameworkBlock { public OSGiFrameworkBlock(AbstractLauncherTab tab) { IExtensionRegistry registry = Platform.getExtensionRegistry(); - fConfigElements = orderElements(registry.getConfigurationElementsFor("org.eclipse.pde.ui.osgiLauncher")); //$NON-NLS-1$ + fConfigElements = orderElements(validateElements(registry.getConfigurationElementsFor("org.eclipse.pde.ui.osgiLaunchers"))); //$NON-NLS-1$ fTab = tab; fListener = new Listener(); } @@ -76,6 +78,17 @@ public class OSGiFrameworkBlock { return elems; } + private IConfigurationElement[] validateElements(IConfigurationElement[] elems) { + ArrayList list = new ArrayList(elems.length); + for (int i = 0; i < elems.length; i++) { + if (elems[i].getAttribute("id") == null || elems[i].getAttribute("name") == null //$NON-NLS-1$ //$NON-NLS-2$ + || elems[i].getAttribute("class") == null) //$NON-NLS-1$ + continue; + list.add(elems[i]); + } + return (IConfigurationElement[]) list.toArray(new IConfigurationElement[list.size()]); + } + public void createControl(Composite parent) { createFrameworkGroup(parent); createDefaultsGroup(parent); @@ -94,12 +107,18 @@ public class OSGiFrameworkBlock { if (id == null) id = EquinoxLauncher.ID; - for (int i = 0; i < fConfigElements.length; i++) { - if (id.equals(fConfigElements[i].getAttribute("id"))){ //$NON-NLS-1$ - fLauncherCombo.select(i); - return; + for ( int j = 0; j < 2; j++) { + for (int i = 0; i < fConfigElements.length; i++) { + if (id.equals(fConfigElements[i].getAttribute("id"))){ //$NON-NLS-1$ + fLauncherCombo.select(i); + return; + } } + id = EquinoxLauncher.ID; } + // If we can't find equinox, set it to anything + if (fLauncherCombo.getSelectionIndex() == -1) + fLauncherCombo.select(0); } public void performApply(ILaunchConfigurationWorkingCopy config) { @@ -157,13 +176,21 @@ public class OSGiFrameworkBlock { private void setLauncher(ILaunchConfigurationWorkingCopy config) { try { String oldId = config.getAttribute(OSGiLaunchConfiguration.OSGI_ENV_ID, ""); //$NON-NLS-1$ - String newId = fConfigElements[fLauncherCombo.getSelectionIndex()].getAttribute("id"); //$NON-NLS-1$ + int selection = fLauncherCombo.getSelectionIndex(); + if (selection == -1) + return; + String newId = fConfigElements[selection].getAttribute("id"); //$NON-NLS-1$ if (!newId.equals(oldId)) { - AbstractOSGiLaunchConfiguration launcher = (AbstractOSGiLaunchConfiguration) fConfigElements[fLauncherCombo.getSelectionIndex()].createExecutableExtension("class"); //$NON-NLS-1$ - if (launcher != null) { - launcher.initialize(config); + try { config.setAttribute(OSGiLaunchConfiguration.OSGI_ENV_ID, fConfigElements[fLauncherCombo.getSelectionIndex()].getAttribute("id")); //$NON-NLS-1$ - fTab.initializeFrom(config); + AbstractOSGiLaunchConfiguration launcher = (AbstractOSGiLaunchConfiguration) fConfigElements[fLauncherCombo.getSelectionIndex()].createExecutableExtension("class"); //$NON-NLS-1$ + if (launcher != null) { + launcher.initialize(config); + fTab.initializeFrom(config); + } + } catch (Exception e) { + PDEPlugin.logException(e, PDEUIMessages.OSGiFrameworkBlock_initializingErrorTitle, + PDEUIMessages.OSGiFrameworkBlock_initializingErrorMessage); } } } catch (CoreException e) { diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourceLookupDirector.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourceLookupDirector.java index 59710edaf4..275f5d8452 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourceLookupDirector.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourceLookupDirector.java @@ -31,7 +31,9 @@ public class OSGiSourceLookupDirector implements IPersistableSourceLocator { public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException { - String id = configuration.getAttribute(OSGiLaunchConfiguration.OSGI_ENV_ID, ""); //$NON-NLS-1$ + String id = configuration.getAttribute(OSGiLaunchConfiguration.OSGI_ENV_ID, (String)null); + if (id == null) + id = EquinoxLauncher.ID; String locatorId = null; locatorId = getFrameworkSourceLocator(id); if (locatorId == null) @@ -45,7 +47,7 @@ public class OSGiSourceLookupDirector implements IPersistableSourceLocator { private String getFrameworkSourceLocator(String id) { if (id != null) { IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.ui.osgiLauncher"); //$NON-NLS-1$ + IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.ui.osgiLaunchers"); //$NON-NLS-1$ for (int i = 0; i < elements.length; i++) { if (elements[i].getAttribute("id").equals(id)) { //$NON-NLS-1$ String attr = elements[i].getAttribute("sourceLocatorId"); //$NON-NLS-1$ diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourcePathComputer.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourcePathComputer.java index 7425b86701..c30dec40af 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourcePathComputer.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiSourcePathComputer.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer; +import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.ui.launcher.AbstractOSGiLaunchConfiguration; import org.eclipse.pde.ui.launcher.OSGiLaunchConfiguration; @@ -41,17 +42,21 @@ public class OSGiSourcePathComputer extends JavaSourcePathComputer { if (id != null) { try { IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.ui.osgiLauncher"); //$NON-NLS-1$ + IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.ui.osgiLaunchers"); //$NON-NLS-1$ IConfigurationElement elem = null; for (int i = 0; i < elements.length; i++) { - if (elements[i].getAttribute("id").equals(id)) { //$NON-NLS-1$ + if (id.equals(elements[i].getAttribute("id"))) { //$NON-NLS-1$ elem = elements[i]; break; } } if (elem != null) { - AbstractOSGiLaunchConfiguration launcher= (AbstractOSGiLaunchConfiguration)elem.createExecutableExtension("class"); //$NON-NLS-1$ - return launcher.getSourceContainers(); + try { + AbstractOSGiLaunchConfiguration launcher= (AbstractOSGiLaunchConfiguration)elem.createExecutableExtension("class"); //$NON-NLS-1$ + return launcher.getSourceContainers(); + } catch (Exception e) { + PDEPlugin.log(e); + } } } catch (SecurityException e) { } catch (IllegalArgumentException e) { @@ -61,7 +66,5 @@ public class OSGiSourcePathComputer extends JavaSourcePathComputer { } return null; } - - } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties index 31782d6c7a..3fa4ae6a0d 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties @@ -2543,4 +2543,9 @@ PerspectiveTemplate_perspectiveShortcuts = Add &Related Perspective Shortcuts PerspectiveTemplate_showViewShortcuts = Add Show View &Shortcuts PerspectiveTemplate_newWizardShortcuts = Add New &Wizard Shortcuts PerspectiveTemplate_actionSets = Add &Menu and Toolbar Contributions (Action Sets) + OSGiBundlesTab_frameworkLabel=OSGi &Framework: +OSGiLaunchConfiguration_cannotFindLaunchConfiguration=Cannot find an AbstractOSGiLauncherConfiguration for the {0} OSGi framework +OSGiLaunchConfiguration_selected=selected +OSGiFrameworkBlock_initializingErrorTitle=Error initializing OSGi launch configuration +OSGiFrameworkBlock_initializingErrorMessage=Problems occurred when initializing launch configuration for the selected OSGi Framework diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLaunchConfiguration.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLaunchConfiguration.java index c899d06721..7cbde203a0 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLaunchConfiguration.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/OSGiLaunchConfiguration.java @@ -14,10 +14,16 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.LaunchConfigurationDelegate; +import org.eclipse.osgi.util.NLS; +import org.eclipse.pde.internal.ui.IPDEUIConstants; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.launcher.EquinoxLauncher; /** * A launch delegate for launching OSGi frameworks @@ -33,28 +39,34 @@ public class OSGiLaunchConfiguration extends LaunchConfigurationDelegate { public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { String id = configuration.getAttribute(OSGI_ENV_ID, (String)null); - if (id != null) { - AbstractOSGiLaunchConfiguration launcher = findLauncher(id); + // if no OSGi Env specified, then launch with Equinox + if (id == null) + id = EquinoxLauncher.ID; + AbstractOSGiLaunchConfiguration launcher = findLauncher(id); + if (launcher != null) launcher.launch(configuration, mode, launch, monitor); - } } - private AbstractOSGiLaunchConfiguration findLauncher(String id ) { + private AbstractOSGiLaunchConfiguration findLauncher(String id ) throws CoreException { IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.ui.osgiLauncher"); //$NON-NLS-1$ + IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.ui.osgiLaunchers"); //$NON-NLS-1$ IConfigurationElement elem = null; for (int i = 0; i < elements.length; i++) { - if (elements[i].getAttribute("id").equals(id)) { //$NON-NLS-1$ + if (id.equals(elements[i].getAttribute("id"))) { //$NON-NLS-1$ elem = elements[i]; break; } } - if (elem != null) + if (elem != null) try { return (AbstractOSGiLaunchConfiguration)elem.createExecutableExtension("class"); //$NON-NLS-1$ } catch (CoreException e) { + } catch (ClassCastException e) { } - return null; + String name = (elem == null) ? null : elem.getAttribute("name"); //$NON-NLS-1$ + String message = NLS.bind(PDEUIMessages.OSGiLaunchConfiguration_cannotFindLaunchConfiguration, (name == null) ? PDEUIMessages.OSGiLaunchConfiguration_selected : name); + IStatus status = new Status(IStatus.ERROR, IPDEUIConstants.PLUGIN_ID, IStatus.OK, message , null); + throw new CoreException(status); } } |