/*
 * Perfclispe
 * 
 * 
 * Copyright (c) 2013 Jakub Knetl
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.perfclipse.ui.wizards;

import org.eclipse.swt.widgets.TableItem;
import org.perfcake.model.ObjectFactory;
import org.perfcake.model.Scenario.Reporting.Reporter;
import org.perfclipse.model.PropertyModel;
import org.perfclipse.ui.wizards.pages.ReporterPage;

/**
 * @author Jakub Knetl
 *
 */
public class ReporterAddWizard extends AbstractPerfCakeAddWizard {
	
	private ReporterPage page;
	private Reporter reporter;
	

	public ReporterAddWizard() {
		super();
		setWindowTitle("Add reporter");
	}

	@Override
	public boolean performFinish() {
		reporter = new ObjectFactory().createScenarioReportingReporter();
		
		reporter.setClazz(page.getReporterType());
		reporter.setEnabled(page.getEnabled());
		
		for (TableItem i : page.getPropertyViewer().getTable().getItems()){
			if (i.getData() instanceof PropertyModel){
				PropertyModel p = (PropertyModel) i.getData();
				reporter.getProperty().add(p.getProperty());
			}
		}

		return true;
	}

	@Override
	public void addPages() {
		page = new ReporterPage();
		addPage(page);
		super.addPages();
	}

	public Reporter getReporter() {
		return reporter;
	}
	
	
}

@@ -789,16 +789,62 @@
 porter;%0A
+import org.perfclipse.model.DestinationModel;%0A
 import o
@@ -1379,16 +1379,262 @@
 ());%0A%09%09%0A
+%09%09for (TableItem i : page.getDestinationViewer().getTable().getItems())%7B%0A%09%09%09if (i.getData() instanceof DestinationModel)%7B%0A%09%09%09%09DestinationModel d = (DestinationModel) i.getData();%0A%09%09%09%09reporter.getDestination().add(d.getDestination());%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A
 %09%09for (T

Fix ReporterAddWizard to add destinations to model.