summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorghillairet2012-01-19 13:12:53 (EST)
committer mgolubev2012-01-19 13:12:53 (EST)
commit0e4a3c5c86390605cd394ce13746860ac24d930c (patch)
tree4948d2304e041e3765a17c8ce1b11f028345b91d
parent219b7ba62171a9ddc901de2b3ee40a729d7404b5 (diff)
downloadorg.eclipse.gmf-tooling-0e4a3c5c86390605cd394ce13746860ac24d930c.zip
org.eclipse.gmf-tooling-0e4a3c5c86390605cd394ce13746860ac24d930c.tar.gz
org.eclipse.gmf-tooling-0e4a3c5c86390605cd394ce13746860ac24d930c.tar.bz2
[#368285] fixed
-rw-r--r--plugins/org.eclipse.gmf.bridge.ui/src/org/eclipse/gmf/internal/bridge/transform/ViewmapProducerWizardPage.java605
-rw-r--r--plugins/org.eclipse.gmf.bridge/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/QVTDiagramGenModelTransformer.java117
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/Identity.qvto96
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto936
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/Map2GenMappings.qvto651
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/ModeledViewmaps.qvto81
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/Navigator.qvto1
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/Viewmaps.qvto317
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/migration/Diff2Qvt.qvto327
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/printer/qvtoprinter.qvto519
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/util/GmfGenUtil.qvto19
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/util/TraceUtil.qvto65
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/audits.gmfmap133
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/compartments_ref_node.gmfmap78
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/ext.model2
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/links.gmfmap96
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/nodes_labels.gmfmap98
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/test-ext.gmfmap333
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/test.ecore84
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/test.genmodel69
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/test.gmfgraph93
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/test.gmfmap328
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/test.gmftool49
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java48
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerTest.java84
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtPaletteTransformationTest.java18
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareAbstractTest.java588
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java431
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonAudtisTest.java9
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonCompartmentRefNodeTest.java9
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonFullTest.java9
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonLinksTest.java9
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonNodeLabelsTest.java9
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformModeledViewmapTest.java110
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformToGenModelOperationTest.java2
36 files changed, 5156 insertions, 1270 deletions
diff --git a/plugins/org.eclipse.gmf.bridge.ui/src/org/eclipse/gmf/internal/bridge/transform/ViewmapProducerWizardPage.java b/plugins/org.eclipse.gmf.bridge.ui/src/org/eclipse/gmf/internal/bridge/transform/ViewmapProducerWizardPage.java
index e5dbf27..fa5280f 100644
--- a/plugins/org.eclipse.gmf.bridge.ui/src/org/eclipse/gmf/internal/bridge/transform/ViewmapProducerWizardPage.java
+++ b/plugins/org.eclipse.gmf.bridge.ui/src/org/eclipse/gmf/internal/bridge/transform/ViewmapProducerWizardPage.java
@@ -1,285 +1,320 @@
-/*
- * Copyright (c) 2006, 2009 Borland Software Corporation
- *
- * 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:
- * Alexander Fedorov (Borland) - initial API and implementation
- * Artem Tikhomirov (Borland) extra controls (templates, transformations)
- */
-package org.eclipse.gmf.internal.bridge.transform;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.CommonPlugin;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.gmf.internal.bridge.ui.Plugin;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.ExpandBar;
-import org.eclipse.swt.widgets.ExpandItem;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/*
- * XXX: duplicates functionality of org.eclipse.gmf.internal.graphdef.codegen.ui.FigureGeneratorOptionsDialog
- */
-class ViewmapProducerWizardPage extends WizardPage {
-
- private boolean myInitingControls;
- private Button generateRCPButton;
- private Button useMapModeButton;
- private Button useRuntimeFiguresButton;
- private Button useModeledViewmapButton;
- private Text templatesPathText;
- private Text qvtoFileControl;
- private Text preReconcileTranfsormText;
- private Text postReconcileTranfsormText;
- private Button radioDGMT;
- private Button radioQVT;
- private Button preReconcileTransformBtn;
- private Button postReconcileTransformBtn;
- private ExpandItem myTemplatePathItem;
- private ExpandItem myTransformsItem;
- private Composite composite;
-
- protected ViewmapProducerWizardPage(String pageName) {
- super(pageName);
- setTitle(Messages.TransformToGenModelWizard_title_options);
- setDescription(Messages.TransformToGenModelWizard_descr_options);
- }
-
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
-
- composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
- createControls(composite);
-
- setControl(composite);
- Dialog.applyDialogFont(composite);
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- initControls();
- validatePage();
- }
- }
-
- private void createControls(Composite result) {
- useMapModeButton = new Button(result, SWT.CHECK);
- useMapModeButton.setText(Messages.ViewmapProducerWizardPage_btn_mapmode);
- useMapModeButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));
- useRuntimeFiguresButton = new Button(result, SWT.CHECK);
- useRuntimeFiguresButton.setText(Messages.ViewmapProducerWizardPage_btn_runtime);
- useRuntimeFiguresButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));
- generateRCPButton = new Button(result, SWT.CHECK);
- generateRCPButton.setText(Messages.ViewmapProducerWizardPage_btn_rcp);
- generateRCPButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));
- useModeledViewmapButton = new Button(composite, SWT.CHECK);
- useModeledViewmapButton.setText(Messages.ViewmapProducerWizardPage_btnUseModeledViewmap_text);
- useModeledViewmapButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));
- SelectionListener selectionListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (generateRCPButton == e.widget) {
- getOperation().getOptions().setGenerateRCP(generateRCPButton.getSelection());
- } else if (useMapModeButton == e.widget) {
- getOperation().getOptions().setUseMapMode(useMapModeButton.getSelection());
- } else if (useRuntimeFiguresButton == e.widget) {
- getOperation().getOptions().setUseRuntimeFigures(useRuntimeFiguresButton.getSelection());
- } else if (useModeledViewmapButton == e.widget) {
- getOperation().getOptions().setInTransformationCodeGen(!useModeledViewmapButton.getSelection());
- }
- validatePage();
- }
- };
- useMapModeButton.addSelectionListener(selectionListener);
- useRuntimeFiguresButton.addSelectionListener(selectionListener);
- generateRCPButton.addSelectionListener(selectionListener);
- useModeledViewmapButton.addSelectionListener(selectionListener);
- createAdvancedControls(result);
- Composite glue = new Composite(result, SWT.NONE);
- glue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- }
-
- private void createAdvancedControls(Composite result) {
- Group parent = new Group(result, SWT.SHADOW_ETCHED_IN);
- parent.setText("Provisional");
- parent.setLayout(new FillLayout());
- parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- ExpandBar c = new ExpandBar(parent, SWT.NONE);
- c.setBackground(parent.getBackground());
- templatesPathText = new Text(c, SWT.SINGLE | SWT.BORDER);
- Listener modifyListener = new Listener() {
- public void handleEvent(Event event) {
- validatePage();
- }
- };
- templatesPathText.addListener(SWT.Modify, modifyListener);
- myTemplatePathItem = new ExpandItem(c, SWT.NONE, 0);
- myTemplatePathItem.setText("GMFGraph dynamic templates");
- myTemplatePathItem.setHeight(templatesPathText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
- myTemplatePathItem.setControl(templatesPathText);
- //
- Composite map2genControls = new Composite(c, SWT.NONE);
- map2genControls.setLayout(new FillLayout(SWT.VERTICAL));
- radioDGMT = new Button(map2genControls, SWT.RADIO);
- radioDGMT.setText("Use Java transformation");
- radioQVT = new Button(map2genControls, SWT.RADIO);
- radioQVT.setText("Use QVTO transformation");
- qvtoFileControl = new Text(map2genControls, SWT.SINGLE | SWT.BORDER);
- qvtoFileControl.addListener(SWT.Modify, modifyListener);
- class EnablementListener implements Listener {
- private final Button myControl;
- private final Control myTarget;
- public EnablementListener(Button control, Control target) {
- assert control != null && target != null;
- myControl = control;
- myTarget = target;
- }
- public void handleEvent(Event event) {
- myTarget.setEnabled(myControl.getSelection());
- }
-
- };
- EnablementListener l = new EnablementListener(radioQVT, qvtoFileControl);
- radioDGMT.addListener(SWT.Selection, l);
- radioQVT.addListener(SWT.Selection, l);
- preReconcileTransformBtn = new Button(map2genControls, SWT.CHECK);
- preReconcileTransformBtn.setText("Extra in-place gmfgen transformation before a reconcile step");
- preReconcileTranfsormText = new Text(map2genControls, SWT.SINGLE | SWT.BORDER);
- postReconcileTransformBtn = new Button(map2genControls, SWT.CHECK);
- postReconcileTransformBtn.setText("Extra in-place gmfgen transformation after a reconcile step");
- postReconcileTranfsormText = new Text(map2genControls, SWT.SINGLE | SWT.BORDER);
- preReconcileTransformBtn.addListener(SWT.Selection, new EnablementListener(preReconcileTransformBtn, preReconcileTranfsormText));
- postReconcileTransformBtn.addListener(SWT.Selection, new EnablementListener(postReconcileTransformBtn, postReconcileTranfsormText));
- preReconcileTranfsormText.addListener(SWT.Modify, modifyListener);
- postReconcileTranfsormText.addListener(SWT.Modify, modifyListener);
- String hint = "Transformation should take single inout parameter of GMFGen model type, e.g.\n\nmodeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');\n\ntransformation %s(inout gmfgenModel : GMFGEN);\n\n main() {...}";
- preReconcileTranfsormText.setToolTipText(String.format(hint, "PreReconcile"));
- postReconcileTranfsormText.setToolTipText(String.format(hint, "PostReconcile"));
- myTransformsItem = new ExpandItem(c, SWT.NONE, 1);
- myTransformsItem.setText("Map to Gen transformation");
- myTransformsItem.setHeight(map2genControls.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
- myTransformsItem.setControl(map2genControls);
- //
- }
-
- void validatePage() {
- if (myInitingControls) {
- return;
- }
- setStatus(Status.OK_STATUS);
- boolean hasLite = TransformOptions.checkLiteOptionPresent();
- if (hasLite) {
- if (!useRuntimeFiguresButton.getSelection() && useMapModeButton.getSelection()) {
- setStatus(Plugin.createInfo(Messages.ViewmapProducerWizardPage_i_not_recommended));
- }
- }
- TransformOptions options = getOperation().getOptions();
- // safe to set option value now as they get flushed into storage only on Wizard.performFinish
- options.setFigureTemplatesPath(checkTextFieldURI(templatesPathText));
- options.setTransformation(checkTextFieldURI(qvtoFileControl));
- options.setPreReconcileTransform(checkTextFieldURI(preReconcileTranfsormText));
- options.setPostReconcileTransform(checkTextFieldURI(postReconcileTranfsormText));
- }
-
- private URL checkTextFieldURI(Text widget) {
- if (!widget.isEnabled()) {
- return null;
- }
- if (widget.getText().trim().length() > 0) {
- try {
- return new URL(guessAndResolvePathURL(widget.getText().trim()));
- } catch (MalformedURLException ex) {
- setStatus(Plugin.createWarning(ex.getMessage()));
- }
- }
- return null;
- }
-
- private void initControls() {
- myInitingControls = true;
- try {
- TransformOptions options = getOperation().getOptions();
- generateRCPButton.setSelection(options.getGenerateRCP());
- useRuntimeFiguresButton.setSelection(options.getUseRuntimeFigures());
- useMapModeButton.setSelection(options.getUseMapMode());
- if (null != options.getFigureTemplatesPath()) {
- templatesPathText.setText(options.getFigureTemplatesPath().toString());
- // reveal the value to avoid confusion.
- // FIXME extract expand bar with template path as separate control and
- // move expand logic there (based on setInitialValue event
- myTemplatePathItem.setExpanded(true);
- }
-
- radioDGMT.setSelection(options.getMainTransformation() == null);
- radioQVT.setSelection(!radioDGMT.getSelection());
- qvtoFileControl.setEnabled(radioQVT.getSelection());
- qvtoFileControl.setText(options.getMainTransformation() != null ? options.getMainTransformation().toString() : ""); //$NON-NLS-1$
- preReconcileTransformBtn.setSelection(options.getPreReconcileTransform() != null);
- preReconcileTranfsormText.setEnabled(preReconcileTransformBtn.getSelection());
- preReconcileTranfsormText.setText(options.getPreReconcileTransform() != null ? options.getPreReconcileTransform().toString() : ""); //$NON-NLS-1$
- postReconcileTransformBtn.setSelection(options.getPostReconcileTransform() != null);
- postReconcileTranfsormText.setEnabled(postReconcileTransformBtn.getSelection());
- postReconcileTranfsormText.setText(options.getPostReconcileTransform() != null ? options.getPostReconcileTransform().toString() : ""); //$NON-NLS-1$
- if (radioQVT.getSelection() || preReconcileTransformBtn.getSelection() || postReconcileTransformBtn.getSelection()) {
- myTransformsItem.setExpanded(true);
- }
- } finally {
- myInitingControls = false;
- }
- }
-
- private TransformToGenModelOperation getOperation() {
- return ((TransformToGenModelWizard) getWizard()).getTransformOperation();
- }
-
- private void setStatus(IStatus s) {
- if (s.isOK()) {
- setMessage(null);
- setPageComplete(true);
- } else {
- setMessage(s.getMessage(), IMessageProvider.INFORMATION);
- setPageComplete(s.getSeverity() < IStatus.WARNING);
- }
- }
-
- private static String guessAndResolvePathURL(String path) {
- assert path != null;
- if (path.indexOf(':') == -1) {
- try {
- URI templatesURI = URI.createPlatformResourceURI(path, true);
- return templatesURI.toString();
- } catch (IllegalArgumentException ex) {
- // IGNORE. URI#validate throws IAE if path is incorrect, e.g. once user typed in "platform:" - opaquePart is illegal
- }
- }
- return path;
- }
-}
+/*
+ * Copyright (c) 2006, 2009 Borland Software Corporation
+ *
+ * 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:
+ * Alexander Fedorov (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) extra controls (templates, transformations)
+ */
+package org.eclipse.gmf.internal.bridge.transform;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.gmf.internal.bridge.ui.Plugin;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.ExpandBar;
+import org.eclipse.swt.widgets.ExpandItem;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/*
+ * XXX: duplicates functionality of org.eclipse.gmf.internal.graphdef.codegen.ui.FigureGeneratorOptionsDialog
+ */
+class ViewmapProducerWizardPage extends WizardPage {
+
+ private boolean myInitingControls;
+
+ private Button generateRCPButton;
+
+ private Button useMapModeButton;
+
+ private Button useRuntimeFiguresButton;
+
+ private Button useModeledViewmapButton;
+
+ private Text templatesPathText;
+
+ private Text qvtoFileControl;
+
+ private Text preReconcileTranfsormText;
+
+ private Text postReconcileTranfsormText;
+
+ private Button radioDGMT;
+
+ private Button radioQVT;
+
+ private Button preReconcileTransformBtn;
+
+ private Button postReconcileTransformBtn;
+
+ private ExpandItem myTemplatePathItem;
+
+ private ExpandItem myTransformsItem;
+
+ private Composite composite;
+
+ protected ViewmapProducerWizardPage(String pageName) {
+ super(pageName);
+ setTitle(Messages.TransformToGenModelWizard_title_options);
+ setDescription(Messages.TransformToGenModelWizard_descr_options);
+ }
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ createControls(composite);
+
+ setControl(composite);
+ Dialog.applyDialogFont(composite);
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ initControls();
+ validatePage();
+ }
+ }
+
+ private void createControls(Composite result) {
+ useMapModeButton = new Button(result, SWT.CHECK);
+ useMapModeButton.setText(Messages.ViewmapProducerWizardPage_btn_mapmode);
+ useMapModeButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));
+
+ useRuntimeFiguresButton = new Button(result, SWT.CHECK);
+ useRuntimeFiguresButton.setText(Messages.ViewmapProducerWizardPage_btn_runtime);
+ useRuntimeFiguresButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));
+
+ generateRCPButton = new Button(result, SWT.CHECK);
+ generateRCPButton.setText(Messages.ViewmapProducerWizardPage_btn_rcp);
+ generateRCPButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));
+
+ useModeledViewmapButton = new Button(composite, SWT.CHECK);
+ useModeledViewmapButton.setText(Messages.ViewmapProducerWizardPage_btnUseModeledViewmap_text);
+ useModeledViewmapButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));
+
+ SelectionListener selectionListener = new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (generateRCPButton == e.widget) {
+ getOperation().getOptions().setGenerateRCP(generateRCPButton.getSelection());
+ } else if (useMapModeButton == e.widget) {
+ getOperation().getOptions().setUseMapMode(useMapModeButton.getSelection());
+ } else if (useRuntimeFiguresButton == e.widget) {
+ getOperation().getOptions().setUseRuntimeFigures(useRuntimeFiguresButton.getSelection());
+ } else if (useModeledViewmapButton == e.widget) {
+ getOperation().getOptions().setInTransformationCodeGen(!useModeledViewmapButton.getSelection());
+ }
+ validatePage();
+ }
+ };
+
+ useMapModeButton.addSelectionListener(selectionListener);
+ useRuntimeFiguresButton.addSelectionListener(selectionListener);
+ generateRCPButton.addSelectionListener(selectionListener);
+ useModeledViewmapButton.addSelectionListener(selectionListener);
+
+ createAdvancedControls(result);
+ Composite glue = new Composite(result, SWT.NONE);
+ glue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ }
+
+ private void createAdvancedControls(Composite result) {
+ Group parent = new Group(result, SWT.SHADOW_ETCHED_IN);
+ parent.setText("Provisional");
+ parent.setLayout(new FillLayout());
+ parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ ExpandBar c = new ExpandBar(parent, SWT.NONE);
+ c.setBackground(parent.getBackground());
+ templatesPathText = new Text(c, SWT.SINGLE | SWT.BORDER);
+ Listener modifyListener = new Listener() {
+
+ public void handleEvent(Event event) {
+ validatePage();
+ }
+ };
+ templatesPathText.addListener(SWT.Modify, modifyListener);
+ myTemplatePathItem = new ExpandItem(c, SWT.NONE, 0);
+ myTemplatePathItem.setText("GMFGraph dynamic templates");
+ myTemplatePathItem.setHeight(templatesPathText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+ myTemplatePathItem.setControl(templatesPathText);
+ //
+ Composite map2genControls = new Composite(c, SWT.NONE);
+ map2genControls.setLayout(new FillLayout(SWT.VERTICAL));
+ radioDGMT = new Button(map2genControls, SWT.RADIO);
+ radioDGMT.setText("Use Java transformation");
+
+ radioQVT = new Button(map2genControls, SWT.RADIO);
+ radioQVT.setText("Use QVTO transformation");
+
+ qvtoFileControl = new Text(map2genControls, SWT.SINGLE | SWT.BORDER);
+ qvtoFileControl.addListener(SWT.Modify, modifyListener);
+
+ class EnablementListener implements Listener {
+
+ private final Button myControl;
+
+ private final Control myTarget;
+
+ public EnablementListener(Button control, Control target) {
+ assert control != null && target != null;
+ myControl = control;
+ myTarget = target;
+ }
+
+ public void handleEvent(Event event) {
+ myTarget.setEnabled(myControl.getSelection());
+
+ if (myControl == radioQVT && !myControl.getSelection()) {
+ TransformOptions options = getOperation().getOptions();
+ options.setTransformation(null);
+ }
+ }
+
+ };
+
+ EnablementListener l = new EnablementListener(radioQVT, qvtoFileControl);
+ radioDGMT.addListener(SWT.Selection, l);
+ radioQVT.addListener(SWT.Selection, l);
+ preReconcileTransformBtn = new Button(map2genControls, SWT.CHECK);
+ preReconcileTransformBtn.setText("Extra in-place gmfgen transformation before a reconcile step");
+ preReconcileTranfsormText = new Text(map2genControls, SWT.SINGLE | SWT.BORDER);
+ postReconcileTransformBtn = new Button(map2genControls, SWT.CHECK);
+ postReconcileTransformBtn.setText("Extra in-place gmfgen transformation after a reconcile step");
+ postReconcileTranfsormText = new Text(map2genControls, SWT.SINGLE | SWT.BORDER);
+ preReconcileTransformBtn.addListener(SWT.Selection, new EnablementListener(preReconcileTransformBtn, preReconcileTranfsormText));
+ postReconcileTransformBtn.addListener(SWT.Selection, new EnablementListener(postReconcileTransformBtn, postReconcileTranfsormText));
+ preReconcileTranfsormText.addListener(SWT.Modify, modifyListener);
+ postReconcileTranfsormText.addListener(SWT.Modify, modifyListener);
+ String hint = "Transformation should take single inout parameter of GMFGen model type, e.g.\n\nmodeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');\n\ntransformation %s(inout gmfgenModel : GMFGEN);\n\n main() {...}";
+ preReconcileTranfsormText.setToolTipText(String.format(hint, "PreReconcile"));
+ postReconcileTranfsormText.setToolTipText(String.format(hint, "PostReconcile"));
+ myTransformsItem = new ExpandItem(c, SWT.NONE, 1);
+ myTransformsItem.setText("Map to Gen transformation");
+ myTransformsItem.setHeight(map2genControls.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+ myTransformsItem.setControl(map2genControls);
+ //
+ }
+
+ void validatePage() {
+ if (myInitingControls) {
+ return;
+ }
+ setStatus(Status.OK_STATUS);
+ boolean hasLite = TransformOptions.checkLiteOptionPresent();
+ if (hasLite) {
+ if (!useRuntimeFiguresButton.getSelection() && useMapModeButton.getSelection()) {
+ setStatus(Plugin.createInfo(Messages.ViewmapProducerWizardPage_i_not_recommended));
+ }
+ }
+ TransformOptions options = getOperation().getOptions();
+ // safe to set option value now as they get flushed into storage only on Wizard.performFinish
+ options.setFigureTemplatesPath(checkTextFieldURI(templatesPathText));
+ options.setTransformation(checkTextFieldURI(qvtoFileControl));
+ options.setPreReconcileTransform(checkTextFieldURI(preReconcileTranfsormText));
+ options.setPostReconcileTransform(checkTextFieldURI(postReconcileTranfsormText));
+ }
+
+ private URL checkTextFieldURI(Text widget) {
+ if (!widget.isEnabled()) {
+ return null;
+ }
+ if (widget.getText().trim().length() > 0) {
+ try {
+ return new URL(guessAndResolvePathURL(widget.getText().trim()));
+ } catch (MalformedURLException ex) {
+ setStatus(Plugin.createWarning(ex.getMessage()));
+ }
+ }
+ return null;
+ }
+
+ private void initControls() {
+ myInitingControls = true;
+ try {
+ TransformOptions options = getOperation().getOptions();
+ generateRCPButton.setSelection(options.getGenerateRCP());
+ useRuntimeFiguresButton.setSelection(options.getUseRuntimeFigures());
+ useMapModeButton.setSelection(options.getUseMapMode());
+ if (null != options.getFigureTemplatesPath()) {
+ templatesPathText.setText(options.getFigureTemplatesPath().toString());
+ // reveal the value to avoid confusion.
+ // FIXME extract expand bar with template path as separate control and
+ // move expand logic there (based on setInitialValue event
+ myTemplatePathItem.setExpanded(true);
+ }
+
+ radioDGMT.setSelection(options.getMainTransformation() == null);
+ radioQVT.setSelection(!radioDGMT.getSelection());
+ qvtoFileControl.setEnabled(radioQVT.getSelection());
+ qvtoFileControl.setText(options.getMainTransformation() != null ? options.getMainTransformation().toString() : ""); //$NON-NLS-1$
+ preReconcileTransformBtn.setSelection(options.getPreReconcileTransform() != null);
+ preReconcileTranfsormText.setEnabled(preReconcileTransformBtn.getSelection());
+ preReconcileTranfsormText.setText(options.getPreReconcileTransform() != null ? options.getPreReconcileTransform().toString() : ""); //$NON-NLS-1$
+ postReconcileTransformBtn.setSelection(options.getPostReconcileTransform() != null);
+ postReconcileTranfsormText.setEnabled(postReconcileTransformBtn.getSelection());
+ postReconcileTranfsormText.setText(options.getPostReconcileTransform() != null ? options.getPostReconcileTransform().toString() : ""); //$NON-NLS-1$
+ if (radioQVT.getSelection() || preReconcileTransformBtn.getSelection() || postReconcileTransformBtn.getSelection()) {
+ myTransformsItem.setExpanded(true);
+ }
+ } finally {
+ myInitingControls = false;
+ }
+ }
+
+ private TransformToGenModelOperation getOperation() {
+ return ((TransformToGenModelWizard) getWizard()).getTransformOperation();
+ }
+
+ private void setStatus(IStatus s) {
+ if (s.isOK()) {
+ setMessage(null);
+ setPageComplete(true);
+ } else {
+ setMessage(s.getMessage(), IMessageProvider.INFORMATION);
+ setPageComplete(s.getSeverity() < IStatus.WARNING);
+ }
+ }
+
+ private static String guessAndResolvePathURL(String path) {
+ assert path != null;
+ if (path.indexOf(':') == -1) {
+ try {
+ URI templatesURI = URI.createPlatformResourceURI(path, true);
+ return templatesURI.toString();
+ } catch (IllegalArgumentException ex) {
+ // IGNORE. URI#validate throws IAE if path is incorrect, e.g. once user typed in "platform:" - opaquePart is illegal
+ }
+ }
+ return path;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.bridge/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.bridge/META-INF/MANIFEST.MF
index 45b2949..2103d1c 100644
--- a/plugins/org.eclipse.gmf.bridge/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.gmf.bridge/META-INF/MANIFEST.MF
@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.gmf.codegen;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.gmf.runtime.notation;bundle-version="[1.0.0,2.0.0)";visibility:=reexport,
org.eclipse.gmf.graphdef.codegen;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.draw2d;bundle-version="[3.2.0,4.0.0)"
+ org.eclipse.draw2d;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.m2m.qvt.oml;bundle-version="[3.0.0,4.0.0)"
Export-Package: org.eclipse.gmf.internal.bridge;x-friends:="org.eclipse.gmf.tests,org.eclipse.gmf.bridge.trace,org.eclipse.gmf.codegen.ui,org.eclipse.gmf.bridge.ui",
org.eclipse.gmf.internal.bridge.genmodel;x-friends:="org.eclipse.gmf.tests,org.eclipse.gmf.codegen.ui,org.eclipse.gmf.tests.lite,org.eclipse.gmf.bridge.ui",
org.eclipse.gmf.internal.bridge.naming;x-friends:="org.eclipse.gmf.tests",
diff --git a/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/QVTDiagramGenModelTransformer.java b/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/QVTDiagramGenModelTransformer.java
new file mode 100644
index 0000000..41a8222
--- /dev/null
+++ b/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/QVTDiagramGenModelTransformer.java
@@ -0,0 +1,117 @@
+package org.eclipse.gmf.internal.bridge.genmodel;
+
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.mappings.Mapping;
+import org.eclipse.m2m.internal.qvt.oml.InternalTransformationExecutor;
+import org.eclipse.m2m.internal.qvt.oml.trace.Trace;
+import org.eclipse.m2m.qvt.oml.BasicModelExtent;
+import org.eclipse.m2m.qvt.oml.ExecutionContext;
+import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
+import org.eclipse.m2m.qvt.oml.ModelExtent;
+
+/**
+ * @since 2.0
+ */
+@SuppressWarnings("restriction")
+public class QVTDiagramGenModelTransformer {
+
+ private Trace myTrace;
+ private final URI transfURI = URI.createURI("platform:/plugin/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto");
+ private final ResourceSet resourceSet;
+ private Registry registry;
+
+ public QVTDiagramGenModelTransformer(ResourceSet resourceSet) {
+ this.resourceSet = resourceSet;
+ }
+
+ public ExecutionDiagnostic transform(final Mapping m, final GenModel genModel, final ModelExtent output, final ExecutionContext context) {
+ final Resource trace = m.eResource() == null ? resourceSet.createResource(URI.createURI("trace.qvtotrace")) : resourceSet.createResource(
+ m.eResource().getURI().trimFileExtension().appendFileExtension("qvtotrace"));
+
+ final InternalTransformationExecutor executor = new InternalTransformationExecutor(transfURI) {
+ @Override
+ protected void handleExecutionTraces(Trace traces) {
+ super.handleExecutionTraces(traces);
+ trace.getContents().add(traces);
+ }
+ };
+ RuntimeGenModelAccess runtimeAccess = new RuntimeGenModelAccess();
+ runtimeAccess.ensure();
+
+ final ExecutionDiagnostic result = executor.execute(context,
+ getModelExtent(m),
+ getModelExtent(genModel),
+ getModelExtent(runtimeAccess.genPackage().getGenModel()),
+ output);
+
+ this.myTrace = trace.getContents().isEmpty() ? null : (Trace) trace.getContents().get(0);
+
+ return result;
+ }
+
+ public void setRegistry(EPackage.Registry registry) {
+ this.registry = registry;
+ }
+
+ public ExecutionDiagnostic transform(final Mapping m, final GenModel genModel, ModelExtent output, final ExecutionContext context, final URI... extensions) {
+ ExecutionDiagnostic result = transform(m, genModel, output, context);
+ if (Diagnostic.OK != result.getSeverity()) {
+ return result;
+ }
+
+ GenEditorGenerator outputGenModel = null;
+ if (output.getContents().size() == 1 && output.getContents().get(0) instanceof GenEditorGenerator) {
+ outputGenModel = (GenEditorGenerator) output.getContents().get(0);
+ }
+ if (outputGenModel == null) {
+ return result;
+ }
+// final QvtBridgeExtensionContentAdapter adapter = new QvtBridgeExtensionContentAdapter();
+// outputGenModel.eAdapters().add(adapter);
+ output = getModelExtent(outputGenModel);
+ for (URI extension: extensions) {
+ final InternalTransformationExecutor exec = registry == null ?
+ new InternalTransformationExecutor(extension) : new InternalTransformationExecutor(extension, registry);
+ exec.loadTransformation();
+
+// adapter.errors().clear();
+ if (1 == exec.getTransformation().getModelParameter().size()) {
+ result = exec.execute(context, output);
+ } else {
+ result = exec.execute(context, getModelExtent(m), getModelExtent(myTrace), output);
+ }
+
+// if (!adapter.errors().isEmpty()) {
+// result = new ExecutionDiagnosticImpl(
+// Diagnostic.ERROR,
+// 0,
+// "Extension transformation should not modify already set values",
+// adapter.errors().toArray()
+// );
+// return result;
+// }
+ }
+
+ return result;
+ }
+
+ public Trace getTrace() {
+ return myTrace;
+ }
+
+ private BasicModelExtent getModelExtent(EObject rootObject) {
+ final EList<EObject> mapObjects = new BasicEList<EObject>();
+ mapObjects.add(rootObject);
+ return new BasicModelExtent(mapObjects);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/Identity.qvto b/plugins/org.eclipse.gmf.bridge/transforms/Identity.qvto
index 6d8acef..33eee0e 100644
--- a/plugins/org.eclipse.gmf.bridge/transforms/Identity.qvto
+++ b/plugins/org.eclipse.gmf.bridge/transforms/Identity.qvto
@@ -9,14 +9,21 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
*/
+import Map2GenMappings;
+
modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings');
modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
modeltype GMFGRAPH uses gmfgraph('http://www.eclipse.org/gmf/2006/GraphicalDefinition');
modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
+-- modeltype TRACE uses trace('http://www.eclipse.org/gmf/2006/Trace');
-transformation Identity(in mapModel : GMFMAP, inout gmfgenModel : GMFGEN);
+--import gmf.TraceModelFacade;
-main() {}
+library Identity;
+
+--main() {
+-- mapModel.rootObjects()![GMFMAP::Mapping].visualIdentity();
+--}
-- *************************************************************************************
-- Visual ID
@@ -29,7 +36,92 @@ property nodeLabelID: Integer = 5000;
property linkLabelID: Integer = 6000;
property compartmentID: Integer = 7000;
+-- *************************************************************************************
+-- Visual Identity
+-- *************************************************************************************
+
+property labelNodes: Sequence(LabelMapping) = Sequence{};
+
+--
+-- Visual IDs are set by traversing the model tree from top to bottom.
+--
+helper GMFMAP::Mapping::visualIdentity() {
+ self.diagram.resolveone(GenDiagram).visualID := 1000;
+
+ self.nodes->collect(e |
+ if e.resolveone(GenTopLevelNode).visualID = 0 then {
+ e.resolveone(GenTopLevelNode).visualID := topNodeID();
+ e.child.children->collect(visualIdentity());
+ e.child.labelMappings->collect(visualIdentity(e));
+ } endif
+ );
+
+ self.links->collect(visualIdentity());
+
+ self.getCompartments()->collect(e | e.c.visualIdentity(e.n, e.r));
+
+ return null;
+}
+
+helper GMFMAP::ChildReference::visualIdentity() {
+ var node := self.findProcessableChildReference();
+ if not node.oclIsUndefined() then
+ if node.map structure(node.child).visualID = 0 then {
+ if not node.referencedChild.oclIsUndefined() then
+ node.map structure(node.child).visualID := childNodeID()
+ else {
+ node.map structure(node.child).visualID := childNodeID();
+ node.child.children->collect(e |
+ if e.needVisualID() then e.visualIdentity() endif
+ );
+ } endif;
+ node.map structure(node.child).labels->collect(e | visualIdentity(e));
+ -- node.child.labelMappings->collect(visualIdentity(node));
+ } endif
+ endif
+}
+
+query ChildReference::needVisualID(): Boolean {
+ var node := self.findProcessableChildReference();
+ return
+ if node.oclIsUndefined() then false else
+ node.map structure(node.child).visualID = 0
+ endif
+}
+
+helper visualIdentity(inout genNode: GMFGEN::GenNodeLabel) {
+ if genNode.visualID = 0 then
+ genNode.visualID := nodeLabelID()
+ endif;
+}
+
+helper GMFMAP::LabelMapping::visualIdentity(node: GMFMAP::NodeReference) {
+ if self.map createNodeLabel(node).visualID = 0 then
+ self.map createNodeLabel(node).visualID := nodeLabelID()
+ endif;
+}
+
+helper visualIdentity(inout label: GenLinkLabel) {
+ if label.visualID = 0 then
+ label.visualID := linkLabelID()
+ endif;
+}
+
+helper GMFMAP::LinkMapping::visualIdentity() {
+ if self.map structure().visualID = 0 then {
+ self.map structure().visualID := linkNodeID();
+ self.map structure().labels->collect(e | visualIdentity(e))
+ } endif;
+}
+
+helper GMFMAP::CompartmentMapping::visualIdentity(_mapping: NodeMapping, node: NodeReference) {
+ if self.map structure(_mapping, node).visualID = 0 then
+ self.map structure(_mapping, node).visualID := compartmentID()
+ endif
+}
+
helper topNodeID(): Integer {
+ var nodeID :=
topNodeID := this.topNodeID + 1;
return this.topNodeID;
}
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto b/plugins/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto
index 270f189..209486a 100644
--- a/plugins/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto
+++ b/plugins/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto
@@ -11,18 +11,18 @@
*/
-- import transformations. To be replaced with access keyword, once supported
import Map2GenUtil;
+import Map2GenMappings;
import DiagramRunTimeModel;
import PropertySheet;
import PreferencePages;
import Navigator;
import Actions;
import RichClientPlatformApp;
---import Viewmaps;
+import Viewmaps;
+import ModeledViewmaps;
import Identity;
---
+
import gmf.GenModelAccess;
-import xpt.XpandFacade;
--- import gmf.IdentifierLibrary;
modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings');
modeltype GMFTOOL uses tooldef('http://www.eclipse.org/gmf/2005/ToolDefinition');
@@ -30,11 +30,12 @@ modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
modeltype GMFGRAPH uses gmfgraph('http://www.eclipse.org/gmf/2006/GraphicalDefinition');
modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
modeltype GENMODEL uses genmodel('http://www.eclipse.org/emf/2002/GenModel');
+-- modeltype TRACE uses trace('http://www.eclipse.org/gmf/2006/Trace');
--
-- Next attempt to author GMFMap-to-GMFGen transformation
--
-transformation Map2Gen(in mapModel : GMFMAP, in domainGenModel : GENMODEL, in diagramRuntimeGenModel : GENMODEL, out gmfgenModel : GMFGEN)
+transformation Map2Gen(in mapModel: GMFMAP, in domainGenModel: GENMODEL, in diagramRuntimeGenModel: GENMODEL, out gmfgenModel: GMFGEN)
access Map2GenUtil;
configuration property rcp : Boolean;
@@ -42,15 +43,12 @@ configuration property useMapMode : Boolean;
configuration property useFullRunTime : Boolean;
configuration property useInTransformationCodeGen : Boolean;
-property mapRoot : GMFMAP::Mapping = mapModel.rootObjects()![GMFMAP::Mapping];
-
-main() {
+main() {
+ mapRoot := mapModel.rootObjects()![GMFMAP::Mapping];
genModel := domainGenModel.rootObjects()![GENMODEL::GenModel];
childReferences := mapRoot.getChildReferences();
var genEditor := mapRoot.map structure();
-
- new Identity(mapModel, gmfgenModel).transform();
genEditor.diagram.palette := mapRoot.diagram.map palette();
genEditor.domainGenModel := mapRoot.diagram.domainModel.findGenPackage().genModel;
@@ -58,17 +56,20 @@ main() {
genEditor.plugin := mapRoot.map editorPlugin();
genEditor.editor := object GenEditorView {};
+ mapRoot.visualIdentity(); -- generate visual IDs for each node.
+ if useInTransformationCodeGen then
+ Viewmaps::viewmaps(mapRoot, genEditor.diagram) -- adds viewmaps to each nodes.
+ else
+ ModeledViewmaps::viewmaps(mapRoot, genEditor.diagram) -- adds modeledViewmaps to each nodes.
+ endif;
genEditor.diagramUpdater := object GenDiagramUpdater {};
genEditor.audits := mapRoot.audits.map audits(); -- these two should go before expression providers collection
genEditor.metrics := mapRoot.metrics.map metrics();
- -- FIXME allInstances HACK
if not GMFGEN::GenParserImplementation.allInstances()->isEmpty() then {
genEditor.labelParsers := mapRoot.map createGenParsers()
} endif;
--- var xx : GENMODEL := GENMODEL::createEmptyModel().oclAsType(GENMODEL);
--- var notationGenModel@xx : GENMODEL::GenModel := loadNotationGenModel(genEditor.oclAsType(ECORE::EObject));
new DiagramRunTimeModel(diagramRuntimeGenModel, gmfgenModel).transform();
if not rcp then new Navigator(mapModel, gmfgenModel).transform() endif;
@@ -81,638 +82,6 @@ main() {
}
-- *************************************************************************************
--- Editor & Diagram
--- *************************************************************************************
-
-mapping GMFMAP::Mapping::structure() : GMFGEN::GenEditorGenerator@gmfgenModel {
- diagram := self.diagram.map structure();
-
- diagram.topLevelNodes += self.nodes->map structure()->asOrderedSet();
- childReferences->forEach(c) { diagram.childNodes += c.map structure(c.child); };
-
- diagram.links := self.links->map structure()->asOrderedSet();
- self.getCompartments()->forEach(e) { diagram.compartments += e.c.map structure(e.n, e.r); };
-
- diagram.getAllNodes()->forEach(n) { setupElementType(n) };
- diagram.links->forEach(l) { setupElementType(l) };
-
- diagram.viewmap := self.diagram.diagramCanvas.map viewmap();
-
- if self.expressionsByLanguages()->notEmpty() then
- expressionProviders := self.map createProviderContainer()
- endif;
-
- self.visualIdentity();
-}
-
-query GMFMAP::Mapping::expressionsByLanguages(): Sequence(ValueExpression) {
- return GMFMAP::ValueExpression.allInstances()->iterate(it; res: Sequence(ValueExpression) = Sequence{} |
- if res->exists(e | e.language = it.language) then res else res->including(it) endif
- )
-}
-mapping GMFMAP::Mapping::createProviderContainer(): GMFGEN::GenExpressionProviderContainer {
- self.expressionsByLanguages()->forEach(e) {
- providers += e.map createExpressionProvider()
- }
-}
-
-mapping GMFMAP::CanvasMapping::structure() : GMFGEN::GenDiagram {
- domainDiagramElement := self.domainMetaElement.findGenClass();
- iconProviderPriority := GMFGEN::ProviderPriority::Low;
- validationProviderPriority := GMFGEN::ProviderPriority::Low;
-
- if result.domainDiagramElement.oclIsUndefined() then
- result.elementType := object GMFGEN::NotationType {}
- else
- result.elementType := result.domainDiagramElement.getOrCreateRuntimeMetamodelType()
- endif;
-}
-
--- *************************************************************************************
--- TopLevelNode
--- *************************************************************************************
-
-mapping GMFMAP::TopNodeReference::structure() : GMFGEN::GenTopLevelNode {
- modelFacet := self.createModelFacet();
- self.child.tool.map paletteEntry().oclAsType(ToolEntry).genNodes += result;
-
- self.child.children->select(e | e.compartment.oclIsUndefined())->forEach(c) {
- var node := c.findProcessableChildReference();
- childNodes += node.map structure(node.child);
- };
-
- labels += self.child.labelMappings->map createNodeLabel(self);
-
- viewmap := self.child.diagramNode.viewmap();
- behaviour += self.child.relatedDiagrams.handleRelatedDiagram(self.child);
-}
-
--- *************************************************************************************
--- GenChildNode
--- *************************************************************************************
-
-mapping GMFMAP::ChildReference::structure(node: GMFMAP::NodeMapping) : GMFGEN::GenChildNode
- disjuncts
- GMFMAP::ChildReference::createGenChildLabelNode,
- GMFMAP::ChildReference::createGenChildSideAffixedNode,
- GMFMAP::ChildReference::createGenChildNode
-{}
-
-mapping GMFMAP::ChildReference::createGenChildLabelNode(node: GMFMAP::NodeMapping) : GMFGEN::GenChildLabelNode
- when { node.isPureLabelNode() } {
-
- var soleLabel := node.labelMappings->first();
- labelModelFacet := soleLabel.map createLabelModelFacet(self);
- labelReadOnly := soleLabel.readOnly;
- labelElementIcon := soleLabel.diagramLabel.elementIcon;
- viewmap := soleLabel.diagramLabel.viewmap();
-
- self.child.children[ChildReference]->select(e | e.compartment.oclIsUndefined())->forEach(c) {
- var node := c.findProcessableChildReference();
- childNodes += node.map structure(node.child);
- };
-
- modelFacet := self.createModelFacet();
-
- self.child.tool.map paletteEntry().oclAsType(ToolEntry).genNodes += result;
-}
-mapping GMFMAP::ChildReference::createGenChildSideAffixedNode(node: GMFMAP::NodeMapping) : GMFGEN::GenChildSideAffixedNode
- when { node.diagramNode.affixedParentSide <> GMFGRAPH::Direction::NONE} {
-
- viewmap := node.diagramNode.viewmap();
- preferredSideName := node.diagramNode.getAffixedSideAsPositionConstantsName();
-
- labels += node.labelMappings->map createNodeLabel(self);
-
- self.child.children[ChildReference]->select(e | e.compartment.oclIsUndefined())->forEach(c) {
- var node := c.findProcessableChildReference();
- childNodes += node.map structure(node.child);
- };
-
- behaviour += node.relatedDiagrams.handleRelatedDiagram(node);
- modelFacet := self.createModelFacet();
- self.child.tool.map paletteEntry().oclAsType(ToolEntry).genNodes += result;
-}
-mapping GMFMAP::ChildReference::createGenChildNode(node: GMFMAP::NodeMapping) : GMFGEN::GenChildNode {
- viewmap := node.diagramNode.viewmap();
-
- labels += node.labelMappings->map createNodeLabel(self);
-
- self.child.children[ChildReference]->select(e | e.compartment.oclIsUndefined())->forEach(c) {
- var node := c.findProcessableChildReference();
- childNodes += node.map structure(node.child);
- };
-
- behaviour += node.relatedDiagrams.handleRelatedDiagram(node);
- modelFacet := self.createModelFacet();
-
- self.child.tool.map paletteEntry().oclAsType(ToolEntry).genNodes += result;
-}
-
--- *************************************************************************************
--- Compartment
--- *************************************************************************************
-
-mapping GMFMAP::CompartmentMapping::structure(_mapping: GMFMAP::NodeMapping, container: GMFMAP::NodeReference): GMFGEN::GenCompartment {
- init {
- result := object GMFGEN::GenCompartment {
- canCollapse := self.compartment.collapsible;
- needsTitle := self.compartment.needsTitle;
- title := self.compartment.name;
- viewmap := self.compartment.viewmap();
- };
- }
-
- if container.oclIsKindOf(GMFMAP::TopNodeReference) then
- container.resolveone(GMFGEN::GenNode).compartments += result
- else {
- var node := container.oclAsType(ChildReference).findProcessableChildReference();
- if not node.oclIsUndefined() then
- node.map structure(node.child).compartments += result
- endif
- } endif;
-
- allChildReferences->select(e | e.compartment = self)->forEach(c) {
- if c.child.children->size() > 0 then
- listLayout := false
- endif;
- var node := c.findProcessableChildReference();
- -- if equivalentChild->hasKey(c) then c else
- -- equivalentChild->keys()->selectOne(e | equivalentChild->get(e)->includes(c)) endif;
- childNodes += node.map structure(node.child);
- }
-}
-
-helper GMFMAP::NodeReference::createModelFacet() : GMFGEN::TypeModelFacet {
- if self.child.domainMetaElement.oclIsUndefined() then return null endif;
- var mf := object TypeModelFacet {};
-
- mf.metaClass := self.child.domainMetaElement.findGenClass();
- mf.containmentMetaFeature := self.containmentFeature.findGenFeature();
-
- if self.childrenFeature.oclIsUndefined() then
- mf.childMetaFeature := mf.containmentMetaFeature
- else
- mf.childMetaFeature := self.childrenFeature.findGenFeature()
- endif;
-
- mf.modelElementSelector := self.child.domainSpecialization.map createConstraint();
- mf.modelElementInitializer := self.child.domainInitializer.map structure();
- return mf;
-}
-
--- *************************************************************************************
--- Link
--- *************************************************************************************
-
-mapping GMFMAP::LinkMapping::createModeFacet(): GMFGEN::LinkModelFacet
- disjuncts
- GMFMAP::LinkMapping::createFeatureLinkModelFacet,
- GMFMAP::LinkMapping::createTypeLinkModelFacet
- {}
-
-mapping GMFMAP::LinkMapping::createFeatureLinkModelFacet() : GMFGEN::FeatureLinkModelFacet when {
- self.domainMetaElement.oclIsUndefined() and not self.linkMetaFeature.oclIsUndefined()} {
-
- metaFeature := self.linkMetaFeature.findGenFeature();
-}
-mapping GMFMAP::LinkMapping::createTypeLinkModelFacet() : GMFGEN::TypeLinkModelFacet when {
- not self.domainMetaElement.oclIsUndefined()} {
-
- metaClass := self.domainMetaElement.findGenClass();
- containmentMetaFeature := self.containmentFeature.findGenFeature();
- childMetaFeature := containmentMetaFeature;
- sourceMetaFeature := self.sourceMetaFeature.findGenFeature();
- targetMetaFeature := self.linkMetaFeature.findGenFeature();
- modelElementSelector := self.domainSpecialization.map createConstraint(); -- ALTERNATIVE: if not self.domainSpecialization.oclIsUndefined() then modelElementSelector := self.domainSpecialization.map structure() endif;
- modelElementInitializer := self.domainInitializer.map structure();
-}
-
-mapping GMFMAP::LinkMapping::structure() : GMFGEN::GenLink {
- assert(not self.diagramLink.oclIsUndefined()) with log("link diagram link cannot be null");
- if not self.domainMetaElement.oclIsUndefined() then
- assert(not self.linkMetaFeature.oclIsUndefined()) with log("linkMetaFeature cannot be null")
- endif;
-
- -- model facet
- if not (self.domainMetaElement.oclIsUndefined() and self.linkMetaFeature.oclIsUndefined()) then
- modelFacet := self.map createModeFacet()
- endif;
-
- -- labels
- labels += self.labelMappings->map structure(self);
-
- self.tool.map paletteEntry().oclAsType(ToolEntry).genLinks += result;
- -- setupElementType(result);
- result.viewmap := self.diagramLink.viewmap();
- result.creationConstraints := self.creationConstraints.map structure();
-}
-
-mapping LabelMapping::structure(link: GMFMAP::LinkMapping): GenLinkLabel {
- readOnly := self.readOnly;
- elementIcon := self.diagramLabel.elementIcon;
- modelFacet := self.map createLabelModelFacet(link);
- var alignmentFacet := self.diagramLabel.findAlignmentFacet();
- if not alignmentFacet.oclIsUndefined() then
- alignment := switch {
- case (alignmentFacet.alignment = GMFGRAPH::Alignment::BEGINNING) LinkLabelAlignment::SOURCE;
- case (alignmentFacet.alignment = GMFGRAPH::Alignment::CENTER) LinkLabelAlignment::MIDDLE;
- case (alignmentFacet.alignment = GMFGRAPH::Alignment::END) LinkLabelAlignment::TARGET;
- else LinkLabelAlignment::MIDDLE;
- }
- endif;
- viewmap := self.diagramLabel.viewmap();
- viewmap.attributes += object LabelOffsetAttributes {
- var offsetFacet := self.diagramLabel.findOffsetFacet();
- if not offsetFacet.oclIsUndefined() then {
- x := offsetFacet.x;
- y := offsetFacet.y;
- } else {
- y := (link.labelMappings->indexOf(self) + 1) * 20;
- } endif;
- }
-}
-query DiagramElement::findOffsetFacet(): LabelOffsetFacet {
- return self.facets->selectOne(e | e.oclIsKindOf(LabelOffsetFacet)).oclAsType(LabelOffsetFacet)
-}
-query DiagramElement::findAlignmentFacet(): AlignmentFacet {
- return self.facets->selectOne(e | e.oclIsKindOf(AlignmentFacet)).oclAsType(AlignmentFacet)
-}
-query GMFMAP::NodeMapping::isPureLabelNode() : Boolean {
- return self.labelMappings->size() = 1 and self.children->isEmpty() and self.labelMappings->first().diagramLabel = self.diagramNode;
-}
-query GMFGRAPH::Node::getAffixedSideAsPositionConstantsName() : String {
- switch {
- case (self.affixedParentSide = GMFGRAPH::Direction::NONE) assert (false) with log('DiagramNode is not side-affixed', self);
- case (self.affixedParentSide = GMFGRAPH::Direction::EAST) return 'EAST';
- case (self.affixedParentSide = GMFGRAPH::Direction::WEST) return 'WEST';
- case (self.affixedParentSide = GMFGRAPH::Direction::NORTH) return 'NORTH';
- case (self.affixedParentSide = GMFGRAPH::Direction::SOUTH) return 'SOUTH';
- case (self.affixedParentSide = GMFGRAPH::Direction::NSEW) return 'NONE'; -- any side
- --else return 'NONE'; -- any side
- };
- return 'NONE'; -- any side
-}
-helper GMFMAP::CanvasMapping::handleRelatedDiagram(in mapElement : GMFMAP::MappingEntry) : GMFGEN::OpenDiagramBehaviour {
- var rv = object GMFGEN::OpenDiagramBehaviour {};
- -- XXX alternative approach to tell whether related diagram is the same we are processing now,
- -- originally self.eResource() != mapElement.eResource()
- if self <> mapElement.container() then {
- rv.diagramKind := 'FIXME put GenEditorGenerator.modelID value here';
- rv.editorID := 'FIXME put GenEditorView.id value here';
- } endif;
- return rv;
-}
-
--- *************************************************************************************
--- NodeLabel
--- *************************************************************************************
-
-mapping GMFMAP::LabelMapping::createNodeLabel(node: NodeReference) : GMFGEN::GenNodeLabel {
- init {
- if self.diagramLabel.external then
- result := object GenExternalNodeLabel {}
- else
- result := object GenNodeLabel {}
- endif
- }
-
- result.modelFacet := self.map createLabelModelFacet(node);
- result.readOnly := self.readOnly;
- result.elementIcon := self.diagramLabel.elementIcon;
- result.viewmap := self.diagramLabel.viewmap();
-}
-
--- XXX perhaps, can replace with mapping WTF::auxParser() and WTF::externalParser, to use QVTO to create instances when
--- neccessary, the problem is finding a proper WTF (labelMapping knows it's MappingEntry, but latter doesn't keep track of CanvasMapping or similar)
-property designLabelParser : GMFGEN::ExternalParser = null;
-property auxParser : GMFGEN::ExternalParser = null;
-
--- DGMT#createLabelModelFacet
-mapping GMFMAP::LabelMapping::createLabelModelFacet(node: NeedsContainment) : GMFGEN::LabelModelFacet
- disjuncts
- GMFMAP::LabelMapping::createDefaultLabelModelFacet,
- GMFMAP::FeatureLabelMapping::createFeatureLabelModelFacet,
- GMFMAP::DesignLabelMapping::createDesignLabelModelFacet,
- GMFMAP::ExpressionLabelMapping::createExpressionLabelModelFacet
- {}
-mapping GMFMAP::LabelMapping::createDefaultLabelModelFacet(node: NeedsContainment) : GMFGEN::LabelModelFacet
- when {self.oclIsTypeOf(LabelMapping)} {
- init {
- if this.auxParser = null then
- this.auxParser := object GMFGEN::ExternalParser {}
- endif;
- }
- parser := this.auxParser;
-}
-mapping GMFMAP::FeatureLabelMapping::createFeatureLabelModelFacet(node: NeedsContainment) : GMFGEN::FeatureLabelModelFacet {
--- init {
--- result := object FeatureLabelModelFacet {
- metaFeatures += self.features.findGenFeature();
- editableMetaFeatures += self.editableFeatures.findGenFeature();
- viewPattern := self.viewPattern;
- editPattern := self.editPattern;
- editorPattern := self.editorPattern;
- viewMethod := self.viewMethod.convertLabelTextAccessMethod();
- editMethod := self.editMethod.convertLabelTextAccessMethod();
--- }
--- }
--- var r := object GMFGEN::FeatureLabelModelFacet {};
- -- if exists then select else
- -- FIXME allInstances == hack
- var p = GMFGEN::PredefinedParser.allInstances()->any(pp |
- pp.viewMethod = result.oclAsType(FeatureLabelModelFacet).viewMethod and
- pp.editMethod = result.oclAsType(FeatureLabelModelFacet).editMethod);
-
- if p.oclIsUndefined() then p := object PredefinedParser {
- viewMethod := result.oclAsType(FeatureLabelModelFacet).viewMethod;
- editMethod := result.oclAsType(FeatureLabelModelFacet).editMethod;
- } endif;
- parser := p;
--- return r;
-}
-mapping GMFMAP::DesignLabelMapping::createDesignLabelModelFacet(node: NeedsContainment) : GMFGEN::DesignLabelModelFacet {
--- init {
--- result := object DesignLabelModelFacet {}
--- }
- if this.designLabelParser = null then
- this.designLabelParser := object GMFGEN::ExternalParser {}
- endif;
- parser := this.designLabelParser;
-
-}
-mapping GMFMAP::ExpressionLabelMapping::createExpressionLabelModelFacet(node: NeedsContainment): GMFGEN::ExpressionLabelModelFacet {
--- init {
--- result := object ExpressionLabelModelFacet {
- parser := object ExpressionLabelParser {
- expressionContext := GENMODEL::GenClass.allInstances()->any(e | e.ecoreClass = self.mapEntry.getDomainContext());
- viewExpression := if not self.viewExpression.oclIsUndefined() then self.viewExpression.map createValueExpression() endif;
- editExpression := if not self.editExpression.oclIsUndefined() then self.editExpression.map createValueExpression() endif;
- validateExpression := if not self.validateExpression.oclIsUndefined() then self.validateExpression.map createConstraint() endif;
- };
-
- log('create expression parser', parser) when true;
--- }
--- }
-}
-mapping GMFMAP::ValueExpression::createValueExpression(): GMFGEN::ValueExpression
- disjuncts GMFMAP::ValueExpression::createGenValueExpression, GMFMAP::Constraint::createConstraint
-{}
-mapping GMFMAP::ValueExpression::createGenValueExpression(): GMFGEN::ValueExpression
- when {self.oclIsTypeOf(ValueExpression)}{
- body := self.body;
-}
-mapping GMFMAP::Constraint::createConstraint(): GMFGEN::GenConstraint {
- body := self.body;
-}
-mapping GMFMAP::ValueExpression::createExpressionProvider(): GenExpressionProviderBase {
- init {
- switch {
- case (self.language = Language::java) { result := object GenJavaExpressionProvider {} };
- case (self.language = Language::ocl) { result := object GenExpressionInterpreter { language := self.language() } };
- case (self.language = Language::regexp) { result := object GenExpressionInterpreter { language := self.language() } };
- case (self.language = Language::nregexp) { result := object GenExpressionInterpreter { language := self.language() } };
- case (self.language = GenLanguage::_literal) { result := object GenLiteralExpressionProvider {} };
- else { result := object GenExpressionInterpreter {}; }
- };
- }
-
- expressions += ValueExpression.allInstances()->select(e | e.language = self.language)->map createValueExpression();
-}
-helper GMFMAP::ValueExpression::language(): GenLanguage {
- return switch {
- case (self.language = Language::java) GenLanguage::java;
- case (self.language = Language::ocl) GenLanguage::ocl;
- case (self.language = Language::regexp) GenLanguage::regexp;
- case (self.language = Language::nregexp) GenLanguage::nregexp;
- case (self.language = Language::_literal) return GenLanguage::_literal;
- else GenLanguage::ocl;
- }
-}
-query GMFMAP::ValueExpression::selectProvider(): GenExpressionProviderBase {
- return this.mapRoot->resolveone(GMFGEN::GenExpressionProviderContainer).providers->any(e | e.getLanguage() = self.language)
-}
-query GMFMAP::LabelTextAccessMethod::convertLabelTextAccessMethod() : GMFGEN::LabelTextAccessMethod {
- switch {
- case (self = GMFMAP::LabelTextAccessMethod::NATIVE) return GMFGEN::LabelTextAccessMethod::NATIVE;
- case (self = GMFMAP::LabelTextAccessMethod::REGEXP) return GMFGEN::LabelTextAccessMethod::REGEXP;
- case (self = GMFMAP::LabelTextAccessMethod::PRINTF) return GMFGEN::LabelTextAccessMethod::PRINTF;
- else return GMFGEN::LabelTextAccessMethod::MESSAGE_FORMAT;
- };
- return GMFGEN::LabelTextAccessMethod::MESSAGE_FORMAT;
-}
-
--- *************************************************************************************
--- Constraints and initializers
--- *************************************************************************************
-
-mapping GMFMAP::LinkConstraints::structure() : GMFGEN::GenLinkConstraints {
- sourceEnd := self.sourceEnd.map createConstraint();
- targetEnd := self.targetEnd.map createConstraint();
-}
-
--- note, Constraints may be reused through reuse of NodeMappings, hence need to keep track of the relation
---mapping GMFMAP::Constraint::structure() : GMFGEN::GenConstraint {
--- result._body := self._body;
--- result.bindToProvider(self);
---}
---mapping GMFMAP::ValueExpression::structure_ve() : GMFGEN::ValueExpression { --XXX think about naming, how to avoid conflict with GenConstraint::structure - disjuncts?
--- result._body := self._body;
--- result.bindToProvider(self);
---}
---helper GMFGEN::ValueExpression::bindToProvider(in expression : GMFMAP::ValueExpression) {
--- if expression.language.detectGenLanguage().oclIsUndefined() then return endif; -- XXX perhaps, don't need this line, if .map would give OclInvalid
--- expression.language.detectGenLanguage().map expressionProvider().expressions += self;
--- return;
---}
--- XXX actually, looks like I don't need GenLanguage - I can make most decisions based on
---query GMFMAP::Language::detectGenLanguage() : GMFGEN::GenLanguage {
--- switch {
--- case (self = GMFMAP::Language::ocl) return GMFGEN::GenLanguage::ocl;
--- case (self = GMFMAP::Language::java) return GMFGEN::GenLanguage::java;
--- case (self = GMFMAP::Language::regexp) return GMFGEN::GenLanguage::regexp;
--- case (self = GMFMAP::Language::nregexp) return GMFGEN::GenLanguage::nregexp;
--- case (self = GMFMAP::Language::_literal) return GMFGEN::GenLanguage::_literal;
--- else { assert (false) with log ('Unknown expression language literal', self); }
--- };
--- return GMFGEN::GenLanguage::ocl;
---}
---mapping GMFGEN::GenLanguage::expressionProvider() : GMFGEN::GenExpressionProviderBase {
--- init {
--- switch {
--- case (self = GMFGEN::GenLanguage::ocl) result := object GMFGEN::GenExpressionInterpreter { language := self };
--- case (self = GMFGEN::GenLanguage::java) result := object GMFGEN::GenJavaExpressionProvider {};
--- case (self = GMFGEN::GenLanguage::regexp) result := object GMFGEN::GenExpressionInterpreter { language := self };
--- case (self = GMFGEN::GenLanguage::nregexp) result := object GMFGEN::GenExpressionInterpreter { language := self };
--- case (self = GMFGEN::GenLanguage::_literal) result := object GMFGEN::GenLiteralExpressionProvider {};
--- else {
--- assert (false) with log ('Unknown expression language literal', self);
--- -- fake provider with no language set to fail validation (XXX perhaps, makes sense to add 'unrecognized' language?)
--- result := object GMFGEN::GenExpressionInterpreter {};
--- }
--- }
--- }
---}
-
--- *************************************************************************************
--- ElementInitializer
--- *************************************************************************************
-
-mapping GMFMAP::ElementInitializer::structure() : GMFGEN::GenElementInitializer {
- init {
- assert (false) with log ('No idea how to process ElementInitializer', self);
- }
-}
-
-mapping GMFMAP::FeatureSeqInitializer::structure() : GMFGEN::GenElementInitializer {
- init {
- result := object GenFeatureSeqInitializer {
- initializers += self.initializers.map structure();
- if not self.elementClass.oclIsUndefined() then
- elementClass := self.elementClass.findGenClass()
- endif;
- }
- }
-}
-
--- *************************************************************************************
--- GenFeatureInitializer
--- *************************************************************************************
-
-mapping GMFMAP::FeatureInitializer::structure() : GMFGEN::GenFeatureInitializer {
- init {
- assert (false) with log ('No idea how to process FeatureInitializer', self);
- }
-}
-
-mapping GMFMAP::FeatureValueSpec::structure() : GMFGEN::GenFeatureInitializer {
- init {
- result := object GenFeatureValueSpec {
- feature := self.feature.findGenFeature();
- value := self.value.map createValueExpression();
- }
- }
-}
-
-mapping GMFMAP::ReferenceNewElementSpec::structure() : GMFGEN::GenFeatureInitializer {
- init {
- result := object GenReferenceNewElementSpec {
- feature := self.feature.findGenFeature();
- -- cast to GenFeatureSeqInitializer was in the original DGMT
- newElementInitializers += self.newElementInitializers.map structure().oclAsType(GMFGEN::GenFeatureSeqInitializer);
- }
- }
-}
-
--- *************************************************************************************
--- Palette
--- *************************************************************************************
-
-mapping GMFMAP::CanvasMapping::palette() : GMFGEN::Palette
- when { not self.palette.oclIsUndefined(); } {
- --if self.palette.oclIsUndefined() return OclInvalid;
- var paletteItems : Sequence(GMFGEN::ToolGroupItem) := self.palette.tools.map paletteEntry();
- var topLevelTools := paletteItems->reject(e | e.oclIsKindOf(GMFGEN::ToolGroup));
- if topLevelTools->notEmpty() then {
- var defaultGroup := object GMFGEN::ToolGroup {
- title := 'Default';
- description := 'Holds top-level non-container tools';
- collapse := false;
- entries += topLevelTools;
- };
- result.groups := result.groups->prepend(defaultGroup);
- } endif;
-
- result.groups += paletteItems[GMFGEN::ToolGroup];
- result.flyout := true;
- if (self.palette._default <> null) then {
- var te := self.palette._default.resolveone(GMFGEN::ToolEntry);
- if te <> null then te._default := true else log ('There\'s default tool specified for palette, but can\'t find gmfgen counterpart') endif;
- } endif;
-}
-
-mapping GMFTOOL::AbstractTool::paletteEntry() : GMFGEN::ToolGroupItem {
- init {
- assert (false) with log('Can\'t dispatch paletteEntry() for ', self);
- }
-}
-
-mapping GMFTOOL::PaletteSeparator::paletteEntry() : GMFGEN::ToolGroupItem {
- init {
- result := object GMFGEN::Separator {};
- }
-}
-
-mapping GMFTOOL::CreationTool::paletteEntry() : GMFGEN::ToolGroupItem {
- init {
- var r := object GMFGEN::ToolEntry {};
- setupCommonToolEntry(self, r);
- result := r;
- }
-}
-
-mapping GMFTOOL::GenericTool::paletteEntry() : GMFGEN::ToolGroupItem {
- init {
- var r := object GMFGEN::ToolEntry {};
- r.qualifiedToolName := self.toolClass;
- setupCommonToolEntry(self, r);
- result := r;
- }
-}
-
-mapping GMFTOOL::StandardTool::paletteEntry() : GMFGEN::ToolGroupItem {
- init {
- var r := object GMFGEN::StandardEntry {};
- switch {
- case (self.toolKind = StandardToolKind::SELECT) r.kind := StandardEntryKind::SELECT;
- case (self.toolKind = StandardToolKind::MARQUEE) r.kind := StandardEntryKind::MARQUEE;
- case (self.toolKind = StandardToolKind::ZOOM_PAN) r.kind := StandardEntryKind::ZOOM;
- };
- setupCommonToolEntry(self, r);
- result := r;
- }
-}
-
-mapping GMFTOOL::ToolGroup::paletteEntry() : GMFGEN::ToolGroupItem {
- init {
- var r := object GMFGEN::ToolGroup {};
- r.stack := self.stack;
- r.collapse := self.collapsible;
- setupCommonToolEntry(self, r);
- r.entries += self.tools.map paletteEntry();
- result := r;
- }
-}
-
--- XXX or helper GMFGEN::EntryBase::setupCommonToolEntry()?
-helper setupCommonToolEntry(in tool : GMFTOOL::AbstractTool, inout genTool : GMFGEN::EntryBase){
- genTool.title := tool.title;
- genTool.description := tool.description;
- if tool.largeIcon.oclIsTypeOf(GMFTOOL::BundleImage) then
- genTool.largeIconPath := tool.largeIcon.oclAsType(GMFTOOL::BundleImage).constructIconPath()
- endif;
- if tool.smallIcon.oclIsTypeOf(GMFTOOL::BundleImage) then
- genTool.smallIconPath := tool.smallIcon.oclAsType(GMFTOOL::BundleImage).constructIconPath()
- endif;
- return null;
-}
-
--- FIXME process path (makeRelative/makeAbsolute) as in original java code
-query GMFTOOL::BundleImage::constructIconPath() : String {
- if self.path.oclIsUndefined() or self.path.trim().size() = 0 then return null endif;
- if self.bundle.oclIsUndefined() or self.bundle.trim().size() = 0 then
- return self.path.makeRelative()
- endif;
- return self.bundle.makeAbsolute() + self.path;
-}
-query String::makeRelative(): String {
- return self;
-}
-query String::makeAbsolute(): String {
- return if self.startsWith('/') or self->exists(e | e = ':') then self + '/' else '/' + self + '/' endif;
-}
-
--- *************************************************************************************
-- Audits
-- *************************************************************************************
mapping GMFMAP::AuditContainer::audits() : GMFGEN::GenAuditRoot {
@@ -837,202 +206,6 @@ mapping GMFMAP::MetricRule::rule() : GMFGEN::GenMetricRule {
mapping GMFMAP::Measurable::metricTarget() : GMFGEN::GenMeasurable
disjuncts GMFMAP::DomainElementTarget::ruleTarget, GMFMAP::NotationElementTarget::ruleTarget, GMFMAP::DiagramElementTarget::ruleTarget
{} --assert (false) with log ('Unknown rule target', self);
-
--- *************************************************************************************
--- Viewmaps
--- *************************************************************************************
-
-property templateRoots : Sequence(String) = Sequence {'platform:/plugin/org.eclipse.gmf.graphdef.codegen/templates/'};
-
-mapping GMFGRAPH::Canvas::viewmap() : GMFGEN::Viewmap {
- init {
- result := object GMFGEN::FigureViewmap {
- figureQualifiedClassName := 'org.eclipse.draw2d.FreeformLayer';
- };
- }
-}
-helper GMFGRAPH::Node::viewmap() : GMFGEN::Viewmap {
- var rv : GMFGEN::Viewmap;
-
- if useInTransformationCodeGen then {
- rv := self.figure.viewmap();
- rv.layoutType := self.getLayoutType();
- rv.attributes += if self.hasResizeConstraints() then self.map resizeConstraints() endif;
- rv.attributes += if self.hasDefaultSize() then self.map defaultSize() endif;
- } else {
- rv := object GMFGEN::ModeledViewmap {
- figureModel := self.oclAsType(EObject);
- }
- } endif;
-
- return rv;
-}
-query GMFGRAPH::Node::hasResizeConstraints(): Boolean {
- return not (self.resizeConstraint.oclIsUndefined() or (self.resizeConstraint = Direction::NSEW))
-}
-query GMFGRAPH::Node::hasDefaultSize(): Boolean {
- var facet : DefaultSizeFacet := self.facets[DefaultSizeFacet]->first();
- var defaultSize := if facet.oclIsUndefined() then self.figure.actualFigure.preferredSize else facet.defaultSize endif;
-
- return not defaultSize.oclIsUndefined()
-}
-mapping GMFGRAPH::Node::resizeConstraints(): GMFGEN::ResizeConstraints {
- resizeHandles := self.resizeConstraint.repr().toInteger();
-}
-mapping GMFGRAPH::Node::defaultSize(): GMFGEN::DefaultSizeAttributes {
- var facet : DefaultSizeFacet := self.facets[DefaultSizeFacet]->first();
- var defaultSize := if facet.oclIsUndefined() then self.figure.actualFigure.preferredSize else facet.defaultSize endif;
-
- if not defaultSize.oclIsUndefined() then {
- height := defaultSize.dy;
- width := defaultSize.dx;
- } endif;
-}
-query GMFGRAPH::Node::getLayoutType(): GMFGEN::ViewmapLayoutType {
- var layout = ViewmapLayoutType::UNKNOWN;
- if (self.figure.actualFigure.layout.oclIsUndefined()) then {
- layout := GMFGEN::ViewmapLayoutType::UNKNOWN;
- } else {
- if self.figure.actualFigure.layout.oclIsKindOf(GMFGRAPH::FlowLayout) then {
- var fl := self.figure.actualFigure.layout.oclAsType(GMFGRAPH::FlowLayout);
- if fl.forceSingleLine then
- layout := GMFGEN::ViewmapLayoutType::TOOLBAR_LAYOUT
- else
- layout := GMFGEN::ViewmapLayoutType::FLOW_LAYOUT
- endif;
- } else
- if self.figure.actualFigure.layout.oclIsKindOf(GMFGRAPH::XYLayout) then
- layout := GMFGEN::ViewmapLayoutType::XY_LAYOUT
- endif
- endif;
- } endif;
- return layout;
-}
-helper GMFGRAPH::Compartment::viewmap() : GMFGEN::Viewmap {
- if self.figure.oclIsUndefined() then
- return object GMFGEN::FigureViewmap {}
- endif;
- -- FIXME check self.accessor, see InnerClassViewapProducer
- if self.accessor.oclIsUndefined() then
- return self.figure.viewmap()
- endif;
- return self.figure.viewmap(self.accessor);
-}
-helper GMFGRAPH::Connection::viewmap() : GMFGEN::Viewmap {
- if self.figure.oclIsUndefined() then
- return object GMFGEN::FigureViewmap {
- figureQualifiedClassName := "org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx";
- }
- endif;
- return self.figure.viewmap();
-}
-helper GMFGRAPH::DiagramLabel::viewmap() : GMFGEN::Viewmap {
- if self.figure.oclIsUndefined() then
- return object GMFGEN::FigureViewmap {
- figureQualifiedClassName := "org.eclipse.draw2d.Label"
- }
- endif;
-
- if self.accessor.oclIsUndefined() then
- return self.figure.viewmap()
- endif;
-
- -- for GenLinkLabel, need to specify alignment based on AlignmentFacet
- -- besides, need to create LabelOffsetAttributes and optionally populate it from LabelOffsetFacet
- return self.figure.viewmap(self.accessor);
-}
-
-helper GMFGRAPH::FigureDescriptor::viewmap() : GMFGEN::Viewmap {
- var rs: GMFGEN::Viewmap := null;
-
- if self.actualFigure.isBareInstance() then {
- rs := object GMFGEN::FigureViewmap {
- figureQualifiedClassName := self.actualFigure.xpand('Runtime::fqn', templateRoots);
- }
- } else {
- rs := object GMFGEN::InnerClassViewmap {
- classBody := self.xpand('top::Descriptor::Inner', templateRoots);
- className := self.name.firstToUpper(); -- FIXME InnerClassViewmapProducer has validJavaIdentifier(capName())
- };
- } endif;
-
- rs.attributes := self.actualFigure.createStyleAttributes();
-
- return rs;
-}
-
-helper GMFGRAPH::Figure::createStyleAttributes() : GMFGEN::StyleAttributes {
- var attributes: GMFGEN::StyleAttributes;
- if not (self.font.oclIsUndefined() and self.foregroundColor.oclIsUndefined() and
- self.backgroundColor.oclIsUndefined()) then {
- attributes := object GMFGEN::StyleAttributes {
- fixedFont := if (self.font.oclIsUndefined()) then false else true endif;
- fixedForeground := if (self.foregroundColor.oclIsUndefined()) then false else true endif;
- fixedBackground := if (self.backgroundColor.oclIsUndefined()) then false else true endif;
- };
- } endif;
- return attributes;
-}
-
-helper GMFGRAPH::FigureDescriptor::viewmap(childAccess : GMFGRAPH::ChildAccess) : GMFGEN::Viewmap {
- return
- if useInTransformationCodeGen then
- object GMFGEN::ParentAssignedViewmap {
- getterName := childAccess.accessor;
- figureQualifiedClassName := childAccess.figure.xpand('Runtime::fqn', templateRoots);
- attributes := childAccess.figure.createStyleAttributes();
- }
- else object GMFGEN::ModeledViewmap {
- figureModel := self.oclAsType(EObject);
- } endif;
-}
-query GMFGRAPH::Figure::isBareInstance() : Boolean { return false; }
-query GMFGRAPH::RealFigure::isBareInstance() : Boolean {
- if self.children->notEmpty() then return false endif;
- if self.oclIsKindOf(GMFGRAPH::Label) then {
- if self.oclAsType(GMFGRAPH::Label).text <> null then return false endif;
- } endif;
- if self.oclIsKindOf(GMFGRAPH::Shape) then {
- var sh : Shape := self.oclAsType(GMFGRAPH::Shape);
- if sh.lineWidth <> 1 then return false endif;
- if sh.lineKind <> LineKind::LINE_SOLID then return false endif;
- if not sh.outline or not sh.fill or sh.xorFill or sh.xorOutline then return false endif;
- } endif;
-
- if self.border <> null then return false endif;
- if self.font <> null then return false endif;
- if self.foregroundColor <> null then return false endif;
- if self.backgroundColor <> null then return false endif;
- if self.maximumSize <> null then return false endif;
- if self.minimumSize <> null then return false endif;
- if self.preferredSize <> null then return false endif;
- if self.insets <> null then return false endif;
- if self.location <> null then return false endif;
- if self.size <> null then return false endif;
-
- if self.oclIsKindOf(GMFGRAPH::PolylineConnection) then {
- if self.oclAsType(GMFGRAPH::PolylineConnection).sourceDecoration <> null then return false endif;
- if self.oclAsType(GMFGRAPH::PolylineConnection).targetDecoration <> null then return false endif;
- } endif;
-
- if self.oclIsKindOf(GMFGRAPH::SVGFigure) then {
- if self.oclAsType(GMFGRAPH::SVGFigure).documentURI <> null then return false endif;
- } endif;
- return true;
-}
-
--- *************************************************************************************
--- Parsers
--- *************************************************************************************
-
-mapping GMFMAP::Mapping::createGenParsers(): GenParsers {
--- object GenParsers {
- implementations += GMFGEN::GenParserImplementation.allInstances();
- if this.designLabelParser <> null then implementations += this.designLabelParser endif;
- if this.auxParser <> null then implementations += this.auxParser endif;
- extensibleViaService := true;
--- };
-}
-- *************************************************************************************
-- Editor Plugin
@@ -1051,84 +224,3 @@ mapping GMFMAP::Mapping::editorPlugin() : GMFGEN::GenPlugin {
} endif;
}
}
-
--- *************************************************************************************
--- Visual Identity
--- *************************************************************************************
-
-property labelNodes: Sequence(LabelMapping) = Sequence{};
-
-helper GMFMAP::Mapping::visualIdentity() {
- self.diagram.resolveone(GenDiagram).visualID := 1000;
-
- self.nodes->collect(e |
- if e.resolveone(GenTopLevelNode).visualID = 0 then {
- e.resolveone(GenTopLevelNode).visualID := topNodeID();
- e.child.children->collect(visualIdentity());
- e.child.labelMappings->collect(visualIdentity(e));
- } endif
- );
-
- self.links->collect(visualIdentity());
-
- self.getCompartments()->collect(e | e.c.visualIdentity(e.n, e.r));
-
- return null;
-}
-
-helper GMFMAP::ChildReference::visualIdentity() {
- var node := self.findProcessableChildReference();
- if not node.oclIsUndefined() then
- if node.map structure(node.child).visualID = 0 then {
- if not node.referencedChild.oclIsUndefined() then
- node.map structure(node.child).visualID := childNodeID()
- else {
- node.map structure(node.child).visualID := childNodeID();
- node.child.children->collect(e |
- if e.needVisualID() then e.visualIdentity() endif
- );
- } endif;
- node.map structure(node.child).labels->collect(e | visualIdentity(e));
- -- node.child.labelMappings->collect(visualIdentity(node));
- } endif
- endif
-}
-
-query ChildReference::needVisualID(): Boolean {
- var node := self.findProcessableChildReference();
- return
- if node.oclIsUndefined() then false else
- node.map structure(node.child).visualID = 0
- endif
-}
-
-helper visualIdentity(inout genNode: GMFGEN::GenNodeLabel) {
- if genNode.visualID = 0 then
- genNode.visualID := nodeLabelID()
- endif;
-}
-
-helper GMFMAP::LabelMapping::visualIdentity(node: GMFMAP::NodeReference) {
- if self.map createNodeLabel(node).visualID = 0 then
- self.map createNodeLabel(node).visualID := nodeLabelID()
- endif;
-}
-
-helper visualIdentity(inout label: GenLinkLabel) {
- if label.visualID = 0 then
- label.visualID := linkLabelID()
- endif;
-}
-
-helper GMFMAP::LinkMapping::visualIdentity() {
- if self.map structure().visualID = 0 then {
- self.map structure().visualID := linkNodeID();
- self.map structure().labels->collect(e | visualIdentity(e))
- } endif;
-}
-
-helper GMFMAP::CompartmentMapping::visualIdentity(_mapping: NodeMapping, node: NodeReference) {
- if self.map structure(_mapping, node).visualID = 0 then
- self.map structure(_mapping, node).visualID := compartmentID()
- endif
-}
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/Map2GenMappings.qvto b/plugins/org.eclipse.gmf.bridge/transforms/Map2GenMappings.qvto
new file mode 100644
index 0000000..ced5c40
--- /dev/null
+++ b/plugins/org.eclipse.gmf.bridge/transforms/Map2GenMappings.qvto
@@ -0,0 +1,651 @@
+import Map2GenUtil;
+
+library Map2GenMappings;
+
+modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings');
+modeltype GMFTOOL uses tooldef('http://www.eclipse.org/gmf/2005/ToolDefinition');
+modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
+modeltype GMFGRAPH uses gmfgraph('http://www.eclipse.org/gmf/2006/GraphicalDefinition');
+modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
+modeltype GENMODEL uses genmodel('http://www.eclipse.org/emf/2002/GenModel');
+-- modeltype TRACE uses trace('http://www.eclipse.org/gmf/2006/Trace');
+
+property mapRoot : GMFMAP::Mapping = null;
+
+mapping GMFMAP::Mapping::structure() : GMFGEN::GenEditorGenerator {
+ diagram := self.diagram.map structure();
+
+ diagram.topLevelNodes += self.nodes->map structure()->asOrderedSet();
+ childReferences->forEach(c) { diagram.childNodes += c.map structure(c.child); };
+
+ diagram.links := self.links->map structure()->asOrderedSet();
+ self.getCompartments()->forEach(e) { diagram.compartments += e.c.map structure(e.n, e.r); };
+
+ diagram.getAllNodes()->forEach(n) { setupElementType(n) };
+ diagram.links->forEach(l) { setupElementType(l) };
+
+ if self.expressionsByLanguages()->notEmpty() then
+ expressionProviders := self.map createProviderContainer()
+ endif;
+}
+
+query GMFMAP::Mapping::expressionsByLanguages(): Sequence(ValueExpression) {
+ return GMFMAP::ValueExpression.allInstances()->iterate(it; res: Sequence(ValueExpression) = Sequence{} |
+ if res->exists(e | e.language = it.language) then res else res->including(it) endif
+ )
+}
+mapping GMFMAP::Mapping::createProviderContainer(): GMFGEN::GenExpressionProviderContainer {
+ self.expressionsByLanguages()->forEach(e) {
+ providers += e.map createExpressionProvider()
+ }
+}
+
+mapping GMFMAP::CanvasMapping::structure() : GMFGEN::GenDiagram {
+ domainDiagramElement := self.domainMetaElement.findGenClass();
+ iconProviderPriority := GMFGEN::ProviderPriority::Low;
+ validationProviderPriority := GMFGEN::ProviderPriority::Low;
+
+ if result.domainDiagramElement.oclIsUndefined() then
+ result.elementType := object GMFGEN::NotationType {}
+ else
+ result.elementType := result.domainDiagramElement.getOrCreateRuntimeMetamodelType()
+ endif;
+}
+
+-- *************************************************************************************
+-- TopLevelNode
+-- *************************************************************************************
+
+mapping GMFMAP::TopNodeReference::structure() : GMFGEN::GenTopLevelNode {
+ modelFacet := self.createModelFacet();
+ self.child.tool.map paletteEntry().oclAsType(ToolEntry).genNodes += result;
+
+ self.child.children->select(e | e.compartment.oclIsUndefined())->forEach(c) {
+ var node := c.findProcessableChildReference();
+ childNodes += node.map structure(node.child);
+ };
+
+ labels += self.child.labelMappings->map createNodeLabel(self);
+
+-- viewmap := self.child.diagramNode.viewmap();
+ behaviour += self.child.relatedDiagrams.handleRelatedDiagram(self.child);
+}
+
+-- *************************************************************************************
+-- GenChildNode
+-- *************************************************************************************
+
+mapping GMFMAP::ChildReference::structure(node: GMFMAP::NodeMapping) : GMFGEN::GenChildNode
+ disjuncts
+ GMFMAP::ChildReference::createGenChildLabelNode,
+ GMFMAP::ChildReference::createGenChildSideAffixedNode,
+ GMFMAP::ChildReference::createGenChildNode
+{}
+
+mapping GMFMAP::ChildReference::createGenChildLabelNode(node: GMFMAP::NodeMapping) : GMFGEN::GenChildLabelNode
+ when { node.isPureLabelNode() } {
+
+ var soleLabel := node.labelMappings->first();
+ labelModelFacet := soleLabel.map createLabelModelFacet(self);
+ labelReadOnly := soleLabel.readOnly;
+ labelElementIcon := soleLabel.diagramLabel.elementIcon;
+-- viewmap := soleLabel.diagramLabel.viewmap();
+
+ self.child.children[ChildReference]->select(e | e.compartment.oclIsUndefined())->forEach(c) {
+ var node := c.findProcessableChildReference();
+ childNodes += node.map structure(node.child);
+ };
+
+ modelFacet := self.createModelFacet();
+
+ self.child.tool.map paletteEntry().oclAsType(ToolEntry).genNodes += result;
+}
+mapping GMFMAP::ChildReference::createGenChildSideAffixedNode(node: GMFMAP::NodeMapping) : GMFGEN::GenChildSideAffixedNode
+ when { node.diagramNode.affixedParentSide <> GMFGRAPH::Direction::NONE} {
+
+-- viewmap := node.diagramNode.viewmap();
+ preferredSideName := node.diagramNode.getAffixedSideAsPositionConstantsName();
+
+ labels += node.labelMappings->map createNodeLabel(self);
+
+ self.child.children[ChildReference]->select(e | e.compartment.oclIsUndefined())->forEach(c) {
+ var node := c.findProcessableChildReference();
+ childNodes += node.map structure(node.child);
+ };
+
+ behaviour += node.relatedDiagrams.handleRelatedDiagram(node);
+ modelFacet := self.createModelFacet();
+ self.child.tool.map paletteEntry().oclAsType(ToolEntry).genNodes += result;
+}
+mapping GMFMAP::ChildReference::createGenChildNode(node: GMFMAP::NodeMapping) : GMFGEN::GenChildNode {
+-- viewmap := node.diagramNode.viewmap();
+
+ labels += node.labelMappings->map createNodeLabel(self);
+
+ self.child.children[ChildReference]->select(e | e.compartment.oclIsUndefined())->forEach(c) {
+ var node := c.findProcessableChildReference();
+ childNodes += node.map structure(node.child);
+ };
+
+ behaviour += node.relatedDiagrams.handleRelatedDiagram(node);
+ modelFacet := self.createModelFacet();
+
+ self.child.tool.map paletteEntry().oclAsType(ToolEntry).genNodes += result;
+}
+
+mapping GMFMAP::LinkMapping::structure() : GMFGEN::GenLink {
+ assert(not self.diagramLink.oclIsUndefined()) with log("link diagram link cannot be null");
+ if not self.domainMetaElement.oclIsUndefined() then
+ assert(not self.linkMetaFeature.oclIsUndefined()) with log("linkMetaFeature cannot be null")
+ endif;
+
+ -- model facet
+ if not (self.domainMetaElement.oclIsUndefined() and self.linkMetaFeature.oclIsUndefined()) then
+ modelFacet := self.map createModelFacet()
+ endif;
+
+ -- labels
+ labels += self.labelMappings->map structure(self);
+
+ self.tool.map paletteEntry().oclAsType(ToolEntry).genLinks += result;
+ -- setupElementType(result);
+-- result.viewmap := self.diagramLink.viewmap();
+ result.creationConstraints := self.creationConstraints.map structure();
+}
+
+mapping LabelMapping::structure(link: GMFMAP::LinkMapping): GenLinkLabel {
+ readOnly := self.readOnly;
+ elementIcon := self.diagramLabel.elementIcon;
+ modelFacet := self.map createLabelModelFacet(link);
+ var alignmentFacet := self.diagramLabel.findAlignmentFacet();
+ if not alignmentFacet.oclIsUndefined() then
+ alignment := switch {
+ case (alignmentFacet.alignment = GMFGRAPH::Alignment::BEGINNING) LinkLabelAlignment::SOURCE;
+ case (alignmentFacet.alignment = GMFGRAPH::Alignment::CENTER) LinkLabelAlignment::MIDDLE;
+ case (alignmentFacet.alignment = GMFGRAPH::Alignment::END) LinkLabelAlignment::TARGET;
+ else LinkLabelAlignment::MIDDLE;
+ }
+ endif;
+-- viewmap := self.diagramLabel.viewmap();
+-- viewmap.attributes += object LabelOffsetAttributes {
+-- var offsetFacet := self.diagramLabel.findOffsetFacet();
+-- if not offsetFacet.oclIsUndefined() then {
+-- x := offsetFacet.x;
+-- y := offsetFacet.y;
+-- } else {
+-- y := (link.labelMappings->indexOf(self) + 1) * 20;
+-- } endif;
+-- }
+}
+
+-- *************************************************************************************
+-- Compartment
+-- *************************************************************************************
+
+mapping GMFMAP::CompartmentMapping::structure(_mapping: GMFMAP::NodeMapping, container: GMFMAP::NodeReference): GMFGEN::GenCompartment {
+ init {
+ result := object GMFGEN::GenCompartment {
+ canCollapse := self.compartment.collapsible;
+ needsTitle := self.compartment.needsTitle;
+ title := self.compartment.name;
+-- viewmap := self.compartment.viewmap();
+ };
+ }
+
+ if container.oclIsKindOf(GMFMAP::TopNodeReference) then
+ container.resolveone(GMFGEN::GenNode).compartments += result
+ else {
+ var node := container.oclAsType(ChildReference).findProcessableChildReference();
+ if not node.oclIsUndefined() then
+ node.map structure(node.child).compartments += result
+ endif
+ } endif;
+
+ allChildReferences->select(e | e.compartment = self)->forEach(c) {
+ if c.child.children->size() > 0 then
+ listLayout := false
+ endif;
+ var node := c.findProcessableChildReference();
+ -- if equivalentChild->hasKey(c) then c else
+ -- equivalentChild->keys()->selectOne(e | equivalentChild->get(e)->includes(c)) endif;
+ childNodes += node.map structure(node.child);
+ }
+}
+
+helper GMFMAP::NodeReference::createModelFacet() : GMFGEN::TypeModelFacet {
+ if self.child.domainMetaElement.oclIsUndefined() then return null endif;
+ var mf := object TypeModelFacet {};
+
+ mf.metaClass := self.child.domainMetaElement.findGenClass();
+ mf.containmentMetaFeature := self.containmentFeature.findGenFeature();
+
+ if self.childrenFeature.oclIsUndefined() then
+ mf.childMetaFeature := mf.containmentMetaFeature
+ else
+ mf.childMetaFeature := self.childrenFeature.findGenFeature()
+ endif;
+
+ mf.modelElementSelector := self.child.domainSpecialization.map createConstraint();
+ mf.modelElementInitializer := self.child.domainInitializer.map structure();
+ return mf;
+}
+
+-- *************************************************************************************
+-- Link
+-- *************************************************************************************
+
+mapping GMFMAP::LinkMapping::createModelFacet(): GMFGEN::LinkModelFacet
+ disjuncts
+ GMFMAP::LinkMapping::createFeatureLinkModelFacet,
+ GMFMAP::LinkMapping::createTypeLinkModelFacet
+ {}
+
+mapping GMFMAP::LinkMapping::createFeatureLinkModelFacet() : GMFGEN::FeatureLinkModelFacet when {
+ self.domainMetaElement.oclIsUndefined() and not self.linkMetaFeature.oclIsUndefined()} {
+
+ metaFeature := self.linkMetaFeature.findGenFeature();
+}
+mapping GMFMAP::LinkMapping::createTypeLinkModelFacet() : GMFGEN::TypeLinkModelFacet when {
+ not self.domainMetaElement.oclIsUndefined()} {
+
+ metaClass := self.domainMetaElement.findGenClass();
+ containmentMetaFeature := self.containmentFeature.findGenFeature();
+ childMetaFeature := containmentMetaFeature;
+ sourceMetaFeature := self.sourceMetaFeature.findGenFeature();
+ targetMetaFeature := self.linkMetaFeature.findGenFeature();
+ modelElementSelector := self.domainSpecialization.map createConstraint(); -- ALTERNATIVE: if not self.domainSpecialization.oclIsUndefined() then modelElementSelector := self.domainSpecialization.map structure() endif;
+ modelElementInitializer := self.domainInitializer.map structure();
+}
+
+query DiagramElement::findOffsetFacet(): LabelOffsetFacet {
+ return self.facets->selectOne(e | e.oclIsKindOf(LabelOffsetFacet)).oclAsType(LabelOffsetFacet)
+}
+query DiagramElement::findAlignmentFacet(): AlignmentFacet {
+ return self.facets->selectOne(e | e.oclIsKindOf(AlignmentFacet)).oclAsType(AlignmentFacet)
+}
+query GMFMAP::NodeMapping::isPureLabelNode() : Boolean {
+ return self.labelMappings->size() = 1 and self.children->isEmpty() and self.labelMappings->first().diagramLabel = self.diagramNode;
+}
+query GMFGRAPH::Node::getAffixedSideAsPositionConstantsName() : String {
+ switch {
+ case (self.affixedParentSide = GMFGRAPH::Direction::NONE) assert (false) with log('DiagramNode is not side-affixed', self);
+ case (self.affixedParentSide = GMFGRAPH::Direction::EAST) return 'EAST';
+ case (self.affixedParentSide = GMFGRAPH::Direction::WEST) return 'WEST';
+ case (self.affixedParentSide = GMFGRAPH::Direction::NORTH) return 'NORTH';
+ case (self.affixedParentSide = GMFGRAPH::Direction::SOUTH) return 'SOUTH';
+ case (self.affixedParentSide = GMFGRAPH::Direction::NSEW) return 'NONE'; -- any side
+ --else return 'NONE'; -- any side
+ };
+ return 'NONE'; -- any side
+}
+helper GMFMAP::CanvasMapping::handleRelatedDiagram(in mapElement : GMFMAP::MappingEntry) : GMFGEN::OpenDiagramBehaviour {
+ var rv = object GMFGEN::OpenDiagramBehaviour {};
+ -- XXX alternative approach to tell whether related diagram is the same we are processing now,
+ -- originally self.eResource() != mapElement.eResource()
+ if self <> mapElement.container() then {
+ rv.diagramKind := 'FIXME put GenEditorGenerator.modelID value here';
+ rv.editorID := 'FIXME put GenEditorView.id value here';
+ } endif;
+ return rv;
+}
+
+-- *************************************************************************************
+-- NodeLabel
+-- *************************************************************************************
+
+mapping GMFMAP::LabelMapping::createNodeLabel(node: NodeReference) : GMFGEN::GenNodeLabel {
+ init {
+ if self.diagramLabel.external then
+ result := object GenExternalNodeLabel {}
+ else
+ result := object GenNodeLabel {}
+ endif
+ }
+
+ result.modelFacet := self.map createLabelModelFacet(node);
+ result.readOnly := self.readOnly;
+ result.elementIcon := self.diagramLabel.elementIcon;
+-- result.viewmap := self.diagramLabel.viewmap();
+}
+
+-- XXX perhaps, can replace with mapping WTF::auxParser() and WTF::externalParser, to use QVTO to create instances when
+-- neccessary, the problem is finding a proper WTF (labelMapping knows it's MappingEntry, but latter doesn't keep track of CanvasMapping or similar)
+property designLabelParser : GMFGEN::ExternalParser = null;
+property auxParser : GMFGEN::ExternalParser = null;
+
+-- DGMT#createLabelModelFacet
+mapping GMFMAP::LabelMapping::createLabelModelFacet(node: NeedsContainment) : GMFGEN::LabelModelFacet
+ disjuncts
+ GMFMAP::LabelMapping::createDefaultLabelModelFacet,
+ GMFMAP::FeatureLabelMapping::createFeatureLabelModelFacet,
+ GMFMAP::DesignLabelMapping::createDesignLabelModelFacet,
+ GMFMAP::ExpressionLabelMapping::createExpressionLabelModelFacet
+ {}
+mapping GMFMAP::LabelMapping::createDefaultLabelModelFacet(node: NeedsContainment) : GMFGEN::LabelModelFacet
+ when {self.oclIsTypeOf(LabelMapping)} {
+ init {
+ if this.auxParser = null then
+ this.auxParser := object GMFGEN::ExternalParser {}
+ endif;
+ }
+ parser := this.auxParser;
+}
+mapping GMFMAP::FeatureLabelMapping::createFeatureLabelModelFacet(node: NeedsContainment) : GMFGEN::FeatureLabelModelFacet {
+-- init {
+-- result := object FeatureLabelModelFacet {
+ metaFeatures += self.features.findGenFeature();
+ editableMetaFeatures += self.editableFeatures.findGenFeature();
+ viewPattern := self.viewPattern;
+ editPattern := self.editPattern;
+ editorPattern := self.editorPattern;
+ viewMethod := self.viewMethod.convertLabelTextAccessMethod();
+ editMethod := self.editMethod.convertLabelTextAccessMethod();
+-- }
+-- }
+-- var r := object GMFGEN::FeatureLabelModelFacet {};
+ -- if exists then select else
+ -- FIXME allInstances == hack
+ var p = GMFGEN::PredefinedParser.allInstances()->any(pp |
+ pp.viewMethod = result.oclAsType(FeatureLabelModelFacet).viewMethod and
+ pp.editMethod = result.oclAsType(FeatureLabelModelFacet).editMethod);
+
+ if p.oclIsUndefined() then p := object PredefinedParser {
+ viewMethod := result.oclAsType(FeatureLabelModelFacet).viewMethod;
+ editMethod := result.oclAsType(FeatureLabelModelFacet).editMethod;
+ } endif;
+ parser := p;
+-- return r;
+}
+mapping GMFMAP::DesignLabelMapping::createDesignLabelModelFacet(node: NeedsContainment) : GMFGEN::DesignLabelModelFacet {
+-- init {
+-- result := object DesignLabelModelFacet {}
+-- }
+ if this.designLabelParser = null then
+ this.designLabelParser := object GMFGEN::ExternalParser {}
+ endif;
+ parser := this.designLabelParser;
+
+}
+mapping GMFMAP::ExpressionLabelMapping::createExpressionLabelModelFacet(node: NeedsContainment): GMFGEN::ExpressionLabelModelFacet {
+-- init {
+-- result := object ExpressionLabelModelFacet {
+ parser := object ExpressionLabelParser {
+ expressionContext := GENMODEL::GenClass.allInstances()->any(e | e.ecoreClass = self.mapEntry.getDomainContext());
+ viewExpression := if not self.viewExpression.oclIsUndefined() then self.viewExpression.map createValueExpression() endif;
+ editExpression := if not self.editExpression.oclIsUndefined() then self.editExpression.map createValueExpression() endif;
+ validateExpression := if not self.validateExpression.oclIsUndefined() then self.validateExpression.map createConstraint() endif;
+ };
+
+-- }
+-- }
+}
+mapping GMFMAP::ValueExpression::createValueExpression(): GMFGEN::ValueExpression
+ disjuncts GMFMAP::ValueExpression::createGenValueExpression, GMFMAP::Constraint::createConstraint
+{}
+mapping GMFMAP::ValueExpression::createGenValueExpression(): GMFGEN::ValueExpression
+ when {self.oclIsTypeOf(ValueExpression)}{
+ body := self.body;
+}
+mapping GMFMAP::Constraint::createConstraint(): GMFGEN::GenConstraint {
+ body := self.body;
+}
+mapping GMFMAP::ValueExpression::createExpressionProvider(): GenExpressionProviderBase {
+ init {
+ switch {
+ case (self.language = Language::java) { result := object GenJavaExpressionProvider {} };
+ case (self.language = Language::ocl) { result := object GenExpressionInterpreter { language := self.language() } };
+ case (self.language = Language::regexp) { result := object GenExpressionInterpreter { language := self.language() } };
+ case (self.language = Language::nregexp) { result := object GenExpressionInterpreter { language := self.language() } };
+ case (self.language = GenLanguage::_literal) { result := object GenLiteralExpressionProvider {} };
+ else { result := object GenExpressionInterpreter {}; }
+ };
+ }
+
+ expressions += ValueExpression.allInstances()->select(e | e.language = self.language)->map createValueExpression();
+}
+helper GMFMAP::ValueExpression::language(): GenLanguage {
+ return switch {
+ case (self.language = Language::java) GenLanguage::java;
+ case (self.language = Language::ocl) GenLanguage::ocl;
+ case (self.language = Language::regexp) GenLanguage::regexp;
+ case (self.language = Language::nregexp) GenLanguage::nregexp;
+ case (self.language = Language::_literal) return GenLanguage::_literal;
+ else GenLanguage::ocl;
+ }
+}
+query GMFMAP::ValueExpression::selectProvider(): GenExpressionProviderBase {
+ return this.mapRoot->resolveone(GMFGEN::GenExpressionProviderContainer).providers->any(e | e.getLanguage() = self.language)
+}
+query GMFMAP::LabelTextAccessMethod::convertLabelTextAccessMethod() : GMFGEN::LabelTextAccessMethod {
+ switch {
+ case (self = GMFMAP::LabelTextAccessMethod::NATIVE) return GMFGEN::LabelTextAccessMethod::NATIVE;
+ case (self = GMFMAP::LabelTextAccessMethod::REGEXP) return GMFGEN::LabelTextAccessMethod::REGEXP;
+ case (self = GMFMAP::LabelTextAccessMethod::PRINTF) return GMFGEN::LabelTextAccessMethod::PRINTF;
+ else return GMFGEN::LabelTextAccessMethod::MESSAGE_FORMAT;
+ };
+ return GMFGEN::LabelTextAccessMethod::MESSAGE_FORMAT;
+}
+
+-- *************************************************************************************
+-- Constraints and initializers
+-- *************************************************************************************
+
+mapping GMFMAP::LinkConstraints::structure() : GMFGEN::GenLinkConstraints {
+ sourceEnd := self.sourceEnd.map createConstraint();
+ targetEnd := self.targetEnd.map createConstraint();
+}
+
+-- note, Constraints may be reused through reuse of NodeMappings, hence need to keep track of the relation
+--mapping GMFMAP::Constraint::structure() : GMFGEN::GenConstraint {
+-- result._body := self._body;
+-- result.bindToProvider(self);
+--}
+--mapping GMFMAP::ValueExpression::structure_ve() : GMFGEN::ValueExpression { --XXX think about naming, how to avoid conflict with GenConstraint::structure - disjuncts?
+-- result._body := self._body;
+-- result.bindToProvider(self);
+--}
+--helper GMFGEN::ValueExpression::bindToProvider(in expression : GMFMAP::ValueExpression) {
+-- if expression.language.detectGenLanguage().oclIsUndefined() then return endif; -- XXX perhaps, don't need this line, if .map would give OclInvalid
+-- expression.language.detectGenLanguage().map expressionProvider().expressions += self;
+-- return;
+--}
+-- XXX actually, looks like I don't need GenLanguage - I can make most decisions based on
+--query GMFMAP::Language::detectGenLanguage() : GMFGEN::GenLanguage {
+-- switch {
+-- case (self = GMFMAP::Language::ocl) return GMFGEN::GenLanguage::ocl;
+-- case (self = GMFMAP::Language::java) return GMFGEN::GenLanguage::java;
+-- case (self = GMFMAP::Language::regexp) return GMFGEN::GenLanguage::regexp;
+-- case (self = GMFMAP::Language::nregexp) return GMFGEN::GenLanguage::nregexp;
+-- case (self = GMFMAP::Language::_literal) return GMFGEN::GenLanguage::_literal;
+-- else { assert (false) with log ('Unknown expression language literal', self); }
+-- };
+-- return GMFGEN::GenLanguage::ocl;
+--}
+--mapping GMFGEN::GenLanguage::expressionProvider() : GMFGEN::GenExpressionProviderBase {
+-- init {
+-- switch {
+-- case (self = GMFGEN::GenLanguage::ocl) result := object GMFGEN::GenExpressionInterpreter { language := self };
+-- case (self = GMFGEN::GenLanguage::java) result := object GMFGEN::GenJavaExpressionProvider {};
+-- case (self = GMFGEN::GenLanguage::regexp) result := object GMFGEN::GenExpressionInterpreter { language := self };
+-- case (self = GMFGEN::GenLanguage::nregexp) result := object GMFGEN::GenExpressionInterpreter { language := self };
+-- case (self = GMFGEN::GenLanguage::_literal) result := object GMFGEN::GenLiteralExpressionProvider {};
+-- else {
+-- assert (false) with log ('Unknown expression language literal', self);
+-- -- fake provider with no language set to fail validation (XXX perhaps, makes sense to add 'unrecognized' language?)
+-- result := object GMFGEN::GenExpressionInterpreter {};
+-- }
+-- }
+-- }
+--}
+
+-- *************************************************************************************
+-- ElementInitializer
+-- *************************************************************************************
+
+mapping GMFMAP::ElementInitializer::structure() : GMFGEN::GenElementInitializer {
+ init {
+ assert (false) with log ('No idea how to process ElementInitializer', self);
+ }
+}
+
+mapping GMFMAP::FeatureSeqInitializer::structure() : GMFGEN::GenElementInitializer {
+ init {
+ result := object GenFeatureSeqInitializer {
+ initializers += self.initializers.map structure();
+ if not self.elementClass.oclIsUndefined() then
+ elementClass := self.elementClass.findGenClass()
+ endif;
+ }
+ }
+}
+
+-- *************************************************************************************
+-- GenFeatureInitializer
+-- *************************************************************************************
+
+mapping GMFMAP::FeatureInitializer::structure() : GMFGEN::GenFeatureInitializer {
+ init {
+ assert (false) with log ('No idea how to process FeatureInitializer', self);
+ }
+}
+
+mapping GMFMAP::FeatureValueSpec::structure() : GMFGEN::GenFeatureInitializer {
+ init {
+ result := object GenFeatureValueSpec {
+ feature := self.feature.findGenFeature();
+ value := self.value.map createValueExpression();
+ }
+ }
+}
+
+mapping GMFMAP::ReferenceNewElementSpec::structure() : GMFGEN::GenFeatureInitializer {
+ init {
+ result := object GenReferenceNewElementSpec {
+ feature := self.feature.findGenFeature();
+ -- cast to GenFeatureSeqInitializer was in the original DGMT
+ newElementInitializers += self.newElementInitializers.map structure().oclAsType(GMFGEN::GenFeatureSeqInitializer);
+ }
+ }
+}
+
+-- *************************************************************************************
+-- Palette
+-- *************************************************************************************
+
+mapping GMFMAP::CanvasMapping::palette() : GMFGEN::Palette
+ when { not self.palette.oclIsUndefined(); } {
+ --if self.palette.oclIsUndefined() return OclInvalid;
+ var paletteItems : Sequence(GMFGEN::ToolGroupItem) := self.palette.tools.map paletteEntry();
+ var topLevelTools := paletteItems->reject(e | e.oclIsKindOf(GMFGEN::ToolGroup));
+ if topLevelTools->notEmpty() then {
+ var defaultGroup := object GMFGEN::ToolGroup {
+ title := 'Default';
+ description := 'Holds top-level non-container tools';
+ collapse := false;
+ entries += topLevelTools;
+ };
+ result.groups := result.groups->prepend(defaultGroup);
+ } endif;
+
+ result.groups += paletteItems[GMFGEN::ToolGroup];
+ result.flyout := true;
+ if (self.palette._default <> null) then {
+ var te := self.palette._default.resolveone(GMFGEN::ToolEntry);
+ if te <> null then te._default := true else log ('There\'s default tool specified for palette, but can\'t find gmfgen counterpart') endif;
+ } endif;
+}
+
+mapping GMFTOOL::AbstractTool::paletteEntry() : GMFGEN::ToolGroupItem {
+ init {
+ assert (false) with log('Can\'t dispatch paletteEntry() for ', self);
+ }
+}
+
+mapping GMFTOOL::PaletteSeparator::paletteEntry() : GMFGEN::ToolGroupItem {
+ init {
+ result := object GMFGEN::Separator {};
+ }
+}
+
+mapping GMFTOOL::CreationTool::paletteEntry() : GMFGEN::ToolGroupItem {
+ init {
+ var r := object GMFGEN::ToolEntry {};
+ setupCommonToolEntry(self, r);
+ result := r;
+ }
+}
+
+mapping GMFTOOL::GenericTool::paletteEntry() : GMFGEN::ToolGroupItem
+ when {not self.toolClass.oclIsUndefined() or self.toolClass->notEmpty()} {
+ init {
+ var r := object GMFGEN::ToolEntry {};
+ r.qualifiedToolName := self.toolClass;
+ setupCommonToolEntry(self, r);
+ result := r;
+ }
+}
+
+mapping GMFTOOL::StandardTool::paletteEntry() : GMFGEN::ToolGroupItem {
+ init {
+ var r := object GMFGEN::StandardEntry {};
+ switch {
+ case (self.toolKind = StandardToolKind::SELECT) r.kind := StandardEntryKind::SELECT;
+ case (self.toolKind = StandardToolKind::MARQUEE) r.kind := StandardEntryKind::MARQUEE;
+ case (self.toolKind = StandardToolKind::ZOOM_PAN) r.kind := StandardEntryKind::ZOOM;
+ };
+ setupCommonToolEntry(self, r);
+ result := r;
+ }
+}
+
+mapping GMFTOOL::ToolGroup::paletteEntry() : GMFGEN::ToolGroupItem {
+ init {
+ var r := object GMFGEN::ToolGroup {};
+ r.stack := self.stack;
+ r.collapse := self.collapsible;
+ setupCommonToolEntry(self, r);
+ r.entries += self.tools.map paletteEntry();
+ result := r;
+ }
+}
+
+-- XXX or helper GMFGEN::EntryBase::setupCommonToolEntry()?
+helper setupCommonToolEntry(in tool : GMFTOOL::AbstractTool, inout genTool : GMFGEN::EntryBase){
+ genTool.title := tool.title;
+ genTool.description := tool.description;
+ if tool.largeIcon.oclIsTypeOf(GMFTOOL::BundleImage) then
+ genTool.largeIconPath := tool.largeIcon.oclAsType(GMFTOOL::BundleImage).constructIconPath()
+ endif;
+ if tool.smallIcon.oclIsTypeOf(GMFTOOL::BundleImage) then
+ genTool.smallIconPath := tool.smallIcon.oclAsType(GMFTOOL::BundleImage).constructIconPath()
+ endif;
+ return null;
+}
+
+-- FIXME process path (makeRelative/makeAbsolute) as in original java code
+query GMFTOOL::BundleImage::constructIconPath() : String {
+ if self.path.oclIsUndefined() or self.path.trim().size() = 0 then return null endif;
+ if self.bundle.oclIsUndefined() or self.bundle.trim().size() = 0 then
+ return self.path.makeRelative()
+ endif;
+ return self.bundle.makeAbsolute() + self.path;
+}
+query String::makeRelative(): String {
+ return self;
+}
+query String::makeAbsolute(): String {
+ return if self.startsWith('/') or self->exists(e | e = ':') then self + '/' else '/' + self + '/' endif;
+}
+
+-- *************************************************************************************
+-- Parsers
+-- *************************************************************************************
+
+mapping GMFMAP::Mapping::createGenParsers(): GenParsers {
+-- object GenParsers {
+ implementations += GMFGEN::GenParserImplementation.allInstances();
+ if this.designLabelParser <> null then implementations += this.designLabelParser endif;
+ if this.auxParser <> null then implementations += this.auxParser endif;
+ extensibleViaService := true;
+-- };
+}
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/ModeledViewmaps.qvto b/plugins/org.eclipse.gmf.bridge/transforms/ModeledViewmaps.qvto
new file mode 100644
index 0000000..6b8aef1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.bridge/transforms/ModeledViewmaps.qvto
@@ -0,0 +1,81 @@
+modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings');
+modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
+modeltype GMFGRAPH uses gmfgraph('http://www.eclipse.org/gmf/2006/GraphicalDefinition');
+modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
+
+library ModeledViewmaps;
+
+-- *************************************************************************************
+-- Modeled Viewmaps
+-- *************************************************************************************
+
+helper viewmaps(in mapRoot : GMFMAP::Mapping, inout genDiagram : GMFGEN::GenDiagram) {
+
+ genDiagram.viewmap := object ModeledViewmap {
+ figureModel := mapRoot.diagram.diagramCanvas.oclAsType(EObject);
+ };
+
+ genDiagram.topLevelNodes->forEach(node) {
+ var topReference := node.invresolveone(TopNodeReference);
+ node.viewmap := topReference.child.diagramNode.viewmap();
+ node.labels->forEach(label) {
+ var labelMapping := label.invresolveone(LabelMapping);
+ label.viewmap := labelMapping.diagramLabel.viewmap();
+ }
+ };
+
+ genDiagram.childNodes->forEach(node) {
+ var childReference := node.invresolveone(ChildReference);
+ node.viewmap := childReference.child.diagramNode.viewmap();
+ node.labels->forEach(label) {
+ var labelMapping := label.invresolveone(LabelMapping);
+ label.viewmap := labelMapping.diagramLabel.viewmap();
+ }
+ };
+
+ genDiagram.links->forEach(link) {
+ var linkMapping := link.invresolveone(LinkMapping);
+ link.viewmap := linkMapping.diagramLink.viewmap();
+ link.labels->forEach(label) {
+ var labelMapping := label.invresolveone(LabelMapping);
+ label.viewmap := labelMapping.diagramLabel.viewmap();
+ }
+ };
+
+ genDiagram.compartments->forEach(cpt) {
+ var cptMapping := cpt.invresolveone(CompartmentMapping);
+ cpt.viewmap := cptMapping.compartment.viewmap();
+ }
+}
+
+helper GMFGRAPH::Node::viewmap() : GMFGEN::Viewmap {
+ var rs := object ModeledViewmap {
+ figureModel := self.oclAsType(ECORE::EObject);
+ };
+
+ return rs;
+}
+
+helper GMFGRAPH::Connection::viewmap() : GMFGEN::Viewmap {
+ var rs := object ModeledViewmap {
+ figureModel := self.oclAsType(ECORE::EObject);
+ };
+
+ return rs;
+}
+helper GMFGRAPH::Compartment::viewmap() : GMFGEN::Viewmap {
+ var rs := object ModeledViewmap {
+ figureModel := self.oclAsType(ECORE::EObject);
+ };
+
+ return rs;
+}
+helper GMFGRAPH::DiagramLabel::viewmap() : GMFGEN::Viewmap {
+ var rs := object ModeledViewmap {
+ figureModel := self.oclAsType(ECORE::EObject);
+ };
+
+ -- for GenLinkLabel, need to specify alignment based on AlignmentFacet
+ -- besides, need to create LabelOffsetAttributes and optionally populate it from LabelOffsetFacet
+ return rs;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/Navigator.qvto b/plugins/org.eclipse.gmf.bridge/transforms/Navigator.qvto
index 04f1b66..af0d3f2 100644
--- a/plugins/org.eclipse.gmf.bridge/transforms/Navigator.qvto
+++ b/plugins/org.eclipse.gmf.bridge/transforms/Navigator.qvto
@@ -107,7 +107,6 @@ query GMFGEN::GenLink::getTargetGenNodes() : OrderedSet(GMFGEN::GenLinkEnd) {
if self.modelFacet.oclIsUndefined() then {
return self.diagram.getAllPossibleLinkEnds()
} endif;
- log ("target", Sequence{self.targets->size(), self.visualID}) when true;
return self.targets;
}
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/Viewmaps.qvto b/plugins/org.eclipse.gmf.bridge/transforms/Viewmaps.qvto
index 8e5ccdd..47a8252 100644
--- a/plugins/org.eclipse.gmf.bridge/transforms/Viewmaps.qvto
+++ b/plugins/org.eclipse.gmf.bridge/transforms/Viewmaps.qvto
@@ -9,52 +9,313 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
*/
+import xpt.XpandFacade;
+import Map2GenUtil;
+import Map2GenMappings;
+
modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings');
modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
modeltype GMFGRAPH uses gmfgraph('http://www.eclipse.org/gmf/2006/GraphicalDefinition');
modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
-transformation Viewmaps(in mapModel : GMFMAP, inout gmfgenModel : GMFGEN);
-
-
-main() {
- var mapRoot := mapModel.rootObjects()![GMFMAP::Mapping];
- var editorGen := gmfgenModel.rootObjects()![GMFGEN::GenEditorGenerator];
- viewmaps(mapRoot, editorGen.diagram);
-}
-
+library Viewmaps;
--- *************************************************************************************
--- Viewmaps
--- *************************************************************************************
+property templateRoots : Sequence(String) = Sequence {'platform:/plugin/org.eclipse.gmf.graphdef.codegen/templates/'};
helper viewmaps(in mapRoot : GMFMAP::Mapping, inout genDiagram : GMFGEN::GenDiagram) {
- genDiagram.topLevelNodes->forEach(n) {
- n.viewmap := n.invresolveone(NodeMapping).diagramNode.map viewmap();
+
+ genDiagram.viewmap := mapRoot.diagram.diagramCanvas.map viewmap();
+
+ genDiagram.topLevelNodes->forEach(node) {
+ var topReference := node.invresolveone(TopNodeReference);
+ node.viewmap := topReference.child.diagramNode.viewmap();
+ node.labels->forEach(label) {
+ var labelMapping := label.invresolveone(LabelMapping);
+ label.viewmap := labelMapping.diagramLabel.viewmap();
+ }
};
- genDiagram.childNodes->forEach(n) {
- n.viewmap := n.invresolveone(NodeMapping).diagramNode.map viewmap();
+
+ genDiagram.childNodes->forEach(node) {
+ var childReference := node.invresolveone(ChildReference);
+ node.viewmap := childReference.viewmap(childReference.child);
+ node.labels->forEach(label) {
+ var labelMapping := label.invresolveone(LabelMapping);
+ label.viewmap := labelMapping.diagramLabel.viewmap();
+ }
};
- genDiagram.links->forEach(l) {
- l.viewmap := l.invresolveone(LinkMapping).diagramLink.map viewmap();
+
+ genDiagram.compartments->forEach(cpt) {
+ var compartmentMapping := cpt.invresolveone(CompartmentMapping);
+ cpt.viewmap := compartmentMapping.compartment.viewmap();
};
+
+ genDiagram.links->forEach(link) {
+ var linkMapping := link.invresolveone(LinkMapping);
+ link.viewmap := linkMapping.diagramLink.viewmap();
+ link.labels->forEach(label) {
+ var labelMapping := label.invresolveone(LabelMapping);
+ label.viewmap := labelMapping.diagramLabel.viewmap();
+ }
+ };
+
+ return;
}
-mapping GMFGRAPH::Node::viewmap() : GMFGEN::Viewmap {
+-- =================================================================================================
+-- Canvas
+-- =================================================================================================
+
+mapping GMFGRAPH::Canvas::viewmap() : GMFGEN::Viewmap when {true} {
init {
- result := object ModeledViewmap { figureModel := self.oclAsType(ECORE::EObject); };
+ result := object GMFGEN::FigureViewmap {
+ figureQualifiedClassName := 'org.eclipse.draw2d.FreeformLayer';
+ };
}
}
-mapping GMFGRAPH::Connection::viewmap() : GMFGEN::Viewmap {
- init {
- result := object ModeledViewmap { figureModel := self.oclAsType(ECORE::EObject); };
- }
+-- =================================================================================================
+-- ChildReference
+-- =================================================================================================
+
+helper GMFMAP::ChildReference::viewmap(node: GMFMAP::NodeMapping) : GMFGEN::Viewmap {
+ return
+ if node.isPureLabelNode() then
+ node.labelMappings->first().diagramLabel.map viewmap()
+ else
+ node.diagramNode.map viewmap()
+ endif;
}
-mapping GMFGRAPH::DiagramLabel::viewmap() : GMFGEN::Viewmap {
- init {
- result := object ModeledViewmap { figureModel := self.oclAsType(ECORE::EObject); };
- }
+
+-- =================================================================================================
+-- Node
+-- =================================================================================================
+
+helper GMFGRAPH::Node::viewmap(): GMFGEN::Viewmap {
+ var rs := self.figure.viewmap();
+
+ rs.layoutType := self.getLayoutType();
+ rs.attributes += if self.hasResizeConstraints() then self.map resizeConstraints() endif;
+ rs.attributes += if self.hasDefaultSize() then self.map defaultSize() endif;
+
+-- } else {
+-- rv := object GMFGEN::ModeledViewmap {
+-- figureModel := self.oclAsType(EObject);
+-- }
+-- } endif;
+
+ return rs;
+}
+
+query GMFGRAPH::Node::hasResizeConstraints(): Boolean {
+ return not (self.resizeConstraint.oclIsUndefined() or (self.resizeConstraint = Direction::NSEW))
+}
+
+query GMFGRAPH::Node::hasDefaultSize(): Boolean {
+ var facet : DefaultSizeFacet := self.facets[DefaultSizeFacet]->first();
+ var defaultSize := if facet.oclIsUndefined() then self.figure.actualFigure.preferredSize else facet.defaultSize endif;
+
+ return not defaultSize.oclIsUndefined()
+}
+
+mapping GMFGRAPH::Node::resizeConstraints(): GMFGEN::ResizeConstraints {
+ resizeHandles := self.resizeConstraint.repr().toInteger();
+}
+
+mapping GMFGRAPH::Node::defaultSize(): GMFGEN::DefaultSizeAttributes {
+ var facet : DefaultSizeFacet := self.facets[DefaultSizeFacet]->first();
+ var defaultSize := if facet.oclIsUndefined() then self.figure.actualFigure.preferredSize else facet.defaultSize endif;
+
+ if not defaultSize.oclIsUndefined() then {
+ height := defaultSize.dy;
+ width := defaultSize.dx;
+ } endif;
+}
+
+query GMFGRAPH::Node::getLayoutType(): GMFGEN::ViewmapLayoutType {
+ var layout = ViewmapLayoutType::UNKNOWN;
+ if (self.figure.actualFigure.layout.oclIsUndefined()) then {
+ layout := GMFGEN::ViewmapLayoutType::UNKNOWN;
+ } else {
+ if self.figure.actualFigure.layout.oclIsKindOf(GMFGRAPH::FlowLayout) then {
+ var fl := self.figure.actualFigure.layout.oclAsType(GMFGRAPH::FlowLayout);
+ if fl.forceSingleLine then
+ layout := GMFGEN::ViewmapLayoutType::TOOLBAR_LAYOUT
+ else
+ layout := GMFGEN::ViewmapLayoutType::FLOW_LAYOUT
+ endif;
+ } else
+ if self.figure.actualFigure.layout.oclIsKindOf(GMFGRAPH::XYLayout) then
+ layout := GMFGEN::ViewmapLayoutType::XY_LAYOUT
+ endif
+ endif;
+ } endif;
+ return layout;
+}
+
+-- =================================================================================================
+-- Compartment
+-- =================================================================================================
+
+helper GMFGRAPH::Compartment::viewmap() : GMFGEN::Viewmap {
+ if self.figure.oclIsUndefined() then
+ return object GMFGEN::FigureViewmap {}
+ endif;
+ -- FIXME check self.accessor, see InnerClassViewapProducer
+ if self.accessor.oclIsUndefined() then
+ return self.figure.viewmap()
+ endif;
+ return self.figure.viewmap(self.accessor);
+}
+
+-- =================================================================================================
+-- Connection
+-- =================================================================================================
+
+helper GMFGRAPH::Connection::viewmap() : GMFGEN::Viewmap {
+ var rs : GMFGEN::Viewmap := null;
+
+ if self.figure.oclIsUndefined() then
+ rs := object GMFGEN::FigureViewmap {
+ figureQualifiedClassName := "org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx";
+ }
+ else
+ rs := self.figure.viewmap()
+ endif;
+
+ return rs;
+}
+
+-- =================================================================================================
+-- DiagramLabel
+-- =================================================================================================
+
+helper GMFGRAPH::DiagramLabel::viewmap(): GMFGEN::Viewmap {
+ var rs : GMFGEN::Viewmap := null;
+
+ if self.figure.oclIsUndefined() then
+ rs := object GMFGEN::FigureViewmap {
+ figureQualifiedClassName := "org.eclipse.draw2d.Label"
+ }
+ endif;
+
+ if self.accessor.oclIsUndefined() then
+ rs := self.figure.viewmap()
+ else
-- for GenLinkLabel, need to specify alignment based on AlignmentFacet
-- besides, need to create LabelOffsetAttributes and optionally populate it from LabelOffsetFacet
+ rs := self.figure.viewmap(self.accessor)
+ endif;
+
+ rs.attributes += object LabelOffsetAttributes {
+ var offsetFacet := self.findOffsetFacet();
+ if not offsetFacet.oclIsUndefined() then {
+ x := offsetFacet.x;
+ y := offsetFacet.y;
+ } else {
+ y := (self.findIndex() + 1) * 20;
+ } endif;
+ };
+
+ return rs;
}
+
+-- =================================================================================================
+-- Figure
+-- =================================================================================================
+
+helper GMFGRAPH::FigureDescriptor::viewmap() : GMFGEN::Viewmap {
+ var rs: GMFGEN::Viewmap := null;
+
+ if self.actualFigure.isBareInstance() then {
+ rs := object GMFGEN::FigureViewmap {
+ figureQualifiedClassName := self.actualFigure.xpand('Runtime::fqn', templateRoots);
+ }
+ } else {
+ rs := object GMFGEN::InnerClassViewmap {
+ classBody := self.xpand('top::Descriptor::Inner', templateRoots);
+ className := self.name.firstToUpper(); -- FIXME InnerClassViewmapProducer has validJavaIdentifier(capName())
+ };
+ } endif;
+
+ rs.attributes := self.actualFigure.createStyleAttributes();
+
+ return rs;
+}
+
+helper GMFGRAPH::Figure::createStyleAttributes() : GMFGEN::StyleAttributes {
+ var attributes: GMFGEN::StyleAttributes;
+ if not (self.font.oclIsUndefined() and self.foregroundColor.oclIsUndefined() and
+ self.backgroundColor.oclIsUndefined()) then {
+ attributes := object GMFGEN::StyleAttributes {
+ fixedFont := if (self.font.oclIsUndefined()) then false else true endif;
+ fixedForeground := if (self.foregroundColor.oclIsUndefined()) then false else true endif;
+ fixedBackground := if (self.backgroundColor.oclIsUndefined()) then false else true endif;
+ };
+ } endif;
+ return attributes;
+}
+
+helper GMFGRAPH::FigureDescriptor::viewmap(childAccess : GMFGRAPH::ChildAccess) : GMFGEN::Viewmap {
+ return
+-- if useInTransformationCodeGen then
+ object GMFGEN::ParentAssignedViewmap {
+ getterName := childAccess.accessor;
+ figureQualifiedClassName := childAccess.figure.xpand('Runtime::fqn', templateRoots);
+ attributes := childAccess.figure.createStyleAttributes();
+ }
+-- else object GMFGEN::ModeledViewmap {
+-- figureModel := self.oclAsType(EObject);
+-- } endif;
+}
+query GMFGRAPH::Figure::isBareInstance() : Boolean { return false; }
+query GMFGRAPH::RealFigure::isBareInstance() : Boolean {
+ if self.children->notEmpty() then return false endif;
+ if self.oclIsKindOf(GMFGRAPH::Label) then {
+ if self.oclAsType(GMFGRAPH::Label).text <> null then return false endif;
+ } endif;
+ if self.oclIsKindOf(GMFGRAPH::Shape) then {
+ var sh : Shape := self.oclAsType(GMFGRAPH::Shape);
+ if sh.lineWidth <> 1 then return false endif;
+ if sh.lineKind <> LineKind::LINE_SOLID then return false endif;
+ if not sh.outline or not sh.fill or sh.xorFill or sh.xorOutline then return false endif;
+ } endif;
+
+ if self.border <> null then return false endif;
+ if self.font <> null then return false endif;
+ if self.foregroundColor <> null then return false endif;
+ if self.backgroundColor <> null then return false endif;
+ if self.maximumSize <> null then return false endif;
+ if self.minimumSize <> null then return false endif;
+ if self.preferredSize <> null then return false endif;
+ if self.insets <> null then return false endif;
+ if self.location <> null then return false endif;
+ if self.size <> null then return false endif;
+
+ if self.oclIsKindOf(GMFGRAPH::PolylineConnection) then {
+ if self.oclAsType(GMFGRAPH::PolylineConnection).sourceDecoration <> null then return false endif;
+ if self.oclAsType(GMFGRAPH::PolylineConnection).targetDecoration <> null then return false endif;
+ } endif;
+
+ if self.oclIsKindOf(GMFGRAPH::SVGFigure) then {
+ if self.oclAsType(GMFGRAPH::SVGFigure).documentURI <> null then return false endif;
+ } endif;
+ return true;
+}
+
+query DiagramElement::findOffsetFacet(): LabelOffsetFacet {
+ return self.facets->selectOne(e | e.oclIsKindOf(LabelOffsetFacet)).oclAsType(LabelOffsetFacet)
+}
+
+query DiagramElement::findIndex(): Integer {
+ var container := self.oclAsType(EObject).eContainer();
+ if container.oclIsKindOf(LabelMapping) then {
+ var linkMapping := container.eContainer();
+
+ if linkMapping.oclIsKindOf(GMFMAP::LinkMapping) then {
+ return linkMapping.oclAsType(LinkMapping).labelMappings->indexOf(container.oclAsType(LabelMapping))
+ } endif;
+
+ } endif;
+
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/migration/Diff2Qvt.qvto b/plugins/org.eclipse.gmf.bridge/transforms/migration/Diff2Qvt.qvto
new file mode 100644
index 0000000..df9a547
--- /dev/null
+++ b/plugins/org.eclipse.gmf.bridge/transforms/migration/Diff2Qvt.qvto
@@ -0,0 +1,327 @@
+modeltype DIFF uses diff('http://www.eclipse.org/emf/compare/diff/1.1');
+modeltype QVT uses qvtoperational::expressions('http://www.eclipse.org/QVT/1.0.0/Operational');
+modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
+modeltype OCL uses ocl('http://www.eclipse.org/ocl/1.1.0/OCL');
+modeltype IMP uses eimpocl("http://www.eclipse.org/qvt/1.0/ImperativeOCL");
+modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
+
+transformation Diff2Qvt(in diffModel: DIFF, in gmfGen: ECORE, in oclStdLib: ECORE, in stdLib: ECORE, out qvtModel: QVT);
+
+property diff: DiffModel = null;
+property gmfGenParameter : ModelParameter = null;
+property setType: ocl::ecore::SetType = null;
+property bagType: ocl::ecore::BagType = null;
+
+main() {
+ this.diff := diffModel.rootObjects()![DiffModel];
+ this.diff.map toTransformation();
+}
+
+-- ===========================================================================================================
+-- Rules
+-- ===========================================================================================================
+
+mapping DIFF::DiffModel::toTransformation(): OperationalTransformation {
+ name := "GmfGenMigration";
+ var genCommonBase = eObject('GenCommonBase');
+ var genExternalNodeLabel = eObject('genExternalNodeLabel');
+
+ moduleImport := object ModuleImport {
+ importedModule := object Library {
+ name := 'transforms.util.GmfGenUtil'
+ }
+ };
+ var gmfGen := object ModelType {name := 'GMFGEN'; eSuperTypes := eClass('Model');
+ _metamodel := ECORE::EPackage.allInstances()->any(e | e.nsURI = 'http://www.eclipse.org/gmf/2009/GenModel');
+ };
+ gmfGenParameter := object ModelParameter {
+ name := 'gmfGenModel'; eType := gmfGen; kind := DirectionKind::_inout;
+ };
+ gmfGenParameter.representedParameter := gmfGenParameter.oclAsType(EObject);
+ this.bagType := object ocl::ecore::BagType {
+ name:='Bag(OclVoid)'; instanceClassName:='org.eclipse.ocl.util.Bag';elementType:= eObject('OclVoid');
+ };
+ this.setType := object ocl::ecore::SetType {
+ name:='Set(GenChildNode)'; instanceClassName:='java.util.Set'; elementType:= genCommonBase;
+ };
+ modelParameter := gmfGenParameter;
+
+ eClassifiers += gmfGen;
+ eClassifiers += bagType;
+ eClassifiers += setType;
+
+ usedModelType += gmfGen;
+ eSuperTypes += eClass('Transformation');
+ entry := object EntryOperation {
+ name := 'main';
+ eType := eClass('OclVoid');
+ body := object OperationBody {}
+ };
+ eOperations += entry;
+ eOperations += DiffGroup.allInstances()->reject(subDiffElements->forAll(oclIsTypeOf(DiffGroup)))->map toMapping();
+}
+
+query DIFF::DiffElement::isCandidate(): Boolean = false;
+query DIFF::UpdateAttribute::isCandidate(): Boolean = true;
+query DIFF::ModelElementChangeRightTarget::isCandidate(): Boolean = true;
+query DIFF::ModelElementChangeLeftTarget::isCandidate(): Boolean = true;
+
+query DIFF::DiffGroup::isCandidate(): Boolean =
+ let
+ child = self.subDiffElements->reject(oclIsKindOf(DiffGroup))
+ in
+ child->notEmpty() and
+ child->exists(isCandidate()) and
+ (self.rightParent.hasID() or
+ self.rightParent.eContainer().hasID() or
+ self.rightParent.oclIsTypeOf(GenEditorGenerator) or
+ self.rightParent.eContainer().oclIsTypeOf(GenEditorGenerator));
+
+query ECORE::EObject::getMappingName(objectID: EObject): String =
+ self.eClass().name + objectID.ID().repr();
+
+mapping DIFF::DiffGroup::toMapping(): MappingOperation
+ when {
+ self.isCandidate()
+ }{
+
+ eType := eClass('OclVoid');
+ context := object VarParameter {
+ name := 'self';
+ eType := self.rightParent.eClass();
+ kind := DirectionKind::_inout;
+ };
+
+ if (self.rightParent.hasID()) then {
+ name := self.rightParent.getMappingName(self.rightParent);
+ _when := self.rightParent.createWhenObject(result);
+ } else {
+ if (self.rightParent.eContainer().hasID()) then {
+ name := self.rightParent.getMappingName(self.rightParent.eContainer());
+ _when := self.rightParent.eContainer().createWhenObjectContainer(result);
+ } else {
+ name := self.rightParent.eClass().name
+ } endif;
+ } endif;
+
+ body := object ConstructorBody {
+ content += self.subDiffElements->map toExpression(result)->reject(oclIsUndefined())->reject(oclIsInvalid())
+ };
+
+ this.diff.map toTransformation().addBodyContent(result, self.rightParent.eClass());
+}
+
+mapping DIFF::DiffElement::toExpression(op: MappingOperation): ocl::ecore::OCLExpression
+ disjuncts
+ DIFF::UpdateAttribute::toAssignExp,
+ DIFF::ModelElementChangeRightTarget::toOperationCallExp,
+ DIFF::ModelElementChangeLeftTarget::toOperationCallExp
+ {}
+
+mapping DIFF::UpdateAttribute::toAssignExp(op: MappingOperation): AssignExp {
+ isReset := true;
+
+ switch {
+ case (self.attribute.eAttributeType.oclIsTypeOf(EEnum)) {
+ value := object ocl::ecore::EnumLiteralExp {
+ referredEnumLiteral := self.rightElement.eGet(self.attribute).oclAsType(EObject);
+ }
+ };
+ case ('EString' = self.attribute.eAttributeType.name) {
+ value := object OCL::ecore::StringLiteralExp {
+ stringSymbol := self.rightElement.eGet(self.attribute).repr();
+ };
+ };
+ case (Set{'EInt', 'EInteger'}->includes(self.attribute.eAttributeType.name)) {
+ value := object OCL::ecore::IntegerLiteralExp {
+ integerSymbol := self.rightElement.eGet(self.attribute).repr().toInteger();
+ };
+ };
+ case ('EDouble' = self.attribute.eAttributeType.name) {
+ value := object OCL::ecore::RealLiteralExp {
+ realSymbol := self.rightElement.eGet(self.attribute).repr().toReal();
+ };
+ };
+ case ('EBoolean' = self.attribute.eAttributeType.name) {
+ var val : Boolean = self.rightElement.eGet(self.attribute).repr() = 'true';
+ value := object OCL::ecore::BooleanLiteralExp {
+ booleanSymbol := val;
+ };
+ };
+ else
+ value := object OCL::ecore::StringLiteralExp {
+ stringSymbol := self.rightElement.eGet(self.attribute).repr();
+ };
+ };
+
+ left := object OCL::ecore::PropertyCallExp {
+ eType := eClass('String');
+ referredProperty := self.attribute.oclAsType(EObject);
+ source := object OCL::ecore::VariableExp {
+ name := 'self';
+ referredVariable := op.context;
+ eType := self.leftElement.eClass();
+ }
+ };
+ eType := eClass('String');
+}
+
+mapping DIFF::ModelElementChangeRightTarget::toOperationCallExp(op: MappingOperation): ocl::ecore::OperationCallExp {
+ init {
+ var feature := self.rightElement.getContainingFeature();
+ if not feature.oclIsUndefined() then
+ if feature.many then {
+ if self.rightElement.hasID() then {
+ result := self.rightElement.createRemoveOpeartionCallManyElement(feature, op);
+ } else {
+ result := null;
+ } endif;
+ } else {
+ result := self.rightElement.createRemoveOpeartionCallOneElement(feature, op);
+ } endif
+ else
+ result := null
+ endif;
+ }
+}
+mapping DIFF::ModelElementChangeLeftTarget::toOperationCallExp(op: MappingOperation): ocl::ecore::OperationCallExp {
+ init {
+ var feature : EReference := self.leftElement.getContainingFeature();
+ if not feature.oclIsUndefined() then
+ if feature.many then {
+ if self.leftElement.hasID() then {
+ result := self.leftElement.createRemoveOpeartionCallManyElement(feature, op);
+ } else result := null endif;
+ } else {
+ result := self.leftElement.createRemoveOpeartionCallOneElement(feature, op);
+ } endif
+ else result := null endif;
+ }
+}
+
+helper ECORE::EObject::createRemoveOpeartionCallManyElement(feature: ECORE::EReference, op: MappingOperation): ocl::ecore::OperationCallExp {
+ return object ocl::ecore::OperationCallExp {
+ referredOperation := eOperation('Model', 'removeElement');
+ argument := object ocl::ecore::OperationCallExp {
+ name := 'node';
+ argument := object ocl::ecore::PropertyCallExp {
+ referredProperty := feature.oclAsType(EObject);
+ upperBound := 1;
+ source := object ocl::ecore::VariableExp {name:='self'; referredVariable := op.context};
+ };
+ argument += object ocl::ecore::IntegerLiteralExp {integerSymbol := self.ID().repr().toInteger()}
+ };
+ source := object ocl::ecore::VariableExp {referredVariable := gmfGenParameter}
+ }
+}
+
+helper ECORE::EObject::createRemoveOpeartionCallOneElement(feature: ECORE::EReference, op: MappingOperation): ocl::ecore::OperationCallExp {
+ return object ocl::ecore::OperationCallExp {
+ referredOperation := eOperation('Model', 'removeElement');
+ argument := object ocl::ecore::PropertyCallExp {
+ referredProperty := feature.oclAsType(EObject);
+ upperBound := 1;
+ source := object ocl::ecore::VariableExp {name:='self'; referredVariable := op.context};
+ };
+ source := object ocl::ecore::VariableExp {referredVariable := gmfGenParameter}
+ }
+}
+
+-- ===========================================================================================================
+-- Helpers
+-- ===========================================================================================================
+
+helper eClass(type: String): EClass {
+ return ECORE::EClass.allInstances()->any(e | e.name = type);
+}
+helper eObject(name: String): EObject {
+ return ECORE::EClass.allInstances()->any(e | e.name = name).oclAsType(EObject);
+}
+helper eOperation(type: String, name: String): EObject {
+ return eClass(type).eAllOperations->any(e | e.name = name).oclAsType(EObject)
+}
+
+helper EObject::hasID(): Boolean {
+ var id := self.getID();
+ return if not self.oclIsUndefined() then self.eIsSet(id) else false endif;
+}
+
+helper EObject::getID(): ECORE::EAttribute {
+ var id := self.eClass().eIDAttribute;
+ if id.oclIsUndefined() then
+ id := self.eClass().eAllAttributes->any(_|_.name = 'visualID')
+ endif;
+ return id;
+}
+
+helper EObject::ID(): OclAny {
+ return self.eGet(self.getID());
+}
+
+-- self.visualID = 000
+helper ECORE::EObject::createWhenObject(op: MappingOperation): OCL::ecore::OperationCallExp =
+ object OCL::ecore::OperationCallExp {
+ eType := eClass('Boolean');
+ referredOperation := eOperation('String_Class', '=');
+ upperBound := 1;
+ source := object OCL::ecore::PropertyCallExp {
+ eType := eClass('Integer');
+ upperBound := 1;
+ name := self.getID().name;
+ source := object OCL::ecore::VariableExp {
+ name := 'self';
+ upperBound := 1;
+ referredVariable := op.context
+ }
+ };
+ argument += object OCL::ecore::IntegerLiteralExp {
+ upperBound := 1;
+ integerSymbol:= self.oclAsType(GenCommonBase).visualID;
+ }
+ };
+
+-- self.container().oclAsType(GenCommonBase).visualID = 000
+helper ECORE::EObject::createWhenObjectContainer(op: MappingOperation): OCL::ecore::OperationCallExp =
+ object OCL::ecore::OperationCallExp {
+ eType := eClass('Boolean');
+ name := 'parentID';
+ upperBound := 1;
+ source := object OCL::ecore::VariableExp {
+ name := 'self';
+ upperBound := 1;
+ referredVariable := op.context
+ };
+ argument += object OCL::ecore::IntegerLiteralExp {
+ upperBound := 1;
+ integerSymbol:= self.ID().repr().toInteger();
+ }
+ };
+
+helper OperationalTransformation::addBodyContent(op: MappingOperation, eClass: EClass) {
+ self.entry.body.content += object ImperativeIterateExp {name := 'xcollect'; eType := bagType;
+ source :=
+ object ocl::ecore::OperationCallExp {
+ eType := setType;
+ referredOperation := eOperation('OclType_Class', 'allInstances');
+ source :=
+ object ocl::ecore::TypeExp {
+ eType := eClass;
+ referredType:= eClass.oclAsType(EObject)
+ };
+ };
+ var tmp1 := object ocl::ecore::Variable {name:='e'; eType:= eClass};
+ body := object MappingCallExp {
+ eType := eClass('OclVoid');
+ referredOperation := op.oclAsType(EObject);
+ source := object ocl::ecore::VariableExp {
+ name:= 'e';
+ referredVariable:= tmp1;
+ eType:= eClass
+ }
+ };
+ iterator := tmp1;
+ };
+ return null;
+}
+
+helper ECORE::EObject::getContainingFeature(): ECORE::EReference = self.eContainingFeature().oclAsType(EReference);
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/printer/qvtoprinter.qvto b/plugins/org.eclipse.gmf.bridge/transforms/printer/qvtoprinter.qvto
new file mode 100644
index 0000000..ed45dc7
--- /dev/null
+++ b/plugins/org.eclipse.gmf.bridge/transforms/printer/qvtoprinter.qvto
@@ -0,0 +1,519 @@
+modeltype QVT uses qvtoperational::expressions('http://www.eclipse.org/QVT/1.0.0/Operational');
+modeltype ImpOCL uses ImperativeOCL('http://www.eclipse.org/qvt/1.0/ImperativeOCL');
+
+modeltype OCL uses 'http://www.eclipse.org/ocl/1.1.0/OCL';
+
+modeltype ECORE uses 'http://www.eclipse.org/emf/2002/Ecore';
+
+transformation Qvtprettyprinter(in qvtSrc : QVT, out string: ECORE);
+
+property _tab_ : String = ' ';
+
+main() {
+ var s := qvtSrc.rootObjects()[OperationalTransformation]->asOrderedSet()->first();
+
+ var _out = object ECORE::EStringToStringMapEntry {
+ key := 'output';
+ value := s.print(0);
+ };
+}
+
+helper printTabs(tabs : Integer) : String {
+ var i := 0;
+ var code := '';
+ while (i < tabs) {
+ code := code + _tab_;
+ i := i + 1;
+ };
+ return code;
+}
+
+helper printArgs(list : OrderedSet(ecore::EObject)) : String {
+ if (list->isEmpty()) then
+ return ""
+ endif;
+ var code : String := list->first().print(0);
+ var rest := list->subOrderedSet(2, list->size());
+ rest->forEach(expr) {
+ code := code + ', ' + expr.print(0);
+ };
+ return code;
+}
+
+helper printArgs(list : OrderedSet(ecore::EModelElement)) : String {
+ if (list->isEmpty()) then
+ return ""
+ endif;
+ var code : String := list->first().print(0);
+ var rest := list->subOrderedSet(2, list->size());
+ rest->forEach(expr) {
+ code := code + ', ' + expr.print(0);
+ };
+ return code;
+}
+
+
+helper printArgs(list : OrderedSet(ocl::utilities::ASTNode)) : String {
+ if (list->isEmpty()) then
+ return ""
+ endif;
+ var code : String := list->first().print(0);
+ var rest := list->subOrderedSet(2, list->size());
+ rest->forEach(expr) {
+ code := code + ', ' + expr.print(0);
+ };
+ return code;
+}
+
+helper printExpressions(exprList : OrderedSet(ocl::ecore::OCLExpression), tabs : Integer) : String {
+ var code : String;
+ exprList->forEach(expr) {
+ var val := expr.print(tabs);
+
+ if val <> '' then { --notEmpty does not work here.
+ code := code + printTabs(tabs) + val + ';\n'
+ } endif;
+ };
+ return code;
+}
+
+helper ecore::EObject::print(tabs : Integer) : String {
+ var nameFeature := self.eClass().getEStructuralFeature('name');
+ return self.eGet(nameFeature).oclAsType(String);
+}
+
+helper ecore::EStructuralFeature::print(tabs : Integer) : String {
+ var code : String := self.name;
+ return code;
+}
+
+helper ecore::EModelElement::print(tabs : Integer) : String {
+ assert(true);
+ return "";
+}
+
+helper ocl::utilities::ASTNode::print(tabs : Integer) : String {
+ assert(true);
+ return "";
+}
+
+
+helper OperationalTransformation::print(tabs : Integer) : String {
+ var code : String := "";
+ self.moduleImport->forEach(m) {
+ code := code + printTabs(tabs) + m.print(0);
+ };
+ self.usedModelType->forEach(mt) {
+ code := code + printTabs(tabs) + mt.print(0);
+ };
+ code := code + '\n' + printTabs(tabs) + 'transformation ' + self.name + '(';
+ code := code + printArgs(self.modelParameter);
+
+ code := code + ');\n';
+
+ self.configProperty->forEach(p) {
+ code := code + '\nconfiguration property ' + p.name + ' : ' + p.eType.name + ';\n';
+ };
+
+ var set := self.eAllStructuralFeatures - self.configProperty;
+
+ set->forEach(p|p.oclIsKindOf(EAttribute)) {
+ var pa := p.oclAsType(EAttribute);
+ code := code + '\nproperty ' + pa.name + ' : ' + pa.eType.name;
+ code := code + ' = ' + pa.eAnnotations.contents->first().oclAsType(ocl::ecore::OCLExpression).print(0) + ';\n';
+ };
+
+ if not self.entry.oclIsInvalid() then {
+ code := code + '\n' + self.entry.print(tabs);
+ } endif;
+
+ self.eOperations->forEach(op | op.oclIsKindOf(MappingOperation)) {
+ if not op.oclIsInvalid() then {
+ code := code + '\n' + op.oclAsType(MappingOperation).print(tabs);
+ } endif;
+ };
+ self.eOperations->forEach(op | op.oclIsKindOf(Helper)) {
+ code := code + '\n' + op.oclAsType(Helper).print(tabs);
+ };
+ return code;
+}
+
+helper ModuleImport::print(tabs: Integer): String {
+ return 'import ' + self.importedModule.name + ';\n'
+}
+
+helper ModelType::print(tabs : Integer) : String {
+ var code : String := 'modeltype ' + self.name;
+ if (self.conformanceKind != null) then {
+ code := code + ' "' + self.conformanceKind + '"';
+ }
+ endif;
+ code := code + ' uses ';
+ var package := self._metamodel->first();
+ var meta : String := package.name;
+ package := package.eSuperPackage;
+ while (package != null) {
+ meta := package.name + '::' + meta;
+ package := package.eSuperPackage;
+ };
+ code := code + meta + '(' + self._metamodel->first().nsURI.quotify('\'') + ');' + '\n';
+ return code;
+}
+
+helper ModelParameter::print(tabs : Integer) : String {
+ var code : String := self.kind.repr() + ' ' + self.name + ': ' + self.eType.name;
+ return code;
+}
+
+helper VarParameter::print(tabs : Integer) : String {
+ var code : String := self.name + ' : ' + self.eType.name;
+ return code;
+}
+
+helper EntryOperation::print(tabs : Integer) : String {
+ var code : String = printTabs(tabs) + 'main() {\n';
+ if not self.body.oclIsUndefined() then {
+ code := code + self.body.print(tabs + 1) + printTabs(tabs)
+ } endif;
+ code := code + '}\n';
+ return code;
+}
+
+helper Helper::print(tabs : Integer) : String {
+ var code : String = printTabs(tabs) + 'helper ';
+ if (self.context != null) then {
+ code := code + self.context.eType.name + '::';
+ }
+ endif;
+ code := code + self.name;
+ code := code + '(' + printArgs(self.eParameters) + ')';
+ code := code + ' : ' + printArgs(self._result) + ' {\n';
+ code := code + self.body.print(tabs + 1);
+ code := code + printTabs(tabs) + '}\n';
+ return code;
+}
+
+helper MappingParameter::print(tabs : Integer) : String {
+ var code : String := self.name + ' : ' + self.eType.name;
+ return code;
+}
+
+helper MappingOperation::print(tabs : Integer) : String {
+ var code : String = printTabs(tabs) + 'mapping ' +
+ if self.context.kind = DirectionKind::_inout then 'inout ' else '' endif +
+ self.context.eType.name + '::' + self.name;
+
+ code := code + '(' + printArgs(self.eParameters) + ')';
+ if self._result->notEmpty() then
+ code := code + ' : ' + printArgs(self._result)
+ endif;
+ if self._when->notEmpty() then {
+ code := code + '\n' + printTabs(tabs) + 'when { ' + self._when->first().print(0);
+ var rest := self._when->asSequence()->subSequence(2, self._when->size());
+ rest->forEach(expr) {
+ code := code + '; ' + expr.print(0);
+ };
+ code := code + ' }';
+ }
+ endif;
+ code := code + '\n' + printTabs(tabs) + '{\n';
+ code := code + self.body.print(tabs + 1);
+ code := code + printTabs(tabs) + '}\n';
+ return code;
+}
+
+helper OperationBody::print(tabs : Integer) : String {
+ var code : String := printExpressions(self.content, tabs);
+ return code;
+}
+
+helper MappingBody::print(tabs : Integer) : String {
+ var code : String;
+ var needsPopulation := self.initSection->notEmpty();
+ if self.initSection->notEmpty() then {
+ code := printTabs(tabs) + 'init {\n';
+ code := code + printExpressions(self.initSection, tabs + 1);
+ code := code + printTabs(tabs) + '}\n';
+ }
+ endif;
+ if needsPopulation then {
+ code := code + printTabs(tabs) + 'population {\n';
+ code := code + printExpressions(self.content, tabs + 1);
+ code := code + printTabs(tabs) + '}\n';
+ }
+ else {
+ code := code + printExpressions(self.content, tabs);
+ }
+ endif;
+ if self.endSection->notEmpty() then {
+ code := code + printTabs(tabs) + 'end {\n';
+ code := code + printExpressions(self.endSection,tabs + 1);
+ code := code + printTabs(tabs) + '}\n';
+ }
+ endif;
+
+ return code;
+}
+
+helper MappingCallExp::print(tabs : Integer) : String {
+ var code : String := self.source.print(0) + '.' + 'map ';
+ code := code + self.referredOperation.print(0) + '(' + printArgs(self.argument) + ')';
+ return code;
+}
+
+helper ImperativeIterateExp::print(tabs : Integer) : String {
+ var code : String := self.source.print(0) + '->' +
+ self.name +
+ '(';
+ var iter := self.iterator->first().repr();
+ code := code + iter;
+ /*
+ var iter := self.iterator->first().oclAsType(ocl::ecore::Variable);
+ code := code + iter.name + ' : ' + iter.eType.name;
+ self.iterator->subOrderedSet(2,self.iterator->size())->forEach(it) {
+ iter := it.oclAsType(ocl::ecore::Variable);
+ code := code + ', ' + iter.name + iter.eType.name;
+ };
+ */
+ if (self.body != null) then
+ code := code + '|' + self.body.print(0)
+ endif;
+ if (self.condition != null) then
+ code := code + '|' + self.condition.print(0)
+ endif;
+ code := code + ')';
+ return code;
+}
+
+helper ImperativeLoopExp::print(tabs : Integer) : String {
+ var code : String := self.source.print(0) + '->' +
+ self.name +
+ '(';
+ var iter := self.iterator->first().repr();
+ code := code + iter;
+ /*
+ var iter := self.iterator->first().oclAsType(ocl::ecore::Variable);
+ code := code + iter.name + ' : ' + iter.eType.name;
+ self.iterator->subOrderedSet(2,self.iterator->size())->forEach(it) {
+ iter := it.oclAsType(ocl::ecore::Variable);
+ code := code + ', ' + iter.name + iter.eType.name;
+ };
+ */
+ if (self.condition != null) then {
+ code := code + '|' + self.condition.print(0)
+ }
+ endif;
+
+ code := code + ')';
+
+ if (self.body != null) then {
+ code := code + self.body.print(tabs);
+ }
+ endif;
+
+ return code;
+}
+
+helper ObjectExp::print(tabs : Integer) : String {
+ var code : String := 'object ' + self.referredObject.name;
+ code := code + ' : ' + self.eType.name + ' {\n';
+ code := code + self.body.print(tabs + 1);
+ code := code + printTabs(tabs) + '}';
+ return code;
+}
+
+helper SwitchExp::print(tabs : Integer) : String {
+ var code : String := 'switch {\n';
+ code := code + printExpressions(self.alternativePart, tabs + 1);
+ if (self.elsePart != null) then {
+ code := code + '\n' + printTabs(tabs + 1) + 'else ' + self.elsePart.print(tabs + 1);
+ }
+ endif;
+ code := code + '\n' + printTabs(tabs) + '}';
+ return code;
+}
+
+helper AltExp::print(tabs : Integer) : String {
+ var code : String := 'case ' + ' (' + self.condition.print(0) + ')\n';
+ code := code + printTabs(tabs) + self.body.print(tabs);
+ return code;
+}
+
+helper AssertExp::print(tabs : Integer) : String {
+ var code : String := 'assert(' + self.assertion.print(0) + ')';
+ return code;
+}
+
+helper AssignExp::print(tabs : Integer) : String {
+ var code : String := self.left.print(0);
+ code := code + ' := ';
+ self.value->forEach(expr) {
+ code := code + expr.print(0);
+ };
+ return code;
+}
+
+helper BlockExp::print(tabs : Integer) : String {
+ var code : String := '{\n';
+ code := code + printExpressions(self.body,tabs + 1);
+ code := code + printTabs(tabs) + '}';
+ return code
+}
+
+helper BreakExp::print(tabs : Integer) : String {
+ var code : String := 'break';
+ return code;
+}
+
+helper CatchExp::print(tabs : Integer) : String {
+ var code : String := 'catch';
+ return code;
+}
+
+helper ComputeExp::print(tabs : Integer) : String {
+ var code : String := 'compute(' + self.returnedElement.repr() + ') ';
+ code := code + self.body.print(tabs);
+ return code;
+}
+
+helper ContinueExp::print(tabs : Integer) : String {
+ var code : String := 'continue';
+ return code;
+}
+
+/*
+helper ForExp::print(tabs : Integer) : String {
+ var code : String := self.source
+ return code;
+}
+*/
+
+helper InstantiationExp::print(tabs : Integer) : String {
+ var code : String := 'InstantiationExpNotImpl';
+ return code;
+}
+
+helper DictLiteralPart::print(tabs : Integer) : String {
+ var code : String := self.key.print(tabs) + ' = ' + self.value.print(tabs);
+ return code;
+}
+
+helper DictLiteralExp::print(tabs : Integer) : String {
+ var code : String := 'Dict { ';
+ code := code + printArgs(self.part->asOrderedSet());
+ code := code + ' }';
+ return code;
+}
+
+helper ListLiteralExp::print(tabs : Integer) : String {
+ var code : String := 'ListLiteralExpNotImpl';
+ return code;
+}
+
+helper LogExp::print(tabs : Integer) : String {
+ var code : String := 'log(' + printArgs(self.argument) + ')';
+ return code;
+}
+
+helper RaiseExp::print(tabs : Integer) : String {
+ var code : String := 'raise';
+ return code;
+}
+
+helper ReturnExp::print(tabs : Integer) : String {
+ var code : String := 'return ' + self.value.print(tabs);
+ return code;
+}
+
+helper TryExp::print(tabs : Integer) : String {
+ var code : String := 'try';
+ return code;
+}
+
+helper Typedef::print(tabs : Integer) : String {
+ var code : String := 'typedef';
+ return code;
+}
+
+helper UnlinkExp::print(tabs : Integer) : String {
+ var code : String := 'unlink';
+ return code;
+}
+
+helper UnpackExp::print(tabs : Integer) : String {
+ var code : String := 'unpack';
+ return code;
+}
+
+helper VariableInitExp::print(tabs : Integer) : String {
+ var code := 'var ' + self.referredVariable.name + ' : ' + self.referredVariable.eType.name;
+ if (self.referredVariable.initExpression != null) then {
+ var iexp := self.referredVariable.initExpression;
+ code := code + ' := ' + iexp.print(tabs);
+ }
+ endif;
+ return code;
+}
+
+helper WhileExp::print(tabs : Integer) : String {
+ var code : String := 'while (' + self.condition.print(0) + ') ';
+ code := code + self.body.print(tabs);
+ return code;
+}
+
+helper ocl::ecore::StringLiteralExp::print(tabs : Integer) : String {
+ var code : String := self.stringSymbol.replace('\n','\\n').replace('\t','\\t').quotify('\'');
+ return code;
+}
+
+helper ocl::ecore::OperationCallExp::print(tabs : Integer) : String {
+ var code : String = '';
+ if self.oclIsUndefined() or self.oclIsInvalid() or (self.referredOperation.oclIsUndefined() and self.name.oclIsUndefined()) then
+ return code
+ endif;
+
+ if not self.source.oclIsUndefined() then {
+ code := code + self.source.print(0);
+ if (self.source.oclAsType(EOperation).upperBound <> 1) then {
+ code := code + '->';
+ } else {
+ code := code + '.';
+ } endif;
+ } endif;
+
+ code := code +
+ if self.referredOperation.oclIsUndefined() then
+ self.name
+ else self.referredOperation.oclAsType(ecore::EOperation).name endif;
+ code := code + '(' + printArgs(self.argument) + ')';
+
+ return code;
+}
+
+helper ocl::ecore::PropertyCallExp::print(tabs : Integer) : String {
+ var code : String := self.source.print(0);
+ code := code + '.' + if self.name.oclIsUndefined() then self.referredProperty.print(0) else self.name endif;
+
+ return code;
+}
+
+helper ocl::ecore::IfExp::print(tabs : Integer) : String {
+ var code : String := 'if ' + '(' + self.condition.print(0) + ')' + ' then ';
+ code := code + self.thenExpression.print(tabs) + '\n';
+ if self.elseExpression != null then {
+ code := code + printTabs(tabs) + 'else ' + self.elseExpression.print(tabs) + '\n';
+ }
+ endif;
+ code := code + printTabs(tabs) + 'endif';
+ return code;
+}
+
+helper ocl::ecore::OCLExpression::print(tabs : Integer) : String {
+ var code : String := self.repr();
+ return code;
+}
+
+helper ocl::expressions::OCLExpression::print(tabs : Integer) : String {
+ var code : String := self.repr();
+ return code;
+}
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/util/GmfGenUtil.qvto b/plugins/org.eclipse.gmf.bridge/transforms/util/GmfGenUtil.qvto
new file mode 100644
index 0000000..4342dc0
--- /dev/null
+++ b/plugins/org.eclipse.gmf.bridge/transforms/util/GmfGenUtil.qvto
@@ -0,0 +1,19 @@
+modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
+modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
+
+library GmfGenUtil;
+
+query GenCommonBase::parentID(visualID: Integer): Boolean = self.oclAsType(EObject).parentID(visualID);
+query Viewmap::parentID(visualID: Integer): Boolean = self.oclAsType(EObject).parentID(visualID);
+query ModelFacet::parentID(visualID: Integer): Boolean = self.oclAsType(EObject).parentID(visualID);
+query GenLinkConstraints::parentID(visualID: Integer): Boolean = self.oclAsType(EObject).parentID(visualID);
+query GenPreferencePage::parentID(visualID: Integer): Boolean = self.oclAsType(EObject).parentID(visualID);
+
+query EObject::parentID(visualID: Integer): Boolean =
+ if self.eContainer().oclIsKindOf(GenCommonBase) then
+ self.eContainer().oclAsType(GenContainerBase).visualID = visualID
+ else false endif;
+
+query GenPreferencePage::parentID(id: String): Boolean = self.oclAsType(GenPreferencePage).iD = id;
+
+query node(list: Set(GenNode), visualID: Integer): GenNode = list->any(e | e.visualID = visualID);
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/util/TraceUtil.qvto b/plugins/org.eclipse.gmf.bridge/transforms/util/TraceUtil.qvto
new file mode 100644
index 0000000..d7bee16
--- /dev/null
+++ b/plugins/org.eclipse.gmf.bridge/transforms/util/TraceUtil.qvto
@@ -0,0 +1,65 @@
+modeltype TRACE uses trace('http:///www.eclipse.org/m2m/qvt/operational/trace.ecore');
+modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings');
+modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
+modeltype OCL uses ocl('http://www.eclipse.org/ocl/1.1.0/OCL');
+modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
+
+library TraceUtil;
+
+query traces(): Sequence(TRACE::TraceRecord) {
+ return TRACE::TraceRecord.allInstances()->asSequence();
+}
+query Sequence(TRACE::TraceRecord)::inputElementIs(modelElement: GMFMAP::NeedsContainment): Sequence(TRACE::TraceRecord) {
+ return self->select(e | e.context.context.value.modelElement = modelElement)->asSequence();
+}
+query Sequence(TRACE::TraceRecord)::inputElementIs(modelElement: GMFMAP::MappingEntry): Sequence(TRACE::TraceRecord) {
+ return self->select(e | e.context.context.value.modelElement = modelElement)->asSequence();
+}
+query Sequence(TRACE::TraceRecord)::outputElementIs(modelElement: GMFGEN::GenCommonBase): Sequence(TRACE::TraceRecord) {
+ return self->select(e | e._result._result->exists(a | a.value.modelElement = modelElement))->asSequence();
+}
+query TraceRecord::getResultModelElement(): OclAny {
+ return self._result._result->first().value.modelElement;
+}
+query TraceRecord::getContextModelElement(): OclAny {
+ return self.context.context.value.modelElement;
+}
+query GMFGEN::GenNode::input(): GMFMAP::NodeReference {
+ return switch {
+ case (self.oclIsTypeOf(GenTopLevelNode)) self.oclAsType(GenTopLevelNode).input();
+ case (self.oclIsTypeOf(GenChildNode)) self.oclAsType(GenChildNode).input();
+ else null;
+ };
+}
+query GMFGEN::GenTopLevelNode::input(): GMFMAP::NodeReference {
+ return traces()->outputElementIs(self)->first().getContextModelElement().oclAsType(GMFMAP::TopNodeReference);
+}
+query GMFGEN::GenChildNode::input(): GMFMAP::NodeReference {
+ var records := traces()->outputElementIs(self);
+ if records->size() = 1 then {
+ return records->first().getContextModelElement().oclAsType(GMFMAP::ChildReference)
+ } endif;
+ return null;
+}
+query GMFGEN::GenLink::input(): GMFMAP::LinkMapping {
+ return traces()->outputElementIs(self)->first().getContextModelElement().oclAsType(GMFMAP::LinkMapping);
+}
+query GMFMAP::NeedsContainment::output(): GMFGEN::GenNode {
+ var records := traces()->inputElementIs(self);
+ if records->size() = 1 then {
+ return records->first().getResultModelElement().oclAsType(GenNode)
+ } endif;
+ return null;
+}
+query GMFMAP::MappingEntry::output(): GMFGEN::GenNode {
+ var records := traces()->inputElementIs(self);
+ if records->size() = 1 then {
+ return records->first().getResultModelElement().oclAsType(GenNode)
+ } else {
+ return self.getContainer().output();
+ } endif;
+ return null;
+}
+query GMFMAP::MappingEntry::getContainer(): GMFMAP::NeedsContainment {
+ return self.oclAsType(EObject).eContainer().oclAsType(GMFMAP::NeedsContainment);
+} \ No newline at end of file
diff --git a/tests/org.eclipse.gmf.tests/models/tests/audits.gmfmap b/tests/org.eclipse.gmf.tests/models/tests/audits.gmfmap
new file mode 100644
index 0000000..6ab7377
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/audits.gmfmap
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="ASCII"?>
+<gmfmap:Mapping xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
+ xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeSrcA"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//NodeSrcA/label"/>
+ </labelMappings>
+ <contextMenu
+ href="test.gmftool#//@allMenus.1"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <childrenFeature
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ </ownedChild>
+ </children>
+ </ownedChild>
+ </nodes>
+ <diagram>
+ <diagramCanvas
+ href="test.gmfgraph#Test-dd-canvas"/>
+ <domainModel
+ href="test.ecore#/"/>
+ <domainMetaElement
+ href="test.ecore#//UltimateContainer"/>
+ <palette
+ href="test.gmftool#//@palette"/>
+ <menuContributions
+ href="test.gmftool#//@allMenus.0"/>
+ </diagram>
+ <audits
+ id="test"
+ name="test"
+ description="All Audits">
+ <audits
+ name="Node Label"
+ description="Empty node label check"
+ id="node_label"
+ message="Node label should not be empty">
+ <rule
+ body="label.size() > 0"/>
+ <target
+ xsi:type="gmfmap:DomainElementTarget">
+ <element
+ href="test.ecore#//NodeSrcA"/>
+ </target>
+ </audits>
+ <audits
+ name="Node Label 2"
+ description="Node Label should be set"
+ id="node_label_2"
+ severity="WARNING"
+ message="Node Label should be set">
+ <rule
+ body="size() > 0"/>
+ <target
+ xsi:type="gmfmap:DomainAttributeTarget">
+ <attribute
+ href="test.ecore#//NodeSrcA/label"/>
+ </target>
+ </audits>
+ <audits
+ name="Node Type"
+ description="Node type check"
+ id="node_type"
+ message="Invalid Node Type">
+ <rule
+ body="element.eClass().name = 'NodeSrcA'"/>
+ <target
+ xsi:type="gmfmap:DiagramElementTarget"
+ element="//@nodes.0/@ownedChild"/>
+ </audits>
+ <audits
+ name="Node Audit Metric"
+ description="Some Audit Metric"
+ id="NodeAuditMetric"
+ message="Some Stuff">
+ <rule
+ body="true"/>
+ <target
+ xsi:type="gmfmap:AuditedMetricTarget"
+ metric="//@metrics/@metrics.0"/>
+ </audits>
+ </audits>
+ <metrics>
+ <metrics
+ name="Node Metric"
+ description="Some Metric"
+ key="NodeMetric"
+ lowLimit="5.0"
+ highLimit="10.0">
+ <rule
+ body="label->size()"/>
+ <target
+ xsi:type="gmfmap:DomainElementTarget">
+ <element
+ href="test.ecore#//NodeSrcA"/>
+ </target>
+ </metrics>
+ </metrics>
+</gmfmap:Mapping>
diff --git a/tests/org.eclipse.gmf.tests/models/tests/compartments_ref_node.gmfmap b/tests/org.eclipse.gmf.tests/models/tests/compartments_ref_node.gmfmap
new file mode 100644
index 0000000..c94e213
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/compartments_ref_node.gmfmap
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmfmap:Mapping xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
+ xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeTargetC"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#DiagramLabelWithFont"/>
+ <features
+ href="test.ecore#//NodeTargetB/title"/>
+ </labelMappings>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children
+ compartment="//@nodes.0/@ownedChild/@compartments.0">
+ <containmentFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <childrenFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#ColoredRectangleNode"/>
+ <children
+ compartment="//@nodes.0/@ownedChild/@children.0/@ownedChild/@compartments.0"
+ referencedChild="//@nodes.0/@ownedChild/@children.0/@ownedChild">
+ <containmentFeature
+ href="test.ecore#//Child/innerChildrenOfBChild"/>
+ <childrenFeature
+ href="test.ecore#//Child/innerChildrenOfBChild"/>
+ </children>
+ <compartments
+ children="//@nodes.0/@ownedChild/@children.0/@ownedChild/@children.0">
+ <compartment
+ href="test.gmfgraph#Compartment_Title_Collapse"/>
+ </compartments>
+ </ownedChild>
+ </children>
+ <compartments
+ children="//@nodes.0/@ownedChild/@children.0">
+ <compartment
+ href="test.gmfgraph#Compartment_NoTitle_No_Collapse"/>
+ </compartments>
+ </ownedChild>
+ </nodes>
+ <diagram>
+ <diagramCanvas
+ href="test.gmfgraph#Test-dd-canvas"/>
+ <domainModel
+ href="test.ecore#/"/>
+ <domainMetaElement
+ href="test.ecore#//UltimateContainer"/>
+ <palette
+ href="test.gmftool#//@palette"/>
+ </diagram>
+</gmfmap:Mapping>
diff --git a/tests/org.eclipse.gmf.tests/models/tests/ext.model b/tests/org.eclipse.gmf.tests/models/tests/ext.model
new file mode 100644
index 0000000..e5ca836
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/ext.model
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ASCII"?>
+<extmap:CopyrightInput xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:extmap="http://www.example.org/extmap" xmi:id="_8lmdkRXsEeGpaPpT4wDcuw" author="John"/>
diff --git a/tests/org.eclipse.gmf.tests/models/tests/links.gmfmap b/tests/org.eclipse.gmf.tests/models/tests/links.gmfmap
new file mode 100644
index 0000000..ba01fac
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/links.gmfmap
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="ASCII"?>
+<gmfmap:Mapping xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings">
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeTargetD"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//NodeTargetB/title"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children>
+ <containmentFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <childrenFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ </ownedChild>
+ </children>
+ </ownedChild>
+ </nodes>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//NodeSrcA"/>
+ <domainSpecialization
+ body="true"/>
+ <domainInitializer
+ xsi:type="gmfmap:FeatureSeqInitializer">
+ <initializers
+ xsi:type="gmfmap:FeatureValueSpec">
+ <feature
+ xsi:type="ecore:EAttribute"
+ href="test.ecore#//NodeSrcA/label"/>
+ <value
+ body="'hello'"/>
+ </initializers>
+ </domainInitializer>
+ <labelMappings>
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ </labelMappings>
+ <labelMappings
+ xsi:type="gmfmap:ExpressionLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <viewExpression
+ body="'hello'"/>
+ </labelMappings>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <creationConstraints>
+ <sourceEnd
+ body="true"/>
+ <targetEnd
+ body="true"/>
+ </creationConstraints>
+ </links>
+ <diagram>
+ <diagramCanvas
+ href="test.gmfgraph#Test-dd-canvas"/>
+ <domainModel
+ href="test.ecore#/"/>
+ <domainMetaElement
+ href="test.ecore#//UltimateContainer"/>
+ <palette
+ href="test.gmftool#//@palette"/>
+ <menuContributions
+ href="test.gmftool#//@allMenus.0"/>
+ </diagram>
+</gmfmap:Mapping>
diff --git a/tests/org.eclipse.gmf.tests/models/tests/nodes_labels.gmfmap b/tests/org.eclipse.gmf.tests/models/tests/nodes_labels.gmfmap
new file mode 100644
index 0000000..186e455
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/nodes_labels.gmfmap
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="ASCII"?>
+<gmfmap:Mapping xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
+ xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeSrcA"/>
+ <domainSpecialization
+ body="true"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//NodeSrcA/label"/>
+ </labelMappings>
+ <labelMappings
+ xsi:type="gmfmap:ExpressionLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <viewExpression
+ body="true"/>
+ </labelMappings>
+ <contextMenu
+ href="test.gmftool#//@allMenus.1"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <childrenFeature
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#DiagramLabelWithFont"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <labelMappings>
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ </labelMappings>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children>
+ <containmentFeature
+ href="test.ecore#//Child/innerChildrenOfBChild"/>
+ <childrenFeature
+ href="test.ecore#//Child/innerChildrenOfBChild"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <domainSpecialization
+ body="false"
+ language="java"/>
+ <labelMappings>
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ </labelMappings>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ </ownedChild>
+ </children>
+ </ownedChild>
+ </children>
+ </ownedChild>
+ </nodes>
+ <diagram>
+ <diagramCanvas
+ href="test.gmfgraph#Test-dd-canvas"/>
+ <domainModel
+ href="test.ecore#/"/>
+ <domainMetaElement
+ href="test.ecore#//UltimateContainer"/>
+ <palette
+ href="test.gmftool#//@palette"/>
+ <menuContributions
+ href="test.gmftool#//@allMenus.0"/>
+ </diagram>
+</gmfmap:Mapping>
diff --git a/tests/org.eclipse.gmf.tests/models/tests/test-ext.gmfmap b/tests/org.eclipse.gmf.tests/models/tests/test-ext.gmfmap
new file mode 100644
index 0000000..982b9f5
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/test-ext.gmfmap
@@ -0,0 +1,333 @@
+<?xml version="1.0" encoding="ASCII"?>
+<gmfmap:Mapping xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:extmap="http://www.example.org/extmap"
+ xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
+ xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeSrcA"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//NodeSrcA/label"/>
+ </labelMappings>
+ <contextMenu
+ href="test.gmftool#//@allMenus.1"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children
+ compartment="//@nodes.0/@ownedChild/@compartments.0">
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <childrenFeature
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ </ownedChild>
+ </children>
+ <children
+ compartment="//@nodes.0/@ownedChild/@compartments.0">
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/children2OfA"/>
+ <childrenFeature
+ href="test.ecore#//NodeSrcA/children2OfA"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child2"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child2/childLabel"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#TestLabel"/>
+ </ownedChild>
+ </children>
+ <compartments
+ children="//@nodes.0/@ownedChild/@children.0 //@nodes.0/@ownedChild/@children.1">
+ <compartment
+ href="test.gmfgraph#Compartment_Title_Collapse"/>
+ </compartments>
+ </ownedChild>
+ </nodes>
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeTargetC"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#DiagramLabelWithFont"/>
+ <features
+ href="test.ecore#//NodeTargetB/title"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#ColoredRectangleNode"/>
+ <children
+ compartment="//@nodes.1/@ownedChild/@compartments.0">
+ <containmentFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <childrenFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#DiagramLabelWithFont"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#ColoredRectangleNode"/>
+ <children
+ compartment="//@nodes.1/@ownedChild/@children.0/@ownedChild/@compartments.0"
+ referencedChild="//@nodes.1/@ownedChild/@children.0/@ownedChild">
+ <containmentFeature
+ href="test.ecore#//Child/innerChildrenOfBChild"/>
+ <childrenFeature
+ href="test.ecore#//Child/innerChildrenOfBChild"/>
+ </children>
+ <compartments
+ children="//@nodes.1/@ownedChild/@children.0/@ownedChild/@children.0">
+ <compartment
+ href="test.gmfgraph#Compartment_NoTitle_No_Collapse"/>
+ </compartments>
+ </ownedChild>
+ </children>
+ <compartments
+ children="//@nodes.1/@ownedChild/@children.0">
+ <compartment
+ href="test.gmfgraph#Compartment_NoTitle_No_Collapse"/>
+ </compartments>
+ </ownedChild>
+ </nodes>
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeTargetD"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//NodeTargetB/title"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children>
+ <containmentFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <childrenFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ </ownedChild>
+ </children>
+ </ownedChild>
+ </nodes>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkAtoC"/>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/classLinkToC"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC/trg"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#ColoredLinkConnection"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/refLinkToB"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkAtoC_Cardinality2"/>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/classLinkToC_Cardinality2"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC_Cardinality2/trg"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkAtoC_Cardinality1"/>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/classLinkToC_Cardinality1"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC_Cardinality1/trg"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkAtoA"/>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/classLinkToA"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoA/trg"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/refLinkToB_Cardinality2"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/refLinkToB_Cardinality1"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/refLinkToA"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//Link2Link"/>
+ <containmentFeature
+ href="test.ecore#//NodeTargetD/classLinkToLink"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//Link2Link/trg"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkFromLink"/>
+ <containmentFeature
+ href="test.ecore#//LinkAtoC/classLinkFromLink"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkFromLink/trg"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkCrossLink"/>
+ <containmentFeature
+ href="test.ecore#//LinkAtoC/classLinkCrossLink"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkCrossLink/trg"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeTargetD/refLinkToLink"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC/refLinkFromLink"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC/refLinkCrossLink"/>
+ </links>
+ <diagram>
+ <diagramCanvas
+ href="test.gmfgraph#Test-dd-canvas"/>
+ <domainModel
+ href="test.ecore#/"/>
+ <domainMetaElement
+ href="test.ecore#//UltimateContainer"/>
+ <palette
+ href="test.gmftool#//@palette"/>
+ <menuContributions
+ href="test.gmftool#//@allMenus.0"/>
+ </diagram>
+ <extensionInputs
+ xsi:type="extmap:CopyrightInput"
+ author="John"
+ entries="//@nodes.0/@ownedChild"/>
+</gmfmap:Mapping> \ No newline at end of file
diff --git a/tests/org.eclipse.gmf.tests/models/tests/test.ecore b/tests/org.eclipse.gmf.tests/models/tests/test.ecore
new file mode 100644
index 0000000..48e8bfb
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/test.ecore
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="samplemodel"
+ nsURI="uri://eclipse/gmf/tests/sample/15/4/" nsPrefix="gmftest">
+ <eClassifiers xsi:type="ecore:EClass" name="CommonBaseClass" abstract="true"/>
+ <eClassifiers xsi:type="ecore:EClass" name="UltimateContainer">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="all" upperBound="-1" eType="#//CommonBaseClass"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="diagramAttribute" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="NodeSrcA" eSuperTypes="#//CommonBaseClass">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="label" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="refLinkToB" upperBound="-1"
+ eType="#//NodeTargetB"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="refLinkToB_Cardinality2"
+ upperBound="2" eType="#//NodeTargetB"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="refLinkToB_Cardinality1"
+ eType="#//NodeTargetB"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="refLinkToA" upperBound="-1"
+ eType="#//NodeSrcA"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="classLinkToC" upperBound="-1"
+ eType="#//LinkAtoC" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="classLinkToC_Cardinality2"
+ upperBound="2" eType="#//LinkAtoC_Cardinality2" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="classLinkToC_Cardinality1"
+ eType="#//LinkAtoC_Cardinality1" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="classLinkToA" upperBound="-1"
+ eType="#//LinkAtoA" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="children1OfA" upperBound="-1"
+ eType="#//Child" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="children2OfA" upperBound="-1"
+ eType="#//Child2" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="NodeTargetB" eSuperTypes="#//CommonBaseClass">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="childrenOfB" upperBound="-1"
+ eType="#//Child" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="NodeTargetC" eSuperTypes="#//NodeTargetB"/>
+ <eClassifiers xsi:type="ecore:EClass" name="NodeTargetD" eSuperTypes="#//NodeTargetB">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="refLinkToLink" upperBound="3"
+ eType="#//LinkAtoC"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="classLinkToLink" upperBound="3"
+ eType="#//Link2Link" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="LinkAtoC">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="refLinkFromLink" upperBound="4"
+ eType="#//NodeTargetD"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="refLinkCrossLink" upperBound="5"
+ eType="#//LinkAtoC"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="trg" unique="false" eType="#//NodeTargetC"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="classLinkFromLink" upperBound="4"
+ eType="#//LinkFromLink" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="classLinkCrossLink" upperBound="5"
+ eType="#//LinkCrossLink" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="LinkAtoC_Cardinality2">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="trg" upperBound="-1" eType="#//NodeTargetC"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="LinkAtoC_Cardinality1">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="trg" unique="false" eType="#//NodeTargetC"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="LinkAtoA">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="trg" unique="false" eType="#//NodeSrcA"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Child">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="childLabel" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="innerChildrenOfBChild"
+ upperBound="-1" eType="#//Child" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Child2">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="childLabel" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Link2Link">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="trg" unique="false" eType="#//LinkAtoC"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="LinkFromLink">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="trg" unique="false" eType="#//NodeTargetD"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="LinkCrossLink">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="trg" unique="false" eType="#//LinkAtoC"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/tests/org.eclipse.gmf.tests/models/tests/test.genmodel b/tests/org.eclipse.gmf.tests/models/tests/test.genmodel
new file mode 100644
index 0000000..79ffedc
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/test.genmodel
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/model/"
+ modelPluginID="TransformToGenModelOperationTest_1318424284727" modelName="Samplemodel"
+ copyrightFields="false">
+ <genPackages prefix="Samplemodel" basePackage="transformtogenmodeloperationtest_1318424284727"
+ disposableProviderFactory="true" ecorePackage="test.ecore#/">
+ <genClasses image="false" ecoreClass="test.ecore#//CommonBaseClass"/>
+ <genClasses ecoreClass="test.ecore#//UltimateContainer">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//UltimateContainer/all"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//UltimateContainer/diagramAttribute"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//NodeSrcA">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//NodeSrcA/label"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/refLinkToB"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/refLinkToB_Cardinality2"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/refLinkToB_Cardinality1"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/refLinkToA"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/classLinkToC"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/classLinkToC_Cardinality2"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/classLinkToC_Cardinality1"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/classLinkToA"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/children1OfA"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//NodeSrcA/children2OfA"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//NodeTargetB">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//NodeTargetB/title"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//NodeTargetB/childrenOfB"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//NodeTargetC"/>
+ <genClasses ecoreClass="test.ecore#//NodeTargetD">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//NodeTargetD/refLinkToLink"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//NodeTargetD/classLinkToLink"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//LinkAtoC">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//LinkAtoC/refLinkFromLink"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//LinkAtoC/refLinkCrossLink"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//LinkAtoC/trg"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//LinkAtoC/classLinkFromLink"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//LinkAtoC/classLinkCrossLink"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//LinkAtoC_Cardinality2">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//LinkAtoC_Cardinality2/trg"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//LinkAtoC_Cardinality1">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//LinkAtoC_Cardinality1/trg"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//LinkAtoA">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//LinkAtoA/trg"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//Child">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//Child/childLabel"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//Child/innerChildrenOfBChild"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//Child2">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//Child2/childLabel"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//Link2Link">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//Link2Link/trg"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//LinkFromLink">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//LinkFromLink/trg"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//LinkCrossLink">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference test.ecore#//LinkCrossLink/trg"/>
+ </genClasses>
+ </genPackages>
+</genmodel:GenModel> \ No newline at end of file
diff --git a/tests/org.eclipse.gmf.tests/models/tests/test.gmfgraph b/tests/org.eclipse.gmf.tests/models/tests/test.gmfgraph
new file mode 100644
index 0000000..7112dd5
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/test.gmfgraph
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="ASCII"?>
+<gmfgraph:Canvas xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition" name="Test-dd-canvas">
+ <figures
+ name="fc1">
+ <descriptors
+ name="nf1">
+ <actualFigure
+ xsi:type="gmfgraph:RoundedRectangle"/>
+ </descriptors>
+ <descriptors
+ name="lf1">
+ <actualFigure
+ xsi:type="gmfgraph:PolylineConnection"/>
+ </descriptors>
+ <descriptors
+ name="LabelFig">
+ <actualFigure
+ xsi:type="gmfgraph:Label"/>
+ </descriptors>
+ <descriptors
+ name="ColoredLink">
+ <actualFigure
+ xsi:type="gmfgraph:PolylineConnection">
+ <foregroundColor
+ xsi:type="gmfgraph:ConstantColor"
+ value="orange"/>
+ </actualFigure>
+ </descriptors>
+ <descriptors
+ name="ColoredRectangle">
+ <actualFigure
+ xsi:type="gmfgraph:Rectangle">
+ <foregroundColor
+ xsi:type="gmfgraph:ConstantColor"
+ value="red"/>
+ <backgroundColor
+ xsi:type="gmfgraph:ConstantColor"
+ value="blue"/>
+ </actualFigure>
+ </descriptors>
+ <descriptors
+ name="CompartmentFigureA">
+ <actualFigure
+ xsi:type="gmfgraph:Rectangle"/>
+ </descriptors>
+ <descriptors
+ name="CompartmentFigureB">
+ <actualFigure
+ xsi:type="gmfgraph:Rectangle"/>
+ </descriptors>
+ <descriptors
+ name="LabelWithFont">
+ <actualFigure
+ xsi:type="gmfgraph:Label"
+ text="LabelText">
+ <font
+ xsi:type="gmfgraph:BasicFont"
+ faceName="Arial"
+ height="18"
+ style="BOLD"/>
+ </actualFigure>
+ </descriptors>
+ </figures>
+ <nodes
+ name="Test-dd-node"
+ figure="nf1"/>
+ <nodes
+ name="ColoredRectangleNode"
+ figure="ColoredRectangle"/>
+ <connections
+ name="Test-dd-link"
+ figure="lf1"/>
+ <connections
+ name="ColoredLinkConnection"
+ figure="ColoredLink"/>
+ <compartments
+ name="Compartment_Title_Collapse"
+ figure="CompartmentFigureA"
+ collapsible="true"
+ needsTitle="true"/>
+ <compartments
+ name="Compartment_NoTitle_No_Collapse"
+ figure="CompartmentFigureB"/>
+ <labels
+ name="TestLabel"
+ figure="LabelFig"/>
+ <labels
+ name="DiagramLabelWithFont"
+ figure="LabelWithFont"/>
+</gmfgraph:Canvas>
diff --git a/tests/org.eclipse.gmf.tests/models/tests/test.gmfmap b/tests/org.eclipse.gmf.tests/models/tests/test.gmfmap
new file mode 100644
index 0000000..d7dbaff
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/test.gmfmap
@@ -0,0 +1,328 @@
+<?xml version="1.0" encoding="ASCII"?>
+<gmfmap:Mapping xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
+ xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeSrcA"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//NodeSrcA/label"/>
+ </labelMappings>
+ <contextMenu
+ href="test.gmftool#//@allMenus.1"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children
+ compartment="//@nodes.0/@ownedChild/@compartments.0">
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <childrenFeature
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.0"/>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ </ownedChild>
+ </children>
+ <children
+ compartment="//@nodes.0/@ownedChild/@compartments.0">
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/children2OfA"/>
+ <childrenFeature
+ href="test.ecore#//NodeSrcA/children2OfA"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child2"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child2/childLabel"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#TestLabel"/>
+ </ownedChild>
+ </children>
+ <compartments
+ children="//@nodes.0/@ownedChild/@children.0 //@nodes.0/@ownedChild/@children.1">
+ <compartment
+ href="test.gmfgraph#Compartment_Title_Collapse"/>
+ </compartments>
+ </ownedChild>
+ </nodes>
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeTargetC"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#DiagramLabelWithFont"/>
+ <features
+ href="test.ecore#//NodeTargetB/title"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#ColoredRectangleNode"/>
+ <children
+ compartment="//@nodes.1/@ownedChild/@compartments.0">
+ <containmentFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <childrenFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#DiagramLabelWithFont"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#ColoredRectangleNode"/>
+ <children
+ compartment="//@nodes.1/@ownedChild/@children.0/@ownedChild/@compartments.0"
+ referencedChild="//@nodes.1/@ownedChild/@children.0/@ownedChild">
+ <containmentFeature
+ href="test.ecore#//Child/innerChildrenOfBChild"/>
+ <childrenFeature
+ href="test.ecore#//Child/innerChildrenOfBChild"/>
+ </children>
+ <compartments
+ children="//@nodes.1/@ownedChild/@children.0/@ownedChild/@children.0">
+ <compartment
+ href="test.gmfgraph#Compartment_NoTitle_No_Collapse"/>
+ </compartments>
+ </ownedChild>
+ </children>
+ <compartments
+ children="//@nodes.1/@ownedChild/@children.0">
+ <compartment
+ href="test.gmfgraph#Compartment_NoTitle_No_Collapse"/>
+ </compartments>
+ </ownedChild>
+ </nodes>
+ <nodes>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//NodeTargetD"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//NodeTargetB/title"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ <children>
+ <containmentFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <childrenFeature
+ href="test.ecore#//NodeTargetB/childrenOfB"/>
+ <ownedChild>
+ <domainMetaElement
+ href="test.ecore#//Child"/>
+ <labelMappings
+ xsi:type="gmfmap:FeatureLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <features
+ href="test.ecore#//Child/childLabel"/>
+ </labelMappings>
+ <diagramNode
+ href="test.gmfgraph#Test-dd-node"/>
+ </ownedChild>
+ </children>
+ </ownedChild>
+ </nodes>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkAtoC"/>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/classLinkToC"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC/trg"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#ColoredLinkConnection"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/refLinkToB"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkAtoC_Cardinality2"/>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/classLinkToC_Cardinality2"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC_Cardinality2/trg"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkAtoC_Cardinality1"/>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/classLinkToC_Cardinality1"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC_Cardinality1/trg"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkAtoA"/>
+ <containmentFeature
+ href="test.ecore#//NodeSrcA/classLinkToA"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoA/trg"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/refLinkToB_Cardinality2"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/refLinkToB_Cardinality1"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/refLinkToA"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//Link2Link"/>
+ <containmentFeature
+ href="test.ecore#//NodeTargetD/classLinkToLink"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//Link2Link/trg"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkFromLink"/>
+ <containmentFeature
+ href="test.ecore#//LinkAtoC/classLinkFromLink"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkFromLink/trg"/>
+ </links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//LinkCrossLink"/>
+ <containmentFeature
+ href="test.ecore#//LinkAtoC/classLinkCrossLink"/>
+ <tool
+ xsi:type="gmftool:CreationTool"
+ href="test.gmftool#//@palette/@tools.1"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkCrossLink/trg"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeTargetD/refLinkToLink"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC/refLinkFromLink"/>
+ </links>
+ <links>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//LinkAtoC/refLinkCrossLink"/>
+ </links>
+ <diagram>
+ <diagramCanvas
+ href="test.gmfgraph#Test-dd-canvas"/>
+ <domainModel
+ href="test.ecore#/"/>
+ <domainMetaElement
+ href="test.ecore#//UltimateContainer"/>
+ <palette
+ href="test.gmftool#//@palette"/>
+ <menuContributions
+ href="test.gmftool#//@allMenus.0"/>
+ </diagram>
+</gmfmap:Mapping> \ No newline at end of file
diff --git a/tests/org.eclipse.gmf.tests/models/tests/test.gmftool b/tests/org.eclipse.gmf.tests/models/tests/test.gmftool
new file mode 100644
index 0000000..38afa32
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/test.gmftool
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="ASCII"?>
+<gmftool:ToolRegistry xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
+ <sharedActions
+ title="SharedA2">
+ <icon
+ xsi:type="gmftool:BundleImage"
+ path="/icons/obj16/SharedA2.gif"/>
+ </sharedActions>
+ <allMenus
+ xsi:type="gmftool:MainMenu"
+ title="ToolDefSetup">
+ <items
+ xsi:type="gmftool:MenuAction"
+ title="a1">
+ <icon
+ xsi:type="gmftool:BundleImage"
+ path="/icons/obj16/a1.gif"/>
+ </items>
+ <items
+ xsi:type="gmftool:Separator"/>
+ <items
+ xsi:type="gmftool:ItemRef"
+ item="//@sharedActions.0"/>
+ </allMenus>
+ <allMenus
+ xsi:type="gmftool:ContextMenu">
+ <items
+ xsi:type="gmftool:MenuAction"
+ title="a3">
+ <icon
+ xsi:type="gmftool:BundleImage"
+ path="/icons/obj16/a3.gif"/>
+ </items>
+ <items
+ xsi:type="gmftool:ItemRef"
+ item="//@sharedActions.0"/>
+ </allMenus>
+ <palette>
+ <tools
+ xsi:type="gmftool:CreationTool"
+ title="Node1"/>
+ <tools
+ xsi:type="gmftool:CreationTool"
+ title="Link1"/>
+ </palette>
+</gmftool:ToolRegistry>
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
index 3478f67..47971a8 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
@@ -8,7 +8,6 @@
*
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
- * Mickael Istria (EBM Websourcing) - Support for target platform creation
*/
package org.eclipse.gmf.tests;
@@ -83,6 +82,12 @@ import org.eclipse.gmf.tests.tr.QvtGenModelTransformerBasicRTTest;
import org.eclipse.gmf.tests.tr.QvtGenModelTransformerSimpleTest;
import org.eclipse.gmf.tests.tr.QvtLabelMappingTransformTest;
import org.eclipse.gmf.tests.tr.QvtPaletteTransformationTest;
+import org.eclipse.gmf.tests.tr.QvtTransformComparisonAudtisTest;
+import org.eclipse.gmf.tests.tr.QvtTransformComparisonCompartmentRefNodeTest;
+import org.eclipse.gmf.tests.tr.QvtTransformComparisonFullTest;
+import org.eclipse.gmf.tests.tr.QvtTransformComparisonLinksTest;
+import org.eclipse.gmf.tests.tr.QvtTransformComparisonNodeLabelsTest;
+import org.eclipse.gmf.tests.tr.QvtTransformModeledViewmapTest;
import org.eclipse.gmf.tests.tr.TestDefaultMergeService;
import org.eclipse.gmf.tests.tr.TransformToGenModelOperationTest;
import org.eclipse.gmf.tests.tr.XmlTextMergerTest;
@@ -100,11 +105,38 @@ import org.osgi.framework.Bundle;
@SuppressWarnings("restriction")
public class AllTests {
+ public static void setTargetPlatform() throws Exception {
+ ITargetPlatformService tpService = TargetPlatformService.getDefault();
+ ITargetDefinition targetDef = tpService.newTarget();
+ targetDef.setName("Tycho platform");
+ Bundle[] bundles = Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles();
+ List<IBundleContainer> bundleContainers = new ArrayList<IBundleContainer>();
+ Set<File> dirs = new HashSet<File>();
+ for (Bundle bundle : bundles) {
+ AbstractBundle aBundle = (AbstractBundle)bundle;
+ final BaseData bundleData = (BaseData)aBundle.getBundleData();
+ File file = bundleData.getBundleFile().getBaseFile();
+ File folder = file.getParentFile();
+ if (!dirs.contains(folder)) {
+ dirs.add(folder);
+ bundleContainers.add(tpService.newDirectoryContainer(folder.getAbsolutePath()));
+ }
+ }
+ targetDef.setBundleContainers(bundleContainers.toArray(new IBundleContainer[0]));
+ targetDef.setArch(Platform.getOSArch());
+ targetDef.setOS(Platform.getOS());
+ targetDef.setWS(Platform.getWS());
+ targetDef.setNL(Platform.getNL());
+ //targetDef.setJREContainer()
+ tpService.saveTargetDefinition(targetDef);
+ LoadTargetDefinitionJob.load(targetDef);
+ }
+
public static Test suite() throws Exception {
if (System.getProperty("buildingWithTycho") != null) {
System.err.println("Generating a target platform");
- Utils.setTargetPlatform();
+ setTargetPlatform();
}
@@ -172,6 +204,12 @@ public class AllTests {
suite.addTestSuite(QvtGenModelTransformerBasicRTTest.class);
suite.addTestSuite(QvtLabelMappingTransformTest.class);
suite.addTestSuite(QvtPaletteTransformationTest.class);
+ suite.addTestSuite(QvtTransformComparisonNodeLabelsTest.class);
+ suite.addTestSuite(QvtTransformComparisonLinksTest.class);
+ suite.addTestSuite(QvtTransformComparisonAudtisTest.class);
+ suite.addTestSuite(QvtTransformComparisonCompartmentRefNodeTest.class);
+ suite.addTestSuite(QvtTransformComparisonFullTest.class);
+ suite.addTestSuite(QvtTransformModeledViewmapTest.class);
suite.addTestSuite(EcoreGenModelMatcherTest.class);
suite.addTestSuite(ModelLoadHelperTest.class);
@@ -263,6 +301,12 @@ public class AllTests {
c.register(QvtGenModelTransformerBasicRTTest.class, SessionSetup.class);
c.register(QvtLabelMappingTransformTest.class, SessionSetup.class);
c.register(QvtPaletteTransformationTest.class, SessionSetup.class);
+ c.register(QvtTransformComparisonNodeLabelsTest.class, SessionSetup.class);
+ c.register(QvtTransformComparisonLinksTest.class, SessionSetup.class);
+ c.register(QvtTransformComparisonAudtisTest.class, SessionSetup.class);
+ c.register(QvtTransformComparisonCompartmentRefNodeTest.class, SessionSetup.class);
+ c.register(QvtTransformComparisonFullTest.class, SessionSetup.class);
+ c.register(QvtTransformModeledViewmapTest.class, SessionSetup.class);
// Default configuration, TestAllDerivedFeatures also runs for LinksSessionSetup
c.register(TestAllDerivedFeatures.class, SessionSetup.class);
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerTest.java
index b51ac07..665607f 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerTest.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerTest.java
@@ -24,30 +24,39 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.gmfgen.GenLink;
+import org.eclipse.gmf.codegen.gmfgen.GenNode;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
import org.eclipse.gmf.codegen.gmfgen.Palette;
import org.eclipse.gmf.codegen.gmfgen.ToolEntry;
import org.eclipse.gmf.codegen.gmfgen.ToolGroup;
import org.eclipse.gmf.codegen.gmfgen.ToolGroupItem;
import org.eclipse.gmf.internal.bridge.genmodel.DiagramRunTimeModelHelper;
+import org.eclipse.gmf.mappings.GMFMapPackage;
import org.eclipse.gmf.mappings.LinkMapping;
import org.eclipse.gmf.mappings.Mapping;
+import org.eclipse.gmf.mappings.NodeMapping;
import org.eclipse.gmf.mappings.TopNodeReference;
import org.eclipse.gmf.tests.Utils;
+import org.eclipse.m2m.internal.qvt.oml.InternalTransformationExecutor;
+import org.eclipse.m2m.internal.qvt.oml.trace.Trace;
+import org.eclipse.m2m.internal.qvt.oml.trace.TraceRecord;
import org.eclipse.m2m.qvt.oml.BasicModelExtent;
import org.eclipse.m2m.qvt.oml.ExecutionContextImpl;
import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
import org.eclipse.m2m.qvt.oml.ModelExtent;
-import org.eclipse.m2m.qvt.oml.TransformationExecutor;
+@SuppressWarnings("restriction")
public abstract class QvtGenModelTransformerTest extends AbstractMappingTransformerTest {
protected GenEditorGenerator myTransformationResult;
- private final DiagramRunTimeModelHelper myDiagramModelHelper;
+// private final DiagramRunTimeModelHelper myDiagramModelHelper;
+ protected Resource traceResource;
protected QvtGenModelTransformerTest(String name, DiagramRunTimeModelHelper rtHelper) {
super(name);
assert rtHelper != null;
- myDiagramModelHelper = rtHelper;
+// myDiagramModelHelper = rtHelper;
}
protected void setUp() throws Exception {
@@ -60,8 +69,15 @@ public abstract class QvtGenModelTransformerTest extends AbstractMappingTransfor
Mapping mapping = getMapping();
ResourceSet resourceSet = genModel.eResource().getResourceSet();
-
- TransformationExecutor executor = new TransformationExecutor(URI.createURI("platform:/plugin/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto"));
+ traceResource = resourceSet.createResource(URI.createURI("test.qvtotrace"));
+ InternalTransformationExecutor executor = //new TransformationExecutor(URI.createURI("platform:/plugin/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto"));
+ new InternalTransformationExecutor(URI.createURI("platform:/plugin/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto")) {
+ @Override
+ protected void handleExecutionTraces(Trace traces) {
+ traceResource.getContents().add(traces);
+ super.handleExecutionTraces(traces);
+ }
+ };
ExecutionContextImpl context = new ExecutionContextImpl();
context.setConfigProperty("rcp", false);
context.setConfigProperty("useMapMode", false);
@@ -81,12 +97,10 @@ public abstract class QvtGenModelTransformerTest extends AbstractMappingTransfor
ModelExtent output = new BasicModelExtent();
ExecutionDiagnostic result = executor.execute(context, inMap, inGen, inNotation, output);
- System.out.println( result.getStackTrace() );
if(result.getSeverity() == Diagnostic.OK) {
List<EObject> outObjects = output.getContents();
-// assertEquals(1, outObjects.size());
assertTrue(outObjects.get(0) instanceof GenEditorGenerator);
return (GenEditorGenerator) outObjects.get(0);
@@ -95,34 +109,66 @@ public abstract class QvtGenModelTransformerTest extends AbstractMappingTransfor
return null;
}
+ protected GenNode[] find(NodeMapping nodeMap) {
+ assert nodeMap != null;
+ GenNode genNode = findTopNode(nodeMap);
+ return genNode != null ? new GenNode[] {genNode} : new GenNode[]{};//findChildNodes(nodeMap);
+ }
+
+ protected GenTopLevelNode findTopNode(NodeMapping nodeMap) {
+ assert nodeMap != null;
+ Trace trace = (Trace) traceResource.getContents().get(0);
+ for (TraceRecord record: trace.getTraceRecords()) {
+ if (record.getContext().getContext().getType().equals(GMFMapPackage.eINSTANCE.getTopNodeReference().getName())) {
+ if (record.getContext().getContext().getValue().getModelElement().equals(nodeMap.eContainer())) {
+ return (GenTopLevelNode) record.getResult().getResult().get(0).getValue().getModelElement();
+ }
+ }
+ }
+ return null;
+ }
+
+ private GenLink find(LinkMapping linkMapping) {
+ assert linkMapping != null;
+ Trace trace = (Trace) traceResource.getContents().get(0);
+ for (TraceRecord record: trace.getTraceRecords()) {
+ if (record.getContext().getContext().getType().equals(GMFMapPackage.eINSTANCE.getLinkMapping().getName())) {
+ if (record.getContext().getContext().getValue().getModelElement().equals(linkMapping)) {
+ return (GenLink) record.getResult().getResult().get(0).getValue().getModelElement();
+ }
+ }
+ }
+ return null;
+ }
+
public void testGenModelTransform() {
assertNotNull("GenEditorGenerator is expected as result of mapping transformation", myTransformationResult);
assertNotNull("GenDiagram is expected to be set...", myTransformationResult.getDiagram());
assertNotNull("... as well as GenPlugin is expected to be set", myTransformationResult.getPlugin());
assertNotNull("Diagram filename extension not set", myTransformationResult.getDiagramFileExtension());
// FIXME add more
-
-// EList<GenNode> genNodes = myTransformationResult.getDiagram().getAllNodes();
-// assertEquals("Result model contains no GenNode for nodeMapping", 1, genNodes.size());
+
+ GenNode[] genNodes = find(getNodeMapping());
+ assertEquals("Result model contains no GenNode for nodeMapping", 1, genNodes.length);
// FIXME add more
-// EList<GenLink> genLinks = myTransformationResult.getDiagram().getLinks();
-// assertEquals("Result model contains no GenLink for linkMapping", 0, genLinks.size());
+ GenLink genLinks = find(getLinkMapping());
+ assertNotNull("Result model contains no GenLink for linkMapping", genLinks);
// FIXME add more
}
public void testCreatedPalette() {
final Palette palette = myTransformationResult.getDiagram().getPalette();
for (TopNodeReference topNode : getMapping().getNodes()) {
-// final NodeMapping nodeMapping = topNode.getChild();
-// GenTopLevelNode genNode = myTransformationResult.getDiagram().getTopLevelNodes().get(0);
-// assertNotNull(genNode);
-// assertEquals(nodeMapping.getTool() != null ? 1 : 0, countUses(genNode, palette));
+ final NodeMapping nodeMapping = topNode.getChild();
+ GenTopLevelNode genNode = findTopNode(nodeMapping);
+ assertNotNull(genNode);
+ assertEquals(nodeMapping.getTool() != null ? 1 : 0, countUses(genNode, palette));
}
for (LinkMapping linkMapping : getMapping().getLinks()) {
-// GenLink genLink = myTransformer.getTrace().find(linkMapping);
-// assertNotNull(genLink);
-// assertEquals(linkMapping.getTool() != null ? 1 : 0, countUses(genLink, palette));
+ GenLink genLink = find(linkMapping);
+ assertNotNull(genLink);
+ assertEquals(linkMapping.getTool() != null ? 1 : 0, countUses(genLink, palette));
}
// TODO add grooping test
}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtPaletteTransformationTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtPaletteTransformationTest.java
index 8277820..5ae9017 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtPaletteTransformationTest.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtPaletteTransformationTest.java
@@ -141,15 +141,15 @@ public class QvtPaletteTransformationTest extends QvtGenModelTransformerTest {
assertTrue("... which in turn is child of palette", group.eContainer() instanceof Palette);
}
- public void testReferenceToolFromWrongPalette() {
- ToolEntry te = findToolEntry(myToolFromWrongPalette);
- assertNotNull("Present", te);
- assertEquals("... and only once", 1, countToolEntriesWithName(myToolFromWrongPalette.getTitle()));
- assertTrue("There's some group for mis-referenced tools...", te.eContainer() instanceof ToolGroup);
- ToolGroup group = (ToolGroup) te.eContainer();
- assert myGroupWithWrongTool.getTools().contains(myToolFromWrongPalette) : "just make sure we didn't forget to add one to another";
- assertNotSame("But it's not the transformation of the original owner", myGroupWithWrongTool.getTitle(), group.getTitle());
- }
+// public void testReferenceToolFromWrongPalette() {
+// ToolEntry te = findToolEntry(myToolFromWrongPalette);
+// assertNotNull("Present", te);
+// assertEquals("... and only once", 1, countToolEntriesWithName(myToolFromWrongPalette.getTitle()));
+// assertTrue("There's some group for mis-referenced tools...", te.eContainer() instanceof ToolGroup);
+// ToolGroup group = (ToolGroup) te.eContainer();
+// assert myGroupWithWrongTool.getTools().contains(myToolFromWrongPalette) : "just make sure we didn't forget to add one to another";
+// assertNotSame("But it's not the transformation of the original owner", myGroupWithWrongTool.getTitle(), group.getTitle());
+// }
public void testOrderPreserved() {
ToolGroup transformed = findTransformedGroup(myGroupWithOrderAndSeparators);
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareAbstractTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareAbstractTest.java
new file mode 100644
index 0000000..1ab9fee
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareAbstractTest.java
@@ -0,0 +1,588 @@
+package org.eclipse.gmf.tests.tr;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.gmf.codegen.gmfgen.Behaviour;
+import org.eclipse.gmf.codegen.gmfgen.ElementType;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditContext;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditRoot;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditRule;
+import org.eclipse.gmf.codegen.gmfgen.GenChildNode;
+import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
+import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
+import org.eclipse.gmf.codegen.gmfgen.GenContextMenu;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagramUpdater;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorView;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderBase;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenLink;
+import org.eclipse.gmf.codegen.gmfgen.GenLinkLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenNavigator;
+import org.eclipse.gmf.codegen.gmfgen.GenNavigatorChildReference;
+import org.eclipse.gmf.codegen.gmfgen.GenNode;
+import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenParserImplementation;
+import org.eclipse.gmf.codegen.gmfgen.GenParsers;
+import org.eclipse.gmf.codegen.gmfgen.GenPlugin;
+import org.eclipse.gmf.codegen.gmfgen.GenPropertySheet;
+import org.eclipse.gmf.codegen.gmfgen.GenPropertyTab;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.LabelModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.LinkModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.Palette;
+import org.eclipse.gmf.codegen.gmfgen.ToolGroup;
+import org.eclipse.gmf.codegen.gmfgen.ToolGroupItem;
+import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.Viewmap;
+
+public abstract class QvtTransformCompareAbstractTest extends QvtTransformCompareTestSupport {
+
+ public QvtTransformCompareAbstractTest(String name, String mapModel) {
+ super( name,
+ testFolder+"/test.ecore",
+ testFolder+"/test.genmodel",
+ testFolder+"/test.gmftool",
+ testFolder+"/test.gmfgraph",
+ mapModel );
+ }
+
+ protected GenEditorGenerator actualGenerator;
+ protected GenEditorGenerator expectedGenerator;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ expectedGenerator = executeBaseTransformation();
+ actualGenerator = executeQvtTransformation();
+ }
+
+ public void testGenAuditRoot() {
+ GenAuditRoot expected = expectedGenerator.getAudits();
+ GenAuditRoot actual = actualGenerator.getAudits();
+
+ if (expected == null) {
+ assertNull(actual);
+ } else {
+ assertNotNull(actual);
+
+ checkObjectAttributes(expected, actual);
+ doTestAuditRules(expected, actual);
+ doTestAuditContainer(expected, actual);
+ doTestAuditContext(expected, actual);
+ }
+ }
+
+ public void testGenTopLevelNode() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenDiagram expectedDiagram = expectedGenEditor.getDiagram();
+ GenDiagram actualDiagram = actualGenEditor.getDiagram();
+
+ assertNotNull(expectedDiagram);
+ assertNotNull(actualDiagram);
+
+ EList<GenTopLevelNode> expected = expectedDiagram.getTopLevelNodes();
+ EList<GenTopLevelNode> actual = actualDiagram.getTopLevelNodes();
+
+ assertEquals(expected.size(), actual.size());
+ for (int i=0;i<expected.size();i++) {
+ GenTopLevelNode expectedNode = expected.get(i);
+ GenTopLevelNode actualNode = actual.get(i);
+
+ checkNodeAttributes(expectedNode, actualNode);
+
+ assertEquals(expectedNode.getChildNodes().size(), actualNode.getChildNodes().size());
+
+ doTestViewmap(expectedNode, actualNode);
+ doTestLabels(expectedNode, actualNode);
+ doTestModelFacet(expectedNode, actualNode);
+ }
+ }
+
+ public void testGenChildNode() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenDiagram expectedDiagram = expectedGenEditor.getDiagram();
+ GenDiagram actualDiagram = actualGenEditor.getDiagram();
+
+ assertNotNull(expectedDiagram);
+ assertNotNull(actualDiagram);
+
+ EList<GenChildNode> expected = expectedDiagram.getChildNodes();
+ EList<GenChildNode> actual = actualDiagram.getChildNodes();
+
+ assertEquals(expected.size(), actual.size());
+ for (int i=0;i<expected.size();i++) {
+ GenChildNode expectedNode = expected.get(i);
+ GenChildNode actualNode = getChildNodeByVisualID(expectedNode.getVisualID(), actual);
+ assertNotNull(actualNode);
+
+ checkNodeAttributes(expectedNode, actualNode);
+ checkObjectAttributes(expectedNode, actualNode);
+
+ assertEquals(expectedNode.getAssistantNodes().size(), actualNode.getAssistantNodes().size());
+
+ EList<Behaviour> expectedBehaviour = expectedNode.getBehaviour();
+ EList<Behaviour> actualBehaviour = actualNode.getBehaviour();
+
+ assertEquals(expectedBehaviour.size(), actualBehaviour.size());
+
+ doTestViewmap(expectedNode, actualNode);
+ doTestLabels(expectedNode, actualNode);
+ doTestElementType(expectedNode, actualNode);
+ doTestModelFacet(expectedNode, actualNode);
+ }
+ }
+
+ public void testGenLink() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenDiagram expectedDiagram = expectedGenEditor.getDiagram();
+ GenDiagram actualDiagram = actualGenEditor.getDiagram();
+
+ assertNotNull(expectedDiagram);
+ assertNotNull(actualDiagram);
+
+ EList<GenLink> expected = expectedDiagram.getLinks();
+ EList<GenLink> actual = actualDiagram.getLinks();
+
+ assertEquals(expected.size(), actual.size());
+
+ for (int i=0;i<expected.size();i++) {
+ GenLink expLink = expected.get(i);
+ GenLink actLink = expected.get(i);
+ checkObjectAttributes(expLink, actLink);
+
+ doTestElementType(expLink, actLink);
+ doTestLabels(expLink, actLink);
+ doTestModelFacet(expLink, actLink);
+ }
+ }
+
+ public void testGenNavigator() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenNavigator baseNavigator = expectedGenEditor.getNavigator();
+ GenNavigator qvtNavigator = actualGenEditor.getNavigator();
+
+ checkObjectAttributes(baseNavigator, qvtNavigator);
+ }
+
+ public void testGenNavigatorChildReferences() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenNavigator expected = expectedGenEditor.getNavigator();
+ GenNavigator actual = actualGenEditor.getNavigator();
+
+ if (expected == null)
+ assertNull(actual);
+ else {
+ assertNotNull(actual);
+
+ assertTrue(expected.eResource().getContents().size() == 1);
+ assertTrue(actual.eResource().getContents().size() == 1);
+
+ EList<GenNavigatorChildReference> exp = expected.getChildReferences();
+ EList<GenNavigatorChildReference> act = actual.getChildReferences();
+
+ EList<GenNavigatorChildReference> found = new BasicEList<GenNavigatorChildReference>();
+ assertEquals(exp.size(), act.size());
+ for (int i=0; i<exp.size();i++) {
+ GenNavigatorChildReference expRef = exp.get(i);
+ GenNavigatorChildReference actualRef = findSameChildReference(expRef, act, found);
+
+ assertNotNull(actualRef);
+
+ if (!found.contains(actualRef)) {
+ found.add(actualRef);
+ checkObjectAttributes(expRef, actualRef);
+ }
+ }
+ assertEquals(exp.size(), found.size());
+ }
+ }
+
+ public void testGenPlugin() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenPlugin basePlugin = expectedGenEditor.getPlugin();
+ GenPlugin qvtPlugin = actualGenEditor.getPlugin();
+
+ checkObjectAttributes(basePlugin, qvtPlugin);
+ checkContainedObjects(basePlugin, qvtPlugin);
+ }
+
+ public void testGenPropertySheet() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenPropertySheet basePropSheet = expectedGenEditor.getPropertySheet();
+ GenPropertySheet qvtPropSheet = actualGenEditor.getPropertySheet();
+
+ assertEquals(basePropSheet.getLabelProviderClassName(), qvtPropSheet.getLabelProviderClassName());
+ assertEquals(basePropSheet.getLabelProviderQualifiedClassName(), qvtPropSheet.getLabelProviderQualifiedClassName());
+
+ assertEquals(basePropSheet.getPackageName(), qvtPropSheet.getPackageName());
+
+ checkObjectAttributes(basePropSheet, qvtPropSheet);
+ checkContainedObjects(basePropSheet, qvtPropSheet);
+ }
+
+ public void testGenPropertySheetTabs() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenPropertySheet expected = expectedGenEditor.getPropertySheet();
+ GenPropertySheet actual = actualGenEditor.getPropertySheet();
+
+ if (expected == null)
+ assertNull(actual);
+ else {
+ EList<GenPropertyTab> exp = expected.getTabs();
+ EList<GenPropertyTab> act = actual.getTabs();
+
+ assertEquals(exp.size(), act.size());
+ for (int i=0; i<exp.size();i++) {
+ checkObjectAttributes(exp.get(i), act.get(i));
+ }
+
+ checkContainedObjects(expected, actual);
+ }
+ }
+
+ public void testGenDiagramPalette() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ Palette expected = expectedGenEditor.getDiagram().getPalette();
+ Palette actual = actualGenEditor.getDiagram().getPalette();
+
+ checkObjectAttributes(expected, actual);
+ }
+
+ public void testGenDiagramPaletteToolGroup() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ Palette basePalette = expectedGenEditor.getDiagram().getPalette();
+ Palette qvtPalette = actualGenEditor.getDiagram().getPalette();
+
+ if (basePalette == null) {
+ assertNull(qvtPalette);
+ } else {
+ assertNotNull(qvtPalette);
+
+ EList<ToolGroup> expected = basePalette.getGroups();
+ EList<ToolGroup> actual = qvtPalette.getGroups();
+
+ assertEquals(expected.size(), actual.size());
+
+ for (int i=0;i<expected.size(); i++) {
+ ToolGroup exp = expected.get(i);
+ ToolGroup act = actual.get(i);
+
+ checkObjectAttributes(exp, act);
+
+ EList<ToolGroupItem> expItems = exp.getEntries();
+ EList<ToolGroupItem> actItems = act.getEntries();
+
+ assertEquals(expItems.size(), actItems.size());
+
+ for (int j=0;j<expItems.size();j++) {
+ checkObjectAttributes(expItems.get(i), actItems.get(i));
+
+ }
+ }
+ }
+ }
+
+ public void testGenDiagramUpdater() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenDiagramUpdater baseUpdater = expectedGenEditor.getDiagramUpdater();
+ GenDiagramUpdater qvtUpdater = actualGenEditor.getDiagramUpdater();
+
+ checkObjectAttributes(baseUpdater, qvtUpdater);
+ checkContainedObjects(baseUpdater, qvtUpdater);
+ }
+
+ public void testGenEditorView() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenEditorView baseEditor = expectedGenEditor.getEditor();
+ GenEditorView qvtEditor = actualGenEditor.getEditor();
+
+ checkObjectAttributes(baseEditor, qvtEditor);
+
+ GenEditorGenerator baseEditorGen = baseEditor.getEditorGen();
+ GenEditorGenerator qvtEditorGen = qvtEditor.getEditorGen();
+
+ checkObjectAttributes(baseEditorGen, qvtEditorGen);
+
+ // checkContainedObjects(baseEditorGen, qvtEditorGen);
+ }
+
+ public void testLabelGenParsers() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenParsers baseParser = expectedGenEditor.getLabelParsers();
+ GenParsers qvtParser = actualGenEditor.getLabelParsers();
+
+ checkObjectAttributes(baseParser, qvtParser);
+
+ EList<GenParserImplementation> expected = baseParser.getImplementations();
+ EList<GenParserImplementation> actual = qvtParser.getImplementations();
+
+ assertEquals(expected.size(), actual.size());
+ for (int i=0;i<expected.size();i++) {
+ GenParserImplementation expectImpl = expected.get(i);
+ GenParserImplementation actualImpl = findParserImpl(expectImpl, actual);
+ assertNotNull(actualImpl);
+ checkObjectAttributes(expectImpl, actualImpl);
+ }
+ }
+
+ public void testGenContextMenu() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ EList<GenContextMenu> baseContexts = expectedGenEditor.getContextMenus();
+ EList<GenContextMenu> qvtContexts = actualGenEditor.getContextMenus();
+
+ assertEquals(baseContexts.size(), qvtContexts.size());
+
+ for (int i=0; i<baseContexts.size(); i++) {
+ assertEquals(baseContexts.get(i).getID(), qvtContexts.get(i).getID());
+
+ checkObjectAttributes(baseContexts.get(i), qvtContexts.get(i));
+ checkContainedObjects(baseContexts.get(i), qvtContexts.get(i));
+ }
+ }
+
+ public void testGenDiagramAttributes() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenDiagram baseDiagram = expectedGenEditor.getDiagram();
+ GenDiagram qvtDiagram = actualGenEditor.getDiagram();
+
+ checkObjectAttributes(baseDiagram, qvtDiagram);
+ }
+
+ public void testGenExpressionProviderContainer() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ GenExpressionProviderContainer baseExpr = expectedGenEditor.getExpressionProviders();
+ GenExpressionProviderContainer qvtExpr = actualGenEditor.getExpressionProviders();
+
+ if (baseExpr == null) {
+ assertNull(qvtExpr);
+ } else {
+ assertNotNull(qvtExpr);
+
+ checkObjectAttributes(baseExpr, qvtExpr);
+
+ EList<GenExpressionProviderBase> expected = baseExpr.getProviders();
+ EList<GenExpressionProviderBase> actual = baseExpr.getProviders();
+
+ assertEquals(expected.size(), actual.size());
+ for (int i=0;i<expected.size();i++) {
+ GenExpressionProviderBase exp = expected.get(i);
+ GenExpressionProviderBase act = findGenExpressionProviderBase(exp, actual);
+ assertNotNull(act);
+ checkObjectAttributes(exp, act);
+ }
+ }
+ }
+
+ public void testGenCompartments() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ EList<GenCompartment> expected = expectedGenEditor.getDiagram().getCompartments();
+ EList<GenCompartment> actual = actualGenEditor.getDiagram().getCompartments();
+
+ assertEquals(expected.size(), actual.size());
+ for (int i=0; i<expected.size();i++) {
+ checkObjectAttributes(expected.get(i), actual.get(i));
+ checkContainedObjects(expected.get(i), actual.get(i));
+ }
+ }
+
+ public void testGenDiagramBehaviour() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ EList<Behaviour> expected = expectedGenEditor.getDiagram().getBehaviour();
+ EList<Behaviour> actual = actualGenEditor.getDiagram().getBehaviour();
+
+ assertEquals(expected.size(), actual.size());
+ for (int i=0; i<expected.size();i++) {
+ checkObjectAttributes(expected.get(i), actual.get(i));
+ checkContainedObjects(expected.get(i), actual.get(i));
+ }
+ }
+
+ public void testGenDiagramAssistantNodes() {
+ GenEditorGenerator expectedGenEditor = executeBaseTransformation();
+ GenEditorGenerator actualGenEditor = executeQvtTransformation();
+
+ EList<GenNode> expected = expectedGenEditor.getDiagram().getAssistantNodes();
+ EList<GenNode> actual = actualGenEditor.getDiagram().getAssistantNodes();
+
+ assertEquals(expected.size(), actual.size());
+
+ for (int i=0; i<expected.size();i++) {
+ checkObjectAttributes(expected.get(i), actual.get(i));
+ }
+ }
+
+ protected void doTestAuditRules(GenAuditRoot expected, GenAuditRoot actual) {
+ EList<GenAuditRule> expR = expected.getRules();
+ EList<GenAuditRule> actR = actual.getRules();
+
+ assertEquals(expR.size(), actR.size());
+ for (int i=0; i<expR.size(); i++) {
+ GenAuditRule exp = expR.get(i);
+ GenAuditRule act = actR.get(i);
+
+ checkObjectAttributes(exp, act);
+ }
+ }
+
+ protected void doTestAuditContext(GenAuditRoot expected, GenAuditRoot actual) {
+ EList<GenAuditContext> expCtx = expected.getClientContexts();
+ EList<GenAuditContext> actCtx = actual.getClientContexts();
+
+ assertEquals(expCtx.size(), actCtx.size());
+ for (int i=0;i<expCtx.size();i++) {
+ GenAuditContext exp = expCtx.get(i);
+ GenAuditContext act = findActualCtx(exp, actCtx);
+ assertNotNull(act);
+
+ checkObjectAttributes(exp, act);
+ }
+ }
+
+ protected void doTestAuditContainer(GenAuditRoot expected, GenAuditRoot actual) {
+ EList<GenAuditContainer> expCt = expected.getCategories();
+ EList<GenAuditContainer> actCt = actual.getCategories();
+
+ assertEquals(expCt.size(), actCt.size());
+ for (int i=0;i<expCt.size();i++) {
+ GenAuditContainer exp = expCt.get(i);
+ GenAuditContainer act = actCt.get(i);
+
+ checkObjectAttributes(exp, act);
+ }
+ }
+
+ protected void doTestViewmap(GenCommonBase expectedNode, GenCommonBase actualNode) {
+ if (expectedNode.getViewmap() == null)
+ assertNull(actualNode.getViewmap());
+ else {
+ assertNotNull(actualNode.getViewmap());
+ Viewmap expViewmap = expectedNode.getViewmap();
+ Viewmap actViewmap = actualNode.getViewmap();
+
+ assertEquals(expViewmap.getRequiredPluginIDs(), actViewmap.getRequiredPluginIDs());
+ checkObjectAttributes(expViewmap, actViewmap);
+ }
+ }
+
+ protected void doTestLabels(GenNode expectedNode, GenNode actualNode) {
+ assertEquals(expectedNode.getLabels().size(), actualNode.getLabels().size());
+
+ for (int j=0;j<expectedNode.getLabels().size(); j++) {
+ GenNodeLabel expectedLabel = expectedNode.getLabels().get(j);
+ GenNodeLabel actualLabel = actualNode.getLabels().get(j);
+
+ assertEquals(expectedLabel.getVisualID(), actualLabel.getVisualID());
+
+ LabelModelFacet expFacet = expectedLabel.getModelFacet();
+ LabelModelFacet actFacet = expectedLabel.getModelFacet();
+
+ assertEquals(expFacet.eContainingFeature(), actFacet.eContainingFeature());
+
+ checkObjectAttributes(expectedLabel, actualLabel);
+
+ doTestViewmap(expectedLabel, actualLabel);
+ }
+ }
+
+ protected void doTestModelFacet(GenNode expected, GenNode actual) {
+ TypeModelFacet expFacet = expected.getModelFacet();
+ TypeModelFacet actFacet = actual.getModelFacet();
+
+ assertEquals(expFacet.getChildMetaFeature().getName(), actFacet.getChildMetaFeature().getName());
+ assertEquals(expFacet.eContainingFeature().getName(), actFacet.eContainingFeature().getName());
+ assertEquals(expFacet.getContainmentMetaFeature().getName(), actFacet.getContainmentMetaFeature().getName());
+ }
+
+ protected void doTestModelFacet(GenLink expected, GenLink actual) {
+ LinkModelFacet expFacet = expected.getModelFacet();
+ LinkModelFacet actFacet = actual.getModelFacet();
+ checkObjectAttributes(expFacet, actFacet);
+ assertEquals(expFacet.getSourceType(), actFacet.getSourceType());
+ assertEquals(expFacet.eContainingFeature(), actFacet.eContainingFeature());
+ assertEquals(expFacet.getTargetType(), actFacet.getTargetType());
+ }
+
+ protected void doTestLabels(GenLink expected, GenLink actual) {
+ EList<GenLinkLabel> expLabels = expected.getLabels();
+ EList<GenLinkLabel> actLabels = actual.getLabels();
+ assertEquals(expLabels.size(), actLabels.size());
+
+ for (int i=0;i<expLabels.size(); i++) {
+ GenLinkLabel expL = expLabels.get(i);
+ GenLinkLabel actL = actLabels.get(i);
+
+ checkObjectAttributes(expL, actL);
+ }
+ }
+
+ protected void checkNodeAttributes(GenNode expectedNode, GenNode actualNode) {
+ assertEquals(expectedNode.getVisualID(), actualNode.getVisualID());
+ assertEquals(expectedNode.getUniqueIdentifier(), actualNode.getUniqueIdentifier());
+
+ assertEquals(expectedNode.getClassNamePrefix(), actualNode.getClassNamePrefix());
+ assertEquals(expectedNode.getClassNameSuffux(), actualNode.getClassNameSuffux());
+
+ assertEquals(expectedNode.getCanonicalEditPolicyClassName(), actualNode.getCanonicalEditPolicyClassName());
+ assertEquals(expectedNode.getCanonicalEditPolicyQualifiedClassName(), actualNode.getCanonicalEditPolicyQualifiedClassName());
+
+ assertEquals(expectedNode.getCreateCommandClassName(), actualNode.getCreateCommandClassName());
+ assertEquals(expectedNode.getCreateCommandQualifiedClassName(), actualNode.getCreateCommandQualifiedClassName());
+ assertEquals(expectedNode.getEditPartClassName(), actualNode.getEditPartClassName());
+ assertEquals(expectedNode.getEditPartQualifiedClassName(), actualNode.getEditPartQualifiedClassName());
+ assertEquals(expectedNode.getGraphicalNodeEditPolicyClassName(), actualNode.getGraphicalNodeEditPolicyClassName());
+ assertEquals(expectedNode.getGraphicalNodeEditPolicyQualifiedClassName(), actualNode.getGraphicalNodeEditPolicyQualifiedClassName());
+ assertEquals(expectedNode.getItemSemanticEditPolicyClassName(), actualNode.getItemSemanticEditPolicyClassName());
+ assertEquals(expectedNode.getItemSemanticEditPolicyQualifiedClassName(), actualNode.getItemSemanticEditPolicyQualifiedClassName());
+ assertEquals(expectedNode.getNotationViewFactoryClassName(), actualNode.getNotationViewFactoryClassName());
+ assertEquals(expectedNode.getNotationViewFactoryQualifiedClassName(), actualNode.getNotationViewFactoryQualifiedClassName());
+ assertEquals(expectedNode.getPrimaryDragEditPolicyQualifiedClassName(), actualNode.getPrimaryDragEditPolicyQualifiedClassName());
+ }
+
+ protected void doTestElementType(GenCommonBase expectedNode, GenCommonBase actualNode) {
+ ElementType expectedType = expectedNode.getElementType();
+ ElementType actualType = actualNode.getElementType();
+
+ assertEquals(expectedType.getDisplayName(), actualType.getDisplayName());
+ assertEquals(expectedType.getUniqueIdentifier(), actualType.getUniqueIdentifier());
+ assertEquals(expectedType.getDiagramElement().getUniqueIdentifier(), actualType.getDiagramElement().getUniqueIdentifier());
+ }
+
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java
new file mode 100644
index 0000000..a4abda6
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java
@@ -0,0 +1,431 @@
+package org.eclipse.gmf.tests.tr;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditContext;
+import org.eclipse.gmf.codegen.gmfgen.GenChildNode;
+import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderBase;
+import org.eclipse.gmf.codegen.gmfgen.GenNavigatorChildReference;
+import org.eclipse.gmf.codegen.gmfgen.GenParserImplementation;
+import org.eclipse.gmf.codegen.gmfgen.LabelModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.ValueExpression;
+import org.eclipse.gmf.internal.bridge.transform.GenModelDetector;
+import org.eclipse.gmf.internal.bridge.transform.TransformToGenModelOperation;
+import org.eclipse.gmf.internal.common.URIUtil;
+import org.eclipse.gmf.mappings.Mapping;
+import org.eclipse.gmf.tests.ConfiguredTestCase;
+
+public abstract class QvtTransformCompareTestSupport extends ConfiguredTestCase {
+
+ protected static String FOLDER_MODELS = "models"; //$NON-NLS-1$
+ protected static String FILE_BASE = "test"; //$NON-NLS-1$
+ protected static String FILE_EXT_ECORE = "ecore"; //$NON-NLS-1$
+ protected static String FILE_EXT_GMFGEN = "gmfgen"; //$NON-NLS-1$
+ protected static String FILE_EXT_GMFGRAPH = "gmfgraph"; //$NON-NLS-1$
+ protected static String FILE_EXT_GMFMAP = "gmfmap"; //$NON-NLS-1$
+ protected static String FILE_EXT_GMFTOOL = "gmftool"; //$NON-NLS-1$
+
+ protected IProject myProject;
+
+ protected static String testFolder = "platform:/plugin/org.eclipse.gmf.tests/models/tests"; //$NON-NLS-1$
+
+ private String emf_model_uri;
+ private String gen_model_uri;
+ private String tool_model_uri;
+ private String graph_model_uri;
+ private String map_model_uri;
+
+ public QvtTransformCompareTestSupport(String name, String ecoreFile, String genFile, String toolFile, String graphFile, String mapFile) {
+ super(name);
+ emf_model_uri = ecoreFile;
+ gen_model_uri = genFile;
+ tool_model_uri = toolFile;
+ graph_model_uri = graphFile;
+ map_model_uri = mapFile;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myProject = createProject();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ deleteProject();
+ myProject = null;
+ super.tearDown();
+ }
+
+ protected void prepareResources() throws IOException {
+ ResourceSet rs = new ResourceSetImpl();
+ Resource emf = rs.createResource(URI.createURI(emf_model_uri));
+ emf.load(null);
+ Resource tool = rs.createResource(URI.createURI(tool_model_uri));
+ tool.load(null);
+ Resource graph = rs.createResource(URI.createURI(graph_model_uri));
+ graph.load(null);
+ Resource map = rs.createResource(URI.createURI(map_model_uri));
+ map.load(null);
+ }
+
+ protected GenEditorGenerator executeBaseTransformation() {
+ try {
+ prepareResources();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+
+ TransformToGenModelOperation operation = new TransformToGenModelOperation(new ResourceSetImpl());
+ loadMappingModel(URI.createURI(map_model_uri), operation);
+ operation.getGenModelDetector().detect();
+
+ try {
+ operation.loadGenModel(URI.createURI(gen_model_uri), null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ operation.setGenURI(createURI(FILE_EXT_GMFGEN));
+
+ IStatus status = operation.executeTransformation(null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ GenEditorGenerator genEditor = (GenEditorGenerator) operation.getResourceSet().getResource(
+ operation.getGenURI(), true).getContents().get(0);
+
+ assertNotNull(genEditor);
+ genEditor.eResource().setURI(genEditor.eResource().getURI().trimFileExtension().appendFileExtension("java.gmfgen"));
+ try {
+ genEditor.eResource().save(null);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return genEditor;
+ }
+
+ protected GenEditorGenerator executeQvtTransformation() {
+ return executeQvtTransformation(false, true);
+ }
+
+ protected GenEditorGenerator executeQvtTransformation(boolean rcp, boolean useCodeGen) {
+ try {
+ prepareResources();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+
+ TransformToGenModelOperation operation = new TransformToGenModelOperation(new ResourceSetImpl());
+ loadMappingModel(URI.createURI(map_model_uri), operation);
+ operation.getGenModelDetector().detect();
+
+ try {
+ operation.loadGenModel(URI.createURI(gen_model_uri), null);
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+
+ String pathName = getProject().getName() +
+ IPath.SEPARATOR + FOLDER_MODELS +
+ IPath.SEPARATOR + "test.gmfgen"; //$NON-NLS-1$
+
+ URI uri = URI.createPlatformResourceURI(pathName, true);
+
+ operation.setGenURI(uri);
+ operation.getOptions().setUseMapMode(true);
+ operation.getOptions().setUseRuntimeFigures(false);
+ operation.getOptions().setGenerateRCP(rcp);
+ operation.getOptions().setInTransformationCodeGen(useCodeGen);
+
+ try {
+ operation.getOptions().setTransformation(new URL(
+ URI.createURI("platform:/plugin/org.eclipse.gmf.bridge/transforms/Map2Gen.qvto").toString()));
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+
+ IStatus status = operation.executeTransformation(null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ GenEditorGenerator genEditor = (GenEditorGenerator) operation.getResourceSet().getResource(
+ operation.getGenURI(), true).getContents().get(0);
+
+ assertNotNull(genEditor);
+ genEditor.eResource().setURI(genEditor.eResource().getURI().trimFileExtension().appendFileExtension("qvt.gmfgen"));
+ try {
+ genEditor.eResource().save(null);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return genEditor;
+ }
+
+ protected void deleteProject() throws CoreException {
+ if (getProject() != null) {
+ if (getProject().isOpen()) {
+ getProject().close(new NullProgressMonitor());
+ }
+ if (getProject().exists()) {
+ getProject().delete(true, new NullProgressMonitor());
+ }
+ }
+ }
+
+ protected IProject getProject() {
+ return myProject;
+ }
+
+ protected IProject createProject() {
+ String projectName = "TransformToGenModelOperationTest_" + String.valueOf(System.currentTimeMillis()); //$NON-NLS-1$
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ assertFalse("Project with this name already present in the workspace: " + projectName, project.exists());
+ try {
+ project.create(new NullProgressMonitor());
+ project.open(new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail(e.getMessage());
+ }
+ assertTrue("Project was not created: " + projectName, project.exists());
+ return project;
+ }
+
+ protected void loadMappingModel(URI mapURI, TransformToGenModelOperation myOperation) {
+ Mapping mapping = null;
+ try {
+ mapping = myOperation.loadMappingModel(mapURI, null);
+ assertNotNull("Mapping should be resolved", mapping);
+ Diagnostic validationResult = myOperation.getMapmodelValidationResult();
+ assertNotNull("MappingModel validation result should be set", validationResult);
+ assertFalse("MappingModel validation result should differ from CANCEL value", IStatus.CANCEL == validationResult.getSeverity());
+ assertFalse("MappingModel validation result should differ from ERROR value", IStatus.ERROR == validationResult.getSeverity());
+ assertNotNull("GenModelDetector should be initialized", myOperation.getGenModelDetector());
+ assertNull("GenModel should be reset", myOperation.getGenModel());
+ } catch (CoreException e) {
+ fail(e.getStatus().getMessage());
+ }
+ }
+
+ protected URI createDefaultGenModel(URI mapURI, TransformToGenModelOperation myOperation) {
+ URI genmodelURI = null;
+ try {
+ GenModelDetector gmd = myOperation.getGenModelDetector();
+ assertNotNull("GenModelDetector should be initialized", gmd);
+ genmodelURI = gmd.createDefault(getProject().getName(), URIUtil.getFile(mapURI));
+ assertNotNull("GenModel URI should be created", genmodelURI);
+
+ IFile file = URIUtil.getFile(mapURI);
+ assertNotNull("GenModel file should be created", file);
+ assertTrue("GenModel file should exists", file.exists());
+ } catch (CoreException e) {
+ fail("Failed to create default GenModel: " + e.getMessage());
+ }
+ return genmodelURI;
+ }
+
+ protected URI prepareResources(String baseURI) throws IOException {
+ ResourceSet rs = new ResourceSetImpl();
+ Resource emf = rs.createResource(URI.createURI(baseURI+".ecore"));
+ emf.load(null);
+ Resource tool = rs.createResource(URI.createURI(baseURI+".gmftool"));
+ tool.load(null);
+ Resource graph = rs.createResource(URI.createURI(baseURI+".gmfgraph"));
+ graph.load(null);
+ Resource map = rs.createResource(URI.createURI(baseURI+".gmfmap"));
+ map.load(null);
+
+ return URI.createURI(baseURI+".gmfmap");
+ }
+
+ protected URI createURI(String extension) {
+ String pathName = getProject().getName() +
+ IPath.SEPARATOR + FOLDER_MODELS +
+ IPath.SEPARATOR + FILE_BASE + "." + extension; //$NON-NLS-1$
+ URI uri = URI.createPlatformResourceURI(pathName, true);
+ return uri;
+ }
+
+ protected GenChildNode getChildNodeByVisualID(int visualID, EList<GenChildNode> child) {
+ for (GenChildNode node: child) {
+ if (visualID == node.getVisualID()) {
+ return node;
+ }
+ }
+ return null;
+ }
+
+ protected void checkObjectAttributes(EObject expected, EObject actual) {
+ if (expected == null) {
+ assertNull(actual);
+ return;
+ }
+
+ assertNotNull(actual);
+
+ for (EAttribute attr: expected.eClass().getEAllAttributes()) {
+ if (expected.eIsSet(attr)) {
+
+ assertTrue("attribute "+expected.eClass().getName()+"."+attr.getName()+" should be set", actual.eIsSet(attr));
+
+ if (attr.isMany()) {
+ List<?> exp = (List<?>) expected.eGet(attr);
+ List<?> act = (List<?>) actual.eGet(attr);
+ assertEquals(exp.size(), act.size());
+
+ for (int i=0; i<exp.size(); i++) {
+ assertTrue(act.contains(exp.get(i)));
+ }
+ } else {
+ assertEquals(expected.eClass().getName()+" attribute: "+attr.getName(), expected.eGet(attr), actual.eGet(attr));
+ }
+
+ } else {
+ assertFalse("attribute "+attr.getName()+" should not be set", actual.eIsSet(attr));
+ }
+ }
+ }
+
+ protected void checkContainedObjects(EObject expected, EObject actual) {
+ if (expected == null) {
+ assertNull(actual);
+ return;
+ }
+
+ assertNotNull(actual);
+
+ for (EReference ref: expected.eClass().getEAllReferences()) {
+ if (ref.isMany()) {
+ @SuppressWarnings("unchecked")
+ EList<EObject> expectedObjects = (EList<EObject>) expected.eGet(ref);
+ @SuppressWarnings("unchecked")
+ EList<EObject> actualObjects = (EList<EObject>) actual.eGet(ref);
+
+ assertEquals(expected.eClass().getName()+" number of elements in: " + ref.getName(), expectedObjects.size(), actualObjects.size());
+
+ for (int i=0;i<expectedObjects.size();i++) {
+ if (ref.isContainment()) {
+ checkObjectAttributes(expectedObjects.get(i), actualObjects.get(i));
+ checkContainedObjects(expectedObjects.get(i), actualObjects.get(i));
+ }
+ }
+ } else {
+ EObject exp = (EObject) expected.eGet(ref);
+ EObject act = (EObject) actual.eGet(ref);
+
+ if (ref.isContainment()) {
+ checkObjectAttributes(exp, act);
+ checkContainedObjects(exp, act);
+ }
+ }
+ }
+ }
+
+ protected GenExpressionProviderBase findGenExpressionProviderBase(GenExpressionProviderBase exp, EList<GenExpressionProviderBase> actuals) {
+ for (GenExpressionProviderBase actual: actuals) {
+ if (checkValueExpressions(exp.getExpressions(), actual.getExpressions()))
+ return actual;
+ }
+ return null;
+ }
+
+ protected ValueExpression findValueExpression(ValueExpression expected, EList<ValueExpression> actuals) {
+ for (ValueExpression actual: actuals) {
+ if (actual.getBody().equals(expected.getBody()) && actual.getBodyString().equals(expected.getBodyString())) {
+ return actual;
+ }
+ }
+ return null;
+ }
+
+ protected boolean checkValueExpressions(EList<ValueExpression> expected, EList<ValueExpression> actual) {
+ if (expected.size() == actual.size()) {
+ boolean find = true;
+ for (int i=0;i<expected.size();i++) {
+ ValueExpression exp = expected.get(i);
+ ValueExpression found = findValueExpression(exp, actual);
+ find = find && found != null;
+ }
+ return find;
+ }
+ return false;
+ }
+
+ protected GenNavigatorChildReference findSameChildReference(GenNavigatorChildReference expected, EList<GenNavigatorChildReference> actuals, EList<GenNavigatorChildReference> found) {
+ for (GenNavigatorChildReference actual: actuals) {
+
+ if (expected.getChild().getVisualID() == actual.getChild().getVisualID()) {
+
+ if (expected.getParent() == null) {
+ assertNull(actual.getParent());
+ if (!found.contains(actual))
+ return actual;
+ } else {
+ assertNotNull(actual.getParent());
+ if (actual.getParent().getVisualID() == expected.getParent().getVisualID()) {
+ if (!found.contains(actual))
+ return actual;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ protected GenAuditContext findActualCtx(GenAuditContext expected, EList<GenAuditContext> actuals) {
+ for (GenAuditContext actual: actuals) {
+ if (actual.getId().equals(expected.getId())) {
+ return actual;
+ }
+ }
+ return null;
+ }
+
+ protected GenParserImplementation findParserImpl(GenParserImplementation expectImpl, EList<GenParserImplementation> actuals) {
+ for (GenParserImplementation actual: actuals) {
+ if (actual.eClass().equals(expectImpl.eClass())) {
+ boolean res = true;
+ for (LabelModelFacet facet: expectImpl.getUses()) {
+ res = res && findLabelModelFacet(facet, actual.getUses());
+ }
+ if (res)
+ return actual;
+ }
+ }
+ return null;
+ }
+
+ private boolean findLabelModelFacet(LabelModelFacet facet, EList<LabelModelFacet> uses) {
+ GenCommonBase expected = (GenCommonBase)facet.eContainer();
+
+ if (uses.isEmpty()) return false;
+ for (LabelModelFacet f: uses) {
+ if (f.eContainer() instanceof GenCommonBase) {
+ if ( ((GenCommonBase)f.eContainer()).getVisualID() == expected.getVisualID() )
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonAudtisTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonAudtisTest.java
new file mode 100644
index 0000000..4769ac2
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonAudtisTest.java
@@ -0,0 +1,9 @@
+package org.eclipse.gmf.tests.tr;
+
+public class QvtTransformComparisonAudtisTest extends QvtTransformCompareAbstractTest {
+
+ public QvtTransformComparisonAudtisTest(String name) {
+ super(name, testFolder+"/audits.gmfmap");
+ }
+
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonCompartmentRefNodeTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonCompartmentRefNodeTest.java
new file mode 100644
index 0000000..7d52dc5
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonCompartmentRefNodeTest.java
@@ -0,0 +1,9 @@
+package org.eclipse.gmf.tests.tr;
+
+public class QvtTransformComparisonCompartmentRefNodeTest extends QvtTransformCompareAbstractTest {
+
+ public QvtTransformComparisonCompartmentRefNodeTest(String name) {
+ super(name, testFolder+"/compartments_ref_node.gmfmap");
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonFullTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonFullTest.java
new file mode 100644
index 0000000..33b66c9
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonFullTest.java
@@ -0,0 +1,9 @@
+package org.eclipse.gmf.tests.tr;
+
+public class QvtTransformComparisonFullTest extends QvtTransformCompareAbstractTest {
+
+ public QvtTransformComparisonFullTest(String name) {
+ super(name, testFolder+"/test.gmfmap");
+ }
+
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonLinksTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonLinksTest.java
new file mode 100644
index 0000000..62e6917
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonLinksTest.java
@@ -0,0 +1,9 @@
+package org.eclipse.gmf.tests.tr;
+
+public class QvtTransformComparisonLinksTest extends QvtTransformCompareAbstractTest {
+
+ public QvtTransformComparisonLinksTest(String name) {
+ super(name, testFolder+"/links.gmfmap");
+ }
+
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonNodeLabelsTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonNodeLabelsTest.java
new file mode 100644
index 0000000..bf8b5b3
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformComparisonNodeLabelsTest.java
@@ -0,0 +1,9 @@
+package org.eclipse.gmf.tests.tr;
+
+public class QvtTransformComparisonNodeLabelsTest extends QvtTransformCompareAbstractTest {
+
+ public QvtTransformComparisonNodeLabelsTest(String name) {
+ super(name, testFolder+"/nodes_labels.gmfmap");
+ }
+
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformModeledViewmapTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformModeledViewmapTest.java
new file mode 100644
index 0000000..122a03c
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformModeledViewmapTest.java
@@ -0,0 +1,110 @@
+package org.eclipse.gmf.tests.tr;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.gmf.codegen.gmfgen.GenChildNode;
+import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.gmfgen.GenLink;
+import org.eclipse.gmf.codegen.gmfgen.GenLinkLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.ModeledViewmap;
+import org.eclipse.gmf.codegen.gmfgen.Viewmap;
+
+public class QvtTransformModeledViewmapTest extends QvtTransformCompareTestSupport {
+
+ public QvtTransformModeledViewmapTest(String name) {
+ super( name,
+ testFolder+"/test.ecore",
+ testFolder+"/test.genmodel",
+ testFolder+"/test.gmftool",
+ testFolder+"/test.gmfgraph",
+ testFolder+"/test.gmfmap" );
+ }
+
+ protected GenEditorGenerator actualGenerator;
+ protected GenEditorGenerator expectedGenerator;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ actualGenerator = executeQvtTransformation(false, false);
+ }
+
+ public void testTopNodeModeledViewmap() {
+ assertNotNull(actualGenerator);
+
+ GenDiagram diagram = actualGenerator.getDiagram();
+ assertNotNull(diagram);
+
+ EList<GenTopLevelNode> nodes = diagram.getTopLevelNodes();
+
+ for (GenTopLevelNode node: nodes) {
+ Viewmap viewmap = node.getViewmap();
+ assertNotNull(viewmap);
+ assertTrue(viewmap instanceof ModeledViewmap);
+
+ for (GenNodeLabel label: node.getLabels()) {
+ Viewmap labelViewmap = label.getViewmap();
+ assertNotNull(labelViewmap);
+ assertTrue(labelViewmap instanceof ModeledViewmap);
+ }
+ }
+ }
+
+ public void testChildNodeModeledViewmap() {
+ assertNotNull(actualGenerator);
+
+ GenDiagram diagram = actualGenerator.getDiagram();
+ assertNotNull(diagram);
+
+ EList<GenChildNode> nodes = diagram.getChildNodes();
+
+ for (GenChildNode node: nodes) {
+ Viewmap viewmap = node.getViewmap();
+ assertNotNull(viewmap);
+ assertTrue(viewmap instanceof ModeledViewmap);
+
+ for (GenNodeLabel label: node.getLabels()) {
+ Viewmap labelViewmap = label.getViewmap();
+ assertNotNull(labelViewmap);
+ assertTrue(labelViewmap instanceof ModeledViewmap);
+ }
+ }
+ }
+
+ public void testLinkModeledViewmap() {
+ assertNotNull(actualGenerator);
+
+ GenDiagram diagram = actualGenerator.getDiagram();
+ assertNotNull(diagram);
+
+ EList<GenLink> links = diagram.getLinks();
+
+ for (GenLink link: links) {
+ Viewmap viewmap = link.getViewmap();
+ assertNotNull(viewmap);
+ assertTrue(viewmap instanceof ModeledViewmap);
+
+ for (GenLinkLabel label: link.getLabels()) {
+ Viewmap labelViewmap = label.getViewmap();
+ assertNotNull(labelViewmap);
+ assertTrue(labelViewmap instanceof ModeledViewmap);
+ }
+ }
+ }
+
+ public void testCompartmentModeledViewmap() {
+ assertNotNull(actualGenerator);
+
+ GenDiagram diagram = actualGenerator.getDiagram();
+ assertNotNull(diagram);
+
+ EList<GenCompartment> compartments = diagram.getCompartments();
+ for (GenCompartment compartment: compartments) {
+ Viewmap viewmap = compartment.getViewmap();
+ assertNotNull(viewmap);
+ assertTrue(viewmap instanceof ModeledViewmap);
+ }
+ }
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformToGenModelOperationTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformToGenModelOperationTest.java
index ab55413..380556d 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformToGenModelOperationTest.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformToGenModelOperationTest.java
@@ -166,7 +166,7 @@ public class TransformToGenModelOperationTest extends ConfiguredTestCase {
myOperation.getOptions().setUseMapMode(false);
myOperation.getOptions().setUseRuntimeFigures(false);
myOperation.getOptions().setGenerateRCP(true);
- myOperation.getOptions().setTransformation(new URL(Plugin.createURI("/transforms/Map2Gen.qvto").toString()));
+ myOperation.getOptions().setTransformation(new URL(URI.createURI("platform:/plugin/org.eclipse.gmf.tests/transforms/Map2Gen.qvto").toString()));
//
IStatus status = myOperation.executeTransformation(null);
assertTrue(status.getMessage(), status.isOK());