Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-05-28 11:43:19 +0000
committerArnaud Cuccuru2015-05-29 16:01:54 +0000
commit35f9f74757351a5ad2681d3bb26a23f17aebce91 (patch)
tree5b5707e9d097f463dc0724c48f42daf7f8c79b01 /extraplugins/alf/ui
parent148e46b8fec2946975875765bb1fb5d04fa225a9 (diff)
downloadorg.eclipse.papyrus-35f9f74757351a5ad2681d3bb26a23f17aebce91.tar.gz
org.eclipse.papyrus-35f9f74757351a5ad2681d3bb26a23f17aebce91.tar.xz
org.eclipse.papyrus-35f9f74757351a5ad2681d3bb26a23f17aebce91.zip
[Alf Properties] Fix ClassCastException and clean-up
Change-Id: Ic21acbcf4e2b034e3e1298f78a1d7cca4ad5cb54 Reviewed-on: https://git.eclipse.org/r/48852 Tested-by: Hudson CI Reviewed-by: Jeremie Tatibouet <jeremie.tatibouet@cea.fr> Reviewed-by: Arnaud Cuccuru <arnaud.cuccuru@cea.fr> Tested-by: Arnaud Cuccuru <arnaud.cuccuru@cea.fr>
Diffstat (limited to 'extraplugins/alf/ui')
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF10
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java95
2 files changed, 48 insertions, 57 deletions
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF
index 3c62be446a9..4ae01be3d59 100644
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF
@@ -3,10 +3,6 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.105.0",
org.eclipse.ui.forms;bundle-version="3.6.0",
org.eclipse.ui.views.properties.tabbed;bundle-version="3.6.0",
org.eclipse.emf.ecore;bundle-version="2.9.0",
- org.eclipse.gmf.runtime.common.core;bundle-version="1.7.0",
- org.eclipse.gmf.runtime.common.ui.services;bundle-version="1.7.0",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.7.0",
- org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.7.0",
org.eclipse.papyrus.infra.core;bundle-version="1.1.0",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.0",
org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.1.0",
@@ -24,7 +20,11 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.105.0",
org.eclipse.papyrus.uml.alf.transaction;bundle-version="0.7.0",
org.eclipse.papyrus.uml.alf.text;bundle-version="0.7.0",
org.eclipse.compare,
- org.eclipse.papyrus.uml.alf.preferences;bundle-version="0.7.0"
+ org.eclipse.papyrus.uml.alf.preferences;bundle-version="0.7.0",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.1.0",
+ org.eclipse.emf.edit;bundle-version="2.11.0",
+ org.eclipse.core.runtime;bundle-version="3.11.0",
+ org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.7.0"
Bundle-Vendor: Eclipse Modeling Project
Bundle-ActivationPolicy: lazy
Bundle-Version: 0.7.0.qualifier
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java
index 2d26942bbfa..d2a887c3d46 100644
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java
@@ -1,38 +1,36 @@
/*****************************************************************************
* Copyright (c) 2014 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:
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.alf.properties.xtext.sheet;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.jface.viewers.IFilter;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.alf.preferences.AlfIntegrationPreferencesUtil;
import org.eclipse.papyrus.uml.alf.transaction.observation.listener.filter.FUMLScopeUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.uml2.uml.Element;
-import org.eclipse.papyrus.uml.alf.preferences.AlfIntegrationPreferencesUtil;
/**
* This class constrains the availability of the embedded ALF editor.
- *
+ *
* The ALF editor must only be available when:
- * 1. The selection is a Class (not composite)
- * 2. The selection is an Association
- * 3. The selection is a Signal
- * 4. The selection is a Datatype
- * 5. The selection is an Enumeration
- * 6. The selection is a Package
- * 7. The selection is an Activity
+ * 1. The selection is a Class (not composite)
+ * 2. The selection is an Association
+ * 3. The selection is a Signal
+ * 4. The selection is a Datatype
+ * 5. The selection is an Enumeration
+ * 6. The selection is a Package
+ * 7. The selection is an Activity
*/
public class AlfEditorPropertySectionFilter implements IFilter {
@@ -40,80 +38,73 @@ public class AlfEditorPropertySectionFilter implements IFilter {
* @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object)
*
* @param toTest
- *
+ *
* @return accepted
*/
+ @Override
public boolean select(Object toTest) {
Element element = this.resolveSemanticElement(toTest);
boolean accepted = false;
- if(element!=null &&
- AlfIntegrationPreferencesUtil.isAlfSupportEnabled()){
+ if (element != null &&
+ AlfIntegrationPreferencesUtil.isAlfSupportEnabled()) {
accepted = this.isValidInput(element);
}
return accepted;
}
-
+
/**
* Check the given input and returns true if it is a valid input for the embedded ALF editor
- * false otherwise
- *
+ * false otherwise
+ *
* @param element
- * an input element for ALF embedded editor
- *
+ * an input element for ALF embedded editor
+ *
* @return true if element is accepted as an input false otherwise
*/
- private boolean isValidInput(Element element){
- /*1. First constraint: the element must be modifiable (i.e. not read only)*/
- if(!this.isModifiable(element)){
+ private boolean isValidInput(Element element) {
+ /* 1. First constraint: the element must be modifiable (i.e. not read only) */
+ if (!this.isModifiable(element)) {
return false;
}
- /*2. It should be in the scope supported by the ALF editor*/
- if(FUMLScopeUtil.isClass(element)){
+ /* 2. It should be in the scope supported by the ALF editor */
+ if (FUMLScopeUtil.isClass(element)) {
return true;
- }else if(FUMLScopeUtil.isPackage(element)){
+ } else if (FUMLScopeUtil.isPackage(element)) {
return true;
- }else if(FUMLScopeUtil.isSignal(element)){
+ } else if (FUMLScopeUtil.isSignal(element)) {
return true;
- }else if(FUMLScopeUtil.isEnumeration(element)){
+ } else if (FUMLScopeUtil.isEnumeration(element)) {
return true;
- }else if(FUMLScopeUtil.isDataType(element)){
+ } else if (FUMLScopeUtil.isDataType(element)) {
return true;
- }else if(FUMLScopeUtil.isAssociation(element)){
+ } else if (FUMLScopeUtil.isAssociation(element)) {
return true;
- }else if(FUMLScopeUtil.isActivity(element)){
+ } else if (FUMLScopeUtil.isActivity(element)) {
return true;
- }else if(FUMLScopeUtil.isOperationWithImplementation(element)){
+ } else if (FUMLScopeUtil.isOperationWithImplementation(element)) {
return true;
}
return false;
}
-
- private boolean isModifiable(Element element){
+
+ private boolean isModifiable(Element element) {
Resource resource = element.eResource();
- if(resource != null ){
+ if (resource != null) {
return !EMFHelper.isReadOnly(element);
}
return false;
}
-
+
/**
* From a selection this methods tries to extract the underlying model element
- *
+ *
* @param selectedElement
- * an object selected in the view (e.g., a class in a diagram)
- *
+ * an object selected in the view (e.g., a class in a diagram)
+ *
* @return semanticElement
- * the model element that is under the graphical element (may be null)
+ * the model element that is under the graphical element (may be null)
*/
- private Element resolveSemanticElement(Object selectedElement){
- Element semanticElement = null;
- if (selectedElement instanceof IAdaptable) {
- semanticElement = (Element) ((IAdaptable) selectedElement).getAdapter(EObject.class);
- }
- else if (selectedElement instanceof GraphicalEditPart) {
- GraphicalEditPart part = (GraphicalEditPart) selectedElement;
- semanticElement = (Element)part.resolveSemanticElement();
- }
- return semanticElement;
+ private Element resolveSemanticElement(Object selectedElement) {
+ return UMLUtil.resolveUMLElement(selectedElement);
}
} \ No newline at end of file

Back to the top