diff options
author | cdumoulin | 2010-01-27 21:33:13 +0000 |
---|---|---|
committer | cdumoulin | 2010-01-27 21:33:13 +0000 |
commit | a7ee9aa6e31d98f4f9a5ed0e8b576dfc005a32f6 (patch) | |
tree | 9725b4ac2d4f58e11c101391e6bb4d9ac762df25 /extraplugins | |
parent | 839061d48103888a90c8a31715a9f8685a04dda7 (diff) | |
download | org.eclipse.papyrus-a7ee9aa6e31d98f4f9a5ed0e8b576dfc005a32f6.tar.gz org.eclipse.papyrus-a7ee9aa6e31d98f4f9a5ed0e8b576dfc005a32f6.tar.xz org.eclipse.papyrus-a7ee9aa6e31d98f4f9a5ed0e8b576dfc005a32f6.zip |
NEW - bug 300048: [General] Move extra plugins in more appropriate directory
https://bugs.eclipse.org/bugs/show_bug.cgi?id=300048
Move example.
Diffstat (limited to 'extraplugins')
7 files changed, 251 insertions, 0 deletions
diff --git a/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/.classpath b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/.classpath new file mode 100644 index 00000000000..2d1a4302f04 --- /dev/null +++ b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/.project b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/.project new file mode 100644 index 00000000000..36c1a814102 --- /dev/null +++ b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.example.lifecycleevents</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/META-INF/MANIFEST.MF b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..d7ee9b5b4ef --- /dev/null +++ b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Lifecycleevents +Bundle-SymbolicName: org.eclipse.papyrus.example.lifecycleevents;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.papyrus.example.lifecycleevents.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.papyrus.core;bundle-version="0.7.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/build.properties b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/build.properties new file mode 100644 index 00000000000..6f20375d6c7 --- /dev/null +++ b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/build.properties @@ -0,0 +1,5 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/plugin.xml b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/plugin.xml new file mode 100644 index 00000000000..9a09addcc8b --- /dev/null +++ b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/plugin.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.core.service">
+ <service
+ classname="org.eclipse.papyrus.example.lifecycleevents.LifeCycleEventsMonitorService"
+ priority="1"
+ startKind="startup"
+ useClassTypeAsKey="true">
+ </service>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/src/org/eclipse/papyrus/example/lifecycleevents/Activator.java b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/src/org/eclipse/papyrus/example/lifecycleevents/Activator.java new file mode 100644 index 00000000000..31f569ee966 --- /dev/null +++ b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/src/org/eclipse/papyrus/example/lifecycleevents/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.papyrus.example.lifecycleevents;
+
+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.papyrus.example.lifecycleevents";
+
+ // 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/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/src/org/eclipse/papyrus/example/lifecycleevents/LifeCycleEventsMonitorService.java b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/src/org/eclipse/papyrus/example/lifecycleevents/LifeCycleEventsMonitorService.java new file mode 100644 index 00000000000..be2bec8f17f --- /dev/null +++ b/extraplugins/core.examples/org.eclipse.papyrus.example.lifecycleevents/src/org/eclipse/papyrus/example/lifecycleevents/LifeCycleEventsMonitorService.java @@ -0,0 +1,136 @@ +/**
+ *
+ */
+package org.eclipse.papyrus.example.lifecycleevents;
+
+import org.eclipse.papyrus.core.lifecycleevents.DoSaveEvent;
+import org.eclipse.papyrus.core.lifecycleevents.ILifeCycleEventsProvider;
+import org.eclipse.papyrus.core.lifecycleevents.ISaveEventListener;
+import org.eclipse.papyrus.core.lifecycleevents.LifeCycleEventsProvider;
+import org.eclipse.papyrus.core.services.IService;
+import org.eclipse.papyrus.core.services.ServiceException;
+import org.eclipse.papyrus.core.services.ServicesRegistry;
+
+
+/**
+ * A simple example of a class monitoring the life cycle events from the mlti editor.
+ * This class is registered as a Papyrus service.
+ * It then registered itself to the {@link LifeCycleEventsProvider}.
+ *
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class LifeCycleEventsMonitorService implements IService {
+
+ protected ServicesRegistry servicesRegistry;
+
+ /**
+ * Listener on aboutToSave events.
+ */
+ protected ISaveEventListener aboutToSaveListener = new ISaveEventListener() {
+
+ public void doSaveAs(DoSaveEvent event) {
+ System.out.println("event received: aboutToSaveAs");
+ }
+
+ public void doSave(DoSaveEvent event) {
+ System.out.println("event received: aboutToSave");
+ }
+ };
+
+ /**
+ * Listener on doSave events.
+ */
+ protected ISaveEventListener saveListener= new ISaveEventListener() {
+
+ public void doSaveAs(DoSaveEvent event) {
+ System.out.println("event received: doSaveAs");
+ }
+
+ public void doSave(DoSaveEvent event) {
+ System.out.println("event received: doSave");
+ }
+ };
+
+ /**
+ * Listener on postSave events.
+ */
+ protected ISaveEventListener postSaveListener= new ISaveEventListener() {
+
+ public void doSaveAs(DoSaveEvent event) {
+ System.out.println("event received: postSaveAs");
+ }
+
+ public void doSave(DoSaveEvent event) {
+ System.out.println("event received: postSave");
+ }
+ };
+
+ /**
+ * Constructor.
+ * This constructor is called by the ServiceRegistry when this service is created. The
+ * parameter is provided by the ServiceRegistry itself.
+ *
+ * @param servicesRegistry
+ */
+ public LifeCycleEventsMonitorService(ServicesRegistry servicesRegistry) {
+ this.servicesRegistry = servicesRegistry;
+ System.out.println("LifeCycleEventsMonitorService created");
+ }
+
+ /**
+ * @see org.eclipse.papyrus.core.services.IService#disposeService()
+ *
+ */
+ public void disposeService() {
+ deactivate();
+ System.out.println("LifeCycleEventsMonitorService disposed");
+
+ }
+
+ /**
+ * @see org.eclipse.papyrus.core.services.IService#startService()
+ *
+ */
+ public void startService() {
+ System.out.println("LifeCycleEventsMonitorService started");
+ activate();
+ }
+
+ /**
+ * Activate listeners.
+ */
+ private void activate() {
+ try {
+ ILifeCycleEventsProvider eventProvider = servicesRegistry.getService(ILifeCycleEventsProvider.class);
+ eventProvider.addAboutToDoSaveListener(aboutToSaveListener);
+ eventProvider.addDoSaveListener(saveListener);
+ eventProvider.addPostDoSaveListener(postSaveListener);
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
+ /**
+ * Deactivate listeners
+ */
+ private void deactivate() {
+ try {
+ ILifeCycleEventsProvider eventProvider = servicesRegistry.getService(ILifeCycleEventsProvider.class);
+ eventProvider.removeAboutToDoSaveListener(aboutToSaveListener);
+ eventProvider.removeDoSaveListener(saveListener);
+ eventProvider.removePostDoSaveListener(postSaveListener);
+ } catch (ServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
|