Remove UI code for giraph from interpreter.ui project (2)
Change-Id: I41eabc214d94a72d7919343bbf2d3563e39510f9
diff --git a/plugins/org.eclipse.emf.henshin.interpreter.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.henshin.interpreter.ui/META-INF/MANIFEST.MF
index ff26020..364009b 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.henshin.interpreter.ui/META-INF/MANIFEST.MF
@@ -14,7 +14,6 @@
org.eclipse.ui.ide;bundle-version="3.6.0",
org.eclipse.compare;bundle-version="3.5.0",
org.eclipse.emf.henshin.diagram;bundle-version="0.9.0",
- org.eclipse.emf.henshin.giraph;bundle-version="1.0.0",
org.eclipse.emf.henshin.interpreter;bundle-version="0.9.0",
org.eclipse.emf.compare;bundle-version="1.1.0",
org.eclipse.emf.common.ui;bundle-version="2.6.0",
diff --git a/plugins/org.eclipse.emf.henshin.interpreter.ui/plugin.xml b/plugins/org.eclipse.emf.henshin.interpreter.ui/plugin.xml
index 434e943..408e405 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.henshin.interpreter.ui/plugin.xml
@@ -166,54 +166,6 @@
</objectContribution>
<objectContribution
adaptable="false"
- id="org.eclipse.emf.henshin.interpreter.ui.henshincontribution4"
- objectClass="org.eclipse.emf.henshin.diagram.edit.parts.RuleEditPart">
- <action
- class="org.eclipse.emf.henshin.interpreter.ui.giraph.GenerateGiraphCodeAction"
- icon="icons/giraph.gif"
- id="org.eclipse.emf.henshin.interpreter.ui.action1"
- label="%_UI_Command_GenerateGiraphCode"
- menubarPath="additions">
- </action>
- </objectContribution>
- <objectContribution
- adaptable="false"
- id="org.eclipse.emf.henshin.interpreter.ui.henshincontribution5"
- objectClass="org.eclipse.emf.henshin.diagram.edit.parts.RuleCompartmentEditPart">
- <action
- class="org.eclipse.emf.henshin.interpreter.ui.giraph.GenerateGiraphCodeAction"
- icon="icons/giraph.gif"
- id="org.eclipse.emf.henshin.interpreter.ui.action1"
- label="%_UI_Command_GenerateGiraphCode"
- menubarPath="additions">
- </action>
- </objectContribution>
- <objectContribution
- adaptable="false"
- id="org.eclipse.emf.henshin.interpreter.ui.henshincontribution6"
- objectClass="org.eclipse.emf.henshin.diagram.edit.parts.UnitEditPart">
- <action
- class="org.eclipse.emf.henshin.interpreter.ui.giraph.GenerateGiraphCodeAction"
- icon="icons/giraph.gif"
- id="org.eclipse.emf.henshin.interpreter.ui.action1"
- label="%_UI_Command_GenerateGiraphCode"
- menubarPath="additions">
- </action>
- </objectContribution>
- <objectContribution
- adaptable="false"
- id="org.eclipse.emf.henshin.interpreter.ui.henshincontribution7"
- objectClass="org.eclipse.emf.henshin.diagram.edit.parts.UnitCompartmentEditPart">
- <action
- class="org.eclipse.emf.henshin.interpreter.ui.giraph.GenerateGiraphCodeAction"
- icon="icons/giraph.gif"
- id="org.eclipse.emf.henshin.interpreter.ui.action1"
- label="%_UI_Command_GenerateGiraphCode"
- menubarPath="additions">
- </action>
- </objectContribution>
- <objectContribution
- adaptable="false"
id="org.eclipse.emf.henshin.interpreter.ui.henshincontribution8"
objectClass="org.eclipse.emf.henshin.diagram.edit.parts.RuleEditPart">
<action
diff --git a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/IHenshinConfigConstants.java b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/IHenshinConfigConstants.java
index 8cea9e9..c26a69e 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/IHenshinConfigConstants.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/IHenshinConfigConstants.java
@@ -1,13 +1,13 @@
-package org.eclipse.emf.henshin.interpreter.ui.debug;
-
-public interface IHenshinConfigConstants {
- public static final String MODULE_PATH = "MODULE_PATH";
- public static final String UNIT_NAME = "UNIT_NAME";
- public static final String INPUT_URI = "INPUT_URI";
- public static final String OUTPUT_URI = "OUTPUT_URI";
- public static final String UNIT_INDEX = "UNIT_INDEX";
- public static final String PARAMETER_TYPES = "PARAMETER_TYPES";
- public static final String PARAMETER_VALUES = "PARAMETER_VALUES";
- public static final String UNSET_PARAMETERS = "UNSET_PARAMETERS";
- public static final String OPEN_COMPARE = "OPEN_COMPARE";
-}
+package org.eclipse.emf.henshin.interpreter.ui.debug;
+
+public interface IHenshinConfigConstants {
+ public static final String MODULE_PATH = "MODULE_PATH";
+ public static final String UNIT_NAME = "UNIT_NAME";
+ public static final String INPUT_URI = "INPUT_URI";
+ public static final String OUTPUT_URI = "OUTPUT_URI";
+ public static final String UNIT_INDEX = "UNIT_INDEX";
+ public static final String PARAMETER_TYPES = "PARAMETER_TYPES";
+ public static final String PARAMETER_VALUES = "PARAMETER_VALUES";
+ public static final String UNSET_PARAMETERS = "UNSET_PARAMETERS";
+ public static final String OPEN_COMPARE = "OPEN_COMPARE";
+}
diff --git a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleConfigurationTabGroup.java b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleConfigurationTabGroup.java
index 291f814..76b635b 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleConfigurationTabGroup.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleConfigurationTabGroup.java
@@ -1,14 +1,14 @@
-package org.eclipse.emf.henshin.interpreter.ui.debug;
-
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
-import org.eclipse.debug.ui.ILaunchConfigurationDialog;
-import org.eclipse.debug.ui.ILaunchConfigurationTab;
-
-public class LaunchRuleConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
-
- @Override
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- setTabs(new ILaunchConfigurationTab[] {new RuleLaunchTab()});
- }
-
-}
+package org.eclipse.emf.henshin.interpreter.ui.debug;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+public class LaunchRuleConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ @Override
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ setTabs(new ILaunchConfigurationTab[] {new RuleLaunchTab()});
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleControl.java b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleControl.java
index e473326..88cae31 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleControl.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleControl.java
@@ -1,270 +1,270 @@
-package org.eclipse.emf.henshin.interpreter.ui.debug;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.henshin.interpreter.ui.util.ParameterConfig;
-import org.eclipse.emf.henshin.interpreter.ui.util.TransformOperation;
-import org.eclipse.emf.henshin.interpreter.ui.wizard.ModelSelector;
-import org.eclipse.emf.henshin.interpreter.ui.wizard.ModelSelector.ModelSelectorListener;
-import org.eclipse.emf.henshin.interpreter.ui.wizard.ParameterEditTable;
-import org.eclipse.emf.henshin.interpreter.ui.wizard.ParameterEditTable.ParameterChangeListener;
-import org.eclipse.emf.henshin.interpreter.ui.wizard.UnitSelector;
-import org.eclipse.emf.henshin.interpreter.ui.wizard.UnitSelector.UnitSelectionListener;
-import org.eclipse.emf.henshin.model.Module;
-import org.eclipse.emf.henshin.model.ParameterKind;
-import org.eclipse.emf.henshin.model.Unit;
-import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-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.Group;
-
-public class LaunchRuleControl {
-
- protected static int CONTROL_OFFSET = 5;
-
- ModelSelector moduleSelector;
-
- UnitSelector unitSelector;
-
- ModelSelector inputSelector;
-
- ModelSelector outputSelector;
-
- ParameterEditTable parameterEditor;
-
- Button openCompare;
-
- protected Unit initialUnit;
-
- protected Module module;
-
- protected List<Unit> allUnits;
-
- protected List<Unit> outerUnits;
-
- protected TransformOperation transformOperation;
-
- public Composite createControl(Composite parent, final RuleLaunchTab parentTab) {
- Composite container = new Composite(parent, SWT.NONE);
- container.setLayout(new GridLayout(1, true));
-
- transformOperation = new TransformOperation();
-
- IResource selected = null;
-
- if (module == null) {
- // show file selector to select module
- moduleSelector = new ModelSelector(container, selected, false);
- moduleSelector.getControl().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, false));
- ((Group) moduleSelector.getControl()).setText("Module (.henshin file)");
- moduleSelector.addModelSelectorListener(new ModelSelectorListener() {
- @Override
- public boolean modelURIChanged(String modulePath) {
- // Create a resource set and load the resource:
- HenshinResourceSet resourceSet = new HenshinResourceSet();
- try {
- // Load the module:
- URI uri = URI.createURI(modulePath);
- module = resourceSet.getModule(uri, false);
-
- // display the units in the unit selector
- updateUnitSelector();
- parentTab.updateLaunchConfigurationDialog();
-
- return true;
- } catch (RuntimeException e) {
- // no valid module path entered
- clearModule();
- return false;
- }
- }
- });
- } else {
- String path = module.eResource().getURI().toPlatformString(true);
- selected = ResourcesPlugin.getWorkspace().getRoot()
- .findMember(path);
- }
-
- unitSelector = new UnitSelector(container);
- unitSelector.getControl().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, false));
-
- inputSelector = new ModelSelector(container, selected, false);
- inputSelector.getControl().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, false));
-
- outputSelector = new ModelSelector(container, selected, true);
- outputSelector.getControl().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, false));
-
- inputSelector.addModelSelectorListener(new ModelSelectorListener() {
- @Override
- public boolean modelURIChanged(String modelURI) {
- String output = deriveOutputURI(modelURI);
- if (output != null) {
- outputSelector.setModelURI(output);
- }
- parentTab.updateLaunchConfigurationDialog();
- return true;
- }
- });
-
- parameterEditor = new ParameterEditTable(container);
- parameterEditor.getControl().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, true));
- parameterEditor.addParameterChangeListener(new ParameterChangeListener() {
-
- @Override
- public void parameterChanged(ParameterConfig paramCfg) {
- // update name, type, and "unset" setting of the parameter
- transformOperation.getParameterConfiguration(paramCfg.getName()).setValue(paramCfg.getValue());
- transformOperation.getParameterConfiguration(paramCfg.getName()).setType(paramCfg.getType());
- transformOperation.getParameterConfiguration(paramCfg.getName()).setUnset(paramCfg.isUnset());
- parentTab.updateLaunchConfigurationDialog();
- }
- });
-
- openCompare = new Button(container, SWT.CHECK);
- openCompare.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- openCompare.setText("Open Compare");
- openCompare.setSelection(true);
- openCompare.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseUp(MouseEvent e) {
- parentTab.updateLaunchConfigurationDialog();
- }
-
- @Override
- public void mouseDown(MouseEvent e) {}
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {}
- });
-
- inputSelector.getBrowseWorkspaceButton().setFocus();
-
- unitSelector.addUnitSelectionListener(new UnitSelectionListener() {
-
- @Override
- public boolean unitSelected(int idx, boolean showInnerUnits) {
- Unit unit = showInnerUnits ?
- LaunchRuleControl.this.allUnits.get(idx) :
- LaunchRuleControl.this.outerUnits.get(idx);
- transformOperation.setUnit(unit, ParamUtil.getParameterPreferences(unit));
-
- for (ParameterConfig parameterConfig : transformOperation.getParameterConfigurations()) {
- if (parameterConfig.getKind() == ParameterKind.IN || parameterConfig.getKind() == ParameterKind.INOUT) {
- parameterConfig.setUnset(false); // has to be set
- }
- if (parameterConfig.getKind() == ParameterKind.OUT || parameterConfig.getKind() == ParameterKind.VAR) {
- parameterConfig.setUnset(true); // must not be set
- }
- }
-
- parameterEditor.setParameters(transformOperation.getParameterConfigurations());
-
-
-
- parentTab.updateLaunchConfigurationDialog();
-
- return false;
- }
- });
-
- return container;
- }
-
- private void updateUnitSelector() {
- allUnits = new ArrayList<Unit>();
- allUnits.addAll(module.getUnits());
- outerUnits = new ArrayList<Unit>();
-
- List<String> selectableUnitLabels = new ArrayList<String>();
- List<String> outerUnitLabels = new ArrayList<String>();
-
- int initIdx = -1;
- int idx = 0;
- Unit selectedUnit = initialUnit;
- for (Unit unit : allUnits) {
- String unitLabel = unit.toString();
- selectableUnitLabels.add(unitLabel);
- boolean isOuterUnit = true;
- for (Unit outerUnit : allUnits) {
- if (outerUnit.getSubUnits(true).contains(unit)) {
- isOuterUnit = false;
- break;
- }
- }
- if (isOuterUnit) {
- outerUnits.add(unit);
- outerUnitLabels.add(unitLabel);
- }
-
- if (initialUnit != null) {
- if (initialUnit == unit) {
- initIdx = idx;
- selectedUnit = unit;
- }
- } else {
- if (initIdx < 0 && unit.getName() != null
- && unit.getName().toLowerCase().equals("main")) {
- initIdx = idx;
- selectedUnit = unit;
- }
- }
- idx++;
- }
- if (initIdx < 0) {
- initIdx = 0;
- selectedUnit = allUnits.get(0);
- }
-
- if (selectedUnit != null) {
- transformOperation.setUnit(selectedUnit,
- ParamUtil.getParameterPreferences(selectedUnit));
- }
-
- if (selectedUnit != null) {
- parameterEditor.setParameters(transformOperation
- .getParameterConfigurations());
- }
-
- unitSelector.setSelectableUnits(
- selectableUnitLabels.toArray(new String[0]),
- outerUnitLabels.toArray(new String[0]));
- unitSelector.setSelection(initIdx);
- }
-
- /**
- * clears selectors relevant to the current module (i.e. the unit selector and parameter editor)
- */
- private void clearModule() {
- unitSelector.setSelectableUnits(new String[0], new String[0]);
- parameterEditor.setParameters(new ArrayList<ParameterConfig>(0));
- }
-
- private String deriveOutputURI(String inputUri) {
- try {
- URI uri = URI.createURI(inputUri);
- String fileExt = uri.fileExtension();
- uri = uri.trimFileExtension();
- uri = URI.createURI(uri.toString() + "_transformed")
- .appendFileExtension(fileExt);
- return uri.toString();
- } catch (IllegalArgumentException e) {
- return null;
- }
- }
-
-}
+package org.eclipse.emf.henshin.interpreter.ui.debug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.henshin.interpreter.ui.util.ParameterConfig;
+import org.eclipse.emf.henshin.interpreter.ui.util.TransformOperation;
+import org.eclipse.emf.henshin.interpreter.ui.wizard.ModelSelector;
+import org.eclipse.emf.henshin.interpreter.ui.wizard.ModelSelector.ModelSelectorListener;
+import org.eclipse.emf.henshin.interpreter.ui.wizard.ParameterEditTable;
+import org.eclipse.emf.henshin.interpreter.ui.wizard.ParameterEditTable.ParameterChangeListener;
+import org.eclipse.emf.henshin.interpreter.ui.wizard.UnitSelector;
+import org.eclipse.emf.henshin.interpreter.ui.wizard.UnitSelector.UnitSelectionListener;
+import org.eclipse.emf.henshin.model.Module;
+import org.eclipse.emf.henshin.model.ParameterKind;
+import org.eclipse.emf.henshin.model.Unit;
+import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+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.Group;
+
+public class LaunchRuleControl {
+
+ protected static int CONTROL_OFFSET = 5;
+
+ ModelSelector moduleSelector;
+
+ UnitSelector unitSelector;
+
+ ModelSelector inputSelector;
+
+ ModelSelector outputSelector;
+
+ ParameterEditTable parameterEditor;
+
+ Button openCompare;
+
+ protected Unit initialUnit;
+
+ protected Module module;
+
+ protected List<Unit> allUnits;
+
+ protected List<Unit> outerUnits;
+
+ protected TransformOperation transformOperation;
+
+ public Composite createControl(Composite parent, final RuleLaunchTab parentTab) {
+ Composite container = new Composite(parent, SWT.NONE);
+ container.setLayout(new GridLayout(1, true));
+
+ transformOperation = new TransformOperation();
+
+ IResource selected = null;
+
+ if (module == null) {
+ // show file selector to select module
+ moduleSelector = new ModelSelector(container, selected, false);
+ moduleSelector.getControl().setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, true, false));
+ ((Group) moduleSelector.getControl()).setText("Module (.henshin file)");
+ moduleSelector.addModelSelectorListener(new ModelSelectorListener() {
+ @Override
+ public boolean modelURIChanged(String modulePath) {
+ // Create a resource set and load the resource:
+ HenshinResourceSet resourceSet = new HenshinResourceSet();
+ try {
+ // Load the module:
+ URI uri = URI.createURI(modulePath);
+ module = resourceSet.getModule(uri, false);
+
+ // display the units in the unit selector
+ updateUnitSelector();
+ parentTab.updateLaunchConfigurationDialog();
+
+ return true;
+ } catch (RuntimeException e) {
+ // no valid module path entered
+ clearModule();
+ return false;
+ }
+ }
+ });
+ } else {
+ String path = module.eResource().getURI().toPlatformString(true);
+ selected = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(path);
+ }
+
+ unitSelector = new UnitSelector(container);
+ unitSelector.getControl().setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ inputSelector = new ModelSelector(container, selected, false);
+ inputSelector.getControl().setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ outputSelector = new ModelSelector(container, selected, true);
+ outputSelector.getControl().setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ inputSelector.addModelSelectorListener(new ModelSelectorListener() {
+ @Override
+ public boolean modelURIChanged(String modelURI) {
+ String output = deriveOutputURI(modelURI);
+ if (output != null) {
+ outputSelector.setModelURI(output);
+ }
+ parentTab.updateLaunchConfigurationDialog();
+ return true;
+ }
+ });
+
+ parameterEditor = new ParameterEditTable(container);
+ parameterEditor.getControl().setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, true, true));
+ parameterEditor.addParameterChangeListener(new ParameterChangeListener() {
+
+ @Override
+ public void parameterChanged(ParameterConfig paramCfg) {
+ // update name, type, and "unset" setting of the parameter
+ transformOperation.getParameterConfiguration(paramCfg.getName()).setValue(paramCfg.getValue());
+ transformOperation.getParameterConfiguration(paramCfg.getName()).setType(paramCfg.getType());
+ transformOperation.getParameterConfiguration(paramCfg.getName()).setUnset(paramCfg.isUnset());
+ parentTab.updateLaunchConfigurationDialog();
+ }
+ });
+
+ openCompare = new Button(container, SWT.CHECK);
+ openCompare.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ openCompare.setText("Open Compare");
+ openCompare.setSelection(true);
+ openCompare.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ parentTab.updateLaunchConfigurationDialog();
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {}
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+
+ inputSelector.getBrowseWorkspaceButton().setFocus();
+
+ unitSelector.addUnitSelectionListener(new UnitSelectionListener() {
+
+ @Override
+ public boolean unitSelected(int idx, boolean showInnerUnits) {
+ Unit unit = showInnerUnits ?
+ LaunchRuleControl.this.allUnits.get(idx) :
+ LaunchRuleControl.this.outerUnits.get(idx);
+ transformOperation.setUnit(unit, ParamUtil.getParameterPreferences(unit));
+
+ for (ParameterConfig parameterConfig : transformOperation.getParameterConfigurations()) {
+ if (parameterConfig.getKind() == ParameterKind.IN || parameterConfig.getKind() == ParameterKind.INOUT) {
+ parameterConfig.setUnset(false); // has to be set
+ }
+ if (parameterConfig.getKind() == ParameterKind.OUT || parameterConfig.getKind() == ParameterKind.VAR) {
+ parameterConfig.setUnset(true); // must not be set
+ }
+ }
+
+ parameterEditor.setParameters(transformOperation.getParameterConfigurations());
+
+
+
+ parentTab.updateLaunchConfigurationDialog();
+
+ return false;
+ }
+ });
+
+ return container;
+ }
+
+ private void updateUnitSelector() {
+ allUnits = new ArrayList<Unit>();
+ allUnits.addAll(module.getUnits());
+ outerUnits = new ArrayList<Unit>();
+
+ List<String> selectableUnitLabels = new ArrayList<String>();
+ List<String> outerUnitLabels = new ArrayList<String>();
+
+ int initIdx = -1;
+ int idx = 0;
+ Unit selectedUnit = initialUnit;
+ for (Unit unit : allUnits) {
+ String unitLabel = unit.toString();
+ selectableUnitLabels.add(unitLabel);
+ boolean isOuterUnit = true;
+ for (Unit outerUnit : allUnits) {
+ if (outerUnit.getSubUnits(true).contains(unit)) {
+ isOuterUnit = false;
+ break;
+ }
+ }
+ if (isOuterUnit) {
+ outerUnits.add(unit);
+ outerUnitLabels.add(unitLabel);
+ }
+
+ if (initialUnit != null) {
+ if (initialUnit == unit) {
+ initIdx = idx;
+ selectedUnit = unit;
+ }
+ } else {
+ if (initIdx < 0 && unit.getName() != null
+ && unit.getName().toLowerCase().equals("main")) {
+ initIdx = idx;
+ selectedUnit = unit;
+ }
+ }
+ idx++;
+ }
+ if (initIdx < 0) {
+ initIdx = 0;
+ selectedUnit = allUnits.get(0);
+ }
+
+ if (selectedUnit != null) {
+ transformOperation.setUnit(selectedUnit,
+ ParamUtil.getParameterPreferences(selectedUnit));
+ }
+
+ if (selectedUnit != null) {
+ parameterEditor.setParameters(transformOperation
+ .getParameterConfigurations());
+ }
+
+ unitSelector.setSelectableUnits(
+ selectableUnitLabels.toArray(new String[0]),
+ outerUnitLabels.toArray(new String[0]));
+ unitSelector.setSelection(initIdx);
+ }
+
+ /**
+ * clears selectors relevant to the current module (i.e. the unit selector and parameter editor)
+ */
+ private void clearModule() {
+ unitSelector.setSelectableUnits(new String[0], new String[0]);
+ parameterEditor.setParameters(new ArrayList<ParameterConfig>(0));
+ }
+
+ private String deriveOutputURI(String inputUri) {
+ try {
+ URI uri = URI.createURI(inputUri);
+ String fileExt = uri.fileExtension();
+ uri = uri.trimFileExtension();
+ uri = URI.createURI(uri.toString() + "_transformed")
+ .appendFileExtension(fileExt);
+ return uri.toString();
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleDelegate.java b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleDelegate.java
index 68d15d4..d833ef9 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleDelegate.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/LaunchRuleDelegate.java
@@ -1,302 +1,302 @@
-package org.eclipse.emf.henshin.interpreter.ui.debug;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Observable;
-import java.util.Observer;
-
-import org.eclipse.compare.internal.CompareAction;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.henshin.interpreter.Change;
-import org.eclipse.emf.henshin.interpreter.EGraph;
-import org.eclipse.emf.henshin.interpreter.Match;
-import org.eclipse.emf.henshin.interpreter.debug.HenshinDebugTarget;
-import org.eclipse.emf.henshin.interpreter.impl.DebugEngineImpl;
-import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl;
-import org.eclipse.emf.henshin.interpreter.impl.MatchImpl;
-import org.eclipse.emf.henshin.interpreter.matching.conditions.DebugApplicationCondition;
-import org.eclipse.emf.henshin.interpreter.matching.constraints.Solution;
-import org.eclipse.emf.henshin.interpreter.ui.HenshinInterpreterUIPlugin;
-import org.eclipse.emf.henshin.interpreter.ui.util.ParameterConfig;
-import org.eclipse.emf.henshin.interpreter.ui.util.TransformOperation;
-import org.eclipse.emf.henshin.model.Module;
-import org.eclipse.emf.henshin.model.Parameter;
-import org.eclipse.emf.henshin.model.ParameterKind;
-import org.eclipse.emf.henshin.model.Rule;
-import org.eclipse.emf.henshin.model.Unit;
-import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-
-
-/**
- * The launch delegate responsible for launching a henshin rule application.
- */
-@SuppressWarnings("restriction")
-public class LaunchRuleDelegate implements ILaunchConfigurationDelegate {
-
- @Override
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
- throws CoreException {
- String modulePath = configuration.getAttribute(IHenshinConfigConstants.MODULE_PATH, "");
- String unitName = configuration.getAttribute(IHenshinConfigConstants.UNIT_NAME, "");
- String inputURIString = configuration.getAttribute(IHenshinConfigConstants.INPUT_URI, "");
- String outputURIString = configuration.getAttribute(IHenshinConfigConstants.OUTPUT_URI, "");
- Map<String, String> paramTypes = configuration.getAttribute(IHenshinConfigConstants.PARAMETER_TYPES,
- new HashMap<String, String>());
- Map<String, String> paramValues = configuration.getAttribute(IHenshinConfigConstants.PARAMETER_VALUES,
- new HashMap<String, String>());
- List<String> unsetParamNames = configuration.getAttribute(IHenshinConfigConstants.UNSET_PARAMETERS,
- new ArrayList<String>());
- boolean openCompare = configuration.getAttribute(IHenshinConfigConstants.OPEN_COMPARE, true);
-
- // Load the module:
- URI moduleUri = URI.createURI(modulePath);
-
- // Create a fresh resource set for storing a copy of the module:
- HenshinResourceSet resourceSet = new HenshinResourceSet();
- Module module = resourceSet.getModule(moduleUri, false);
- Resource oldModuleResource = module.eResource();
- Resource newModuleResource = resourceSet.createResource(oldModuleResource.getURI());
-
- // Copy the original module into the fresh resource:
- Copier copier = new Copier();
- Collection<EObject> copies = copier.copyAll(oldModuleResource.getContents());
- copier.copyReferences();
- newModuleResource.getContents().addAll(copies);
-
- // Now switch to the copied version:
- module = (Module) copier.get(module);
-
- // Manually initialize the package registry:
- for (EPackage ePackage : module.getImports()) {
- resourceSet.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
- }
-
- // get the unit with the specified name
- Unit unit = module.getUnit(unitName);
-
- // get parameters for unit
- List<ParameterConfig> paramConfigs = ParamUtil.getParameterPreferences(unit);
- ParamUtil.fillParamConfigs(paramConfigs, paramTypes, paramValues, unsetParamNames);
-
- // get the URIs from the URI Strings
- URI inputUri = URI.createURI(inputURIString);
- URI outputUri = URI.createURI(outputURIString);
-
- TransformOperation transformOperation = new TransformOperation();
- transformOperation.setUnit(unit, paramConfigs);
- transformOperation.setInputURI(inputUri);
- transformOperation.setOutputURI(outputUri);
-
- // remove "var" and "out" params
- Iterator<ParameterConfig> iterator = transformOperation.getParameterConfigurations().iterator();
- while (iterator.hasNext()) {
- ParameterConfig paramConfig = iterator.next();
- if (paramConfig.getKind() == ParameterKind.VAR || paramConfig.getKind() == ParameterKind.OUT) {
- iterator.remove();
- }
- }
-
- // debug launch: add IDebugTarget
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
-
- // Create an engine:
- DebugEngineImpl engine = new DebugEngineImpl();
-
- HenshinDebugTarget target = new HenshinDebugTarget(launch, unitName);
- engine.setDebugTarget(target);
-
- Resource input = resourceSet.getResource(inputUri, true);
- EGraph graph = new EGraphImpl(input);
- Rule rule = null;
- try {
- // we can only debug plain rule applications at the moment
- rule = (Rule) unit;
- } catch (ClassCastException e) {
- final String message = "The selected unit is not a rule";
- final String configName = configuration.getName();
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- MessageDialog.openError(shell, configName, message);
- }
- });
- }
-
- Match partialMatch = new MatchImpl(rule);
-
- for (Parameter param : rule.getParameters()) {
- if (param.getKind() != ParameterKind.VAR && param.getKind() != ParameterKind.OUT) {
- partialMatch.setParameterValue(param, transformOperation.getParameterValue(param.getName()));
- }
- }
-
- DebugApplicationCondition applicationCondition = engine.getDebugApplicationCondition(rule, graph, partialMatch, new Observer() {
- @Override
- public void update(Observable o, Object arg) {
- if (!(arg instanceof Solution)) {
- throw new IllegalStateException("update arg has to be of type Solution, but is of type "
- + arg.getClass().getSimpleName());
- }
- Solution solution = (Solution) arg;
- Match completeMatch = engine.getMatchFinder().basicMatchFromSolution(solution);
- Match resultMatch = new MatchImpl((Rule) unit, true);
- Change change = engine.createChange((Rule) unit, graph, completeMatch, resultMatch);
- change.applyAndReverse();
-
- Resource output;
- if (inputUri.equals(outputUri)) {
- output = input;
- } else {
- output = resourceSet.createResource(outputUri);
- output.getContents().addAll(input.getContents());
- }
-
- Map<Object, Object> options = new HashMap<Object, Object>();
- options.put(XMIResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
- try {
- output.save(options);
-
- if (outputUri.isPlatformResource()) {
- IPath path = new Path(outputUri.toPlatformString(false));
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- if (file != null) {
- file.getParent().refreshLocal(2, SubMonitor.convert(monitor, 2));
-
- }
- }
-
- } catch (CoreException | IOException e) {
- e.printStackTrace();
- displayMessage(configuration, "Error saving transformation result.");
- }
-
- if (openCompare) {
- openCompareView(inputUri, outputUri);
- }
- }
- });
-
- engine.getDebugTarget().initTarget(applicationCondition, findResourceForModulePath(modulePath));
- launch.addDebugTarget(engine.getDebugTarget());
-
- applicationCondition.initNextVariable();
-
- // normal launch
- } else if (mode.equals(ILaunchManager.RUN_MODE)) {
- try {
- // execute the transformOperation
- transformOperation.run(monitor);
-
- if (openCompare) {
- openCompareView(inputUri, outputUri);
- }
- } catch (InvocationTargetException e) {
- if (e.getCause() != null && e.getCause().getMessage() != null) {
- displayMessage(configuration, e.getCause().getMessage());
- } else {
- displayMessage(configuration, "Error applying transformation");
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- private void displayMessage(ILaunchConfiguration configuration, final String message) {
- final String configName = configuration.getName();
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- MessageDialog.openError(shell, configName, message);
- }
- });
- }
-
- private IFile findResourceForModulePath(String modulePath) throws CoreException {
- try {
- // returns IFile to use later in Marker to register breakpoints
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(FileLocator.resolve(java.net.URI.create(modulePath).toURL()).toURI());
- if (files.length > 0)
- return files[0];
- } catch (MalformedURLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (URISyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- throw new CoreException(new Status(IStatus.ERROR, HenshinInterpreterUIPlugin.PLUGIN_ID, "Didn't find resource for modulePath '" + modulePath + "'."));
- }
-
- private void openCompareView(URI inputUri, URI outputUri) {
- IFile left = ParamUtil.getIFile(outputUri);
- IFile right = ParamUtil.getIFile(inputUri);
- if (left != null && right != null) {
- try {
- final ISelection selection = new StructuredSelection(new Object[] { left, right });
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- MyCompareAction c = new MyCompareAction();
- IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage().getActivePart();
- c.setActivePart(null, part);
- c.run(selection);
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- private class MyCompareAction extends CompareAction {
- @Override
- public void run(ISelection selection) {
- if (super.isEnabled(selection)) {
- super.run(selection);
- }
- }
- }
-
-}
+package org.eclipse.emf.henshin.interpreter.ui.debug;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.eclipse.compare.internal.CompareAction;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.henshin.interpreter.Change;
+import org.eclipse.emf.henshin.interpreter.EGraph;
+import org.eclipse.emf.henshin.interpreter.Match;
+import org.eclipse.emf.henshin.interpreter.debug.HenshinDebugTarget;
+import org.eclipse.emf.henshin.interpreter.impl.DebugEngineImpl;
+import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl;
+import org.eclipse.emf.henshin.interpreter.impl.MatchImpl;
+import org.eclipse.emf.henshin.interpreter.matching.conditions.DebugApplicationCondition;
+import org.eclipse.emf.henshin.interpreter.matching.constraints.Solution;
+import org.eclipse.emf.henshin.interpreter.ui.HenshinInterpreterUIPlugin;
+import org.eclipse.emf.henshin.interpreter.ui.util.ParameterConfig;
+import org.eclipse.emf.henshin.interpreter.ui.util.TransformOperation;
+import org.eclipse.emf.henshin.model.Module;
+import org.eclipse.emf.henshin.model.Parameter;
+import org.eclipse.emf.henshin.model.ParameterKind;
+import org.eclipse.emf.henshin.model.Rule;
+import org.eclipse.emf.henshin.model.Unit;
+import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * The launch delegate responsible for launching a henshin rule application.
+ */
+@SuppressWarnings("restriction")
+public class LaunchRuleDelegate implements ILaunchConfigurationDelegate {
+
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+ String modulePath = configuration.getAttribute(IHenshinConfigConstants.MODULE_PATH, "");
+ String unitName = configuration.getAttribute(IHenshinConfigConstants.UNIT_NAME, "");
+ String inputURIString = configuration.getAttribute(IHenshinConfigConstants.INPUT_URI, "");
+ String outputURIString = configuration.getAttribute(IHenshinConfigConstants.OUTPUT_URI, "");
+ Map<String, String> paramTypes = configuration.getAttribute(IHenshinConfigConstants.PARAMETER_TYPES,
+ new HashMap<String, String>());
+ Map<String, String> paramValues = configuration.getAttribute(IHenshinConfigConstants.PARAMETER_VALUES,
+ new HashMap<String, String>());
+ List<String> unsetParamNames = configuration.getAttribute(IHenshinConfigConstants.UNSET_PARAMETERS,
+ new ArrayList<String>());
+ boolean openCompare = configuration.getAttribute(IHenshinConfigConstants.OPEN_COMPARE, true);
+
+ // Load the module:
+ URI moduleUri = URI.createURI(modulePath);
+
+ // Create a fresh resource set for storing a copy of the module:
+ HenshinResourceSet resourceSet = new HenshinResourceSet();
+ Module module = resourceSet.getModule(moduleUri, false);
+ Resource oldModuleResource = module.eResource();
+ Resource newModuleResource = resourceSet.createResource(oldModuleResource.getURI());
+
+ // Copy the original module into the fresh resource:
+ Copier copier = new Copier();
+ Collection<EObject> copies = copier.copyAll(oldModuleResource.getContents());
+ copier.copyReferences();
+ newModuleResource.getContents().addAll(copies);
+
+ // Now switch to the copied version:
+ module = (Module) copier.get(module);
+
+ // Manually initialize the package registry:
+ for (EPackage ePackage : module.getImports()) {
+ resourceSet.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
+ }
+
+ // get the unit with the specified name
+ Unit unit = module.getUnit(unitName);
+
+ // get parameters for unit
+ List<ParameterConfig> paramConfigs = ParamUtil.getParameterPreferences(unit);
+ ParamUtil.fillParamConfigs(paramConfigs, paramTypes, paramValues, unsetParamNames);
+
+ // get the URIs from the URI Strings
+ URI inputUri = URI.createURI(inputURIString);
+ URI outputUri = URI.createURI(outputURIString);
+
+ TransformOperation transformOperation = new TransformOperation();
+ transformOperation.setUnit(unit, paramConfigs);
+ transformOperation.setInputURI(inputUri);
+ transformOperation.setOutputURI(outputUri);
+
+ // remove "var" and "out" params
+ Iterator<ParameterConfig> iterator = transformOperation.getParameterConfigurations().iterator();
+ while (iterator.hasNext()) {
+ ParameterConfig paramConfig = iterator.next();
+ if (paramConfig.getKind() == ParameterKind.VAR || paramConfig.getKind() == ParameterKind.OUT) {
+ iterator.remove();
+ }
+ }
+
+ // debug launch: add IDebugTarget
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+
+ // Create an engine:
+ DebugEngineImpl engine = new DebugEngineImpl();
+
+ HenshinDebugTarget target = new HenshinDebugTarget(launch, unitName);
+ engine.setDebugTarget(target);
+
+ Resource input = resourceSet.getResource(inputUri, true);
+ EGraph graph = new EGraphImpl(input);
+ Rule rule = null;
+ try {
+ // we can only debug plain rule applications at the moment
+ rule = (Rule) unit;
+ } catch (ClassCastException e) {
+ final String message = "The selected unit is not a rule";
+ final String configName = configuration.getName();
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageDialog.openError(shell, configName, message);
+ }
+ });
+ }
+
+ Match partialMatch = new MatchImpl(rule);
+
+ for (Parameter param : rule.getParameters()) {
+ if (param.getKind() != ParameterKind.VAR && param.getKind() != ParameterKind.OUT) {
+ partialMatch.setParameterValue(param, transformOperation.getParameterValue(param.getName()));
+ }
+ }
+
+ DebugApplicationCondition applicationCondition = engine.getDebugApplicationCondition(rule, graph, partialMatch, new Observer() {
+ @Override
+ public void update(Observable o, Object arg) {
+ if (!(arg instanceof Solution)) {
+ throw new IllegalStateException("update arg has to be of type Solution, but is of type "
+ + arg.getClass().getSimpleName());
+ }
+ Solution solution = (Solution) arg;
+ Match completeMatch = engine.getMatchFinder().basicMatchFromSolution(solution);
+ Match resultMatch = new MatchImpl((Rule) unit, true);
+ Change change = engine.createChange((Rule) unit, graph, completeMatch, resultMatch);
+ change.applyAndReverse();
+
+ Resource output;
+ if (inputUri.equals(outputUri)) {
+ output = input;
+ } else {
+ output = resourceSet.createResource(outputUri);
+ output.getContents().addAll(input.getContents());
+ }
+
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMIResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
+ try {
+ output.save(options);
+
+ if (outputUri.isPlatformResource()) {
+ IPath path = new Path(outputUri.toPlatformString(false));
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file != null) {
+ file.getParent().refreshLocal(2, SubMonitor.convert(monitor, 2));
+
+ }
+ }
+
+ } catch (CoreException | IOException e) {
+ e.printStackTrace();
+ displayMessage(configuration, "Error saving transformation result.");
+ }
+
+ if (openCompare) {
+ openCompareView(inputUri, outputUri);
+ }
+ }
+ });
+
+ engine.getDebugTarget().initTarget(applicationCondition, findResourceForModulePath(modulePath));
+ launch.addDebugTarget(engine.getDebugTarget());
+
+ applicationCondition.initNextVariable();
+
+ // normal launch
+ } else if (mode.equals(ILaunchManager.RUN_MODE)) {
+ try {
+ // execute the transformOperation
+ transformOperation.run(monitor);
+
+ if (openCompare) {
+ openCompareView(inputUri, outputUri);
+ }
+ } catch (InvocationTargetException e) {
+ if (e.getCause() != null && e.getCause().getMessage() != null) {
+ displayMessage(configuration, e.getCause().getMessage());
+ } else {
+ displayMessage(configuration, "Error applying transformation");
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private void displayMessage(ILaunchConfiguration configuration, final String message) {
+ final String configName = configuration.getName();
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageDialog.openError(shell, configName, message);
+ }
+ });
+ }
+
+ private IFile findResourceForModulePath(String modulePath) throws CoreException {
+ try {
+ // returns IFile to use later in Marker to register breakpoints
+ IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(FileLocator.resolve(java.net.URI.create(modulePath).toURL()).toURI());
+ if (files.length > 0)
+ return files[0];
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ throw new CoreException(new Status(IStatus.ERROR, HenshinInterpreterUIPlugin.PLUGIN_ID, "Didn't find resource for modulePath '" + modulePath + "'."));
+ }
+
+ private void openCompareView(URI inputUri, URI outputUri) {
+ IFile left = ParamUtil.getIFile(outputUri);
+ IFile right = ParamUtil.getIFile(inputUri);
+ if (left != null && right != null) {
+ try {
+ final ISelection selection = new StructuredSelection(new Object[] { left, right });
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ MyCompareAction c = new MyCompareAction();
+ IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().getActivePart();
+ c.setActivePart(null, part);
+ c.run(selection);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private class MyCompareAction extends CompareAction {
+ @Override
+ public void run(ISelection selection) {
+ if (super.isEnabled(selection)) {
+ super.run(selection);
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/ParamUtil.java b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/ParamUtil.java
index 59a2206..69f211c 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/ParamUtil.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/ParamUtil.java
@@ -1,113 +1,113 @@
-package org.eclipse.emf.henshin.interpreter.ui.debug;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.henshin.interpreter.ui.util.ParameterConfig;
-import org.eclipse.emf.henshin.model.Parameter;
-import org.eclipse.emf.henshin.model.ParameterKind;
-import org.eclipse.emf.henshin.model.Unit;
-
-public class ParamUtil {
-
- /**
- * finds the IFile at the location provided by the string uri
- * @param uriString
- * @return
- */
- public static IFile getIFile(URI uri) {
- try {
- if (uri.isPlatformResource()) {
- IPath path = new Path(uri.toPlatformString(false));
- return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- }
- } catch (IllegalArgumentException e) {
- return null;
- }
- return null;
- }
-
- /**
- * gets the parameter preferences from a given unit
- * @param unit
- * @return
- */
- public static List<ParameterConfig> getParameterPreferences(Unit unit) {
- List<ParameterConfig> result = new ArrayList<ParameterConfig>();
- if (unit != null) {
- for (Parameter param : unit.getParameters()) {
- result.add(new ParameterConfig(param));
- }
- }
- return result;
- }
-
- /**
- * converts the String value to the given type (see ParameterConfig) and returns it as an Object
- * @param type
- * @param value
- * @return the value of the correct type as an Object
- */
- public static Object paramConfigToObject(int type, String value) {
- if(type == ParameterConfig.NULL) return null;
- if(type == ParameterConfig.BOOLEAN) return Boolean.parseBoolean(value);
- if(type == ParameterConfig.INT) return Integer.parseInt(value);
- if(type == ParameterConfig.LONG) return Long.parseLong(value);
- if(type == ParameterConfig.FLOAT) return Float.parseFloat(value);
- if(type == ParameterConfig.DOUBLE) return Double.parseDouble(value);
- return value; // string is also returned unchanged
- }
-
- /**
- * fills the given parameter configuration with the given parameter types and values
- * @param paramConfigs
- * @param paramTypes
- * @param paramValues
- */
- public static void fillParamConfigs(Collection<ParameterConfig> paramConfigs,
- Map<String, String> paramTypes, Map<String, String> paramValues, List<String> unsetParamNames) {
- for (ParameterConfig paramConfig : paramConfigs) {
- // in case the parameter kinds have changed since the last save: update the mandatory 'unset' values
- if (paramConfig.getKind() == ParameterKind.IN || paramConfig.getKind() == ParameterKind.INOUT) {
- paramConfig.setUnset(false); // has to be set
- } else if (paramConfig.getKind() == ParameterKind.OUT || paramConfig.getKind() == ParameterKind.VAR) {
- paramConfig.setUnset(true); // must not be set
- } else {
- // only for UNKNOWN parameter kinds: use the stored 'unset' value
- paramConfig.setUnset(unsetParamNames.contains(paramConfig.getName()));
- }
-
- if (paramConfig.isUnset()) {
- continue;
- }
-
- // parse the type and value (they are stored as strings in the configuration)
- // (use default type if none was stored)
- int paramType = paramConfig.getType();
- if (paramTypes.get(paramConfig.getName()) != null) {
- paramType = Integer.parseInt(paramTypes.get(paramConfig.getName()));
- }
-
- Object paramValue = null;
- if (!paramConfig.isUnset()) {
- String stringValue = paramValues.get(paramConfig.getName());
- try {
- paramValue = (stringValue == null ? null : paramConfigToObject(paramType, stringValue));
- } catch (NumberFormatException e) {
- paramValue = null;
- }
- }
-
- // set the type and value of the parameter
- paramConfig.setType(paramType);
- paramConfig.setValue(paramValue);
- }
- }
-}
+package org.eclipse.emf.henshin.interpreter.ui.debug;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.henshin.interpreter.ui.util.ParameterConfig;
+import org.eclipse.emf.henshin.model.Parameter;
+import org.eclipse.emf.henshin.model.ParameterKind;
+import org.eclipse.emf.henshin.model.Unit;
+
+public class ParamUtil {
+
+ /**
+ * finds the IFile at the location provided by the string uri
+ * @param uriString
+ * @return
+ */
+ public static IFile getIFile(URI uri) {
+ try {
+ if (uri.isPlatformResource()) {
+ IPath path = new Path(uri.toPlatformString(false));
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ }
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * gets the parameter preferences from a given unit
+ * @param unit
+ * @return
+ */
+ public static List<ParameterConfig> getParameterPreferences(Unit unit) {
+ List<ParameterConfig> result = new ArrayList<ParameterConfig>();
+ if (unit != null) {
+ for (Parameter param : unit.getParameters()) {
+ result.add(new ParameterConfig(param));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * converts the String value to the given type (see ParameterConfig) and returns it as an Object
+ * @param type
+ * @param value
+ * @return the value of the correct type as an Object
+ */
+ public static Object paramConfigToObject(int type, String value) {
+ if(type == ParameterConfig.NULL) return null;
+ if(type == ParameterConfig.BOOLEAN) return Boolean.parseBoolean(value);
+ if(type == ParameterConfig.INT) return Integer.parseInt(value);
+ if(type == ParameterConfig.LONG) return Long.parseLong(value);
+ if(type == ParameterConfig.FLOAT) return Float.parseFloat(value);
+ if(type == ParameterConfig.DOUBLE) return Double.parseDouble(value);
+ return value; // string is also returned unchanged
+ }
+
+ /**
+ * fills the given parameter configuration with the given parameter types and values
+ * @param paramConfigs
+ * @param paramTypes
+ * @param paramValues
+ */
+ public static void fillParamConfigs(Collection<ParameterConfig> paramConfigs,
+ Map<String, String> paramTypes, Map<String, String> paramValues, List<String> unsetParamNames) {
+ for (ParameterConfig paramConfig : paramConfigs) {
+ // in case the parameter kinds have changed since the last save: update the mandatory 'unset' values
+ if (paramConfig.getKind() == ParameterKind.IN || paramConfig.getKind() == ParameterKind.INOUT) {
+ paramConfig.setUnset(false); // has to be set
+ } else if (paramConfig.getKind() == ParameterKind.OUT || paramConfig.getKind() == ParameterKind.VAR) {
+ paramConfig.setUnset(true); // must not be set
+ } else {
+ // only for UNKNOWN parameter kinds: use the stored 'unset' value
+ paramConfig.setUnset(unsetParamNames.contains(paramConfig.getName()));
+ }
+
+ if (paramConfig.isUnset()) {
+ continue;
+ }
+
+ // parse the type and value (they are stored as strings in the configuration)
+ // (use default type if none was stored)
+ int paramType = paramConfig.getType();
+ if (paramTypes.get(paramConfig.getName()) != null) {
+ paramType = Integer.parseInt(paramTypes.get(paramConfig.getName()));
+ }
+
+ Object paramValue = null;
+ if (!paramConfig.isUnset()) {
+ String stringValue = paramValues.get(paramConfig.getName());
+ try {
+ paramValue = (stringValue == null ? null : paramConfigToObject(paramType, stringValue));
+ } catch (NumberFormatException e) {
+ paramValue = null;
+ }
+ }
+
+ // set the type and value of the parameter
+ paramConfig.setType(paramType);
+ paramConfig.setValue(paramValue);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/RuleLaunchTab.java b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/RuleLaunchTab.java
index 6ff9282..e6d23a1 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/RuleLaunchTab.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter.ui/src/org/eclipse/emf/henshin/interpreter/ui/debug/RuleLaunchTab.java
@@ -1,160 +1,160 @@
-package org.eclipse.emf.henshin.interpreter.ui.debug;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.henshin.interpreter.ui.util.ParameterConfig;
-import org.eclipse.emf.henshin.model.Module;
-import org.eclipse.emf.henshin.model.Rule;
-import org.eclipse.emf.henshin.model.Unit;
-import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;
-import org.eclipse.swt.widgets.Composite;
-
-public class RuleLaunchTab extends AbstractLaunchConfigurationTab {
-
- LaunchRuleControl ruleControl;
-
- @Override
- public void createControl(Composite parent) {
- ruleControl = new LaunchRuleControl();
- setControl(ruleControl.createControl(parent, this));
- }
-
- @Override
- protected void updateLaunchConfigurationDialog() {
- super.updateLaunchConfigurationDialog();
- }
-
- @Override
- public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
-
- }
-
- @Override
- public void initializeFrom(ILaunchConfiguration configuration) {
- try {
- String modulePath = configuration.getAttribute(IHenshinConfigConstants.MODULE_PATH, "");
- String inputUri = configuration.getAttribute(IHenshinConfigConstants.INPUT_URI, "");
- String outputUri = configuration.getAttribute(IHenshinConfigConstants.OUTPUT_URI, "");
- String unitName = configuration.getAttribute(IHenshinConfigConstants.UNIT_NAME, "");
- int unitIndex = configuration.getAttribute(IHenshinConfigConstants.UNIT_INDEX, -1);
- boolean openCompare = configuration.getAttribute(IHenshinConfigConstants.OPEN_COMPARE, true);
-
- Map<String, String> paramTypes = configuration.getAttribute(
- IHenshinConfigConstants.PARAMETER_TYPES, new HashMap<String, String>());
- Map<String, String> paramValues = configuration.getAttribute(
- IHenshinConfigConstants.PARAMETER_VALUES, new HashMap<String, String>());
- List<String> unsetParams = configuration.getAttribute(
- IHenshinConfigConstants.UNSET_PARAMETERS, new ArrayList<String>());
-
- ruleControl.moduleSelector.setModelURI(modulePath);
- ruleControl.inputSelector.setModelURI(inputUri);
- ruleControl.outputSelector.setModelURI(outputUri);
- ruleControl.unitSelector.setSelection(unitIndex);
- ruleControl.openCompare.setSelection(openCompare);
-
- if (!(modulePath.isEmpty() || unitName.isEmpty() || paramTypes.isEmpty() || paramValues.isEmpty())) {
- // first get the "default" ParameterConfigs of the unit (name, kind, default type)
- HenshinResourceSet resourceSet = new HenshinResourceSet();
- URI uri = URI.createURI(modulePath);
- Module module = resourceSet.getModule(uri, false);
- Unit unit = module.getUnit(unitName);
- List<ParameterConfig> paramConfigs = ParamUtil.getParameterPreferences(unit);
-
- ruleControl.transformOperation.setUnit(unit, paramConfigs);
-
- // fill the parameterConfigs with the types and values
- ParamUtil.fillParamConfigs(ruleControl.transformOperation.getParameterConfigurations(), paramTypes, paramValues, unsetParams);
-
- // show the parameters in the editor
- ruleControl.parameterEditor.setParameters(ruleControl.transformOperation.getParameterConfigurations());
- }
-
- } catch (CoreException e) {
- e.printStackTrace();
- }
-
- }
-
- @Override
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(IHenshinConfigConstants.MODULE_PATH,
- ruleControl.moduleSelector.getModelURI());
- configuration.setAttribute(IHenshinConfigConstants.INPUT_URI,
- ruleControl.inputSelector.getModelURI());
- configuration.setAttribute(IHenshinConfigConstants.OUTPUT_URI,
- ruleControl.outputSelector.getModelURI());
- if (ruleControl.transformOperation.getUnit() != null) {
- configuration.setAttribute(IHenshinConfigConstants.UNIT_NAME,
- ruleControl.transformOperation.getUnit().getName());
- configuration.setAttribute(IHenshinConfigConstants.UNIT_INDEX,
- ruleControl.unitSelector.getUnitSelector().getSelectionIndex());
- }
- configuration.setAttribute(IHenshinConfigConstants.OPEN_COMPARE,
- ruleControl.openCompare.getSelection());
-
- // when creating a new configuration
- if (ruleControl.transformOperation.getParameterConfigurations() == null) return;
-
- Map<String, String> paramTypes = new HashMap<String, String>();
- Map<String, String> paramValues = new HashMap<String, String>();
- List<String> unsetParams = new ArrayList<String>();
-
-
- for (ParameterConfig paramCfg : ruleControl.transformOperation.getParameterConfigurations()) {
- // type and value maps have the parameter names as keys
- paramTypes.put(paramCfg.getName(), String.valueOf(paramCfg.getType()));
- paramValues.put(paramCfg.getName(), String.valueOf(paramCfg.getValue()));
- if (paramCfg.isUnset()) {
- unsetParams.add(paramCfg.getName());
- }
- }
-
- configuration.setAttribute(IHenshinConfigConstants.PARAMETER_TYPES, paramTypes);
- configuration.setAttribute(IHenshinConfigConstants.PARAMETER_VALUES, paramValues);
- configuration.setAttribute(IHenshinConfigConstants.UNSET_PARAMETERS, unsetParams);
- }
-
- @Override
- public boolean isValid(ILaunchConfiguration launchConfig) {
- setErrorMessage(null);
- String modulePath = ruleControl.moduleSelector.getModelURI();
-
- if (modulePath.isEmpty()) {
- setErrorMessage("You must choose a module");
- return false;
- }
- if (ruleControl.unitSelector.getUnitSelector().getSelectionIndex() == -1
- || ruleControl.transformOperation.getUnit() == null) {
- setErrorMessage("You must choose a unit");
- return false;
- }
- // check if the unit is a rule
- if (!(ruleControl.transformOperation.getUnit() instanceof Rule)) {
- setErrorMessage("Selected unit must be a rule");
- }
-
- if (ruleControl.inputSelector.getModelURI().isEmpty()) {
- setErrorMessage("You must choose an input URI");
- return false;
- }
- if (ruleControl.outputSelector.getModelURI().isEmpty()) {
- setErrorMessage("You must choose an output URI");
- return false;
- }
- return true;
- }
-
- @Override
- public String getName() {
- return "Henshin rule launch tab";
- }
-
-}
+package org.eclipse.emf.henshin.interpreter.ui.debug;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.henshin.interpreter.ui.util.ParameterConfig;
+import org.eclipse.emf.henshin.model.Module;
+import org.eclipse.emf.henshin.model.Rule;
+import org.eclipse.emf.henshin.model.Unit;
+import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;
+import org.eclipse.swt.widgets.Composite;
+
+public class RuleLaunchTab extends AbstractLaunchConfigurationTab {
+
+ LaunchRuleControl ruleControl;
+
+ @Override
+ public void createControl(Composite parent) {
+ ruleControl = new LaunchRuleControl();
+ setControl(ruleControl.createControl(parent, this));
+ }
+
+ @Override
+ protected void updateLaunchConfigurationDialog() {
+ super.updateLaunchConfigurationDialog();
+ }
+
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ String modulePath = configuration.getAttribute(IHenshinConfigConstants.MODULE_PATH, "");
+ String inputUri = configuration.getAttribute(IHenshinConfigConstants.INPUT_URI, "");
+ String outputUri = configuration.getAttribute(IHenshinConfigConstants.OUTPUT_URI, "");
+ String unitName = configuration.getAttribute(IHenshinConfigConstants.UNIT_NAME, "");
+ int unitIndex = configuration.getAttribute(IHenshinConfigConstants.UNIT_INDEX, -1);
+ boolean openCompare = configuration.getAttribute(IHenshinConfigConstants.OPEN_COMPARE, true);
+
+ Map<String, String> paramTypes = configuration.getAttribute(
+ IHenshinConfigConstants.PARAMETER_TYPES, new HashMap<String, String>());
+ Map<String, String> paramValues = configuration.getAttribute(
+ IHenshinConfigConstants.PARAMETER_VALUES, new HashMap<String, String>());
+ List<String> unsetParams = configuration.getAttribute(
+ IHenshinConfigConstants.UNSET_PARAMETERS, new ArrayList<String>());
+
+ ruleControl.moduleSelector.setModelURI(modulePath);
+ ruleControl.inputSelector.setModelURI(inputUri);
+ ruleControl.outputSelector.setModelURI(outputUri);
+ ruleControl.unitSelector.setSelection(unitIndex);
+ ruleControl.openCompare.setSelection(openCompare);
+
+ if (!(modulePath.isEmpty() || unitName.isEmpty() || paramTypes.isEmpty() || paramValues.isEmpty())) {
+ // first get the "default" ParameterConfigs of the unit (name, kind, default type)
+ HenshinResourceSet resourceSet = new HenshinResourceSet();
+ URI uri = URI.createURI(modulePath);
+ Module module = resourceSet.getModule(uri, false);
+ Unit unit = module.getUnit(unitName);
+ List<ParameterConfig> paramConfigs = ParamUtil.getParameterPreferences(unit);
+
+ ruleControl.transformOperation.setUnit(unit, paramConfigs);
+
+ // fill the parameterConfigs with the types and values
+ ParamUtil.fillParamConfigs(ruleControl.transformOperation.getParameterConfigurations(), paramTypes, paramValues, unsetParams);
+
+ // show the parameters in the editor
+ ruleControl.parameterEditor.setParameters(ruleControl.transformOperation.getParameterConfigurations());
+ }
+
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(IHenshinConfigConstants.MODULE_PATH,
+ ruleControl.moduleSelector.getModelURI());
+ configuration.setAttribute(IHenshinConfigConstants.INPUT_URI,
+ ruleControl.inputSelector.getModelURI());
+ configuration.setAttribute(IHenshinConfigConstants.OUTPUT_URI,
+ ruleControl.outputSelector.getModelURI());
+ if (ruleControl.transformOperation.getUnit() != null) {
+ configuration.setAttribute(IHenshinConfigConstants.UNIT_NAME,
+ ruleControl.transformOperation.getUnit().getName());
+ configuration.setAttribute(IHenshinConfigConstants.UNIT_INDEX,
+ ruleControl.unitSelector.getUnitSelector().getSelectionIndex());
+ }
+ configuration.setAttribute(IHenshinConfigConstants.OPEN_COMPARE,
+ ruleControl.openCompare.getSelection());
+
+ // when creating a new configuration
+ if (ruleControl.transformOperation.getParameterConfigurations() == null) return;
+
+ Map<String, String> paramTypes = new HashMap<String, String>();
+ Map<String, String> paramValues = new HashMap<String, String>();
+ List<String> unsetParams = new ArrayList<String>();
+
+
+ for (ParameterConfig paramCfg : ruleControl.transformOperation.getParameterConfigurations()) {
+ // type and value maps have the parameter names as keys
+ paramTypes.put(paramCfg.getName(), String.valueOf(paramCfg.getType()));
+ paramValues.put(paramCfg.getName(), String.valueOf(paramCfg.getValue()));
+ if (paramCfg.isUnset()) {
+ unsetParams.add(paramCfg.getName());
+ }
+ }
+
+ configuration.setAttribute(IHenshinConfigConstants.PARAMETER_TYPES, paramTypes);
+ configuration.setAttribute(IHenshinConfigConstants.PARAMETER_VALUES, paramValues);
+ configuration.setAttribute(IHenshinConfigConstants.UNSET_PARAMETERS, unsetParams);
+ }
+
+ @Override
+ public boolean isValid(ILaunchConfiguration launchConfig) {
+ setErrorMessage(null);
+ String modulePath = ruleControl.moduleSelector.getModelURI();
+
+ if (modulePath.isEmpty()) {
+ setErrorMessage("You must choose a module");
+ return false;
+ }
+ if (ruleControl.unitSelector.getUnitSelector().getSelectionIndex() == -1
+ || ruleControl.transformOperation.getUnit() == null) {
+ setErrorMessage("You must choose a unit");
+ return false;
+ }
+ // check if the unit is a rule
+ if (!(ruleControl.transformOperation.getUnit() instanceof Rule)) {
+ setErrorMessage("Selected unit must be a rule");
+ }
+
+ if (ruleControl.inputSelector.getModelURI().isEmpty()) {
+ setErrorMessage("You must choose an input URI");
+ return false;
+ }
+ if (ruleControl.outputSelector.getModelURI().isEmpty()) {
+ setErrorMessage("You must choose an output URI");
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String getName() {
+ return "Henshin rule launch tab";
+ }
+
+}