Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-07-22 21:14:13 +0000
committerAnsgar Radermacher2015-07-27 12:44:10 +0000
commitb8b25802cb2507bce1a4e5e3e236ad7de464351c (patch)
tree2e33ad4a998710699d25fedb0065ae30f2e5da9f /plugins/infra/services
parentd98af9d92762f3dd7d5c62f4ff893c524abcd763 (diff)
downloadorg.eclipse.papyrus-b8b25802cb2507bce1a4e5e3e236ad7de464351c.tar.gz
org.eclipse.papyrus-b8b25802cb2507bce1a4e5e3e236ad7de464351c.tar.xz
org.eclipse.papyrus-b8b25802cb2507bce1a4e5e3e236ad7de464351c.zip
Bug 465899: Cannot connect ports of imported library as "Registered package"
https://bugs.eclipse.org/bugs/show_bug.cgi?id=465899 Introduce request parameters as hints to the read-only advice's handling of CreateRelationshipRequest, to tell it when the source/target of the relationship will or will not be modified by the creation of the relationship. Use these hints, when available, to further refine the determination of read-only violations. Change the read-only advice implementation for create-relationship requests to be an after advice, instead of before, to ensure that it finds as much relevant information in the request as possible that may contributed by before advices and the edit-helper, itself. Add, in the UML Element Types, a new advice that sets these hints for the benefit of improved read-only calculation. The advice intercepts creation requests for Associations of all kinds and for Connectors. JUnit tests are included for association and connector scenarios. Existing tests cover the correct handling of metaclass extensions. Change-Id: I9a03fb3ad943a8ae6713a721937bb82a37966562
Diffstat (limited to 'plugins/infra/services')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.classpath2
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.edit/META-INF/MANIFEST.MF5
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/utils/RequestParameterConstants.java107
4 files changed, 107 insertions, 13 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.classpath b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.classpath
index ad32c83a788..098194ca4b7 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.classpath
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.classpath
@@ -1,6 +1,6 @@
<?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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.settings/org.eclipse.jdt.core.prefs
index 94d61f00da6..f08be2b06c4 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/META-INF/MANIFEST.MF
index 5b995b3ee28..d3393b74e13 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/META-INF/MANIFEST.MF
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.core.log;bundle-version="1.1.0",
org.eclipse.papyrus.infra.core;bundle-version="1.1.0",
org.eclipse.papyrus.infra.emf;bundle-version="1.1.0",
- org.eclipse.papyrus.infra.services.markerlistener;bundle-version="1.1.0"
+ org.eclipse.papyrus.infra.services.markerlistener;bundle-version="1.1.0",
+ com.google.guava;bundle-version="11.0.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.1.0.qualifier
@@ -25,5 +26,5 @@ Bundle-Activator: org.eclipse.papyrus.infra.services.edit.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.infra.services.edit;singleton
:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/utils/RequestParameterConstants.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/utils/RequestParameterConstants.java
index 6d46c7bc115..e76851a7cff 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/utils/RequestParameterConstants.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/utils/RequestParameterConstants.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011-2012 CEA LIST.
+ * Copyright (c) 2011, 2015 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -7,12 +7,17 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
- * CEA LIST - Initial API and implementation
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 465899
*
*****************************************************************************/
package org.eclipse.papyrus.infra.services.edit.utils;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+
+import com.google.common.base.Defaults;
+
/**
* <pre>
* IDs of request parameters.
@@ -103,11 +108,99 @@ public interface RequestParameterConstants {
* the ID to store the name to be set for the new element.
*/
public final static String NAME_TO_SET = "nameToSet";
-
+
/**
* this constant is used to precise if it is needed to launch UI during the edition of an element
*/
- public static String USE_GUI= "USE_GUI";
-
-
+ public static String USE_GUI = "USE_GUI";
+
+ /**
+ * A boolean-valued parameter for {@link CreateRelationshipRequest} that indicates
+ * whether the creation of the relationship will modify the source element (usually
+ * because it will have an inverse reference to some element of the relationship).
+ * The default value is {@code true} if the parameter is not specified. <b>Note</b>
+ * that this is different from the {@link #AFFECTS_TARGET} parameter.
+ *
+ * @see #AFFECTS_TARGET
+ */
+ public static final String AFFECTS_SOURCE = "papyrus.affectsSource"; //$NON-NLS-1$
+
+ /**
+ * A boolean-valued parameter for {@link CreateRelationshipRequest} that indicates
+ * whether the creation of the relationship will modify the target element (usually
+ * because it will have an inverse reference to some element of the relationship).
+ * The default value is {@code false} if the parameter is not specified. <b>Note</b>
+ * that this is different from the {@link #AFFECTS_SOURCE} parameter.
+ *
+ * @see #AFFECTS_SOURCE
+ */
+ public static final String AFFECTS_TARGET = "papyrus.affectsTarget"; //$NON-NLS-1$
+
+ //
+ // Nested types
+ //
+
+ /**
+ * Provider of default values for request parameters that support them, defined in the
+ * {@link RequestParameterConstants} type.
+ */
+ final class DefaultValues {
+ /**
+ * Obtains the value of a parameter of the given {@code type} from a {@code request},
+ * returning the parameter's default value (if any such is defined) in the case that it
+ * is absent from the request.
+ *
+ * @param request
+ * an edit request
+ * @param parameterName
+ * the name of the parameter to retrieve
+ * @param type
+ * the type of the parameter
+ *
+ * @return the parameter value, its default (if specified) in case it is absent from the
+ * {@code request}, or the {@code type}'s default-default otherwise
+ */
+ public static <T> T getValue(IEditCommandRequest request, String parameterName, Class<T> type) {
+ T result;
+
+ try {
+ if (type == Boolean.class) {
+ Boolean booleanResult = (Boolean) request.getParameter(parameterName);
+ if (booleanResult == null) {
+ booleanResult = defaultBoolean(parameterName);
+ }
+ result = type.cast(booleanResult);
+ } else {
+ result = type.cast(Defaults.defaultValue(type));
+ }
+ } catch (IllegalArgumentException e) {
+ // The parameter doesn't specify a default
+ result = type.cast(Defaults.defaultValue(type));
+ }
+
+ return result;
+ }
+
+ /**
+ * Queries the default value of a boolean-valued request parameter.
+ *
+ * @param parameterName
+ * the boolean-value parameter for which to obtain the default value
+ *
+ * @return the default value
+ *
+ * @throws IllegalArgumentException
+ * if the parameter is not boolean-valued or if it does not have a default value
+ */
+ public static boolean defaultBoolean(String parameterName) {
+ switch (parameterName) {
+ case AFFECTS_SOURCE:
+ return true;
+ case AFFECTS_TARGET:
+ return false;
+ default:
+ throw new IllegalArgumentException("Not a boolean parameter or not defaulted: " + parameterName); //$NON-NLS-1$
+ }
+ }
+ }
}

Back to the top