<commit_before>/**
 * 
 */
package de.tuberlin.uebb.emodelica.ui.wizards;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.IPreferencePage;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.preference.PreferenceNode;
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.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.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;

import de.tuberlin.uebb.emodelica.EModelicaPlugin;
import de.tuberlin.uebb.emodelica.preferences.MOSILABPreferencePage;

/**
 * @author choeger
 *
 */
public class NewProjectWizardPage extends WizardPage {

	private Text projectNameField;
	private IProject project;
	private Button useDefaultEnvironment;
	private Button useDefaultLayout;
	
	protected NewProjectWizardPage(String pageName) {
		super(pageName);
	}

	@Override
	public void createControl(Composite parent) {
		this.setTitle("Create a new MOSILAB project");
		
		Composite container = new Composite(parent, SWT.NONE);
		setControl(container);
		
		final GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		container.setLayout(layout);
		
		/* Project name selection */
		createProjectNameGroup(container);
		
		/* MOSILAB installation to use */
		createMosilabSelectionGroup(container);
		
		/* project layout settings */
		createProjectLayoutGroup(container);
		
		updatePageComplete();
	}

	private void createProjectLayoutGroup(Composite container) {
		Group projectLayout = new Group(container, SWT.NONE);
		projectLayout.setText("Project layout");
		final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
		gridData.horizontalSpan = 2;
		projectLayout.setLayoutData(gridData);
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 1;
		projectLayout.setLayout(gridLayout);
		useDefaultLayout = new Button(projectLayout, SWT.RADIO);
		
		/* TODO: add confidure defaults link */
		useDefaultLayout.setText("&Create separate folders for source files and mosilac output");
		useDefaultLayout.setSelection(true);
		
		/* TODO: project root as source and output folder */
	}

	private void createMosilabSelectionGroup(Composite container) {		
		Group mosilabSelection = new Group(container, SWT.NONE);
		mosilabSelection.setText("MOSILAB installation");
		final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
		gridData.horizontalSpan = 2;
		mosilabSelection.setLayoutData(gridData);
		
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 2;
		mosilabSelection.setLayout(gridLayout);
		
		useDefaultEnvironment = new Button(mosilabSelection, SWT.RADIO);
		
		Link confLink = new Link(mosilabSelection, SWT.NONE);
		confLink.setText("<A>Configure MOSILAB</A>");
		confLink.addSelectionListener(new SelectionListener() {

			@Override
			public void widgetDefaultSelected(SelectionEvent arg0) {
				openPreferencePage();
			}

			@Override
			public void widgetSelected(SelectionEvent arg0) {
				openPreferencePage();
			}
		});
		
		updateDefaultEnvironment();
		useDefaultEnvironment.setSelection(true);
		
		/* TODO: add project specific selection */
	}

	/**
	 * @param environmentName
	 */
	private void updateDefaultEnvironment() {
		String environmentName = "none";
		if (EModelicaPlugin.getDefault().getDefaultMosilabEnvironment() != null)
			environmentName = EModelicaPlugin.getDefault().getDefaultMosilabEnvironment().getName();
		
		useDefaultEnvironment.setText("use default installation (Currently '" + 
				environmentName + "')");
	}

	private void openPreferencePage() {
		IPreferencePage page = new MOSILABPreferencePage();<commit_msg>fix button layout in the ui<commit_after>/**
 * 
 */
package de.tuberlin.uebb.emodelica.ui.wizards;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.IPreferencePage;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.preference.PreferenceNode;
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.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.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;

import de.tuberlin.uebb.emodelica.EModelicaPlugin;
import de.tuberlin.uebb.emodelica.preferences.MOSILABPreferencePage;

/**
 * @author choeger
 *
 */
public class NewProjectWizardPage extends WizardPage {

	private Text projectNameField;
	private IProject project;
	private Button useDefaultEnvironment;
	private Button useDefaultLayout;
	
	protected NewProjectWizardPage(String pageName) {
		super(pageName);
	}

	@Override
	public void createControl(Composite parent) {
		this.setTitle("Create a new MOSILAB project");
		
		Composite container = new Composite(parent, SWT.NONE);
		setControl(container);
		
		final GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		container.setLayout(layout);
		
		/* Project name selection */
		createProjectNameGroup(container);
		
		/* MOSILAB installation to use */
		createMosilabSelectionGroup(container);
		
		/* project layout settings */
		createProjectLayoutGroup(container);
		
		updatePageComplete();
	}

	private void createProjectLayoutGroup(Composite container) {
		initializeDialogUnits(container);
		
		Group projectLayout = new Group(container, SWT.NONE);
		projectLayout.setText("Project layout");
		final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
		gridData.horizontalSpan = 2;
		projectLayout.setLayoutData(gridData);
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 1;
		projectLayout.setLayout(gridLayout);
		useDefaultLayout = new Button(projectLayout, SWT.RADIO);
		
		/* TODO: add confidure defaults link */
		useDefaultLayout.setText("&Create separate folders for source files and mosilac output");
		useDefaultLayout.setSelection(true);
		
		/* TODO: project root as source and output folder */
	}

	private void createMosilabSelectionGroup(Composite container) {		
		Group mosilabSelection = new Group(container, SWT.NONE);
		mosilabSelection.setText("MOSILAB installation");
		final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
		gridData.horizontalSpan = 2;
		mosilabSelection.setLayoutData(gridData);
		
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 2;
		mosilabSelection.setLayout(gridLayout);
		
		useDefaultEnvironment = new Button(mosilabSelection, SWT.RADIO);
		
		Link confLink = new Link(mosilabSelection, SWT.NONE);
		confLink.setText("<A>Configure MOSILAB</A>");
		confLink.addSelectionListener(new SelectionListener() {

			@Override
			public void widgetDefaultSelected(SelectionEvent arg0) {
				openPreferencePage();
			}

			@Override
			public void widgetSelected(SelectionEvent arg0) {
				openPreferencePage();
			}
		});
		
		updateDefaultEnvironment();
		useDefaultEnvironment.setSelection(true);
		setButtonLayoutData(useDefaultEnvironment);
		
		/* TODO: add project specific selection */
	}

	/**
	 * @param environmentName
	 */
	private void updateDefaultEnvironment() {
		String environmentName = "none";
		if (EModelicaPlugin.getDefault().getDefaultMosilabEnvironment() != null)
			environmentName = EModelicaPlugin.getDefault().getDefaultMosilabEnvironment().getName();
		
		useDefaultEnvironment.setText("use default installation (Currently '" + 
				environmentName + "')");
	}

	private void openPreferencePage() {
		IPreferencePage page = new MOSILABPreferencePage();
{'fraction_non_alphanumeric': 0.10111962286387743, 'fraction_numerical': 0.0016499705362404242, 'mean_word_length': 5.281273131014063, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5014957', 'n_tokens_mistral': 2768, 'n_tokens_neox': 2469, 'n_words': 498}