classes for composite metrics added resp. changed
diff --git a/org.eclipse.emf.refactor.metrics.generator/plugin.xml b/org.eclipse.emf.refactor.metrics.generator/plugin.xml
index 87fd550..bdbc9c5 100644
--- a/org.eclipse.emf.refactor.metrics.generator/plugin.xml
+++ b/org.eclipse.emf.refactor.metrics.generator/plugin.xml
@@ -10,5 +10,12 @@
id="org.eclipse.emf.refactor.metrics.newwizard"
name="Metric (specified in Java)">
</wizard>
+ <wizard
+ category="org.eclipse.emf.refactor.newwizards.category"
+ class="org.eclipse.emf.refactor.metrics.generator.NewMetricWizardComposite"
+ icon="icons/newmetric.PNG"
+ id="org.eclipse.emf.refactor.metrics.newwizard"
+ name="Metric (compositional)">
+ </wizard>
</extension>
</plugin>
diff --git a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/CompositeDataWizardPage.java b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/CompositeDataWizardPage.java
new file mode 100644
index 0000000..b5f6ee6
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/CompositeDataWizardPage.java
@@ -0,0 +1,250 @@
+package org.eclipse.emf.refactor.metrics.generator;
+
+import java.util.LinkedList;
+
+import org.eclipse.emf.refactor.metrics.core.Metric;
+import org.eclipse.emf.refactor.metrics.managers.MetricManager;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.Group;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class CompositeDataWizardPage extends WizardPage {
+
+ private static final String PAGE_NAME = "org.eclipse.emf.refactor.metrics.CompositeDataWizardPage";
+ private static final String TITLE = "New Metric: Composite Data";
+ private static final String DESCRIPTION = "Please specify two input metrics and a join operation " +
+ "for the new metric. Required fields are denoted by \"(*)\".";
+ private TableViewer viewer;
+ private Table firstMetricTable, secondMetricTable;
+ private TableItemsMapping firstTableMapping, secondTableMapping;
+ private Combo operationCombo;
+ private Metric firstMetric = null, secondMetric = null;
+ private String operation;
+
+ public Metric getFirstMetric() {
+ return firstMetric;
+ }
+
+ public Metric getSecondMetric() {
+ return secondMetric;
+ }
+
+ public CompositeDataWizardPage() {
+ super(PAGE_NAME);
+ setTitle(TITLE);
+ setDescription(DESCRIPTION);
+ }
+
+ protected String getOperationName(){
+ return operation;
+ }
+
+ @Override
+ public IWizardPage getNextPage() {
+ return null;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ MetricManager.getInstance();
+ firstTableMapping = new TableItemsMapping(MetricManager.getAllMetrics());
+ secondTableMapping = new TableItemsMapping(MetricManager.getAllMetrics());
+ Composite container = new Composite(parent, SWT.NULL);
+ final GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ container.setLayout(layout);
+ setControl(container);
+ createContent(container);
+ fillTables();
+ fillOperationNames();
+ this.setPageComplete(false);
+ }
+
+ private void createContent(Composite container) {
+ TableColumn col;
+ GridData gridData;
+ Group group;
+ GridLayout layout;
+ // - First Metric -
+ group = new Group(container, SWT.NONE);
+ group.setText("First metric");
+ layout = new GridLayout();
+ layout.numColumns = 1;
+ group.setLayout(layout);
+ gridData = new GridData(GridData.FILL_BOTH);
+ gridData.horizontalSpan = 2;
+ group.setLayoutData(gridData);
+ firstMetricTable = new Table(group, SWT.CHECK | SWT.SINGLE
+ | SWT.BORDER | SWT.V_SCROLL);
+ firstMetricTable.setHeaderVisible(true);
+ firstMetricTable.addSelectionListener(new MetricTableSelectionListener(
+ firstMetricTable));
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.heightHint = 100;
+ gridData.widthHint = 400;
+ firstMetricTable.setLayoutData(gridData);
+ col = new TableColumn(firstMetricTable, SWT.CENTER | SWT.READ_ONLY);
+ col.setText("Selected");
+ col.setWidth(60);
+ col = new TableColumn(firstMetricTable, SWT.LEFT | SWT.READ_ONLY);
+ col.setText("Name");
+ col.setWidth(100);
+ col = new TableColumn(firstMetricTable, SWT.LEFT | SWT.READ_ONLY);
+ col.setText("Description");
+ col.setWidth(200);
+
+ // - Operation -
+ group = new Group(container, SWT.NONE);
+ group.setText("Operation");
+ layout = new GridLayout();
+ layout.numColumns = 1;
+ group.setLayout(layout);
+ gridData = new GridData(GridData.FILL_BOTH);
+ gridData.horizontalSpan = 2;
+ group.setLayoutData(gridData);
+ operationCombo = new Combo(group, SWT.READ_ONLY);
+ operationCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ operationCombo.setText("Select operation");
+ operationCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setOperationName(((Combo)e.getSource()).getText());
+ updatePageComplete();
+ }
+ });
+
+ // - Second Metric -
+ group = new Group(container, SWT.NONE);
+ group.setText("Second metric");
+ layout = new GridLayout();
+ layout.numColumns = 1;
+ group.setLayout(layout);
+ gridData = new GridData(GridData.FILL_BOTH);
+ gridData.horizontalSpan = 2;
+ group.setLayoutData(gridData);
+ viewer = new TableViewer(group, SWT.CHECK | SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL);
+ secondMetricTable = viewer.getTable();
+ secondMetricTable.setHeaderVisible(true);
+ secondMetricTable.addSelectionListener(new MetricTableSelectionListener(
+ secondMetricTable));
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.heightHint = 100;
+ gridData.widthHint = 400;
+ secondMetricTable.setLayoutData(gridData);
+ col = new TableColumn(secondMetricTable, SWT.CENTER | SWT.READ_ONLY);
+ col.setText("Selected");
+ col.setWidth(60);
+ col = new TableColumn(secondMetricTable, SWT.LEFT | SWT.READ_ONLY);
+ col.setText("Name");
+ col.setWidth(100);
+ col = new TableColumn(secondMetricTable, SWT.LEFT | SWT.READ_ONLY);
+ col.setText("Description");
+ col.setWidth(200);
+ }
+
+ protected void fillTables(){
+ String metamodel = ((NewMetricWizardComposite)getWizard()).getMetamodel();
+ String context = ((NewMetricWizardComposite)getWizard()).getContext() ;
+ System.out.println("filling tables for metamodel:"+metamodel+" context:"+context);
+ firstMetricTable.removeAll();
+ secondMetricTable.removeAll();
+ LinkedList<Metric> metrics = MetricManager.getFilteredMetrics(metamodel, context);
+ System.out.println("found:"+metrics.size()+" metrics");
+ TableItem item;
+ for (Metric metric : metrics) {
+ item = new TableItem(firstMetricTable, SWT.NONE);
+ item.setText(1, metric.getName());
+ item.setText(2, metric.getDescription());
+ item.setText(3, metric.getContext());
+ firstTableMapping.setItemForMetric(metric, item);
+ item = new TableItem(secondMetricTable, SWT.NONE);
+ item.setText(1, metric.getName());
+ item.setText(2, metric.getDescription());
+ item.setText(3, metric.getContext());
+ secondTableMapping.setItemForMetric(metric, item);
+ }
+ }
+
+ private void fillOperationNames(){
+ String[] operationNames = MetricManager.getOperationNames();
+ for(String name : operationNames)
+ operationCombo.add(name);
+ }
+
+ /**
+ * Wird jedes mal ausgeführ wenn sich der Inhalt eines Textfeldes im Wizard
+ * verändert. Überprüft die inhalte der Textfelder und erzeugt
+ * entschprechende Meldungen im Wizardfenster.
+ */
+ private void updatePageComplete() {
+ this.firstMetric = getSelectedMetric(this.firstTableMapping);
+ this.secondMetric = getSelectedMetric(this.secondTableMapping);
+ if (this.firstMetric == null) {
+ setMessage("First Metric is not selected", ERROR);
+ this.setPageComplete(false);
+ getWizard().getContainer().updateButtons();
+ } else if (this.secondMetric == null) {
+ setMessage("Second Metric is not selected", ERROR);
+ this.setPageComplete(false);
+ getWizard().getContainer().updateButtons();
+ } else if (!(this.operationCombo.getSelectionIndex() >= 0)) {
+ setMessage("Join operation is not selected", ERROR);
+ this.setPageComplete(false);
+ getWizard().getContainer().updateButtons();
+ } else {
+ setMessage("");
+ this.setPageComplete(true);
+ getWizard().getContainer().updateButtons();
+ }
+ }
+
+ private void setOperationName(String name){
+ operation = name;
+ }
+
+ private Metric getSelectedMetric(TableItemsMapping mapping) {
+ for (int i = 0; i < mapping.getSize(); i++) {
+ if(mapping.getTableItem(i)!=null)
+ if (mapping.getTableItem(i).getChecked()) {
+ return mapping.getMetric(i);
+ }
+ }
+ return null;
+ }
+
+
+ // -------------------------------------------------------------------------------
+ private class MetricTableSelectionListener implements SelectionListener {
+
+ Table table;
+
+ MetricTableSelectionListener(Table table) {
+ this.table = table;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ for (TableItem item : table.getItems()) {
+ item.setChecked(false);
+ }
+ ((TableItem) e.item).setChecked(true);
+ updatePageComplete();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/CompositeMetricInfo.java b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/CompositeMetricInfo.java
index 76e07ee..75b0401 100644
--- a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/CompositeMetricInfo.java
+++ b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/CompositeMetricInfo.java
@@ -14,7 +14,7 @@
*/
public class CompositeMetricInfo extends MetricInfo {
- private Metric firstMetric, secondMetric;
+ private Metric firstMetric = null, secondMetric = null;
private IOperation operation;
/**
@@ -75,5 +75,19 @@
public String getOperationName(){
return Operations.getOperationName(operation);
}
+
+ @Override
+ public String toString() {
+ return "CompositeMetricInfo [firstMetric=" + firstMetric
+ + ", secondMetric=" + secondMetric + ", operation=" + operation
+ + ", getPackage()=" + getPackage() + ", getId()=" + getId()
+ + ", getName()=" + getName() + ", getClassName()="
+ + getClassName() + ", getDescription()=" + getDescription()
+ + ", getProjectPath()=" + getProjectPath()
+ + ", getProjectName()=" + getProjectName() + ", getContext()="
+ + getContext() + ", getMetamodel()=" + getMetamodel()
+ + ", getJar()=" + getJar() + "]";
+ }
+
}
diff --git a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/GenerationManager.java b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/GenerationManager.java
index 4286c7e..d3869d7 100644
--- a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/GenerationManager.java
+++ b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/GenerationManager.java
@@ -21,6 +21,7 @@
public static void createNewMetric(IProgressMonitor monitor,
MetricInfo metricInfo, IProject targetProject) {
System.out.println("Here we go...");
+ System.out.println(metricInfo);
}
}
diff --git a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/INewMetricWizard.java b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/INewMetricWizard.java
new file mode 100644
index 0000000..05379d1
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/INewMetricWizard.java
@@ -0,0 +1,30 @@
+package org.eclipse.emf.refactor.metrics.generator;
+
+import java.util.LinkedList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.wizard.WizardPage;
+
+public interface INewMetricWizard {
+
+ public void setTargetProject(String projectName);
+
+ public LinkedList<IProject> getProjects();
+
+ public void setName(String name);
+
+ public void setId(String id);
+
+ public void setDescription(String description);
+
+ public void setMetamodel(String metamodel);
+
+ public void setContext(String context);
+
+ public void setJar(String jar);
+
+ public int getPageNumbers();
+
+ public WizardPage getSecondPage();
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/MetricBasicDataWizardPage.java b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/MetricBasicDataWizardPage.java
index 19156eb..d4b82f2 100644
--- a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/MetricBasicDataWizardPage.java
+++ b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/MetricBasicDataWizardPage.java
@@ -18,7 +18,7 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
-public class MetricBasicDataWizardPage extends WizardPage implements Listener{
+public class MetricBasicDataWizardPage extends WizardPage implements Listener {
private static final String PAGE_NAME = "org.eclipse.emf.refactor.metrics.MetricBasicDataWizardPage";
private static final String PAGE_TITLE = "New Metric: Basic Data";
@@ -26,7 +26,6 @@
"Required fields are denoted by \"(*)\".";
private Text nameTextField, idTextField, descriptionTextField;
private Combo projectCombo, metamodelCombo, contextCombo;
- private boolean initialization = false;
private String jar = "";
@Override
@@ -36,23 +35,32 @@
layout.numColumns = 1;
container.setLayout(layout);
createTextFields(container);
- initContents();
+ initProjectsAndMetamodels();
setControl(container);
this.setPageComplete(false);
}
@Override
public boolean canFlipToNextPage() {
- if(! initialization) {
+ if (((INewMetricWizard) getWizard()).getPageNumbers() > 1) {
+ return this.isPageComplete();
+ } else {
return false;
}
- return this.isPageComplete();
+ }
+
+ public WizardPage getNextPage() {
+ if (((INewMetricWizard) getWizard()).getPageNumbers() > 1) {
+ return ((INewMetricWizard) getWizard()).getSecondPage();
+ } else {
+ return null;
+ }
}
@Override
public void handleEvent(Event event) {
if (event.widget == projectCombo) {
- ((NewMetricWizardJava)getWizard()).setTargetProject(projectCombo.getText());
+ ((INewMetricWizard) getWizard()).setTargetProject(projectCombo.getText());
}
if (event.widget == metamodelCombo) {
String nsURI = metamodelCombo.getText();
@@ -78,14 +86,8 @@
contextCombo.removeAll();
}
}
- if(!initialization){
updatePageComplete();
- getWizard().getContainer().updateButtons();
- }
- }
-
- public WizardPage getNextPage() {
- return null;
+ getWizard().getContainer().updateButtons();
}
public MetricBasicDataWizardPage() {
@@ -178,14 +180,8 @@
contextCombo.addListener(SWT.Selection, this);
}
- private void initContents() {
- initialization = true;
- initProjectsAndMetamodels();
- initialization = false;
- }
-
private void initProjectsAndMetamodels(){
- for (IProject project : ((NewMetricWizardJava)getWizard()).getProjects()) {
+ for (IProject project : ((INewMetricWizard) getWizard()).getProjects()) {
projectCombo.add(project.getName());
}
Object [] metamodelObjects =
@@ -235,12 +231,12 @@
}
private void saveTextFieldValues(){
- ((NewMetricWizardJava)getWizard()).setName(this.nameTextField.getText());
- ((NewMetricWizardJava)getWizard()).setId(this.idTextField.getText());
- ((NewMetricWizardJava)getWizard()).setDescription(this.descriptionTextField.getText());
- ((NewMetricWizardJava)getWizard()).setMetamodel(this.metamodelCombo.getText());
- ((NewMetricWizardJava)getWizard()).setContext(this.contextCombo.getText());
- ((NewMetricWizardJava)getWizard()).setJar(jar);
+ ((INewMetricWizard) getWizard()).setName(this.nameTextField.getText());
+ ((INewMetricWizard) getWizard()).setId(this.idTextField.getText());
+ ((INewMetricWizard) getWizard()).setDescription(this.descriptionTextField.getText());
+ ((INewMetricWizard) getWizard()).setMetamodel(this.metamodelCombo.getText());
+ ((INewMetricWizard) getWizard()).setContext(this.contextCombo.getText());
+ ((INewMetricWizard) getWizard()).setJar(jar);
}
}
diff --git a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/NewMetricWizardComposite.java b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/NewMetricWizardComposite.java
new file mode 100644
index 0000000..c13e24e
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/NewMetricWizardComposite.java
@@ -0,0 +1,171 @@
+package org.eclipse.emf.refactor.metrics.generator;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.LinkedList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.refactor.metrics.core.Metric;
+import org.eclipse.emf.refactor.metrics.interfaces.IOperation;
+import org.eclipse.emf.refactor.metrics.managers.MetricManager;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+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 NewMetricWizardComposite extends Wizard implements INewWizard, INewMetricWizard {
+
+ protected static final String TRANSFORMATIONS_DIR = "/transformations/";
+ private final String WINDOW_TITLE = "New Metric";
+ private MetricBasicDataWizardPage basicDataPage;
+ private CompositeDataWizardPage compositePage;
+ private String name, id, description, metamodel, context, jar;
+ private LinkedList<IProject> projects;
+ private IProject targetProject;
+
+ public NewMetricWizardComposite() { }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ initProjects();
+ }
+
+ @Override
+ public void addPages() {
+ setWindowTitle(WINDOW_TITLE);
+ basicDataPage = new MetricBasicDataWizardPage();
+ addPage(basicDataPage);
+ compositePage = new CompositeDataWizardPage();
+ addPage(compositePage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return (basicDataPage.isPageComplete() && compositePage.isPageComplete());
+ }
+
+ @Override
+ public boolean performFinish() {
+ try{
+ getContainer().run(true, true, new IRunnableWithProgress(){
+ public void run(IProgressMonitor monitor)throws InvocationTargetException, InterruptedException{
+ GenerationManager.getInstance();
+ GenerationManager.createNewMetric(monitor, getMetricInfo(), targetProject);
+ }
+ });
+ }
+ catch(InvocationTargetException e){
+ e.printStackTrace();
+ return false;
+ }
+ catch(InterruptedException e){
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ private void initProjects(){
+ this.projects = new LinkedList<IProject>();
+ IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (IProject project : allProjects) {
+ if (project.isOpen()) {
+ IProjectNature nature = null;
+ try {
+ nature = project.getNature("org.eclipse.pde.PluginNature");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (null != nature)
+ this.projects.add(project);
+ }
+ }
+ }
+
+ private CompositeMetricInfo getMetricInfo() {
+ MetricManager.getInstance();
+ String proj = this.targetProject.getLocation().toString();
+ Metric first = compositePage.getFirstMetric();
+ Metric second = compositePage.getSecondMetric();
+ String operationName = compositePage.getOperationName();
+ IOperation operation = MetricManager.getOperation(operationName);
+ CompositeMetricInfo info = new CompositeMetricInfo(this.name, this.id, this.description,
+ this.metamodel, this.context, proj, first, second, operation, getJar());
+ return info;
+ }
+
+
+ private String getJar() {
+ return jar;
+ }
+
+ public MetricBasicDataWizardPage getDataPage() {
+ return basicDataPage;
+ }
+
+ public LinkedList<IProject> getProjects() {
+ return projects;
+ }
+
+ public IProject getTargetProject() {
+ return targetProject;
+ }
+
+ public String getMetamodel() {
+ return metamodel;
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setMetamodel(String metamodel) {
+ this.metamodel = metamodel;
+ }
+
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+ public void setTargetProject(String projectName){
+ for (IProject project : projects)
+ if (project.getName().equals(projectName))
+ this.targetProject = project;
+ }
+
+ public void setJar(String jar) {
+ this.jar = jar;
+ }
+
+ public CompositeDataWizardPage getCompositePage() {
+ return compositePage;
+ }
+
+ @Override
+ public int getPageNumbers() {
+ return 2;
+ }
+
+ @Override
+ public WizardPage getSecondPage() {
+ return this.compositePage;
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/NewMetricWizardJava.java b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/NewMetricWizardJava.java
index 5574d88..680de99 100644
--- a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/NewMetricWizardJava.java
+++ b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/NewMetricWizardJava.java
@@ -11,10 +11,11 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
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 NewMetricWizardJava extends Wizard implements INewWizard {
+public class NewMetricWizardJava extends Wizard implements INewWizard, INewMetricWizard {
private final String WINDOW_TITLE = "New Metric";
private MetricBasicDataWizardPage basicDataPage;
@@ -141,4 +142,14 @@
this.jar = jar;
}
+ @Override
+ public int getPageNumbers() {
+ return 1;
+ }
+
+ @Override
+ public WizardPage getSecondPage() {
+ return null;
+ }
+
}
diff --git a/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/TableItemsMapping.java b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/TableItemsMapping.java
new file mode 100644
index 0000000..83eaa3a
--- /dev/null
+++ b/org.eclipse.emf.refactor.metrics.generator/src/org/eclipse/emf/refactor/metrics/generator/TableItemsMapping.java
@@ -0,0 +1,78 @@
+package org.eclipse.emf.refactor.metrics.generator;
+
+import java.util.LinkedList;
+
+import org.eclipse.emf.refactor.metrics.core.Metric;
+import org.eclipse.swt.widgets.TableItem;
+
+public class TableItemsMapping {
+
+ private TableItemMapping[] tableItems;
+
+ public TableItemsMapping(LinkedList<Metric> inputList) {
+ LinkedList<TableItemMapping> tableItemsList = new LinkedList<TableItemMapping>();
+ for (Metric metric : inputList) {
+ tableItemsList.add(new TableItemMapping(metric));
+ }
+ tableItems = new TableItemMapping[tableItemsList.size()];
+ for (int i = 0; i < tableItemsList.size(); i++) {
+ tableItems[i] = tableItemsList.get(i);
+ }
+ }
+
+ public int getSize() {
+ return tableItems.length;
+ }
+
+ public void setItemForMetric(Metric metric, TableItem item) {
+ int index = getTableItemIndex(metric);
+ setItem(index, item);
+ }
+
+ public Metric getMetric(int index){
+ return tableItems[index].getMetric();
+ }
+
+ public TableItem getTableItem(int index) {
+ return tableItems[index].getItem();
+ }
+
+ public TableItem getTableItem(Metric metric) {
+ return tableItems[getTableItemIndex(metric)].getItem();
+ }
+
+ private void setItem(int index, TableItem item) {
+ tableItems[index].setItem(item);
+ }
+
+ private int getTableItemIndex(Metric metric) {
+ for (int i = 0; i < tableItems.length; i++) {
+ if (tableItems[i].getMetric().equals(metric))
+ return i;
+ }
+ return -1;
+ }
+
+ private class TableItemMapping {
+ private TableItem item;
+ private Metric metric;
+
+ private TableItemMapping(Metric metric) {
+ this.metric = metric;
+ this.item = null;
+ }
+
+ private void setItem(TableItem item) {
+ this.item = item;
+ }
+
+ private TableItem getItem() {
+ return item;
+ }
+
+ private Metric getMetric() {
+ return metric;
+ }
+
+ }
+}