Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortarendt2012-11-22 09:49:11 -0500
committertarendt2012-11-22 09:49:11 -0500
commit8a99f52380dc8ab39bafa9f148c6809436bac8a6 (patch)
treec515f2687e077e48b17bbc05fbdf74aca6c3d3ed
parentbac11a91c4dfa34966a13838ab58dded23b6591b (diff)
downloadorg.eclipse.emf.refactor.refactoring-8a99f52380dc8ab39bafa9f148c6809436bac8a6.tar.gz
org.eclipse.emf.refactor.refactoring-8a99f52380dc8ab39bafa9f148c6809436bac8a6.tar.xz
org.eclipse.emf.refactor.refactoring-8a99f52380dc8ab39bafa9f148c6809436bac8a6.zip
wizard pages added
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF7
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/build.properties3
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/plugin.xml15
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/HenshinTransformationWizardPage.java320
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/NewRefactoringWizardHenshin.java102
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/ParameterWizardPage.java286
6 files changed, 729 insertions, 4 deletions
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF b/org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF
index a71c687..758ca21 100644
--- a/org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF
+++ b/org.eclipse.emf.refactor.refactoring.henshin/META-INF/MANIFEST.MF
@@ -6,11 +6,12 @@ Bundle-Version: 0.7.0.qualifier
Bundle-Activator: org.eclipse.emf.refactor.refactoring.henshin.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
+ org.eclipse.core.resources;bundle-version="3.8.1",
+ org.eclipse.emf.edit;bundle-version="2.8.0",
+ org.eclipse.emf.henshin.interpreter;bundle-version="0.9.4",
org.eclipse.emf.refactor.refactoring;bundle-version="0.7.0",
org.eclipse.emf.refactor.refactoring.generator;bundle-version="0.7.0",
org.eclipse.emf.refactor.refactoring.runtime;bundle-version="0.7.0",
- org.eclipse.emf.henshin.interpreter;bundle-version="0.9.4",
- org.eclipse.ltk.core.refactoring;bundle-version="3.6.0",
- org.eclipse.emf.edit;bundle-version="2.8.0"
+ org.eclipse.ltk.core.refactoring;bundle-version="3.6.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/build.properties b/org.eclipse.emf.refactor.refactoring.henshin/build.properties
index 34d2e4d..e9863e2 100644
--- a/org.eclipse.emf.refactor.refactoring.henshin/build.properties
+++ b/org.eclipse.emf.refactor.refactoring.henshin/build.properties
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/plugin.xml b/org.eclipse.emf.refactor.refactoring.henshin/plugin.xml
new file mode 100644
index 0000000..db3961b
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/plugin.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ category="org.eclipse.emf.refactor.newwizards.category"
+ class="org.eclipse.emf.refactor.refactoring.henshin.ui.NewRefactoringWizardHenshin"
+ icon="icons/refactoring.png"
+ id="org.eclipse.emf.refactor.refactoring.newwizard"
+ name="Refactoring (specified in Henshin)">
+ </wizard>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/HenshinTransformationWizardPage.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/HenshinTransformationWizardPage.java
new file mode 100644
index 0000000..fe44669
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/HenshinTransformationWizardPage.java
@@ -0,0 +1,320 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.henshin.ui;
+
+import java.io.File;
+import java.io.FileFilter;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.refactor.refactoring.henshin.generator.HenshinRefactoringInfo;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+
+/**
+ * Wizard page for specifying Henshin files used for initial checking,
+ * final checking, and executing the EMF model refactoring.
+ * @generated NOT
+ * @author Thorsten Arendt
+ */
+public class HenshinTransformationWizardPage extends WizardPage implements Listener {
+
+ private Combo transformationCombo;
+ private Combo checkInitialCombo;
+ private Combo checkFinalCombo;
+
+ /**
+ * Wizard that owns the WizardPage.
+ */
+ private NewRefactoringWizardHenshin wizard;
+
+ /**
+ * Name of the project the model refactoring code has to be
+ * generated to.
+ */
+ private String projectName = "";
+
+ /**
+ * List of Henshin files contained in the 'transformation' folder
+ * of the project with name 'projectName'.
+ */
+ private File[] henshinFiles;
+
+ /**
+ * Name of the Henshin file used for executing the EMF model
+ * refactoring.
+ */
+ private String transformationFileName = "";
+
+ /**
+ * Name of the Henshin file used for the initial checking
+ * of the EMF model refactoring.
+ */
+ private String checkInitialFileName = "";
+
+ /**
+ * Name of the Henshin file used for the final checking
+ * of the EMF model refactoring.
+ */
+ private String checkFinalFileName = "";
+
+ /**
+ * Default constructor.
+ * @param pageName Name of the wizard page.
+ * @param newRefactoringWizardHenshin Wizard that owns the WizardPage.
+ */
+ protected HenshinTransformationWizardPage
+ (String pageName, NewRefactoringWizardHenshin newRefactoringWizardHenshin) {
+ super(pageName);
+ this.wizard = newRefactoringWizardHenshin;
+ this.henshinFiles = new File[0];
+ }
+
+ /**
+ * Sets the name of the project the model refactoring code has to be
+ * generated to and sets the combos according to the project name.
+ * @param projectName
+ */
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ setHenshinFiles();
+ setCombos();
+ checkIsPageComplete();
+ }
+
+ /**
+ * Sets the name of the Henshin file used for executing the EMF model
+ * refactoring and redirects it to the owning wizard.
+ * @param transformationFileName Name of the Henshin file used for
+ * executing the EMF model refactoring.
+ */
+ private void setTransformationFileName(String transformationFileName) {
+ this.transformationFileName = transformationFileName;
+ this.wizard.setTransformationFileName(transformationFileName);
+ }
+
+ /**
+ * Gets the name of the Henshin file used for executing the EMF model
+ * refactoring.
+ * @return Name of the Henshin file used for executing the EMF model
+ * refactoring.
+ */
+ public String getTransformationFileName() {
+ return transformationFileName;
+ }
+
+ /**
+ * Sets the name of the Henshin file used for the initial checking
+ * of the EMF model refactoring.
+ * @param checkInitialFileName Name of the Henshin file used for the
+ * initial checking of the EMF model refactoring.
+ */
+ private void setCheckInitialFileName(String checkInitialFileName) {
+ this.checkInitialFileName = checkInitialFileName;
+ }
+
+ /**
+ * Gets the name of the Henshin file used for the initial checking
+ * of the EMF model refactoring.
+ * @return Name of the Henshin file used for the initial checking
+ * of the EMF model refactoring.
+ */
+ public String getCheckInitialFileName() {
+ return checkInitialFileName;
+ }
+
+ /**
+ * Sets the name of the Henshin file used for the final checking
+ * of the EMF model refactoring.
+ * @param checkFinalFileName Name of the Henshin file used for the
+ * final checking of the EMF model refactoring.
+ */
+ private void setCheckFinalFileName(String checkFinalFileName) {
+ this.checkFinalFileName = checkFinalFileName;
+ }
+
+ /**
+ * Gets the name of the Henshin file used for the final checking
+ * of the EMF model refactoring.
+ * @return Name of the Henshin file used for the final checking
+ * of the EMF model refactoring.
+ */
+ public String getCheckFinalFileName() {
+ return checkFinalFileName;
+ }
+
+ /**
+ * Sets the list of Henshin files contained in the 'transformation'
+ * folder of the project with name 'projectName'.
+ */
+ private void setHenshinFiles() {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(this.projectName);
+ String path = project.getLocationURI().getPath()
+ + HenshinRefactoringInfo.TRAFODIR;
+ File file = new File(path);
+ FileFilter ff = new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.getName().endsWith(".henshin")){
+ return true;
+ } else {
+ return false;
+ }
+ }
+ };
+ this.henshinFiles = file.listFiles(ff);
+ }
+
+ /**
+ * Sets the combos according to the project name.
+ */
+ private void setCombos() {
+ transformationCombo.removeAll();
+ checkInitialCombo.removeAll();
+ checkFinalCombo.removeAll();
+ if (this.henshinFiles != null){
+ for (File file : henshinFiles){
+ transformationCombo.add(file.getName());
+ checkInitialCombo.add(file.getName());
+ checkFinalCombo.add(file.getName());
+ }
+ }
+ }
+
+ /**
+ * Checks whether the edited data are complete and sets
+ * the corresponding message to the top of the wizard page.
+ */
+ private void checkIsPageComplete() {
+ if (henshinFiles == null){
+ setMessage("The target project '" + projectName +
+ "' does not contain a folder '" +
+ HenshinRefactoringInfo.TRAFODIR + "'.", SWT.ERROR);
+ setPageComplete(false);
+ } else {
+ if (henshinFiles.length == 0){
+ setMessage("There is no henshin transformation file in " +
+ "folder '" + HenshinRefactoringInfo.TRAFODIR +
+ "' of project '" + projectName + "'.", SWT.ERROR);
+ setPageComplete(false);
+ } else {
+ if (transformationCombo.getSelectionIndex() == -1){
+ setMessage("Please select a henshin transformation " +
+ "file (execute).", SWT.ERROR);
+ setPageComplete(false);
+ } else {
+ if (checkInitialCombo.getSelectionIndex() == -1){
+ setMessage("Please select a henshin transformation " +
+ "file (check initial).", SWT.ERROR);
+ } else {
+ if (checkFinalCombo.getSelectionIndex() == -1){
+ setMessage("Please select a henshin " +
+ "transformation file (check final).",
+ SWT.ERROR);
+ } else {
+ setMessage("", SWT.NONE);
+ }
+ }
+ setPageComplete(true);
+ }
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.IDialogPage#
+ * createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.spacing = 5;
+ fillLayout.type = SWT.VERTICAL;
+ composite.setLayout(fillLayout);
+ GridLayout gl = new GridLayout();
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gl.numColumns = 2;
+ Composite transformationComposite =
+ new Composite(composite, SWT.BORDER);
+ transformationComposite.setLayout(gl);
+ Label textTransformationLabel =
+ new Label(transformationComposite, SWT.NONE);
+ textTransformationLabel
+ .setText("Model transformation file name (execute): ");
+ transformationCombo =
+ new Combo (transformationComposite, SWT.READ_ONLY);
+ transformationCombo.setLayoutData(gd);
+ transformationCombo.addListener(SWT.Selection, this);
+ Composite checkInitialComposite =
+ new Composite(composite, SWT.BORDER);
+ checkInitialComposite.setLayout(gl);
+ Label textCheckInitialLabel =
+ new Label(checkInitialComposite, SWT.NONE);
+ textCheckInitialLabel
+ .setText("Model transformation file name (check initial): ");
+ checkInitialCombo = new Combo (checkInitialComposite, SWT.READ_ONLY);
+ checkInitialCombo.setLayoutData(gd);
+ checkInitialCombo.addListener(SWT.Selection, this);
+ Composite checkFinalComposite = new Composite(composite, SWT.BORDER);
+ checkFinalComposite.setLayout(gl);
+ Label textCheckFinalLabel = new Label(checkFinalComposite, SWT.NONE);
+ textCheckFinalLabel
+ .setText("Model transformation file name (check final): ");
+ checkFinalCombo = new Combo (checkFinalComposite, SWT.READ_ONLY);
+ checkFinalCombo.setLayoutData(gd);
+ checkFinalCombo.addListener(SWT.Selection, this);
+ setControl(composite);
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Listener#
+ * handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
+ public void handleEvent(Event event) {
+ if (event.widget == transformationCombo){
+ int index = transformationCombo.getSelectionIndex();
+ if (index == -1){
+ setTransformationFileName("");
+ } else {
+ setTransformationFileName(transformationCombo.getItem(index));
+ }
+ }
+ if (event.widget == checkInitialCombo){
+ int index = checkInitialCombo.getSelectionIndex();
+ if (index == -1){
+ setCheckInitialFileName("");
+ } else {
+ setCheckInitialFileName(checkInitialCombo.getItem(index));
+ }
+ }
+ if (event.widget == checkFinalCombo){
+ int index = checkFinalCombo.getSelectionIndex();
+ if (index == -1){
+ setCheckFinalFileName("");
+ } else {
+ setCheckFinalFileName(checkFinalCombo.getItem(index));
+ }
+ }
+ checkIsPageComplete();
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/NewRefactoringWizardHenshin.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/NewRefactoringWizardHenshin.java
new file mode 100644
index 0000000..0b93bc7
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/NewRefactoringWizardHenshin.java
@@ -0,0 +1,102 @@
+package org.eclipse.emf.refactor.refactoring.henshin.ui;
+
+import java.util.LinkedList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.refactor.refactoring.generator.interfaces.INewRefactoringWizard;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+public class NewRefactoringWizardHenshin extends Wizard implements INewWizard, INewRefactoringWizard {
+
+ public NewRefactoringWizardHenshin() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean performFinish() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public LinkedList<IProject> getProjects() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getPageNumbers() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void updateSecondPage() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public WizardPage getSecondPage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setTargetProject(String text) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setName(String text) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setId(String text) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setMetamodel(String text) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setContext(String text) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setJar(String jar) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setImportPackage(String importPackage) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setTransformationFileName(String transformationFileName) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/ParameterWizardPage.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/ParameterWizardPage.java
new file mode 100644
index 0000000..a69d15a
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/ui/ParameterWizardPage.java
@@ -0,0 +1,286 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.henshin.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.henshin.model.Module;
+import org.eclipse.emf.henshin.model.Parameter;
+import org.eclipse.emf.henshin.model.Unit;
+import org.eclipse.emf.refactor.refactoring.generator.core.ParameterInfo;
+import org.eclipse.emf.refactor.refactoring.henshin.generator.HenshinRefactoringInfo;
+import org.eclipse.emf.refactor.refactoring.henshin.managers.HenshinFileManager;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * WizardPage for selecting refactoring parameters out of those from the
+ * main transformation unit of the specified Henshin transformation file.
+ * @generated NOT
+ * @author Thorsten Arendt
+ */
+public class ParameterWizardPage extends WizardPage implements Listener {
+
+ private Table parameterTable;
+
+ private static final String MAINUNIT = "mainUnit";
+ private static final String SELECTEDEOBJECT = "selectedEObject";
+
+ /**
+ * Name of the project the model refactoring code has to be
+ * generated to.
+ */
+ private String projectName;
+
+ /**
+ * Name of the Henshin file used for executing the EMF model
+ * refactoring.
+ */
+ private String transformationFileName;
+
+ /**
+ * Henshin Module loaded from the specified file name.
+ */
+ private Module module;
+
+ /**
+ * List of all parameters existing in the main transformation unit
+ * of the specified Henshin transformation file.
+ */
+ private List<ParameterInfo> mainUnitParameters;
+
+ /**
+ * List of selected refactoring parameters out of those from the main
+ * transformation unit of the specified Henshin transformation file.
+ */
+ private List<ParameterInfo> selectedParameters;
+
+ /**
+ * Default constructor.
+ * @param pageName Name of the wizard page.
+ */
+ protected ParameterWizardPage(String pageName) {
+ super(pageName);
+ mainUnitParameters = new ArrayList<ParameterInfo>();
+ selectedParameters = new ArrayList<ParameterInfo>();
+ }
+
+ /**
+ * Gets the list of selected refactoring parameters out of those
+ * from the main transformation unit of the specified Henshin
+ * transformation file.
+ * @return List of selected refactoring parameters out of those from
+ * the main transformation unit of the specified Henshin
+ * transformation file.
+ */
+ public List<ParameterInfo> getSelectedParameters() {
+ return selectedParameters;
+ }
+
+ /**
+ * Sets the name of the Henshin file used for executing the EMF model
+ * refactoring.
+ * @param transformationFileName Name of the Henshin file used for
+ * executing the EMF model refactoring.
+ */
+ public void setTransformationFileName(String transformationFileName) {
+ this.transformationFileName = transformationFileName;
+ this.mainUnitParameters.clear();
+ this.parameterTable.removeAll();
+ this.selectedParameters.clear();
+ setMainUnitParameters();
+ fillParameterTable();
+ checkIsPageComplete();
+ }
+
+ /**
+ * Gets the name of the Henshin file used for executing the EMF model
+ * refactoring.
+ * @return Name of the Henshin file used for executing the EMF model
+ * refactoring.
+ */
+ public String getTransformationFileName() {
+ return transformationFileName;
+ }
+
+ /**
+ * Sets the name of the project the model refactoring code has to be
+ * generated to.
+ * @param projectName Name of the project the model refactoring code
+ * has to be generated to.
+ */
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ /**
+ * Gets the name of the project the model refactoring code has to be
+ * generated to.
+ * @return Name of the project the model refactoring code has to be
+ * generated to.
+ */
+ public String getProjectName() {
+ return projectName;
+ }
+
+ /**
+ * Sets the list of all parameters existing in the main transformation
+ * unit of the specified Henshin transformation file.
+ */
+ private void setMainUnitParameters() {
+ setTransformationSystem();
+ if (null != this.module){
+ Unit mainUnit =
+ this.module.getUnit(MAINUNIT);
+ if (mainUnit != null){
+ for (Parameter parameter : mainUnit.getParameters()){
+ if (parameter.getName().equals(SELECTEDEOBJECT)){
+ continue;
+ }
+ ParameterInfo pi =
+ new ParameterInfo(parameter.getName());
+ pi.setDescription(parameter.getDescription());
+ this.mainUnitParameters.add(pi);
+ }
+ }
+ }
+ }
+
+ /**
+ * Sets the Henshin TransformationSystem loaded from the specified
+ * file name.
+ */
+ private void setTransformationSystem() {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(this.projectName);
+ String path = project.getLocationURI().getPath()
+ + HenshinRefactoringInfo.TRAFODIR
+ + this.transformationFileName;
+ this.module = (Module) HenshinFileManager.loadFile(path);
+ }
+
+ /**
+ * Fills the table with parameter data from the main transformation
+ * unit of the specified Henshin transformation file.
+ */
+ private void fillParameterTable() {
+ for (ParameterInfo pi : this.mainUnitParameters){
+ TableItem item = new TableItem (this.parameterTable, SWT.NONE);
+ item.setText (1, pi.getName());
+ item.setText (2, pi.getDescription());
+ item.setChecked(true);
+ selectedParameters.add(pi);
+ }
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.IDialogPage#
+ * createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.spacing = 5;
+ fillLayout.type = SWT.VERTICAL;
+ composite.setLayout(fillLayout);
+ setMessage("Please select the refactoring parameters " +
+ "out of those from the main unit of the " +
+ "selected henshin transformation (execute).");
+ parameterTable = new Table(composite,
+ SWT.CHECK | SWT.SINGLE | SWT.FULL_SELECTION
+ | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ parameterTable.setHeaderVisible(true);
+ parameterTable.addListener(SWT.Selection, this);
+ TableColumn col;
+ col = new TableColumn(parameterTable, SWT.LEFT | SWT.READ_ONLY);
+ col.setText("sel");
+ col.setWidth(30);
+ col = new TableColumn(parameterTable, SWT.LEFT | SWT.READ_ONLY);
+ col.setText("Parameter name");
+ col.setWidth(200);
+ col = new TableColumn(parameterTable, SWT.LEFT | SWT.READ_ONLY);
+ col.setText("Parameter description");
+ col.setWidth(200);
+ setControl(composite);
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Listener#
+ * handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
+ public void handleEvent(Event event) {
+ if (event.widget == parameterTable){
+ this.selectedParameters.clear();
+ for (TableItem tableItem : parameterTable.getItems()){
+ if (tableItem.getChecked()){
+ ParameterInfo pC =
+ new ParameterInfo(tableItem.getText(1));
+ pC.setDescription(tableItem.getText(2));
+ selectedParameters.add(pC);
+ }
+ }
+ checkIsPageComplete();
+ }
+ }
+
+ /**
+ * Checks whether the edited data are complete and sets
+ * the corresponding message to the top of the wizard page.
+ */
+ private void checkIsPageComplete() {
+ setTransformationSystem();
+ if (this.module == null){
+ setMessage("Cannot load henshin transformation system.",
+ SWT.ERROR);
+ setPageComplete(false);
+ return;
+ }
+ Unit mainUnit = this.module.getUnit(MAINUNIT);
+ if (mainUnit == null){
+ setMessage("There is no transformation unit in '" +
+ this.transformationFileName + "' named '" +
+ MAINUNIT + "'", SWT.ERROR);
+ setPageComplete(false);
+ return;
+ }
+ boolean selectedEObjectParameterExists = false;
+ for (Parameter parameter : mainUnit.getParameters()){
+ if (parameter.getName().equals(SELECTEDEOBJECT)){
+ selectedEObjectParameterExists = true;
+ break;
+ }
+ }
+ if (!selectedEObjectParameterExists){
+ setMessage("There is no parameter in unit '" +
+ MAINUNIT + "' named '" + SELECTEDEOBJECT + "'",
+ SWT.ERROR);
+ setPageComplete(false);
+ return;
+ }
+ setMessage("Please select the refactoring parameters " +
+ "out of those from the main unit of the " +
+ "selected henshin transformation (execute).");
+ }
+
+}

Back to the top