Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/org.eclipse.papyrus.examples.restrictedservicecreation')
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/.classpath7
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/.project28
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/META-INF/MANIFEST.MF21
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/build.properties8
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/plugin.properties12
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/plugin.xml27
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/src/org/eclipse/papyrus/restrictedservicecreation/Activator.java68
-rw-r--r--examples/org.eclipse.papyrus.examples.restrictedservicecreation/src/org/eclipse/papyrus/restrictedservicecreation/FilterClassOnPackage.java73
9 files changed, 252 insertions, 0 deletions
diff --git a/examples/org.eclipse.papyrus.examples.restrictedservicecreation/.classpath b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/.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/org.eclipse.papyrus.examples.restrictedservicecreation/.project b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/.project
new file mode 100644
index 00000000000..d6cd9d20511
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.example.restrictedservicecreation</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/org.eclipse.papyrus.examples.restrictedservicecreation/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..828157292c3
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue Aug 24 16:14:29 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/examples/org.eclipse.papyrus.examples.restrictedservicecreation/META-INF/MANIFEST.MF b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..46e3e6004d7
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.example.restrictedservicecreation;singleton:=true
+Bundle-Version: 0.7.1.qualifier
+Bundle-Activator: org.eclipse.papyrus.restrictedservicecreation.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.umlutils;bundle-version="0.7.0",
+ org.eclipse.papyrus.core;bundle-version="0.7.0",
+ org.eclipse.papyrus.diagram.common;bundle-version="0.7.0",
+ org.eclipse.gmt.modisco.infra.browser;bundle-version="0.8.0",
+ org.eclipse.gmt.modisco.infra.browser.uicore;bundle-version="0.8.0",
+ org.eclipse.papyrus.service.creation;bundle-version="0.7.1",
+ org.eclipse.papyrus.uml.service.creation;bundle-version="0.7.1",
+ org.eclipse.gmf.runtime.emf.type.ui;bundle-version="1.2.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.restrictedservicecreation
+Bundle-Vendor: %providerName
diff --git a/examples/org.eclipse.papyrus.examples.restrictedservicecreation/build.properties b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/build.properties
new file mode 100644
index 00000000000..c0d503fd9e3
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
+src.includes = src/,\
+ plugin.xml,\
+ build.properties
diff --git a/examples/org.eclipse.papyrus.examples.restrictedservicecreation/plugin.properties b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/plugin.properties
new file mode 100644
index 00000000000..f5b4a67e73b
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/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:
+# Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+##################################################################################
+pluginName=restrictedservicecreation
+providerName=Eclipse.org
diff --git a/examples/org.eclipse.papyrus.examples.restrictedservicecreation/plugin.xml b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/plugin.xml
new file mode 100644
index 00000000000..5591c133f4c
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/plugin.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
+ <metamodel nsURI="http://www.eclipse.org/uml2/3.0.0/UML">
+
+ <adviceBinding
+ class="org.eclipse.papyrus.restrictedservicecreation.FilterClassOnPackage"
+ id="org.eclipse.papyrus.restrictedservicecreation.FilterClassOnPackage"
+ inheritance="all"
+ typeId="org.eclipse.papyrus.uml.Element">
+ </adviceBinding>
+ </metamodel>
+ </extension>
+
+ <!-- Creating a default binding -->
+ <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
+
+ <!-- Bindings declaration -->
+ <binding context="org.eclipse.papyrus.uml.service.creation.TypeContext">
+ <elementType pattern="org.eclipse.papyrus.uml.*" />
+ <advice ref="org.eclipse.papyrus.restrictedservicecreation.FilterClassOnPackage" />
+ </binding>
+ </extension>
+
+
+</plugin>
diff --git a/examples/org.eclipse.papyrus.examples.restrictedservicecreation/src/org/eclipse/papyrus/restrictedservicecreation/Activator.java b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/src/org/eclipse/papyrus/restrictedservicecreation/Activator.java
new file mode 100644
index 00000000000..0ea5d65b1a6
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/src/org/eclipse/papyrus/restrictedservicecreation/Activator.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.restrictedservicecreation;
+
+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 implements org.eclipse.ui.IStartup{
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.example.restrictedservicecreation"; //$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;
+ }
+
+ public void earlyStartup() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/examples/org.eclipse.papyrus.examples.restrictedservicecreation/src/org/eclipse/papyrus/restrictedservicecreation/FilterClassOnPackage.java b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/src/org/eclipse/papyrus/restrictedservicecreation/FilterClassOnPackage.java
new file mode 100644
index 00000000000..afba04aae08
--- /dev/null
+++ b/examples/org.eclipse.papyrus.examples.restrictedservicecreation/src/org/eclipse/papyrus/restrictedservicecreation/FilterClassOnPackage.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.restrictedservicecreation;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.papyrus.service.creation.PapyrusEditHelperFilter;
+import org.eclipse.papyrus.uml.service.creation.element.UMLElementTypes;
+
+/**
+ * this is a filter used to allow the creation of a class or package in the context on a package,
+ * or to allow only the creation of a property in the context of a class
+ *
+ */
+public class FilterClassOnPackage extends PapyrusEditHelperFilter {
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ICommand getAfterConfigureCommand(final ConfigureRequest request) {
+ return new ConfigureElementCommand(request) {
+
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean validateRequest(IEditCommandRequest request) {
+ if(request instanceof GetEditContextRequest){
+ IEditCommandRequest subrequest= ((GetEditContextRequest)request).getEditCommandRequest();
+ if( subrequest instanceof CreateElementRequest){
+
+ //allow only creation of class or package into a package
+ if(((CreateElementRequest) subrequest).getContainer() instanceof org.eclipse.uml2.uml.Package){
+ if(((CreateElementRequest) subrequest).getElementType().equals(UMLElementTypes.CLASS)||
+ ((CreateElementRequest) subrequest).getElementType().equals(UMLElementTypes.PACKAGE)){
+ return true;
+ }
+ }
+ //allow only creation of property into a class
+ if(((CreateElementRequest) subrequest).getContainer() instanceof org.eclipse.uml2.uml.Class){
+ if(((CreateElementRequest) subrequest).getElementType().equals(UMLElementTypes.PROPERTY)){
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+}

Back to the top