Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-08-29 07:49:14 -0400
committercletavernie2012-08-29 07:49:14 -0400
commite681b1e5e12136f8bc815d8efdcd713dce0fd3f4 (patch)
tree268e037a9d2edbbad592811099f290b0975eae31
parentcd4b2dde021dda32f9497d141d21816e09704ac6 (diff)
downloadorg.eclipse.papyrus-e681b1e5e12136f8bc815d8efdcd713dce0fd3f4.tar.gz
org.eclipse.papyrus-e681b1e5e12136f8bc815d8efdcd713dce0fd3f4.tar.xz
org.eclipse.papyrus-e681b1e5e12136f8bc815d8efdcd713dce0fd3f4.zip
335332: [Property View] Papyrus shall provide an extensible property view runtime
https://bugs.eclipse.org/bugs/show_bug.cgi?id=335332 Improve the properties view generation
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties.generation/META-INF/MANIFEST.MF4
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java17
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/providers/DataContextPropertiesContentProvider.java35
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/providers/DataContextPropertiesLabelProvider.java127
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/SelectFieldsPage.java247
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/ecore2datacontext.qvto26
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto2
7 files changed, 355 insertions, 103 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/META-INF/MANIFEST.MF b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/META-INF/MANIFEST.MF
index 281208d5902..3d493556815 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/META-INF/MANIFEST.MF
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/META-INF/MANIFEST.MF
@@ -28,7 +28,9 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.6.1",
org.eclipse.papyrus.infra.tools;bundle-version="0.9.0",
org.eclipse.papyrus.infra.constraints;bundle-version="0.9.0",
org.eclipse.papyrus.infra.emf;bundle-version="0.9.0",
- org.eclipse.m2m.qvt.oml.project;bundle-version="3.1.0"
+ org.eclipse.m2m.qvt.oml.project;bundle-version="3.1.0",
+ org.eclipse.papyrus.customization.properties;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="0.9.0"
Bundle-Vendor: %Bundle-Vendor
Bundle-Version: 0.9.0.qualifier
Bundle-ManifestVersion: 2
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java
index b50a8544eb9..a001aaf3909 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/generators/EcoreGenerator.java
@@ -28,13 +28,13 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.m2m.qvt.oml.BasicModelExtent;
import org.eclipse.m2m.qvt.oml.ModelExtent;
+import org.eclipse.papyrus.customization.properties.generation.Activator;
import org.eclipse.papyrus.customization.properties.generation.messages.Messages;
import org.eclipse.papyrus.customization.properties.generation.wizard.widget.FileChooser;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.contexts.Property;
import org.eclipse.papyrus.views.properties.root.PropertiesRoot;
import org.eclipse.papyrus.views.properties.runtime.ConfigurationManager;
-import org.eclipse.papyrus.customization.properties.generation.Activator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -84,6 +84,10 @@ public class EcoreGenerator extends AbstractQVTGenerator {
public boolean isSelectedSingle(Property property) {
EStructuralFeature feature = getFeature(property);
+ if(feature == null) {
+ return false;
+ }
+
if(feature.isDerived()) {
return false;
}
@@ -94,8 +98,9 @@ public class EcoreGenerator extends AbstractQVTGenerator {
if(feature instanceof EReference) {
EReference reference = (EReference)feature;
- if(reference.isContainer() || reference.isContainment())
+ if(reference.isContainer() || reference.isContainment()) {
return false;
+ }
}
return true;
@@ -166,8 +171,9 @@ public class EcoreGenerator extends AbstractQVTGenerator {
*/
protected EPackage findSubPackage(EPackage currentPackage, String packageName) {
for(EPackage pack : currentPackage.getESubpackages()) {
- if(pack.getName().equals(packageName))
+ if(pack.getName().equals(packageName)) {
return pack;
+ }
}
return null;
}
@@ -199,8 +205,9 @@ public class EcoreGenerator extends AbstractQVTGenerator {
Set<String> validDataTypes = new HashSet<String>(Arrays.asList(new String[]{ "int", "boolean", "float", "double" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
if(feature.getEType() instanceof EDataType) {
- if(validDataTypes.contains(((EDataType)feature.getEType()).getInstanceTypeName()))
+ if(validDataTypes.contains(((EDataType)feature.getEType()).getInstanceTypeName())) {
return true;
+ }
}
if(feature.getEType() instanceof EEnum) {
@@ -220,7 +227,7 @@ public class EcoreGenerator extends AbstractQVTGenerator {
@Override
protected URI getTransformationURI() {
- return URI.createPlatformPluginURI(Activator.PLUGIN_ID+"/transforms/ecore2datacontext.qvto", true); //$NON-NLS-1$
+ return URI.createPlatformPluginURI(Activator.PLUGIN_ID + "/transforms/ecore2datacontext.qvto", true); //$NON-NLS-1$
}
@Override
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/providers/DataContextPropertiesContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/providers/DataContextPropertiesContentProvider.java
new file mode 100644
index 00000000000..85a55864949
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/providers/DataContextPropertiesContentProvider.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.customization.properties.generation.providers;
+
+import java.util.List;
+
+import org.eclipse.papyrus.customization.properties.providers.PropertyContentProvider;
+import org.eclipse.papyrus.views.properties.contexts.Context;
+
+
+public class DataContextPropertiesContentProvider extends PropertyContentProvider {
+
+ private final List<Context> contexts;
+
+ public DataContextPropertiesContentProvider(List<Context> contexts) {
+ super(contexts.get(0));
+ this.contexts = contexts;
+ }
+
+ @Override
+ public Object[] getElements() {
+ //We're only interested in the generated contexts ; not in their dependencies
+ return contexts.toArray();
+ }
+
+}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/providers/DataContextPropertiesLabelProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/providers/DataContextPropertiesLabelProvider.java
new file mode 100644
index 00000000000..a02107818f3
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/providers/DataContextPropertiesLabelProvider.java
@@ -0,0 +1,127 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.customization.properties.generation.providers;
+
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.papyrus.customization.properties.generation.wizard.SelectFieldsPage;
+import org.eclipse.papyrus.customization.properties.providers.ContextLabelProvider;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.views.properties.contexts.Property;
+import org.eclipse.swt.graphics.Image;
+
+public class DataContextPropertiesLabelProvider extends StyledCellLabelProvider {
+
+ private final SelectFieldsPage selectFieldsPage;
+
+ private final ILabelProvider labelProvider;
+
+ public DataContextPropertiesLabelProvider(SelectFieldsPage selectFieldsPage) {
+ this.selectFieldsPage = selectFieldsPage;
+ labelProvider = new ContextLabelProvider();
+ }
+
+ @Override
+ public void update(ViewerCell cell) {
+ Object element = cell.getElement();
+ int columnIndex = cell.getColumnIndex();
+
+ StyledString styleText = getStyledText(element, columnIndex);
+
+ cell.setText(styleText.getString());
+ cell.setStyleRanges(styleText.getStyleRanges());
+ cell.setImage(getImage(element, columnIndex));
+ }
+
+ protected StyledString getStyledText(Object element, int columnIndex) {
+ String text = getText(element, columnIndex);
+
+ if(columnIndex == selectFieldsPage.fieldColumn) {
+ EObject eObject = EMFHelper.getEObject(element);
+ if(!(eObject instanceof Property)) {
+ StyledString styledString = new StyledString(text, StyledString.QUALIFIER_STYLER);
+
+ return styledString;
+ }
+ }
+
+ // if(columnIndex == selectFieldsPage.selectionSingleColumn) {
+ // //Nothing
+ // }
+ //
+ // if(columnIndex == selectFieldsPage.selectionMultipleColumn) {
+ // //Nothing
+ // }
+ //
+ // if(columnIndex == selectFieldsPage.descriptionColumn) {
+ // //Nothing
+ // }
+
+ //Default
+ return new StyledString(text);
+ }
+
+ protected String getText(Object element, int columnIndex) {
+ if(columnIndex == selectFieldsPage.fieldColumn) {
+ return labelProvider.getText(element);
+ }
+
+ // if(columnIndex == selectFieldsPage.selectionSingleColumn) {
+ // //Nothing
+ // }
+ //
+ // if(columnIndex == selectFieldsPage.selectionMultipleColumn) {
+ // //Nothing
+ // }
+
+ if(columnIndex == selectFieldsPage.descriptionColumn) {
+ EObject eObject = EMFHelper.getEObject(element);
+ if(eObject instanceof Property) {
+ String description = ((Property)element).getDescription();
+ if(description != null) {
+ return description.replaceAll("[\n\r]+", "\\\\");
+ }
+
+ return "";
+ }
+ }
+
+ //Default
+ return "";
+ }
+
+ protected Image getImage(Object element, int columnIndex) {
+ if(columnIndex == selectFieldsPage.fieldColumn) {
+ return labelProvider.getImage(element);
+ }
+
+ // if(columnIndex == selectFieldsPage.selectionSingleColumn) {
+ // //Nothing
+ // }
+ //
+ // if(columnIndex == selectFieldsPage.selectionMultipleColumn) {
+ // //Nothing
+ // }
+ //
+ // if(columnIndex == selectFieldsPage.descriptionColumn) {
+ // //Nothing
+ // }
+
+ //Default
+ return null;
+ }
+
+}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/SelectFieldsPage.java b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/SelectFieldsPage.java
index dd211d42082..d100f1f5366 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/SelectFieldsPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/src/org/eclipse/papyrus/customization/properties/generation/wizard/SelectFieldsPage.java
@@ -16,6 +16,10 @@ import java.util.List;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.papyrus.customization.properties.generation.Activator;
import org.eclipse.papyrus.customization.properties.generation.fieldselection.ContextElement;
import org.eclipse.papyrus.customization.properties.generation.fieldselection.FieldSelection;
@@ -24,20 +28,24 @@ import org.eclipse.papyrus.customization.properties.generation.fieldselection.Fi
import org.eclipse.papyrus.customization.properties.generation.fieldselection.PropertyDefinition;
import org.eclipse.papyrus.customization.properties.generation.generators.IGenerator;
import org.eclipse.papyrus.customization.properties.generation.messages.Messages;
+import org.eclipse.papyrus.customization.properties.generation.providers.DataContextPropertiesContentProvider;
+import org.eclipse.papyrus.customization.properties.generation.providers.DataContextPropertiesLabelProvider;
import org.eclipse.papyrus.customization.properties.generation.wizard.widget.TernaryButton;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.views.properties.contexts.Context;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.contexts.DataContextPackage;
import org.eclipse.papyrus.views.properties.contexts.DataContextRoot;
import org.eclipse.papyrus.views.properties.contexts.Property;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.custom.TreeEditor;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
/**
* A WizardPage to choose the fields that will be displayed in the Property view.
@@ -56,10 +64,12 @@ public class SelectFieldsPage extends AbstractCreateContextPage {
private Composite root;
- private Composite fields;
-
private FieldSelection fieldSelection;
+ public int fieldColumn = -1, selectionSingleColumn = -1, selectionMultipleColumn = -1, descriptionColumn = -1;
+
+ private int columnId = 0;
+
/**
* Constructor.
*/
@@ -98,40 +108,87 @@ public class SelectFieldsPage extends AbstractCreateContextPage {
Label label = new Label(root, SWT.NONE);
label.setText(Messages.SelectFieldsPage_availableFields);
- ScrolledComposite scrollableFields = new ScrolledComposite(root, SWT.V_SCROLL | SWT.H_SCROLL);
- scrollableFields.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- scrollableFields.getVerticalBar().setIncrement(10);
+ TreeViewer viewer = new TreeViewer(root, SWT.BORDER);
+ Tree tree = viewer.getTree();
+ tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ tree.setLayout(new TableLayout());
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- fields = new Composite(scrollableFields, SWT.NONE);
- scrollableFields.setContent(fields);
+ fieldColumn = addColumn(tree, Messages.SelectFieldsPage_field, 40, 200);
+ selectionSingleColumn = addColumn(tree, Messages.SelectFieldsPage_displaySingle, 25, 120);
+ selectionMultipleColumn = addColumn(tree, Messages.SelectFieldsPage_displayMultiple, 25, 120);
+ descriptionColumn = addColumn(tree, Messages.SelectFieldsPage_description, 60, 300);
- fields.setLayout(new GridLayout(4, false));
+ tree.setHeaderVisible(true);
- Label fieldLabel = new Label(fields, SWT.NONE);
- Label selectionSingle = new Label(fields, SWT.NONE);
- Label selectionMultiple = new Label(fields, SWT.NONE);
- Label descriptionLabel = new Label(fields, SWT.NONE);
+ viewer.setContentProvider(new DataContextPropertiesContentProvider(contexts));
+ viewer.setLabelProvider(new DataContextPropertiesLabelProvider(this));
+ viewer.setInput(new Object());
- selectionSingle.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
- selectionMultiple.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
- descriptionLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
+ viewer.expandAll();
- fieldLabel.setText(Messages.SelectFieldsPage_field);
- selectionSingle.setText(Messages.SelectFieldsPage_displaySingle);
- selectionMultiple.setText(Messages.SelectFieldsPage_displayMultiple);
- descriptionLabel.setText(Messages.SelectFieldsPage_description);
+ installEditors(viewer);
- for(Context context : contexts) {
- for(DataContextRoot dataContextRoot : context.getDataContexts()) {
- displayFields(dataContextRoot);
- }
+ root.layout();
+ }
+
+ /**
+ * Creates a column in the treeViewer and returns its id
+ */
+ private int addColumn(Tree tree, String label, int weight, int minimumWidth) {
+ TreeColumn column = new TreeColumn(tree, SWT.NONE);
+
+ column.setText(label);
+ column.setResizable(true);
+ ((TableLayout)tree.getLayout()).addColumnData(new ColumnWeightData(weight, minimumWidth));
+
+ return columnId++;
+ }
+
+ private void installEditors(TreeViewer viewer) {
+ Tree tree = viewer.getTree();
+
+ for(TreeItem treeItem : tree.getItems()) {
+ installEditors(treeItem);
}
+ }
- fields.setSize(fields.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ private void installEditors(TreeItem treeItem) {
- root.layout();
- fields.layout();
- scrollableFields.layout();
+ EObject eObject = EMFHelper.getEObject(treeItem.getData());
+ if(eObject instanceof Property) {
+ Property property = (Property)eObject;
+
+ boolean defaultSingleValue = getGenerator().isSelectedSingle(property);
+ boolean defaultMultipleValue = getGenerator().isSelectedMultiple(property);
+
+ PropertyDefinition propertyDefinition = getWizard().getPropertyDefinition(fieldSelection, property);
+
+ IObservableValue singleValue = EMFProperties.value(FieldSelectionPackage.eINSTANCE.getPropertyDefinition_ValueSingle()).observe(propertyDefinition);
+ IObservableValue multipleValue = EMFProperties.value(FieldSelectionPackage.eINSTANCE.getPropertyDefinition_ValueMultiple()).observe(propertyDefinition);
+
+ createTreeEditor(treeItem, selectionSingleColumn, defaultSingleValue, singleValue);
+ createTreeEditor(treeItem, selectionMultipleColumn, defaultMultipleValue, multipleValue);
+ }
+
+ for(TreeItem subItem : treeItem.getItems()) {
+ installEditors(subItem);
+ }
+
+ }
+
+ private void createTreeEditor(TreeItem treeItem, int columnIndex, boolean defaultValue, IObservableValue observable) {
+ Tree tree = treeItem.getParent();
+
+ TernaryButton button = new TernaryButton(tree, defaultValue);
+
+ TreeEditor editor = new TreeEditor(tree);
+ editor.horizontalAlignment = SWT.CENTER;
+ editor.grabHorizontal = true;
+
+ editor.setEditor(button, treeItem, columnIndex);
+
+ button.setObservable(observable);
}
private FieldSelection createNewFieldSelection() {
@@ -177,71 +234,71 @@ public class SelectFieldsPage extends AbstractCreateContextPage {
return element;
}
- private void displayFields(DataContextElement contextElement) {
-
- if(contextElement.getProperties().size() > 0) {
-
- Label separator = new Label(fields, SWT.SEPARATOR | SWT.HORIZONTAL);
- GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
- separator.setLayoutData(data);
-
- Label elementName = new Label(fields, SWT.NONE);
- elementName.setText(contextElement.getName());
- FontData[] fontDatas = elementName.getFont().getFontData();
- for(FontData fontData : fontDatas) {
- fontData.setStyle(SWT.BOLD);
- // fontData.setHeight(fontData.getHeight() + 2);
- }
- elementName.setFont(new Font(elementName.getDisplay(), fontDatas));
-
- data = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
- elementName.setLayoutData(data);
-
- Label separator2 = new Label(fields, SWT.SEPARATOR | SWT.HORIZONTAL);
- data = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
- separator2.setLayoutData(data);
-
- for(Property property : contextElement.getProperties()) {
- Label label = new Label(fields, SWT.NONE);
- label.setText(property.getName());
-
- TernaryButton showSingle = new TernaryButton(fields, getGenerator().isSelectedSingle(property));
- TernaryButton showMultiple = new TernaryButton(fields, getGenerator().isSelectedMultiple(property));
-
- PropertyDefinition propertyDefinition = getWizard().getPropertyDefinition(fieldSelection, property);
-
- IObservableValue singleValue = EMFProperties.value(FieldSelectionPackage.eINSTANCE.getPropertyDefinition_ValueSingle()).observe(propertyDefinition);
- IObservableValue multipleValue = EMFProperties.value(FieldSelectionPackage.eINSTANCE.getPropertyDefinition_ValueMultiple()).observe(propertyDefinition);
-
- showSingle.setObservable(singleValue);
- showMultiple.setObservable(multipleValue);
-
- Label description = new Label(fields, SWT.WRAP);
- String propertyDescription = "";// property.getTooltipText(); //$NON-NLS-1$
- if(propertyDescription == null || propertyDescription.trim().equals("")) { //$NON-NLS-1$
- propertyDescription = Messages.SelectFieldsPage_descriptionNotAvailable;
- description.setAlignment(SWT.CENTER);
- }
- description.setText(propertyDescription);
-
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- label.setLayoutData(data);
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- showSingle.setLayoutData(data);
- data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- showMultiple.setLayoutData(data);
- data = new GridData(SWT.CENTER, SWT.CENTER, true, false);
- data.widthHint = 500;
- description.setLayoutData(data);
- }
- }
-
- if(contextElement instanceof DataContextPackage) {
- DataContextPackage contextPackage = (DataContextPackage)contextElement;
- for(DataContextElement element : contextPackage.getElements()) {
- displayFields(element);
- }
- }
+ private void displayFields(DataContextElement contextElement, TreeViewer treeViewer) {
+
+ // if(contextElement.getProperties().size() > 0) {
+ //
+ // Label separator = new Label(fields, SWT.SEPARATOR | SWT.HORIZONTAL);
+ // GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
+ // separator.setLayoutData(data);
+ //
+ // Label elementName = new Label(fields, SWT.NONE);
+ // elementName.setText(contextElement.getName());
+ // FontData[] fontDatas = elementName.getFont().getFontData();
+ // for(FontData fontData : fontDatas) {
+ // fontData.setStyle(SWT.BOLD);
+ // // fontData.setHeight(fontData.getHeight() + 2);
+ // }
+ // elementName.setFont(new Font(elementName.getDisplay(), fontDatas));
+ //
+ // data = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
+ // elementName.setLayoutData(data);
+ //
+ // Label separator2 = new Label(fields, SWT.SEPARATOR | SWT.HORIZONTAL);
+ // data = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
+ // separator2.setLayoutData(data);
+ //
+ // for(Property property : contextElement.getProperties()) {
+ // Label label = new Label(fields, SWT.NONE);
+ // label.setText(property.getName());
+ //
+ // TernaryButton showSingle = new TernaryButton(fields, getGenerator().isSelectedSingle(property));
+ // TernaryButton showMultiple = new TernaryButton(fields, getGenerator().isSelectedMultiple(property));
+ //
+ // PropertyDefinition propertyDefinition = getWizard().getPropertyDefinition(fieldSelection, property);
+ //
+ // IObservableValue singleValue = EMFProperties.value(FieldSelectionPackage.eINSTANCE.getPropertyDefinition_ValueSingle()).observe(propertyDefinition);
+ // IObservableValue multipleValue = EMFProperties.value(FieldSelectionPackage.eINSTANCE.getPropertyDefinition_ValueMultiple()).observe(propertyDefinition);
+ //
+ // showSingle.setObservable(singleValue);
+ // showMultiple.setObservable(multipleValue);
+ //
+ // Label description = new Label(fields, SWT.WRAP);
+ // String propertyDescription = "";// property.getTooltipText(); //$NON-NLS-1$
+ // if(propertyDescription == null || propertyDescription.trim().equals("")) { //$NON-NLS-1$
+ // propertyDescription = Messages.SelectFieldsPage_descriptionNotAvailable;
+ // description.setAlignment(SWT.CENTER);
+ // }
+ // description.setText(propertyDescription);
+ //
+ // data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ // label.setLayoutData(data);
+ // data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ // showSingle.setLayoutData(data);
+ // data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ // showMultiple.setLayoutData(data);
+ // data = new GridData(SWT.CENTER, SWT.CENTER, true, false);
+ // data.widthHint = 500;
+ // description.setLayoutData(data);
+ // }
+ // }
+ //
+ // if(contextElement instanceof DataContextPackage) {
+ // DataContextPackage contextPackage = (DataContextPackage)contextElement;
+ // for(DataContextElement element : contextPackage.getElements()) {
+ // displayFields(element, treeViewer);
+ // }
+ // }
}
private IGenerator getGenerator() {
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/ecore2datacontext.qvto b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/ecore2datacontext.qvto
index 4d2edc29468..92424c563ef 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/ecore2datacontext.qvto
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/ecore2datacontext.qvto
@@ -10,7 +10,9 @@ main() {
ecore.rootObjects()[EPackage]->map toContext();
}
-mapping EPackage::toContext() : c: Context, root:DataContextRoot{
+mapping EPackage::toContext() : c: Context, root:DataContextRoot when {
+ self.isMainPackage() //Only transform source EPackages ; not their dependencies
+}{
c.name := self.name;
c.dataContexts := root;
c.views := self.eClassifiers->select(e | e.oclIsKindOf(EClass))->map toDataContextElement().viewSingle
@@ -53,7 +55,10 @@ abstract mapping EClassifier::toDataContextElement() : element : DataContextElem
element.name := self.name;
}
-mapping EClass::toDataContextElement() : element : DataContextElement, viewSingle : View, viewMultiple : View inherits EClassifier::toDataContextElement{
+mapping EClass::toDataContextElement() : element : DataContextElement, viewSingle : View, viewMultiple : View inherits EClassifier::toDataContextElement
+when {
+ self.ePackage.isMainPackage() //Only transform Classifiers from source EPackages ; not their dependencies
+}{
element.properties := self.eStructuralFeatures->map toProperty();
element.supertypes := self.eSuperTypes.map toDataContextElement().element;
@@ -72,6 +77,18 @@ mapping EClass::toDataContextElement() : element : DataContextElement, viewSingl
viewMultiple.context := self.getContext();
}
+query EPackage::isMainPackage() : Boolean {
+ return if ecore.rootObjects()->includes(self) then
+ true
+ else
+ if self.eSuperPackage.oclIsUndefined() then
+ false
+ else
+ self.eSuperPackage.isMainPackage()
+ endif
+ endif;
+}
+
mapping EClass::toConstraint(view : View) : SimpleConstraint {
name := "is" + view.name.replace(' ', '');
display := view;
@@ -91,9 +108,14 @@ mapping EStructuralFeature::toProperty() : Property {
name := self.name;
type := self.eType.toType();
multiplicity := if self.upperBound = 1 then 1 else -1 endif;
+ description := self.getGenModelDocumentation();
//multiplicity := self.upperBound;
}
+query EModelElement::getGenModelDocumentation() : String {
+ return self.eAnnotations->select(e | e.source = 'http://www.eclipse.org/emf/2002/GenModel').details->any(entry | entry.key = 'documentation').value;
+}
+
query EClassifier::toType() : Type {
log("Unknown type : "+self.repr());
return null;
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto
index 8bf467e21b2..1969025a9e4 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto
@@ -152,6 +152,8 @@ mapping UML::Property::toProperty() : PropertyContext::Property {
if self.type.isView() then
self.type.oclAsType(Classifier).map toDCElement()
endif;
+
+ description := profile.objectsOfType(UML::Comment)->select(comment | comment.annotatedElement->includes(self))->any(comment | true).body
}
query UML::Type::getType() : PropertyEnvironment::Type {

Back to the top