Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2018-03-30 11:26:41 +0000
committerAnsgar Radermacher2018-04-16 06:26:04 +0000
commit9bb03d919d334eb3b10ad2bbeeb033412da4f3f5 (patch)
tree7334d801ef755e0be3fee12a223f552db973d5ba /plugins/infra
parent224dfa1c661ec52f4b837d272656f69b61b59799 (diff)
downloadorg.eclipse.papyrus-9bb03d919d334eb3b10ad2bbeeb033412da4f3f5.tar.gz
org.eclipse.papyrus-9bb03d919d334eb3b10ad2bbeeb033412da4f3f5.tar.xz
org.eclipse.papyrus-9bb03d919d334eb3b10ad2bbeeb033412da4f3f5.zip
Bug 528199 - [Xtext, Constraints] The edition of constraints does not choose a suitable editor
- Cleanup implementation in DirectEditorsUtil: * Assure that method implementations are consistent and based on each other (before, implementations were duplicated, some respected priorities while others did not), fix comments * Rename getDirectEditorConfiguration (name was misleading, keep old method as deprecated) - Set version of oep.extensionpoints.editors plugin to 3.0.0, adapt all references (other MANIFEST files) accordingly - If no editor with for a given language is found, search all editors without taking language tag into account (implementations must still be compatible with semantic element). This assures that other editors are used, if the default editor is not compatible (e.g. OCL is default editor for opaque expression, but not compatible with non-OCL bodies) - Add an EmbeddedEditor.usecases txt file in plugin oep.extensionpoints.editors - Replace calls to old methods (in diagram.common, property.sheet, uml.diagram.sequence, diagram.stereotype.edition, service.types.ui and natable.xtext.valuespecification/integration) - Move OCL editor registration from generic plugin oep.uml.properties.xtext to OCL plugin. - Add a test to the existing oep.uml.textedit.tests plugin that checks whether a suitable editor is opened on an opaque expression with (1) a C++ body and (2) OCL body (the plugin registers a dummy C++ editor) Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr> Change-Id: I4cee823b91e13f9601ecb7a9655409a74e3d7579
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/EmbedddedEditor.usecases53
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/pom.xml2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/definition/DirectEditorExtensionPoint.java12
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java260
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF2
7 files changed, 147 insertions, 189 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/EmbedddedEditor.usecases b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/EmbedddedEditor.usecases
new file mode 100644
index 00000000000..26cea759b66
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/EmbedddedEditor.usecases
@@ -0,0 +1,53 @@
+Embedded editor use cases
+
+It is sometimes more efficient to use a textual editor to modify a model element, For instance,
+an operation with parameter definitions has a compact textual representation, but it is
+quite time consuming to create all parameters and provide a type when manipulating it on
+the model level. Other elements have an inherent textual representation, notably opaque expressions
+and behaviors. Therefore, Papyrus offers textual editors for these elements.
+
+Use case 1:
+Edit an OCL expression in an opaque expression.
+This can be done by pressing "F2" after selecting either the constraint owning the expression
+or the expression itself. The editor should support completion and syntax highlighting
+to enable the efficient specification.
+Note that the user wants to open an OCL editor on an existing
+expression with OCL content, even if a different editor has been configured as default
+editor for constraints/expressions. Of course, the default editor is chosen on an empty
+opaque expression.
+
+Use case 2:
+The user edits an attribute declaration with a textual editor. The editor allows to set
+name, type, multiplicities and uniqueness. Compared to the first use case, the textual
+representation is a combination of several model elements. The modification might result
+in a non-valid representation, i.e. a text that cannot be represented in the model, for
+instance an unknown type or a non-parseable multiplicity specification. Since this might
+be caused by a single typo, the edited content of an invalid text should not get lost,
+when the user quits the editor. Papyrus manages this situation with a specific stereotype
+storing the text (automatically managed by the editor). Once the specification is corrected
+in the editor, this additional text storage gets removed automatically.
+
+Requirements
+
+* A UML object of a certain kind (i.e. instance of a meta-model element, such
+ as State or Class) has an associated default edtior. This is configurable
+ in the Papyrus preferences ("Embedded Editors"). Technically, the editor
+ is identified using its name as "language".
+
+* Each editor can have additional constraints denoting whether it is eligible
+ to edit a certain element. For instance, it can check whether a certain stereotype
+ is applied. Another typical use case is to check whether opaque expressions
+ or opaque behaviors are either empty or have a body with the "right" language
+ tag.
+
+* Each editor has a priority that is configurable in the Papyrus preferences
+ ("Embedded Editors"). Five different levels are supported:
+ lowest, low, medium, high, highest
+
+* If the user opens a textual editor for a certain UML element, the tool should
+ check first, whether the default is applicable (check eligibility constraints)
+ to the given element. If this is the case, this editor should be opened. If
+ not, it should check whether other editors are eligible and choose the one with
+ the highest priority. If multiple editors with the same priority exist, the
+ first eligitible editor is chosen. This situation should be avoided by
+ choosing the priorities in a suitable way.
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/META-INF/MANIFEST.MF
index 7cb4b98db80..0c5e07c085a 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/META-INF/MANIFEST.MF
@@ -12,7 +12,7 @@ Export-Package: org.eclipse.papyrus.extensionpoints.editors,
org.eclipse.papyrus.extensionpoints.editors.utils
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.papyrus.extensionpoints.editors.Activator
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/pom.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/pom.xml
index f1abafdf698..ee9f67d6511 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/pom.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.extensionpoints.editors</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/definition/DirectEditorExtensionPoint.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/definition/DirectEditorExtensionPoint.java
index a2dd99eafec..85935077a3c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/definition/DirectEditorExtensionPoint.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/definition/DirectEditorExtensionPoint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2018 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
@@ -8,6 +8,7 @@
* Contributors:
* CEA LIST - initial API and implementation
* Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Bug 528199
*
*******************************************************************************/
package org.eclipse.papyrus.extensionpoints.editors.definition;
@@ -125,11 +126,11 @@ public class DirectEditorExtensionPoint implements IDirectEditorExtensionPoint {
* @param class_
* the type of element to edit
* @return the preferred editor configuration for the specified type or <code>null</code>
- * @deprecated Use {@link DirectEditorsUtil#getDefautDirectEditorConfiguration(Object, Object)} instead
+ * @deprecated Use {@link DirectEditorsUtil#getDefaultDirectEditorExtension(Object, Object)} instead
*/
@Deprecated
public DirectEditorExtensionPoint getDefautDirectEditorConfiguration(EObject semanticObjectToEdit, Object selectedObject) {
- return (DirectEditorExtensionPoint) DirectEditorsUtil.getDefautDirectEditorConfiguration(semanticObjectToEdit, selectedObject);
+ return (DirectEditorExtensionPoint) DirectEditorsUtil.getDefaultDirectEditorExtension(semanticObjectToEdit, selectedObject);
}
@@ -141,11 +142,11 @@ public class DirectEditorExtensionPoint implements IDirectEditorExtensionPoint {
* type of element to be edited
* @return the set of transformations registered in the platform for the specified kind of
* element
- * @deprecated Use {@link DirectEditorsUtil#getDirectEditorConfigurations(Object, Object)} instead
+ * @deprecated Use {@link DirectEditorsUtil#getDirectEditorExtensions(Object, Object)} instead
*/
@Deprecated
public Collection<DirectEditorExtensionPoint> getDirectEditorConfigurations(EObject semanticObjectToEdit, Object selectedObject) {
- Collection<IDirectEditorExtensionPoint> directEditorConfigurations = DirectEditorsUtil.getDirectEditorConfigurations(semanticObjectToEdit, selectedObject);
+ Collection<IDirectEditorExtensionPoint> directEditorConfigurations = DirectEditorsUtil.getDirectEditorExtensions(semanticObjectToEdit, selectedObject);
List<DirectEditorExtensionPoint> returnList = new ArrayList<DirectEditorExtensionPoint>();
for (IDirectEditorExtensionPoint extension : directEditorConfigurations) {
@@ -520,5 +521,4 @@ public class DirectEditorExtensionPoint implements IDirectEditorExtensionPoint {
public boolean isSuperType() {
return superType;
}
-
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java
index 4c35398fe41..56306f8cc33 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/ui/DirectEditorsContributionItem.java
@@ -105,7 +105,7 @@ public class DirectEditorsContributionItem extends ContributionItem implements I
}
// retrieves all editor configurations for this kind of element
- final Collection<IDirectEditorExtensionPoint> configurations = DirectEditorsUtil.getDirectEditorConfigurations(businessObject, selectedElement);
+ final Collection<IDirectEditorExtensionPoint> configurations = DirectEditorsUtil.getDirectEditorExtensions(businessObject, selectedElement);
// if configurations is not empty, a submenu should open to select which
// editor to use...
@@ -132,7 +132,7 @@ public class DirectEditorsContributionItem extends ContributionItem implements I
// items on the submenu
// there are as many items as configurations
- final IDirectEditorExtensionPoint defaultConfig = DirectEditorsUtil.getDefautDirectEditorConfiguration(businessObject, selectedElement);
+ final IDirectEditorExtensionPoint defaultConfig = DirectEditorsUtil.getDefaultDirectEditorExtension(businessObject, selectedElement);
for (final IDirectEditorExtensionPoint configuration : configurations) {
MenuItem item = new MenuItem(subMenu, SWT.NONE);
@@ -306,5 +306,4 @@ public class DirectEditorsContributionItem extends ContributionItem implements I
assert (serviceLocator != null);
this.serviceLocator = serviceLocator;
}
-
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java
index 9a3c4005037..5f43cd5f5aa 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
+ * Copyright (c) 2008, 2018 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Remi Schnekenburger (CEA LIST) Remi.Schnekenburger@cea.fr - Initial API and implementation
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Bug 528199
*
*****************************************************************************/
@@ -32,32 +33,21 @@ public class DirectEditorsUtil {
private static final int UNKNOWN_PRIORITY = 100;
/**
- * Finds a editor for specific language and object to edit type
+ * Find an editor configuration for specific language and object to edit
*
* @param language
* the language to edit
- * @param objectToEdit
- * the type of object to edit
- * @return the extension point proxy that manages this kind of editor
- *
- * @deprecated Use {@link #findEditorConfiguration(String language, EObject eObjectToEdit)} instead
+ * @param semanticObjectToEdit
+ * the semantic object to edit
+ * @return the editor configuration
+ * @since 3.0
*/
- @Deprecated
- public static IDirectEditorConfiguration findEditorConfiguration(String language, String objectToEdit) {
- IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations();
- for (IDirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String lang = directEditorExtensionPoint.getLanguage();
- final String oToEdit = directEditorExtensionPoint.getObjectToEdit();
- if (lang.equals(language) && oToEdit.equals(objectToEdit)) {
- // extension point found!
- return directEditorExtensionPoint.getDirectEditorConfiguration();
- }
- }
- return new DefaultDirectEditorConfiguration();
+ public static IDirectEditorConfiguration findEditorConfiguration(String language, EObject objectToEdit) {
+ return findEditorConfiguration(language, objectToEdit, objectToEdit);
}
/**
- * Finds a editor for specific language and object to edit type
+ * Find an editor configuration for specific language and object to edit
*
* @param language
* the language to edit
@@ -65,50 +55,48 @@ public class DirectEditorsUtil {
* the semantic object to edit
* @param selectedElement
* The real selected element (e.g. widget, edit part, ...)
- * @return the extension point proxy that manages this kind of editor
+ * @return the editor configuration
*/
public static IDirectEditorConfiguration findEditorConfiguration(String language, Object semanticObjectToEdit, Object selectedElement) {
- IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations();
- IDirectEditorConfiguration editorConfiguration = new DefaultDirectEditorConfiguration();
- int configurationPriority = UNKNOWN_PRIORITY;
- for (IDirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String lang = directEditorExtensionPoint.getLanguage();
- final Class<? extends EObject> classToEdit = directEditorExtensionPoint.getObjectClassToEdit();
- if (lang.equals(language) && classToEdit.isInstance(semanticObjectToEdit)) {
- IDirectEditorConstraint constraint = directEditorExtensionPoint.getAdditionalConstraint();
- if ((constraint == null || constraint.appliesTo(selectedElement)) && directEditorExtensionPoint.getPriority() < configurationPriority) {
- // extension point found!
- editorConfiguration = directEditorExtensionPoint.getDirectEditorConfiguration();
- configurationPriority = directEditorExtensionPoint.getPriority();
- }
- }
+ IDirectEditorExtensionPoint extension = findEditorExtension(language, semanticObjectToEdit, selectedElement);
+ if (extension != null) {
+ return extension.getDirectEditorConfiguration();
}
- return editorConfiguration;
+ // none found, return default
+ return new DefaultDirectEditorConfiguration();
}
/**
- * finds if an editor for specific language and object is available to edit type
- *
+ * Find an editor extension for a specific language and object to edit
+ *
* @param language
- * the language to edit
- * @param objectToEdit
- * the object to edit
- * @return <code>true</code> if an editor exists
- *
- * @deprecated Use {@link #hasSpecificEditorConfiguration(String language, EObject eObjectToEdit)} instead
+ * the language to edit, if null accept all languages
+ * @param semanticObjectToEdit
+ * the semantic object to edit
+ * @param selectedElement
+ * The real selected element (e.g. widget, edit part, ...)
+ * @return the extension point that manages this kind of editor
+ * @since 3.0
*/
- @Deprecated
- public static boolean hasSpecificEditorConfiguration(String language, String objectToEdit) {
- IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations();
- for (IDirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String lang = directEditorExtensionPoint.getLanguage();
- final String oToEdit = directEditorExtensionPoint.getObjectToEdit();
- if (lang.equals(language) && oToEdit.equals(objectToEdit)) {
- // extension point found!
- return true;
+ public static IDirectEditorExtensionPoint findEditorExtension(String language, Object semanticObjectToEdit, Object selectedElement) {
+ Collection<IDirectEditorExtensionPoint> configs = getDirectEditorExtensions(semanticObjectToEdit, selectedElement);
+
+ IDirectEditorExtensionPoint currentExtension = null;
+ int currentPriority = UNKNOWN_PRIORITY;
+ for (IDirectEditorExtensionPoint extensionPoint : configs) {
+ if ((language == null || language.equals(extensionPoint.getLanguage())) && extensionPoint.getPriority() < currentPriority) {
+ currentExtension = extensionPoint;
+ currentPriority = extensionPoint.getPriority();
}
}
- return false;
+
+ if (currentExtension == null && language != null) {
+ // no extension found, retry without specific language filter. This is useful, since the default editor
+ // might not match, e.g. if you edit an opaque expression with a non-OCL body, the OCL editor should not
+ // be used, see bug 528199
+ return findEditorExtension(null, semanticObjectToEdit, selectedElement);
+ }
+ return currentExtension;
}
/**
@@ -123,47 +111,22 @@ public class DirectEditorsUtil {
* @return <code>true</code> if an editor exists
*/
public static boolean hasSpecificEditorConfiguration(String language, Object semanticObjectToEdit, Object selectedElement) {
- IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations();
- for (IDirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String lang = directEditorExtensionPoint.getLanguage();
- final Class<? extends EObject> classToEdit = directEditorExtensionPoint.getObjectClassToEdit();
- if (lang.equals(language) && classToEdit.isInstance(semanticObjectToEdit)) {
- IDirectEditorConstraint constraint = directEditorExtensionPoint.getAdditionalConstraint();
- if (constraint == null || constraint.appliesTo(selectedElement)) {
- // extension point found!
- return true;
- }
- }
- }
- return false;
+ return findEditorExtension(language, semanticObjectToEdit, selectedElement) != null;
}
/**
- * finds if an editor for specific object is available to edit type
- *
- * @param language
- * the language to edit
+ * finds whether an editor for specific object is available to edit
+ *
* @param objectToEdit
- * the type of object to edit
* @return <code>true</code> if an editor exists
- *
- * @deprecated Use {@link #hasSpecificEditorConfiguration(EObject)} instead
+ * @since 3.0
*/
- @Deprecated
- public static boolean hasSpecificEditorConfiguration(String objectToEdit) {
- IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations();
- for (IDirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String oToEdit = directEditorExtensionPoint.getObjectToEdit();
- if (oToEdit.equals(objectToEdit)) {
- // extension point found!
- return true;
- }
- }
- return false;
+ public static boolean hasSpecificEditorConfiguration(EObject objectToEdit) {
+ return hasSpecificEditorConfiguration(objectToEdit, objectToEdit);
}
/**
- * finds if an editor for specific object is available to edit type
+ * finds whether an editor for a specific object is available to edit
*
* @param language
* the language to edit
@@ -174,122 +137,65 @@ public class DirectEditorsUtil {
* @return <code>true</code> if an editor exists
*/
public static boolean hasSpecificEditorConfiguration(Object semanticObjectToEdit, Object selectedElement) {
- IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations();
- for (IDirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final Class<? extends EObject> classToEdit = directEditorExtensionPoint.getObjectClassToEdit();
- if (classToEdit.isInstance(semanticObjectToEdit)) {
- IDirectEditorConstraint constraint = directEditorExtensionPoint.getAdditionalConstraint();
- if (constraint == null || constraint.appliesTo(selectedElement)) {
- // extension point found!
- return true;
- }
- }
- }
- return false;
+ return getDirectEditorExtensions(semanticObjectToEdit, selectedElement).size() > 0;
}
/**
- * Retrieves the preferred editor configuration for the specified type
+ * Retrieves the preferred editor extension for the specified type
*
* @param class_
* the type of element to edit
- * @return the preferred editor configuration for the specified type or <code>null</code>
+ * @return the preferred editor extension for the specified or <code>null</code>
+ * @since 3.0
*/
- public static IDirectEditorExtensionPoint getDefautDirectEditorConfiguration(Object semanticObjectToEdit, Object selectedObject) {
+ public static IDirectEditorExtensionPoint getDefaultDirectEditorExtension(Object semanticObjectToEdit) {
+ return getDefaultDirectEditorExtension(semanticObjectToEdit, semanticObjectToEdit);
+ }
+
+ /**
+ * Retrieves the preferred editor extension for the specified type
+ *
+ * @param semanticObjectToEdit
+ * the object that should be edited
+ * @param selectedObject
+ * the currently selected object
+ * @return the default editor extension for the passed elements or <code>null</code>
+ * @since 3.0
+ */
+ public static IDirectEditorExtensionPoint getDefaultDirectEditorExtension(Object semanticObjectToEdit, Object selectedObject) {
// retrieves preference for this element
String language = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + semanticObjectToEdit.getClass().asSubclass(EObject.class));
- if (language == null || IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(language)) {
+ if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(language)) {
return null;
}
- IDirectEditorExtensionPoint currentConfiguration = null;
- int currentPriority = UNKNOWN_PRIORITY;
- Collection<IDirectEditorExtensionPoint> configs = getDirectEditorConfigurations(semanticObjectToEdit, selectedObject);
-
- for (IDirectEditorExtensionPoint extensionPoint : configs) {
- if (language.equals(extensionPoint.getLanguage()) && extensionPoint.getPriority() < currentPriority) {
- currentConfiguration = extensionPoint;
- currentPriority = extensionPoint.getPriority();
- }
- }
-
- return currentConfiguration;
+ return findEditorExtension(language, semanticObjectToEdit, selectedObject);
}
/**
- * Returns the set of transformations registered in the platform for the specified kind of
- * element
+ * Return the set of editor extensions registered in the platform for the specified kind of element
*
- * @param the
- * type of element to be edited
- * @return the set of transformations registered in the platform for the specified kind of
- * element
+ * @param semanticObjectToEdit
+ * the object that should be edited
+ * @param selectedObject
+ * the currently selected object
+ * @return the set of editor extension registered in the platform for the specified elements
+ * @since 3.0
*/
- public static Collection<IDirectEditorExtensionPoint> getDirectEditorConfigurations(Object semanticObjectToEdit, Object selectedObject) {
- // list of configuration to be returned. They correspond to
- // configuration to edit the
- // specified type
- final List<IDirectEditorExtensionPoint> elementConfigurations = new ArrayList<IDirectEditorExtensionPoint>();
+ public static Collection<IDirectEditorExtensionPoint> getDirectEditorExtensions(Object semanticObjectToEdit, Object selectedObject) {
+ // list of extension points to be returned.
+ final List<IDirectEditorExtensionPoint> editorExtensionPoints = new ArrayList<IDirectEditorExtensionPoint>();
- // check each configuration in the platform and select corresponding
- // ones.
+ // check each configuration and select those satisfying the constraints
for (IDirectEditorExtensionPoint configuration : DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations()) {
// both class are compatibles ?
if (configuration.getObjectClassToEdit() != null) {
if (configuration.getObjectClassToEdit().isInstance(semanticObjectToEdit)) {
IDirectEditorConstraint constraint = configuration.getAdditionalConstraint();
if (constraint == null || constraint.appliesTo(selectedObject))
- elementConfigurations.add(configuration);
- }
- }
- }
- return elementConfigurations;
- }
-
- /**
- * Finds a editor for specific language and object to edit type with the higher priority.
- *
- * @param language
- * the language to edit
- * @param objectToEdit
- * the type of object to edit
- * @return the extension point proxy that manages this kind of editor
- */
- public static IDirectEditorConfiguration findEditorConfigurationWithPriority(String language, String objectToEdit) {
- IDirectEditorConfiguration result = null;
- int currentPrority = UNKNOWN_PRIORITY;
- IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations();
- for (IDirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String lang = directEditorExtensionPoint.getLanguage();
- final String oToEdit = directEditorExtensionPoint.getObjectToEdit();
- if (lang.equals(language) && oToEdit.equals(objectToEdit)) {
- // extension point found!
- int directEditorExtensionPointPriority = directEditorExtensionPoint.getPriority() != null ? directEditorExtensionPoint.getPriority() : UNKNOWN_PRIORITY;
- if (result == null || (directEditorExtensionPointPriority < currentPrority)) {
- result = directEditorExtensionPoint.getDirectEditorConfiguration();
- currentPrority = directEditorExtensionPointPriority;
+ editorExtensionPoints.add(configuration);
}
}
}
- return result != null ? result : new DefaultDirectEditorConfiguration();
+ return editorExtensionPoints;
}
-
- /**
- * returns the list of languages that are available from extension points
- *
- * @return the list of languages that have an extended editor
- */
- public static List<String> getLanguages(String objectToEdit) {
- List<String> languages = new ArrayList<String>();
- IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getInstance().getDirectEditorConfigurations();
- for (IDirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- if (objectToEdit == null || directEditorExtensionPoint.getObjectToEdit().equals(objectToEdit)) {
- String lang = directEditorExtensionPoint.getLanguage();
- if (!languages.contains(lang)) {
- languages.add(lang);
- }
- }
- }
- return languages;
- }
-
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
index 07d83fe7dd0..29174d98032 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
@@ -16,7 +16,7 @@ Require-Bundle: org.eclipse.papyrus.infra.nattable.model;bundle-version="[4.0.0,
org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.extensionpoints.editors;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)",
org.eclipse.papyrus.infra.nattable.model.edit;bundle-version="[4.0.0,5.0.0)"

Back to the top