Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed2004-10-07 17:46:53 +0000
committerGrant Gayed2004-10-07 17:46:53 +0000
commitd6148e648829b2a48ef2b94c29a7d269c6e1b930 (patch)
tree401889ec5811b6ed20b72be120cb5d9ebd18a03b /examples
parent13dc6f06b9b15226803049d379450d5c15b07f19 (diff)
downloadeclipse.platform.swt-d6148e648829b2a48ef2b94c29a7d269c6e1b930.tar.gz
eclipse.platform.swt-d6148e648829b2a48ef2b94c29a7d269c6e1b930.tar.xz
eclipse.platform.swt-d6148e648829b2a48ef2b94c29a7d269c6e1b930.zip
56047
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/plugin.xml1
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java16
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java10
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java14
4 files changed, 27 insertions, 14 deletions
diff --git a/examples/org.eclipse.swt.examples.launcher/plugin.xml b/examples/org.eclipse.swt.examples.launcher/plugin.xml
index 9cb2d6fea3..91b8e1e07b 100755
--- a/examples/org.eclipse.swt.examples.launcher/plugin.xml
+++ b/examples/org.eclipse.swt.examples.launcher/plugin.xml
@@ -31,7 +31,6 @@
<import plugin="org.eclipse.debug.core"/>
<import plugin="org.eclipse.core.boot"/>
<import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.swt.examples"/>
</requires>
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java
index 7ec10195b8..cbe6517c0f 100755
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.examples.launcher;
+import org.eclipse.core.runtime.*;
import org.eclipse.swt.graphics.*;
/**
@@ -24,6 +25,7 @@ class ItemDescriptor {
private String view;
private String mainType;
private String pluginId;
+ private IConfigurationElement element;
/**
@@ -38,7 +40,7 @@ class ItemDescriptor {
* @param pluginId the name of the plugin which contains the main class
*/
public ItemDescriptor(String id, String name, String description,
- Image icon, String view, String mainType, String pluginId) {
+ Image icon, String view, String mainType, String pluginId, IConfigurationElement element) {
this.id = id;
this.name = name;
this.description = description;
@@ -46,6 +48,18 @@ class ItemDescriptor {
this.view = view;
this.mainType = mainType;
this.pluginId = pluginId;
+ this.element = element;
+ }
+
+ /**
+ * Creates and returns an instance of the extension's specified type,
+ * or <code>null</code> if no type was specified by the extension.
+ *
+ * @return an instance of the extension's specified type or <code>null</code>
+ */
+ public Object createItemInstance() throws CoreException {
+ if (element == null) return null;
+ return element.createExecutableExtension(LauncherPlugin.LAUNCH_ITEMS_XML_PROGRAM_CLASS);
}
/**
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java
index c5e1f316b6..515623353f 100755
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java
@@ -29,7 +29,7 @@ public class LauncherPlugin extends AbstractUIPlugin {
private static LauncherPlugin plugin;
private static ResourceBundle resourceBundle;
- private static final String
+ public static final String
LAUNCH_ITEMS_POINT_ID = "org.eclipse.swt.examples.launcher.launchItems",
LAUNCH_ITEMS_XML_CATEGORY = "category",
LAUNCH_ITEMS_XML_ITEM = "item",
@@ -164,7 +164,7 @@ public class LauncherPlugin extends AbstractUIPlugin {
*/
public static ItemTreeNode getLaunchItemTree() {
ItemTreeNode categoryTree =
- new ItemTreeNode(new ItemDescriptor("<<Root>>", "<<Root>>", null, null, null, null, null));
+ new ItemTreeNode(new ItemDescriptor("<<Root>>", "<<Root>>", null, null, null, null, null, null));
// get the platform's public plugin registry
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
@@ -188,7 +188,7 @@ public class LauncherPlugin extends AbstractUIPlugin {
if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
final String attribName = getItemName(ce);
ItemDescriptor theDescriptor = new ItemDescriptor(attribId, attribName,
- getItemDescription(ce), null, null, null, null);
+ getItemDescription(ce), null, null, null, null, ce);
idMap.put(attribId, new ItemTreeNode(theDescriptor));
}
}
@@ -274,7 +274,7 @@ public class LauncherPlugin extends AbstractUIPlugin {
return null;
}
return new ItemDescriptor(attribId, attribName, attribDescription,
- attribIcon, attribView, null, null);
+ attribIcon, attribView, null, null, viewCE);
} else {
//Item is a standalone
IConfigurationElement programCE = getItemElement(ce, LAUNCH_ITEMS_XML_PROGRAM);
@@ -287,7 +287,7 @@ public class LauncherPlugin extends AbstractUIPlugin {
return null;
}
return new ItemDescriptor(attribId, attribName, attribDescription,
- attribIcon, null, attribClass, attribPluginId);
+ attribIcon, null, attribClass, attribPluginId, programCE);
} else {
logError(getResourceString("error.IncompleteLaunchItem",
new Object[] { attribId } ), null);
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java
index 663dfd6415..30f10b12ae 100755
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.examples.launcher;
+import org.eclipse.core.runtime.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
@@ -184,15 +185,14 @@ public class LauncherView extends ViewPart {
/* Case 2: The launch item is a standalone program */
if (workbenchShell == null) return;
try {
- Class cl = Class.forName(itemDescriptor.getMainType());
- Display display = workbenchShell.getDisplay();
- Object exampleInstance = cl.newInstance();
- Method openMethod = cl.getDeclaredMethod("open", new Class[] {Display.class});
- openMethod.invoke(exampleInstance, new Object[] {display});
+ Object instance = itemDescriptor.createItemInstance();
+ if (instance != null) {
+ Display display = workbenchShell.getDisplay();
+ Method openMethod = instance.getClass().getDeclaredMethod("open", new Class[] {Display.class});
+ openMethod.invoke(instance, new Object[] {display});
+ }
} catch (NoSuchMethodException e) {
LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.DoesNotImplementMethod"), null);
- } catch (ClassNotFoundException e) {
- LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.CouldNotFindClass"), e);
} catch (Exception e) {
LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.CouldNotInstantiateClass"), e);
}

Back to the top