<commit_before>/* 
 * Licensed to the soi-toolkit project under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The soi-toolkit project licenses this file to You 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.soitoolkit.tools.generator.plugin.createservice;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
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.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.soitoolkit.tools.generator.plugin.model.enums.EnumUtil;
import org.soitoolkit.tools.generator.plugin.model.enums.MepEnum;
import org.soitoolkit.tools.generator.plugin.util.SwtUtil;

/**
 * The "New" wizard page allows setting the container for the new file as well
 * as the file name. The page will only accept file name without the extension
 * OR with the extension that matches the expected one (mpe).
 */

public class CreateServicePage extends WizardPage {

	public boolean isJavaIdentifier(String str) {
		int n = str.length();
		if (n == 0) return false;
		if (!Character.isJavaIdentifierStart(str.charAt(0))) return false;
		for (int i = 1; i < n; i++)
			if (!Character.isJavaIdentifierPart(str.charAt(i))) return false;
		return true;
	}

	private String getSelectedValue(Combo combo) {
		try {
			return combo.getItem(combo.getSelectionIndex());
		} catch (Exception e) {
			return e + " for index = " + combo.getSelectionIndex();
		}
	}

//	public enum MepReqRespInbTranspEnum implements LabeledEnum { 
//		MEP_REQUEST_RESPONSE("Request/Response"), MEP_ONE_WAY("One Way"), MEP_PUBLISH_SUBSCRIBE("Publish/Subscribe"); 
//
//		public static MepReqRespInbTranspEnum get(int ordinal) {
//			return values()[ordinal];
//		}
//
//		private String label;
//		private MepReqRespInbTranspEnum(String label) {
//			this.label = label;
//		}
//		public String getLabel() {return label;}
//	}
	
	private Combo mepCombo;
	private Combo inboundTransportCombo;
	private Combo outboundTransportCombo;

	private int  selectedMep;	
	private int  selectedInboundTransport;	
	private int  selectedOutboundTransport;	
//	private int  serviceType;	
	private Text projectText;
	private Text serviceText;

	private ISelection selection;

	/**
	 * Constructor for CreateServicePage.
	 * 
	 * @param pageName
	 */
	public CreateServicePage(ISelection selection) {
		super("wizardPage");
		setTitle("SOI Toolkit - Create a new service");
		setDescription("This code generator creates files for a new service in the selected integration componentens project.");
		setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "service-large.png"));
		this.selection = selection;
	}

	/**
	 * @see IDialogPage#createControl(Composite)
	 */
	public void createControl(Composite parent) {
		
		/*
		 * valbar kod
		 * - service def
		 * - component ?
		 * - transformer
		 * 
		 * - unit test
		 * - test consumer
		 * - test producer
		 * 
		 * - jmeter loadtest
		 * 
		 * + instruktion
		 * - lgg till i service conf + unit test conf
		 * - lgg till i properties
		 */
		try {
			Composite container = new Composite(parent, SWT.NULL);
			GridLayout layout = new GridLayout();
			container.setLayout(layout);
			layout.numColumns = 1;
			layout.verticalSpacing = 9;
			
			addRadioButtons(container);
			
//			addTextFields(container);

			initialize();
			dialogChanged();
			setControl(container);
		} catch (RuntimeException e) {
			e.printStackTrace();
			throw e;
		}
	}

	private void addRadioButtons (final Composite parent) {

		final Composite container = SwtUtil.createGridContainer(parent, 2);

//		Listener listener = new Listener() {
//			public void handleEvent (Event e) {
//				serviceType = (Integer)e.widget.getData();
//				System.err.println("### Set selected component type to: " + serviceType);
//
//				Control [] children = container.getChildren ();
//				for (int i=0; i<children.length; i++) {
//					Control child = children [i];
//					if (e.widget != child && child instanceof Button && (child.getStyle () & SWT.TOGGLE) != 0) {
//						((Button) child).setSelection (false);
//					}
//				}
//				((Button) e.widget).setSelection (true);
//			}
//		};

		Label label = new Label(container, SWT.NULL);
		label.setText("Message Exchange Pattern:");

		mepCombo = new Combo (container, SWT.READ_ONLY);
//		patternCategoryCombo.setItems (new String [] {"Request/Response Service", "Fire and Forget Service", "File Transfer"});

		mepCombo.setItems (EnumUtil.getLabels(MepEnum.values()));
		
		label = new Label(container, SWT.NULL);
		label.setText("&Inbound Transport:");
		inboundTransportCombo = new Combo (container, SWT.READ_ONLY);
		inboundTransportCombo.setItems (new String [] {"Please select a MEP first!", ""});
	
		label = new Label(container, SWT.NULL);
		label.setText("&Outbound Transport:");
		outboundTransportCombo = new Combo (container, SWT.READ_ONLY);
		outboundTransportCombo.setItems (new String [] {"Please select inbound transport first!", ""});
		
		/*
		 * Mep-Combo-Listener
		 */
		SelectionListener mepComboListener = new SelectionListener () {
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				System.err.println("### Set default selected selectedMep");
				Combo c = (Combo)e.widget;
				selectedMep =  c.getSelectionIndex();
				System.err.println("### Set default selected selectedMep to: " + selectedMep);
			}

			@Override
			public void widgetSelected(SelectionEvent e) {
				System.err.println("### Set selected selectedMep");
				Combo c = (Combo)e.widget;
				selectedMep =  c.getSelectionIndex();
				System.err.println("### Set selected selectedMep to: " + selectedMep);

				switch (MepEnum.get(c.getSelectionIndex())) {
				case MEP_REQUEST_RESPONSE:
//					patternTypeCombo.setItems (new String [] {"SOAP/HTTPS(S) with SOAP/HTTP(S) adapter",
//							"SOAP/HTTPS(S) with JMS adapter",
//							"SOAP/HTTPS(S) with REST/HTTP(S) adapter"});
					inboundTransportCombo.setItems  (new String [] {"SOAP"});
					outboundTransportCombo.setItems (new String [] {"SOAP", "REST", "JMS", "JDBC"});
					break;
				case MEP_ONE_WAY:
//					patternTypeCombo.setItems (new String [] {"JMS with JMS adapter",
//							"JMS with JDBC adapter",
//							"JMS with file adapter"});
					inboundTransportCombo.setItems  (new String [] {"JMS", "SFTP"}); // , "JDBC"
					outboundTransportCombo.setItems (new String [] {"JMS", "SFTP"}); // , "JDBC"
					break;
				case MEP_PUBLISH_SUBSCRIBE:
					inboundTransportCombo.setItems  (new String [] {"JMS"});
					outboundTransportCombo.setItems (new String [] {"JMS"});
					break;
//				case 3:
//					inboundTransportCombo.setItems (new String [] {"SFTP to SFTP",
//							"SFTP to JDBC",
//							"SFTP to JMS"});
//					break;
				}

				dialogChanged();

			}
		};
		mepCombo.addSelectionListener(mepComboListener);

		/*
		 * Inbound-Transport-Combo-Listener
		 */
		SelectionListener inboundTransportComboListener = new SelectionListener () {
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				System.err.println("### Set default selected selectedTransport");
				Combo c = (Combo)e.widget;
				selectedInboundTransport = c.getSelectionIndex();
				System.err.println("### Set default selected selectedTransport to: " + selectedInboundTransport);
			}

			@Override
			public void widgetSelected(SelectionEvent e) {
				System.err.println("### Set selected selectedTransport");
				Combo c = (Combo)e.widget;
				selectedInboundTransport = c.getSelectionIndex();
				System.err.println("### Set selected selectedTransport type to: " + selectedInboundTransport);

				int inbTransp = c.getSelectionIndex();
				switch (MepEnum.get(mepCombo.getSelectionIndex())) {
				case MEP_REQUEST_RESPONSE:
					break;
				case MEP_ONE_WAY:
					outboundTransportCombo.setItems (new String [] {c.getItem(inbTransp)});
					break;
				case MEP_PUBLISH_SUBSCRIBE:
					break;
				}

				dialogChanged();

			}
		};
		inboundTransportCombo.addSelectionListener(inboundTransportComboListener);

		/*
		 * Outbound-Transport-Combo-Listener
		 */
		SelectionListener outboundTransportComboListener = new SelectionListener () {
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				System.err.println("### Set default selected selectedOutboundTransport");
				Combo c = (Combo)e.widget;
				selectedOutboundTransport = c.getSelectionIndex();
				System.err.println("### Set default selected selectedOutboundTransport to: " + selectedOutboundTransport);
			}

			@Override
			public void widgetSelected(SelectionEvent e) {
				System.err.println("### Set selected selectedOutboundTransport");
				Combo c = (Combo)e.widget;
				selectedOutboundTransport = c.getSelectionIndex();
				System.err.println("### Set selected selectedOutboundTransport type to: " + selectedOutboundTransport);

				dialogChanged();

			}
		};
		outboundTransportCombo.addSelectionListener(outboundTransportComboListener);

//	}
//
//	private void addTextFields(Composite parent) {
//
//		Composite container = SwtUtil.createGridContainer(parent, 2);
////		Composite container = new Composite(parent, SWT.NULL);
////		GridLayout layout = new GridLayout();
////		container.setLayout(layout);
////		layout.numColumns = 3;
////		layout.verticalSpacing = 9;

		label = new Label(container, SWT.NULL);
		label.setText("&Project:");

		Composite projectContainer = SwtUtil.createGridContainer(container, 2);

		projectText = new Text(projectContainer, SWT.BORDER | SWT.SINGLE);
		projectText.setText("                  "); // TODO: Otherwise it is shrinked to mimimum width...
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
		projectText.setLayoutData(gd);
		projectText.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				dialogChanged();
			}
		});

		Button button = new Button(projectContainer, SWT.PUSH);
		button.setText("Browse...");
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				handleBrowse();
			}
		});
		label = new Label(container, SWT.NULL);
		label.setText("&Service name:");

		serviceText = new Text(container, SWT.BORDER | SWT.SINGLE);
		gd = new GridData(GridData.FILL_HORIZONTAL);
		serviceText.setLayoutData(gd);
		serviceText.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				dialogChanged();
			}
		});
	}


	/**
	 * Tests if the current workbench selection is a suitable container to use.
	 */

	private void initialize() {
		if (selection != null && selection.isEmpty() == false
				&& selection instanceof IStructuredSelection) {
			IStructuredSelection ssel = (IStructuredSelection) selection;
			if (ssel.size() > 1)
				return;
			Object obj = ssel.getFirstElement();
			if (obj instanceof IResource) {
				IContainer container;
				if (obj instanceof IContainer)
					container = (IContainer) obj;
				else
					container = ((IResource) obj).getParent();
				projectText.setText(container.getFullPath().toString());
			}
		}
		serviceText.setText("myService");
	}

	/**
	 * Uses the standard container selection dialog to choose the new value for
	 * the container field.
	 */

	private void handleBrowse() {
		ContainerSelectionDialog dialog = new ContainerSelectionDialog(
				getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
				"Select new file container");
		if (dialog.open() == ContainerSelectionDialog.OK) {
			Object[] result = dialog.getResult();
			if (result.length == 1) {
				projectText.setText(((Path) result[0]).toString());
			}
		}
	}

	/**
	 * Ensures that both text fields are set.
	 */

	private void dialogChanged() {

		// Validate MEP
		int mepIdx = mepCombo.getSelectionIndex();
		if (mepIdx == -1) {
			updateStatus("Select a message exchenge pattern");
			return;<commit_msg>New issue Summary: Remove "Service" from the default service-name in the new-service-wizard Since various service-components will be named as ${serviceName}-service it is a bad practice using "service" as a part of the serviceName resulting in service names containing "service" twice. E.g. entering the service name "myService" will result in a Mule service named "myService-service"... Changed the default name to "mySample" simply...<commit_after>/* 
 * Licensed to the soi-toolkit project under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The soi-toolkit project licenses this file to You 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.soitoolkit.tools.generator.plugin.createservice;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
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.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.soitoolkit.tools.generator.plugin.model.enums.EnumUtil;
import org.soitoolkit.tools.generator.plugin.model.enums.MepEnum;
import org.soitoolkit.tools.generator.plugin.util.SwtUtil;

/**
 * The "New" wizard page allows setting the container for the new file as well
 * as the file name. The page will only accept file name without the extension
 * OR with the extension that matches the expected one (mpe).
 */

public class CreateServicePage extends WizardPage {

	public boolean isJavaIdentifier(String str) {
		int n = str.length();
		if (n == 0) return false;
		if (!Character.isJavaIdentifierStart(str.charAt(0))) return false;
		for (int i = 1; i < n; i++)
			if (!Character.isJavaIdentifierPart(str.charAt(i))) return false;
		return true;
	}

	private String getSelectedValue(Combo combo) {
		try {
			return combo.getItem(combo.getSelectionIndex());
		} catch (Exception e) {
			return e + " for index = " + combo.getSelectionIndex();
		}
	}

//	public enum MepReqRespInbTranspEnum implements LabeledEnum { 
//		MEP_REQUEST_RESPONSE("Request/Response"), MEP_ONE_WAY("One Way"), MEP_PUBLISH_SUBSCRIBE("Publish/Subscribe"); 
//
//		public static MepReqRespInbTranspEnum get(int ordinal) {
//			return values()[ordinal];
//		}
//
//		private String label;
//		private MepReqRespInbTranspEnum(String label) {
//			this.label = label;
//		}
//		public String getLabel() {return label;}
//	}
	
	private Combo mepCombo;
	private Combo inboundTransportCombo;
	private Combo outboundTransportCombo;

	private int  selectedMep;	
	private int  selectedInboundTransport;	
	private int  selectedOutboundTransport;	
//	private int  serviceType;	
	private Text projectText;
	private Text serviceText;

	private ISelection selection;

	/**
	 * Constructor for CreateServicePage.
	 * 
	 * @param pageName
	 */
	public CreateServicePage(ISelection selection) {
		super("wizardPage");
		setTitle("SOI Toolkit - Create a new service");
		setDescription("This code generator creates files for a new service in the selected integration componentens project.");
		setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "service-large.png"));
		this.selection = selection;
	}

	/**
	 * @see IDialogPage#createControl(Composite)
	 */
	public void createControl(Composite parent) {
		
		/*
		 * valbar kod
		 * - service def
		 * - component ?
		 * - transformer
		 * 
		 * - unit test
		 * - test consumer
		 * - test producer
		 * 
		 * - jmeter loadtest
		 * 
		 * + instruktion
		 * - lgg till i service conf + unit test conf
		 * - lgg till i properties
		 */
		try {
			Composite container = new Composite(parent, SWT.NULL);
			GridLayout layout = new GridLayout();
			container.setLayout(layout);
			layout.numColumns = 1;
			layout.verticalSpacing = 9;
			
			addRadioButtons(container);
			
//			addTextFields(container);

			initialize();
			dialogChanged();
			setControl(container);
		} catch (RuntimeException e) {
			e.printStackTrace();
			throw e;
		}
	}

	private void addRadioButtons (final Composite parent) {

		final Composite container = SwtUtil.createGridContainer(parent, 2);

//		Listener listener = new Listener() {
//			public void handleEvent (Event e) {
//				serviceType = (Integer)e.widget.getData();
//				System.err.println("### Set selected component type to: " + serviceType);
//
//				Control [] children = container.getChildren ();
//				for (int i=0; i<children.length; i++) {
//					Control child = children [i];
//					if (e.widget != child && child instanceof Button && (child.getStyle () & SWT.TOGGLE) != 0) {
//						((Button) child).setSelection (false);
//					}
//				}
//				((Button) e.widget).setSelection (true);
//			}
//		};

		Label label = new Label(container, SWT.NULL);
		label.setText("Message Exchange Pattern:");

		mepCombo = new Combo (container, SWT.READ_ONLY);
//		patternCategoryCombo.setItems (new String [] {"Request/Response Service", "Fire and Forget Service", "File Transfer"});

		mepCombo.setItems (EnumUtil.getLabels(MepEnum.values()));
		
		label = new Label(container, SWT.NULL);
		label.setText("&Inbound Transport:");
		inboundTransportCombo = new Combo (container, SWT.READ_ONLY);
		inboundTransportCombo.setItems (new String [] {"Please select a MEP first!", ""});
	
		label = new Label(container, SWT.NULL);
		label.setText("&Outbound Transport:");
		outboundTransportCombo = new Combo (container, SWT.READ_ONLY);
		outboundTransportCombo.setItems (new String [] {"Please select inbound transport first!", ""});
		
		/*
		 * Mep-Combo-Listener
		 */
		SelectionListener mepComboListener = new SelectionListener () {
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				System.err.println("### Set default selected selectedMep");
				Combo c = (Combo)e.widget;
				selectedMep =  c.getSelectionIndex();
				System.err.println("### Set default selected selectedMep to: " + selectedMep);
			}

			@Override
			public void widgetSelected(SelectionEvent e) {
				System.err.println("### Set selected selectedMep");
				Combo c = (Combo)e.widget;
				selectedMep =  c.getSelectionIndex();
				System.err.println("### Set selected selectedMep to: " + selectedMep);

				switch (MepEnum.get(c.getSelectionIndex())) {
				case MEP_REQUEST_RESPONSE:
//					patternTypeCombo.setItems (new String [] {"SOAP/HTTPS(S) with SOAP/HTTP(S) adapter",
//							"SOAP/HTTPS(S) with JMS adapter",
//							"SOAP/HTTPS(S) with REST/HTTP(S) adapter"});
					inboundTransportCombo.setItems  (new String [] {"SOAP"});
					outboundTransportCombo.setItems (new String [] {"SOAP", "REST", "JMS", "JDBC"});
					break;
				case MEP_ONE_WAY:
//					patternTypeCombo.setItems (new String [] {"JMS with JMS adapter",
//							"JMS with JDBC adapter",
//							"JMS with file adapter"});
					inboundTransportCombo.setItems  (new String [] {"JMS", "SFTP"}); // , "JDBC"
					outboundTransportCombo.setItems (new String [] {"JMS", "SFTP"}); // , "JDBC"
					break;
				case MEP_PUBLISH_SUBSCRIBE:
					inboundTransportCombo.setItems  (new String [] {"JMS"});
					outboundTransportCombo.setItems (new String [] {"JMS"});
					break;
//				case 3:
//					inboundTransportCombo.setItems (new String [] {"SFTP to SFTP",
//							"SFTP to JDBC",
//							"SFTP to JMS"});
//					break;
				}

				dialogChanged();

			}
		};
		mepCombo.addSelectionListener(mepComboListener);

		/*
		 * Inbound-Transport-Combo-Listener
		 */
		SelectionListener inboundTransportComboListener = new SelectionListener () {
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				System.err.println("### Set default selected selectedTransport");
				Combo c = (Combo)e.widget;
				selectedInboundTransport = c.getSelectionIndex();
				System.err.println("### Set default selected selectedTransport to: " + selectedInboundTransport);
			}

			@Override
			public void widgetSelected(SelectionEvent e) {
				System.err.println("### Set selected selectedTransport");
				Combo c = (Combo)e.widget;
				selectedInboundTransport = c.getSelectionIndex();
				System.err.println("### Set selected selectedTransport type to: " + selectedInboundTransport);

				int inbTransp = c.getSelectionIndex();
				switch (MepEnum.get(mepCombo.getSelectionIndex())) {
				case MEP_REQUEST_RESPONSE:
					break;
				case MEP_ONE_WAY:
					outboundTransportCombo.setItems (new String [] {c.getItem(inbTransp)});
					break;
				case MEP_PUBLISH_SUBSCRIBE:
					break;
				}

				dialogChanged();

			}
		};
		inboundTransportCombo.addSelectionListener(inboundTransportComboListener);

		/*
		 * Outbound-Transport-Combo-Listener
		 */
		SelectionListener outboundTransportComboListener = new SelectionListener () {
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				System.err.println("### Set default selected selectedOutboundTransport");
				Combo c = (Combo)e.widget;
				selectedOutboundTransport = c.getSelectionIndex();
				System.err.println("### Set default selected selectedOutboundTransport to: " + selectedOutboundTransport);
			}

			@Override
			public void widgetSelected(SelectionEvent e) {
				System.err.println("### Set selected selectedOutboundTransport");
				Combo c = (Combo)e.widget;
				selectedOutboundTransport = c.getSelectionIndex();
				System.err.println("### Set selected selectedOutboundTransport type to: " + selectedOutboundTransport);

				dialogChanged();

			}
		};
		outboundTransportCombo.addSelectionListener(outboundTransportComboListener);

//	}
//
//	private void addTextFields(Composite parent) {
//
//		Composite container = SwtUtil.createGridContainer(parent, 2);
////		Composite container = new Composite(parent, SWT.NULL);
////		GridLayout layout = new GridLayout();
////		container.setLayout(layout);
////		layout.numColumns = 3;
////		layout.verticalSpacing = 9;

		label = new Label(container, SWT.NULL);
		label.setText("&Project:");

		Composite projectContainer = SwtUtil.createGridContainer(container, 2);

		projectText = new Text(projectContainer, SWT.BORDER | SWT.SINGLE);
		projectText.setText("                  "); // TODO: Otherwise it is shrinked to mimimum width...
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
		projectText.setLayoutData(gd);
		projectText.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				dialogChanged();
			}
		});

		Button button = new Button(projectContainer, SWT.PUSH);
		button.setText("Browse...");
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				handleBrowse();
			}
		});
		label = new Label(container, SWT.NULL);
		label.setText("&Service name:");

		serviceText = new Text(container, SWT.BORDER | SWT.SINGLE);
		gd = new GridData(GridData.FILL_HORIZONTAL);
		serviceText.setLayoutData(gd);
		serviceText.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				dialogChanged();
			}
		});
	}


	/**
	 * Tests if the current workbench selection is a suitable container to use.
	 */

	private void initialize() {
		if (selection != null && selection.isEmpty() == false
				&& selection instanceof IStructuredSelection) {
			IStructuredSelection ssel = (IStructuredSelection) selection;
			if (ssel.size() > 1)
				return;
			Object obj = ssel.getFirstElement();
			if (obj instanceof IResource) {
				IContainer container;
				if (obj instanceof IContainer)
					container = (IContainer) obj;
				else
					container = ((IResource) obj).getParent();
				projectText.setText(container.getFullPath().toString());
			}
		}
		serviceText.setText("mySample");
	}

	/**
	 * Uses the standard container selection dialog to choose the new value for
	 * the container field.
	 */

	private void handleBrowse() {
		ContainerSelectionDialog dialog = new ContainerSelectionDialog(
				getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
				"Select new file container");
		if (dialog.open() == ContainerSelectionDialog.OK) {
			Object[] result = dialog.getResult();
			if (result.length == 1) {
				projectText.setText(((Path) result[0]).toString());
			}
		}
	}

	/**
	 * Ensures that both text fields are set.
	 */

	private void dialogChanged() {

		// Validate MEP
		int mepIdx = mepCombo.getSelectionIndex();
		if (mepIdx == -1) {
			updateStatus("Select a message exchenge pattern");
			return;
{'fraction_non_alphanumeric': 0.1216558610924808, 'fraction_numerical': 0.001564945226917058, 'mean_word_length': 3.9047880116959064, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5049951', 'n_tokens_mistral': 9145, 'n_tokens_neox': 8032, 'n_words': 2035}