Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2013-01-24 07:14:31 +0000
committerslewis2013-01-24 07:14:31 +0000
commit03d63de7cfcb1097491acc5038ab417aab7ec87e (patch)
tree33ad477e565e62e60e01f7b8488a8318684ed2e1 /tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src
parent74e4eded413a6ce5aa05ccb83fd2d46e5984c687 (diff)
downloadorg.eclipse.ecf-03d63de7cfcb1097491acc5038ab417aab7ec87e.tar.gz
org.eclipse.ecf-03d63de7cfcb1097491acc5038ab417aab7ec87e.tar.xz
org.eclipse.ecf-03d63de7cfcb1097491acc5038ab417aab7ec87e.zip
Added new tooling plugin: org.eclipse.ecf.remoteservices.tooling.pde.
This plugin provides two new PDE pluginContent extensions, which show up on the new plugin wizard under examples. Two new examples are added: OSGi Remote Service Host, and OSGi Remote Service Consumer
Diffstat (limited to 'tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src')
-rw-r--r--tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/Activator.java50
-rw-r--r--tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceConsumerExample1Template.java125
-rw-r--r--tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceConsumerExample1Wizard.java30
-rw-r--r--tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceHostExample1Template.java125
-rw-r--r--tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceHostExample1Wizard.java30
5 files changed, 360 insertions, 0 deletions
diff --git a/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/Activator.java b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/Activator.java
new file mode 100644
index 000000000..358389113
--- /dev/null
+++ b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.ecf.remoteservices.internal.tooling.pde;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.ecf.remoteservices.tooling.pde"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceConsumerExample1Template.java b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceConsumerExample1Template.java
new file mode 100644
index 000000000..7de6bc0cc
--- /dev/null
+++ b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceConsumerExample1Template.java
@@ -0,0 +1,125 @@
+package org.eclipse.ecf.remoteservices.internal.tooling.pde;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.IPluginReference;
+import org.eclipse.pde.ui.IFieldData;
+import org.eclipse.pde.ui.templates.OptionTemplateSection;
+import org.osgi.framework.Bundle;
+
+public class RemoteServiceConsumerExample1Template extends OptionTemplateSection {
+
+ private String packageName;
+
+ public RemoteServiceConsumerExample1Template() {
+ setPageCount(1);
+ addOption("consumerName", "User Name", System.getProperty("user.name"), 0);
+ }
+
+ public void addPages(Wizard wizard) {
+ WizardPage page = createPage(0, "org.eclipse.pde.doc.user.rcp_mail");
+ page.setTitle("Hello Remote Service Consumer");
+ page.setDescription("This template creates a Hello remote service consumer");
+ wizard.addPage(page);
+ markPagesAdded();
+ }
+
+ public URL getTemplateLocation() {
+ Bundle b = Activator.getDefault().getBundle();
+ String path = "/templates/"+getSectionId();
+ URL url = b.getEntry(path);
+ if (url != null)
+ try {
+ return new URL(getInstallURL(), path);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public String getSectionId() {
+ return "helloRemoteServiceConsumerExample1"; //$NON-NLS-1$
+ }
+
+ protected void updateModel(IProgressMonitor monitor) {
+ setManifestHeader("Require-Bundle", "org.eclipse.equinox.common");
+ }
+
+ public String getUsedExtensionPoint() {
+ return null;
+ }
+
+ public boolean isDependentOnParentWizard() {
+ return true;
+ }
+
+ public int getNumberOfWorkUnits() {
+ return super.getNumberOfWorkUnits() + 1;
+ }
+
+ public IPluginReference[] getDependencies(String schemaVersion) {
+ return new IPluginReference[0];
+ }
+
+ protected String getFormattedPackageName(String id) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < id.length(); i++) {
+ char ch = id.charAt(i);
+ if (buffer.length() == 0) {
+ if (Character.isJavaIdentifierStart(ch))
+ buffer.append(Character.toLowerCase(ch));
+ } else {
+ if (Character.isJavaIdentifierPart(ch) || ch == '.')
+ buffer.append(ch);
+ }
+ }
+ return buffer.toString().toLowerCase(Locale.ENGLISH);
+ }
+
+
+ protected void initializeFields(IFieldData data) {
+ // In a new project wizard, we don't know this yet - the
+ // model has not been created
+ String packageName = getFormattedPackageName(data.getId());
+ initializeOption(KEY_PACKAGE_NAME, packageName);
+ this.packageName = getFormattedPackageName(data.getId());
+ }
+
+ public void initializeFields(IPluginModelBase model) {
+ String id = model.getPluginBase().getId();
+ String packageName = getFormattedPackageName(id);
+ initializeOption(KEY_PACKAGE_NAME, packageName);
+ this.packageName = getFormattedPackageName(id);
+ }
+
+ public String getStringOption(String name) {
+ if (name.equals(KEY_PACKAGE_NAME)) {
+ return packageName;
+ }
+ return super.getStringOption(name);
+ }
+
+ @Override
+ public String[] getNewFiles() {
+ return new String[0];
+ }
+
+ @Override
+ protected URL getInstallURL() {
+ return Activator.getDefault().getBundle().getEntry("/");
+ }
+
+ @Override
+ protected ResourceBundle getPluginResourceBundle() {
+ return Platform.getResourceBundle(Activator.getDefault().getBundle());
+ }
+
+}
diff --git a/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceConsumerExample1Wizard.java b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceConsumerExample1Wizard.java
new file mode 100644
index 000000000..7f799a3d3
--- /dev/null
+++ b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceConsumerExample1Wizard.java
@@ -0,0 +1,30 @@
+package org.eclipse.ecf.remoteservices.internal.tooling.pde;
+
+import org.eclipse.pde.core.plugin.IPluginReference;
+import org.eclipse.pde.ui.IFieldData;
+import org.eclipse.pde.ui.IPluginContentWizard;
+import org.eclipse.pde.ui.templates.ITemplateSection;
+import org.eclipse.pde.ui.templates.NewPluginTemplateWizard;
+
+public class RemoteServiceConsumerExample1Wizard extends NewPluginTemplateWizard implements
+ IPluginContentWizard {
+
+ public void init(IFieldData data) {
+ super.init(data);
+ setWindowTitle("Remote Services Consumer Example Wizard");
+ }
+
+ public ITemplateSection[] createTemplateSections() {
+ return new ITemplateSection[] {new RemoteServiceConsumerExample1Template()};
+ }
+
+ public String[] getImportPackages() {
+ return new String[] { "org.eclipse.ecf.osgi.services.distribution","org.eclipse.ecf.examples.remoteservices.hello","org.osgi.util.tracker","org.eclipse.ecf.remoteservice","org.eclipse.equinox.concurrent.future" };
+ }
+
+ public IPluginReference[] getDependencies(String schemaVersion) {
+ return new IPluginReference[0];
+ }
+
+}
+
diff --git a/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceHostExample1Template.java b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceHostExample1Template.java
new file mode 100644
index 000000000..b4dcbc8c0
--- /dev/null
+++ b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceHostExample1Template.java
@@ -0,0 +1,125 @@
+package org.eclipse.ecf.remoteservices.internal.tooling.pde;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.IPluginReference;
+import org.eclipse.pde.ui.IFieldData;
+import org.eclipse.pde.ui.templates.OptionTemplateSection;
+import org.osgi.framework.Bundle;
+
+public class RemoteServiceHostExample1Template extends OptionTemplateSection {
+
+ private String packageName;
+
+ public RemoteServiceHostExample1Template() {
+ setPageCount(1);
+ addOption("containerType", "service.exported.configs", "ecf.generic.server", 0);
+ addOption("containerId", "ECF Generic Server URL", "ecftcp://localhost:3282/server", 0);
+ }
+
+ public void addPages(Wizard wizard) {
+ WizardPage page = createPage(0, "org.eclipse.pde.doc.user.rcp_mail");
+ page.setTitle("Hello Remote Service Host");
+ page.setDescription("This template creates and exports a Hello remote service");
+ wizard.addPage(page);
+ markPagesAdded();
+ }
+
+ public URL getTemplateLocation() {
+ Bundle b = Activator.getDefault().getBundle();
+ String path = "/templates/"+getSectionId();
+ URL url = b.getEntry(path);
+ if (url != null)
+ try {
+ return new URL(getInstallURL(), path);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public String getSectionId() {
+ return "helloRemoteServiceHostExample1"; //$NON-NLS-1$
+ }
+
+ protected void updateModel(IProgressMonitor monitor) {
+ }
+
+ public String getUsedExtensionPoint() {
+ return null;
+ }
+
+ public boolean isDependentOnParentWizard() {
+ return true;
+ }
+
+ public int getNumberOfWorkUnits() {
+ return super.getNumberOfWorkUnits() + 1;
+ }
+
+ public IPluginReference[] getDependencies(String schemaVersion) {
+ return new IPluginReference[0];
+ }
+
+ protected String getFormattedPackageName(String id) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < id.length(); i++) {
+ char ch = id.charAt(i);
+ if (buffer.length() == 0) {
+ if (Character.isJavaIdentifierStart(ch))
+ buffer.append(Character.toLowerCase(ch));
+ } else {
+ if (Character.isJavaIdentifierPart(ch) || ch == '.')
+ buffer.append(ch);
+ }
+ }
+ return buffer.toString().toLowerCase(Locale.ENGLISH);
+ }
+
+
+ protected void initializeFields(IFieldData data) {
+ // In a new project wizard, we don't know this yet - the
+ // model has not been created
+ String packageName = getFormattedPackageName(data.getId());
+ initializeOption(KEY_PACKAGE_NAME, packageName);
+ this.packageName = getFormattedPackageName(data.getId());
+ }
+
+ public void initializeFields(IPluginModelBase model) {
+ String id = model.getPluginBase().getId();
+ String packageName = getFormattedPackageName(id);
+ initializeOption(KEY_PACKAGE_NAME, packageName);
+ this.packageName = getFormattedPackageName(id);
+ }
+
+ public String getStringOption(String name) {
+ if (name.equals(KEY_PACKAGE_NAME)) {
+ return packageName;
+ }
+ return super.getStringOption(name);
+ }
+
+ @Override
+ public String[] getNewFiles() {
+ return new String[0];
+ }
+
+ @Override
+ protected URL getInstallURL() {
+ return Activator.getDefault().getBundle().getEntry("/");
+ }
+
+ @Override
+ protected ResourceBundle getPluginResourceBundle() {
+ return Platform.getResourceBundle(Activator.getDefault().getBundle());
+ }
+
+}
diff --git a/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceHostExample1Wizard.java b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceHostExample1Wizard.java
new file mode 100644
index 000000000..1e137a49b
--- /dev/null
+++ b/tooling/plugins/org.eclipse.ecf.remoteservices.tooling.pde/src/org/eclipse/ecf/remoteservices/internal/tooling/pde/RemoteServiceHostExample1Wizard.java
@@ -0,0 +1,30 @@
+package org.eclipse.ecf.remoteservices.internal.tooling.pde;
+
+import org.eclipse.pde.core.plugin.IPluginReference;
+import org.eclipse.pde.ui.IFieldData;
+import org.eclipse.pde.ui.IPluginContentWizard;
+import org.eclipse.pde.ui.templates.ITemplateSection;
+import org.eclipse.pde.ui.templates.NewPluginTemplateWizard;
+
+public class RemoteServiceHostExample1Wizard extends NewPluginTemplateWizard implements
+ IPluginContentWizard {
+
+ public void init(IFieldData data) {
+ super.init(data);
+ setWindowTitle("Remote Services Host Example Wizard");
+ }
+
+ public ITemplateSection[] createTemplateSections() {
+ return new ITemplateSection[] {new RemoteServiceHostExample1Template()};
+ }
+
+ public String[] getImportPackages() {
+ return new String[] { "org.eclipse.ecf.osgi.services.distribution","org.eclipse.ecf.examples.remoteservices.hello","org.eclipse.ecf.remoteservice" };
+ }
+
+ public IPluginReference[] getDependencies(String schemaVersion) {
+ return new IPluginReference[0];
+ }
+
+}
+

Back to the top