Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java342
1 files changed, 171 insertions, 171 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java
index 8c6cb123a05..e0cf96255e1 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java
@@ -1,171 +1,171 @@
-/*****************************************************************************
- * Copyright (c) 2012, 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bug 323802
- * Christian W. Damus - bug 455075
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
-
-import org.eclipse.core.databinding.observable.IObservable;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableList;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableValue;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomEObjectStyleObservableList;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomEObjectStyleObservableValue;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomIntStyleObservableList;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomIntStyleObservableValue;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableList;
-import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableValue;
-import org.eclipse.papyrus.infra.properties.contexts.DataContextElement;
-import org.eclipse.papyrus.infra.properties.contexts.Property;
-import org.eclipse.papyrus.infra.properties.environment.Type;
-import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
-import org.eclipse.papyrus.infra.widgets.creation.StringEditionFactory;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
-
-
-public class CustomStyleModelElement extends EMFModelElement {
-
- private DataContextElement element;
-
- View view;
-
- public CustomStyleModelElement(View source, DataContextElement context) {
- this(source, null, context);
- }
-
- public CustomStyleModelElement(View source, EditingDomain domain, DataContextElement element) {
- super(source, domain);
- this.element = element;
- this.view = source;
- }
-
- protected Property findProperty(String propertyPath) {
- for (Property property : element.getProperties()) {
- if (propertyPath.equals(property.getName())) {
- return property;
- }
- }
- return null;
- }
-
- @Override
- public IObservable doGetObservable(String propertyPath) {
- Property property = findProperty(propertyPath);
- if (property == null) {
- return null;
- }
- if (property.getMultiplicity() == 1) {
- switch (property.getType()) {
- case BOOLEAN:
- return new CustomBooleanStyleObservableValue(view, domain, propertyPath);
- case INTEGER:
- return new CustomIntStyleObservableValue(view, domain, propertyPath);
- case REFERENCE:
- return new CustomEObjectStyleObservableValue(view, domain, propertyPath);
- case STRING:
- return new CustomStringStyleObservableValue(view, domain, propertyPath);
- default:
- return null;
- }
- } else {
- switch (property.getType()) {
- case BOOLEAN:
- return new CustomBooleanStyleObservableList(view, domain, propertyPath);
- case INTEGER:
- return new CustomIntStyleObservableList(view, domain, propertyPath);
- case REFERENCE:
- return new CustomEObjectStyleObservableList(view, domain, propertyPath);
- case STRING:
- return new CustomStringStyleObservableList(view, domain, propertyPath);
- default:
- return null;
- }
- }
- }
-
- @Override
- protected boolean isFeatureEditable(String propertyPath) {
- return findProperty(propertyPath) != null;
- }
-
-
- // TODO: Implement these methods for multivalued properties (XxxListStyle)
-
- @Override
- public IStaticContentProvider getContentProvider(String propertyPath) {
- return super.getContentProvider(propertyPath);
- }
-
- @Override
- public ILabelProvider getLabelProvider(String propertyPath) {
- return super.getLabelProvider(propertyPath);
- }
-
- @Override
- public boolean isOrdered(String propertyPath) {
- return true;
- }
-
- @Override
- public boolean isUnique(String propertyPath) {
- return false;
- }
-
- @Override
- public boolean isMandatory(String propertyPath) {
- return false;
- }
-
- @Override
- public boolean forceRefresh(String propertyPath) {
- return false;
- }
-
- @Override
- public ReferenceValueFactory getValueFactory(String propertyPath) {
- Property property = findProperty(propertyPath);
- if (property == null) {
- return null;
- }
-
- switch (property.getType()) {
- case STRING:
- return new StringEditionFactory();
- case INTEGER:
- case BOOLEAN:
- return null;
- case REFERENCE:
- return null;
- default:
- return null;
- }
- }
-
- @Override
- public Object getDefaultValue(String propertyPath) {
- return null;
- }
-
- @Override
- public boolean getDirectCreation(String propertyPath) {
- Property property = findProperty(propertyPath);
- if (property == null) {
- return false;
- }
-
- return property.getType() != Type.REFERENCE;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ * Christian W. Damus - bug 455075
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
+
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomEObjectStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomEObjectStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomIntStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomIntStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableValue;
+import org.eclipse.papyrus.infra.properties.contexts.DataContextElement;
+import org.eclipse.papyrus.infra.properties.contexts.Property;
+import org.eclipse.papyrus.infra.properties.environment.Type;
+import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement;
+import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
+import org.eclipse.papyrus.infra.widgets.creation.StringEditionFactory;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+
+
+public class CustomStyleModelElement extends EMFModelElement {
+
+ private DataContextElement element;
+
+ View view;
+
+ public CustomStyleModelElement(View source, DataContextElement context) {
+ this(source, null, context);
+ }
+
+ public CustomStyleModelElement(View source, EditingDomain domain, DataContextElement element) {
+ super(source, domain);
+ this.element = element;
+ this.view = source;
+ }
+
+ protected Property findProperty(String propertyPath) {
+ for (Property property : element.getProperties()) {
+ if (propertyPath.equals(property.getName())) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public IObservable doGetObservable(String propertyPath) {
+ Property property = findProperty(propertyPath);
+ if (property == null) {
+ return null;
+ }
+ if (property.getMultiplicity() == 1) {
+ switch (property.getType()) {
+ case BOOLEAN:
+ return new CustomBooleanStyleObservableValue(view, domain, propertyPath);
+ case INTEGER:
+ return new CustomIntStyleObservableValue(view, domain, propertyPath);
+ case REFERENCE:
+ return new CustomEObjectStyleObservableValue(view, domain, propertyPath);
+ case STRING:
+ return new CustomStringStyleObservableValue(view, domain, propertyPath);
+ default:
+ return null;
+ }
+ } else {
+ switch (property.getType()) {
+ case BOOLEAN:
+ return new CustomBooleanStyleObservableList(view, domain, propertyPath);
+ case INTEGER:
+ return new CustomIntStyleObservableList(view, domain, propertyPath);
+ case REFERENCE:
+ return new CustomEObjectStyleObservableList(view, domain, propertyPath);
+ case STRING:
+ return new CustomStringStyleObservableList(view, domain, propertyPath);
+ default:
+ return null;
+ }
+ }
+ }
+
+ @Override
+ protected boolean isFeatureEditable(String propertyPath) {
+ return findProperty(propertyPath) != null;
+ }
+
+
+ // TODO: Implement these methods for multivalued properties (XxxListStyle)
+
+ @Override
+ public IStaticContentProvider getContentProvider(String propertyPath) {
+ return super.getContentProvider(propertyPath);
+ }
+
+ @Override
+ public ILabelProvider getLabelProvider(String propertyPath) {
+ return super.getLabelProvider(propertyPath);
+ }
+
+ @Override
+ public boolean isOrdered(String propertyPath) {
+ return true;
+ }
+
+ @Override
+ public boolean isUnique(String propertyPath) {
+ return false;
+ }
+
+ @Override
+ public boolean isMandatory(String propertyPath) {
+ return false;
+ }
+
+ @Override
+ public boolean forceRefresh(String propertyPath) {
+ return false;
+ }
+
+ @Override
+ public ReferenceValueFactory getValueFactory(String propertyPath) {
+ Property property = findProperty(propertyPath);
+ if (property == null) {
+ return null;
+ }
+
+ switch (property.getType()) {
+ case STRING:
+ return new StringEditionFactory();
+ case INTEGER:
+ case BOOLEAN:
+ return null;
+ case REFERENCE:
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ public Object getDefaultValue(String propertyPath) {
+ return null;
+ }
+
+ @Override
+ public boolean getDirectCreation(String propertyPath) {
+ Property property = findProperty(propertyPath);
+ if (property == null) {
+ return false;
+ }
+
+ return property.getType() != Type.REFERENCE;
+ }
+
+}

Back to the top