diff options
Diffstat (limited to 'plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org')
19 files changed, 195 insertions, 63 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/creation/ExpressionLanguageFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/creation/ExpressionLanguageFactory.java index 81733dab260..b26c5153e5a 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/creation/ExpressionLanguageFactory.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/creation/ExpressionLanguageFactory.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 402525
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.creation;
@@ -85,8 +87,8 @@ public class ExpressionLanguageFactory extends StringEditionFactory { }
@Override
- public Object createObject(Control widget) {
- String languageName = (String)super.createObject(widget);
+ public Object createObject(Control widget, Object context) {
+ String languageName = (String)super.createObject(widget, context);
if(languageName == null) {
return null;
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/creation/MessageValueSpecificationFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/creation/MessageValueSpecificationFactory.java index 9dd2731de73..070f4417d43 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/creation/MessageValueSpecificationFactory.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/creation/MessageValueSpecificationFactory.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 402525
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.creation;
@@ -92,11 +94,8 @@ public class MessageValueSpecificationFactory extends EcorePropertyEditorFactory return result;
}
- /**
- * {@inheritDoc}
- */
@Override
- public Object createObject(Control widget) {
+ protected Object doCreateObject(Control widget, Object context) {
EClass eClass = chooseEClass(widget);
if(eClass == null) {
return null;
@@ -114,7 +113,7 @@ public class MessageValueSpecificationFactory extends EcorePropertyEditorFactory }
}
- return super.createObject(widget, instance);
+ return createObject(widget, context, instance);
}
/**
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypeAppearanceObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypeAppearanceObservableValue.java index ce3d31856d4..f70c0403b32 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypeAppearanceObservableValue.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypeAppearanceObservableValue.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - 402525
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.databinding;
@@ -22,6 +24,7 @@ import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConsta import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.VERTICAL;
import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.IObserving;
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
import org.eclipse.core.internal.databinding.Util;
import org.eclipse.emf.common.notify.Adapter;
@@ -44,7 +47,7 @@ import org.eclipse.uml2.uml.Stereotype; *
* @author Camille Letavernier
*/
-public class StereotypeAppearanceObservableValue extends AbstractObservableValue {
+public class StereotypeAppearanceObservableValue extends AbstractObservableValue implements IObserving {
/**
* The name of the property being observed
@@ -270,11 +273,14 @@ public class StereotypeAppearanceObservableValue extends AbstractObservableValue domain.getCommandStack().execute(command);
}
+ public Object getObserved() {
+ return diagramElement;
+ }
+
/**
* @see org.eclipse.core.databinding.observable.AbstractObservable#dispose()
*
*/
-
@Override
public synchronized void dispose() {
if(diagramElement != null && diagramElementListener != null) {
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypeApplicationObservableList.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypeApplicationObservableList.java index 49e65474e3a..78b252087ad 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypeApplicationObservableList.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypeApplicationObservableList.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - 402525
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.databinding;
@@ -15,6 +17,7 @@ import java.util.Collection; import java.util.LinkedList;
import java.util.List;
+import org.eclipse.core.databinding.observable.IObserving;
import org.eclipse.core.databinding.observable.list.ListDiff;
import org.eclipse.core.databinding.observable.list.ListDiffEntry;
import org.eclipse.core.databinding.observable.list.WritableList;
@@ -38,7 +41,7 @@ import org.eclipse.uml2.uml.Stereotype; *
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
-public class StereotypeApplicationObservableList extends WritableList implements ICommitListener {
+public class StereotypeApplicationObservableList extends WritableList implements ICommitListener, IObserving {
private Element umlSource;
@@ -279,6 +282,10 @@ public class StereotypeApplicationObservableList extends WritableList implements throw new UnsupportedOperationException();
}
+ public Object getObserved() {
+ return umlSource;
+ }
+
@Override
public void dispose() {
super.dispose();
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/expression/ExpressionList.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/expression/ExpressionList.java index 0ff668e7adf..774df66875e 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/expression/ExpressionList.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/expression/ExpressionList.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - 402525
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.expression;
@@ -17,6 +19,7 @@ import java.util.List; import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.IObserving;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
@@ -36,7 +39,7 @@ import org.eclipse.papyrus.infra.widgets.editors.ICommitListener; *
* @author Camille Letavernier
*/
-public class ExpressionList extends WritableList implements IChangeListener, ICommitListener {
+public class ExpressionList extends WritableList implements IChangeListener, ICommitListener, IObserving {
private List<Expression> expressions;
@@ -165,6 +168,13 @@ public class ExpressionList extends WritableList implements IChangeListener, ICo languages.add(language);
}
+
+ public Object getObserved() {
+ return //
+ (languages instanceof IObserving) ? ((IObserving)languages).getObserved() : //
+ (bodies instanceof IObserving) ? ((IObserving)bodies).getObserved() : //
+ null;
+ }
/**
* A helper class to aggregate the expression body and language in a single
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CommentModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CommentModelElement.java index c89b79685ab..da818a1a6a6 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CommentModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CommentModelElement.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Sebastien Poissonnet (CEA LIST) sebastien.poissonnet@cea.fr
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
@@ -68,11 +70,11 @@ public class CommentModelElement extends EMFModelElement { }
@Override
- public boolean isEditable(String propertyPath) {
+ protected boolean isFeatureEditable(String propertyPath) {
if(APPLIED_COMMENTS_PROPERTY.equals(propertyPath)) {
return true;
}
- return super.isEditable(propertyPath);
+ return super.isFeatureEditable(propertyPath);
}
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/MemberEndModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/MemberEndModelElement.java index 7bd9833d571..326e894de72 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/MemberEndModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/MemberEndModelElement.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
@@ -23,6 +25,7 @@ import java.util.List; import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
import org.eclipse.papyrus.uml.properties.Activator;
@@ -119,9 +122,9 @@ public class MemberEndModelElement extends AbstractModelElement { return false;
}
}
- return ((Property)source).getAssociation().getMemberEnds().size() <= 2;
+ return (((Property)source).getAssociation().getMemberEnds().size() <= 2) && !EMFHelper.isReadOnly(source);
}
- return true;
+ return !EMFHelper.isReadOnly(source);
}
private boolean isAssociation(Property property) {
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java index f3f1ae272b0..d8f5bcda7d5 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
@@ -76,4 +78,9 @@ public class ProfileDefinitionModelElement extends AbstractModelElement { public boolean getDirectCreation(String propertyPath) {
return true; //Cannot browse other definitions
}
+
+ @Override
+ public boolean isEditable(String propertyPath) {
+ return !EMFHelper.isReadOnly(profile);
+ }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceModelElement.java index 5da9abffbb4..033b0071f2b 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceModelElement.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
@@ -27,6 +29,7 @@ import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConsta import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
@@ -107,4 +110,8 @@ public class StereotypeAppearanceModelElement extends AbstractModelElement imple return true;
}
+ @Override
+ public boolean isEditable(String propertyPath) {
+ return !EMFHelper.isReadOnly(diagramElement);
+ }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java index 8843c04ca19..94f5a7a61cc 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java @@ -65,6 +65,9 @@ public class StereotypeModelElement extends EMFModelElement { public IObservable doGetObservable(String propertyPath) {
FeaturePath featurePath = getFeaturePath(propertyPath);
EStructuralFeature feature = getFeature(featurePath);
+ if(feature == null) {
+ return super.doGetObservable(propertyPath);
+ }
if(feature.getEType() instanceof EDataType && !(feature.getEType() instanceof EEnum)) {
if(feature.getUpperBound() == 1) {
@@ -89,6 +92,9 @@ public class StereotypeModelElement extends EMFModelElement { @Override
public ILabelProvider getLabelProvider(String propertyPath) {
EStructuralFeature feature = getFeature(propertyPath);
+ if(feature == null) {
+ return super.getLabelProvider(propertyPath);
+ }
if(feature.getEType() instanceof EEnum) {
return super.getLabelProvider(propertyPath);
}
@@ -102,6 +108,10 @@ public class StereotypeModelElement extends EMFModelElement { public IStaticContentProvider getContentProvider(String propertyPath) {
EStructuralFeature feature = getFeature(propertyPath);
+ if(feature == null) {
+ return super.getContentProvider(propertyPath);
+ }
+
return new UMLContentProvider(source, feature, stereotype);
}
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java index 7a4d132cc0a..cef0f90eb28 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
@@ -129,7 +131,7 @@ public class UMLModelElement extends EMFModelElement { }
@Override
- public boolean isEditable(String propertyPath) {
+ protected boolean isFeatureEditable(String propertyPath) {
EStructuralFeature feature = getFeature(propertyPath);
if(feature == UMLPackage.eINSTANCE.getMessage_Signature()) {
return true;
@@ -145,7 +147,7 @@ public class UMLModelElement extends EMFModelElement { return false;
//return true; //TODO : Unsupported yet
}
- return super.isEditable(propertyPath);
+ return super.isFeatureEditable(propertyPath);
}
@Override
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java index d115969535e..c6c680cd2d8 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
@@ -176,4 +178,8 @@ public class UMLNotationModelElement extends AbstractModelElement { return super.isMandatory(propertyPath);
}
+ @Override
+ public boolean isEditable(String propertyPath) {
+ return !EMFHelper.isReadOnly(getEModelElement());
+ }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppearanceForAppliedStereotypeComposite.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppearanceForAppliedStereotypeComposite.java index 24fb4ca48ad..62d808c0e0c 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppearanceForAppliedStereotypeComposite.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositeforview/AppearanceForAppliedStereotypeComposite.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2008 CEA LIST. + * Copyright (c) 2008, 2014 CEA LIST and others. * * * All rights reserved. This program and the accompanying materials @@ -10,6 +10,7 @@ * Contributors: * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification + * Christian W. Damus (CEA) - bug 323802 * *****************************************************************************/ package org.eclipse.papyrus.uml.properties.profile.ui.compositeforview; @@ -25,6 +26,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject; import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper; import org.eclipse.papyrus.uml.profile.Activator; @@ -218,6 +220,12 @@ public class AppearanceForAppliedStereotypeComposite extends org.eclipse.papyrus }); return this; } + + @Override + public boolean isReadOnly() { + EModelElement element = getDiagramElement(); + return (element == null) || EMFHelper.isReadOnly(element); + } /** * Fixed bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=417372 @@ -228,7 +236,7 @@ public class AppearanceForAppliedStereotypeComposite extends org.eclipse.papyrus if(tree == null || tree.isDisposed()) { return; } - boolean enabled = getDiagramElement() != null && !treeViewer.getSelection().isEmpty(); + boolean enabled = (getDiagramElement() != null && !treeViewer.getSelection().isEmpty()) && !isReadOnly(); if(displayButton != null && !displayButton.isDisposed()) { displayButton.setEnabled(enabled); } diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppearanceDecoratedTreeComposite.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppearanceDecoratedTreeComposite.java index ae973dd0084..ca81c7747e8 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppearanceDecoratedTreeComposite.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppearanceDecoratedTreeComposite.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2008 CEA LIST. + * Copyright (c) 2008, 2014 CEA LIST and others. * * * All rights reserved. This program and the accompanying materials @@ -10,12 +10,14 @@ * Contributors: * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification + * Christian W. Damus (CEA) - bug 323802 * *****************************************************************************/ package org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel; import org.eclipse.gef.commands.CommandStack; import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.uml.profile.tree.ProfileElementTreeViewer; import org.eclipse.papyrus.uml.profile.tree.PropertyValueTreeViewer; import org.eclipse.swt.custom.CLabel; @@ -133,6 +135,11 @@ public abstract class AppearanceDecoratedTreeComposite extends Composite impleme public void refresh() { } + public boolean isReadOnly() { + Element element = getElement(); + return (element == null) || EMFHelper.isReadOnly(element); + } + /** * Returns the CommmandStack of the current editor. * diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedProfileCompositeOnModel.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedProfileCompositeOnModel.java index 9dd8446cf9a..ab5020be06e 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedProfileCompositeOnModel.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedProfileCompositeOnModel.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2008, 2013 CEA LIST.
+ * Copyright (c) 2008, 2014 CEA LIST, Atos Origin, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -12,6 +12,7 @@ * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
* Emilien Perico (Atos Origin) - fix bug on refresh
* Christian W. Damus (CEA) - Refactoring package/profile import/apply UI for CDO
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel;
@@ -300,6 +301,8 @@ public class AppliedProfileCompositeOnModel extends Composite { profiles = createProfilesList();
profiles.setVisible(true);
+
+ updateEnablement();
}
/**
@@ -500,6 +503,23 @@ public class AppliedProfileCompositeOnModel extends Composite { }
}
}
+
+ updateEnablement();
+ }
+
+ protected boolean isEditable() {
+ Package currentPackage = getSelectedPackage();
+ return (currentPackage != null) && !EMFHelper.isReadOnly(currentPackage);
+ }
+
+ protected void updateEnablement() {
+ boolean isEditable = isEditable();
+
+ if((addButton != null) && !addButton.isDisposed()) {
+ addButton.setEnabled(isEditable);
+ removeButton.setEnabled(isEditable);
+ addRegisteredButton.setEnabled(isEditable);
+ }
}
/**
@@ -524,6 +544,8 @@ public class AppliedProfileCompositeOnModel extends Composite { */
public void setSelection(ISelection selection) {
this.selectedElement = selection;
+
+ updateEnablement();
}
/**
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java index 812b00961d4..b10aed4ac3c 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
+ * Copyright (c) 2008, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@ * Contributors:
* Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
* Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel;
@@ -287,6 +288,8 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im */
@Override
public void refresh() {
+ super.refresh();
+
if(treeViewer.getTree() != null && !(treeViewer.getTree().isDisposed())) {
treeViewer.setInput(null);
treeViewer.refresh();
@@ -298,10 +301,12 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im return;
}
+ boolean isEditable = isEditable();
+
// If the property is Multivalued show Up - Down
if((rTO.getChildren() != null) && (rTO.getChildren().length > 1)) {
- upButton.setEnabled(true);
- downButton.setEnabled(true);
+ upButton.setEnabled(isEditable);
+ downButton.setEnabled(isEditable);
} else {
upButton.setEnabled(false);
downButton.setEnabled(false);
@@ -310,7 +315,7 @@ public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite im if((rTO.getChildren() != null) && (rTO.getChildren().length == 0)) {
removeButton.setEnabled(false);
} else {
- removeButton.setEnabled(true);
+ removeButton.setEnabled(isEditable);
}
}
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java index 608c1f9f3fd..ce77785961e 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/compositesformodel/DecoratedTreeComposite.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
+ * Copyright (c) 2008, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,12 +10,14 @@ * Contributors:
* Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
* Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.profile.ui.compositesformodel;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.uml.profile.ImageManager;
import org.eclipse.papyrus.uml.profile.tree.ProfileElementTreeViewer;
import org.eclipse.papyrus.uml.profile.tree.PropertyValueTreeViewer;
@@ -144,6 +146,8 @@ public abstract class DecoratedTreeComposite extends Composite implements ISecti */
public void setElement(Element element) {
this.element = element;
+
+ updateEnablement();
}
/**
@@ -265,18 +269,30 @@ public abstract class DecoratedTreeComposite extends Composite implements ISecti data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
tree.setLayoutData(data);
+
+ // initialize enablement of controls
+ updateEnablement();
+
return this;
}
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.composites.ISectionComposite#refresh()
- */
- /**
- *
- */
public void refresh() {
+ updateEnablement();
+ }
+
+ protected boolean isEditable() {
+ return (element != null) && !EMFHelper.isReadOnly(element);
+ }
+
+ protected void updateEnablement() {
+ boolean isEditable = isEditable();
+
+ if((addButton != null) && !addButton.isDisposed()) {
+ addButton.setEnabled(isEditable);
+ removeButton.setEnabled(isEditable);
+ upButton.setEnabled(isEditable);
+ downButton.setEnabled(isEditable);
+ }
}
// /**
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/dialogs/RegisteredProfileSelectionDialog.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/dialogs/RegisteredProfileSelectionDialog.java index 9021d9f0fd0..8c876cdb4ac 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/dialogs/RegisteredProfileSelectionDialog.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/profile/ui/dialogs/RegisteredProfileSelectionDialog.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2008, 2013 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 @@ -17,39 +17,41 @@ package org.eclipse.papyrus.uml.properties.profile.ui.dialogs; import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedList; import java.util.List; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile; import org.eclipse.papyrus.uml.extensionpoints.standard.FilteredRegisteredElementsSelectionDialog; import org.eclipse.papyrus.uml.extensionpoints.utils.Util; -import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileTreeSelectionDialog; import org.eclipse.papyrus.uml.profile.ui.dialogs.ElementImportTreeSelectionDialog.ImportSpec; +import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileTreeSelectionDialog; import org.eclipse.swt.widgets.Composite; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.Profile; /** - * + * */ public class RegisteredProfileSelectionDialog extends FilteredRegisteredElementsSelectionDialog { /** - * + * */ private RegisteredProfile[] regProfiles; /** - * + * */ private Package currentPackage; /** - * - * + * + * * @param umlPackage * @param parent */ @@ -59,8 +61,8 @@ public class RegisteredProfileSelectionDialog extends FilteredRegisteredElements } /** - * - * + * + * * @return */ public List<Profile> run() { @@ -77,21 +79,26 @@ public class RegisteredProfileSelectionDialog extends FilteredRegisteredElements // 0); // dialog.open(); this.open(); - return this.treatSelection(); + List<Profile> profilesToApply = this.treatSelection(); + + List<Profile> result = new LinkedList<Profile>(); + for(Profile profile : profilesToApply) { + result.add(EMFHelper.reloadIntoContext(profile, currentPackage)); + } + return result; } /** - * - * + * + * * @return */ private List<Profile> treatSelection() { // User selection Object[] selection = this.getResult(); - boolean hasChanged = false; - ResourceSet resourceSet = Util.getResourceSet(currentPackage); + ResourceSet resourceSet = Util.getSharedResourceSet(); if(selection == null) { // Cancel was selected return new ArrayList<Profile>(); @@ -146,7 +153,7 @@ public class RegisteredProfileSelectionDialog extends FilteredRegisteredElements if(Dialog.OK == returnValue) { Collection<ImportSpec<Profile>> dlgResult = profileDialog.getResult(); List<Profile> result = new java.util.ArrayList<Profile>(dlgResult.size()); - for (ImportSpec<Profile> next : dlgResult) { + for(ImportSpec<Profile> next : dlgResult) { result.add(next.getElement()); } return result; diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java index 0d92fa6ed33..16e03b2e26a 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2012 Atos.
+ * Copyright (c) 2012, 2014 Atos, CEA, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@ *
* Contributors:
* Mathieu Velten (Atos) mathieu.velten@atos.net - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -212,7 +214,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener, IListChan protected void setValueEditorProperties(AbstractValueEditor editor, EObject stereotypeApplication, EStructuralFeature feature) {
editor.setLabel(feature.getName());
- if(feature.isDerived() || !feature.isChangeable()) {
+ if(!isEditable(stereotypeApplication, feature)) {
editor.setReadOnly(true);
}
@@ -232,7 +234,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener, IListChan editor.setDirectCreation(((EReference)feature).isContainment());
}
- if(feature.isDerived() || !feature.isChangeable()) {
+ if(!isEditable(stereotypeApplication, feature)) {
editor.setReadOnly(true);
}
@@ -243,6 +245,10 @@ public class EStructuralFeatureEditor implements IValueChangeListener, IListChan observable.addListChangeListener(this);
}
+
+ protected boolean isEditable(EObject object, EStructuralFeature feature) {
+ return !feature.isDerived() && feature.isChangeable() && !EMFHelper.isReadOnly(object);
+ }
public void setLayoutData(GridData data) {
pageBook.setLayoutData(data);
|