Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/core/org.eclipse.papyrus.example.core.lifecycleevents')
-rw-r--r--examples/core/org.eclipse.papyrus.example.core.lifecycleevents/.classpath7
-rw-r--r--examples/core/org.eclipse.papyrus.example.core.lifecycleevents/.project28
-rw-r--r--examples/core/org.eclipse.papyrus.example.core.lifecycleevents/META-INF/MANIFEST.MF12
-rw-r--r--examples/core/org.eclipse.papyrus.example.core.lifecycleevents/build.properties5
-rw-r--r--examples/core/org.eclipse.papyrus.example.core.lifecycleevents/plugin.properties12
-rw-r--r--examples/core/org.eclipse.papyrus.example.core.lifecycleevents/plugin.xml14
-rw-r--r--examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/Activator.java50
-rw-r--r--examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java142
8 files changed, 270 insertions, 0 deletions
diff --git a/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/.classpath b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/examples/core/org.eclipse.papyrus.example.core.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/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/.project b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/.project
new file mode 100644
index 00000000000..a165d6f55aa
--- /dev/null
+++ b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.example.core.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/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/META-INF/MANIFEST.MF b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..2e3974acac3
--- /dev/null
+++ b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.example.core.lifecycleevents;singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.example.core.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
+Bundle-Vendor: %providerName
diff --git a/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/build.properties b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/build.properties
new file mode 100644
index 00000000000..6f20375d6c7
--- /dev/null
+++ b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/plugin.properties b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/plugin.properties
new file mode 100644
index 00000000000..d0701f4b9f7
--- /dev/null
+++ b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2008 CEA LIST.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+##################################################################################
+pluginName=Papyrus Editor Life Cycle Example
+providerName=Cedric Dumoulin
diff --git a/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/plugin.xml b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/plugin.xml
new file mode 100644
index 00000000000..14ac9e2043e
--- /dev/null
+++ b/examples/core/org.eclipse.papyrus.example.core.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.core.lifecycleevents.LifeCycleEventsMonitorService"
+ priority="1"
+ startKind="startup"
+ useClassTypeAsKey="true">
+ </service>
+ </extension>
+
+</plugin>
diff --git a/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/Activator.java b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/Activator.java
new file mode 100644
index 00000000000..e39549ce693
--- /dev/null
+++ b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.papyrus.example.core.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/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java
new file mode 100644
index 00000000000..5959b6831ec
--- /dev/null
+++ b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java
@@ -0,0 +1,142 @@
+/**
+ *
+ */
+package org.eclipse.papyrus.example.core.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;
+ /**
+ * The object firing event about the Editor lifecycle.
+ */
+ protected ILifeCycleEventsProvider eventProvider;
+
+ /**
+ * 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() {
+ System.out.println("LifeCycleEventsMonitorService created");
+ }
+
+ /**
+ * @see org.eclipse.papyrus.core.services.IService#disposeService()
+ *
+ */
+ public void disposeService() {
+ deactivate();
+ System.out.println("LifeCycleEventsMonitorService disposed");
+
+ }
+
+ /**
+ * Initialize the service.
+ * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry)
+ *
+ * @param servicesRegistry
+ */
+ public void init(ServicesRegistry servicesRegistry) {
+ this.servicesRegistry = servicesRegistry;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.core.services.IService#startService()
+ *
+ */
+ public void startService() {
+ System.out.println("LifeCycleEventsMonitorService started");
+ activate();
+ }
+
+ /**
+ * Activate listeners.
+ */
+ private void activate() {
+ try {
+ 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() {
+ eventProvider.removeAboutToDoSaveListener(aboutToSaveListener);
+ eventProvider.removeDoSaveListener(saveListener);
+ eventProvider.removePostDoSaveListener(postSaveListener);
+
+ }
+
+
+}

Back to the top