<commit_before>package hu.elte.txtuml.project.wizards;


import hu.elte.txtuml.eclipseutils.Dialogs;

import java.io.ByteArrayInputStream;
import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.actions.WorkspaceModifyOperation;

public class NewTxtUMLModelCreationPage extends NewTypeWizardPage {
	protected static final int COLS = 4;
	protected Button txt;
	protected Button xtxt;
	protected boolean xtxtuml;
	private IResource resource;
	
	protected NewTxtUMLModelCreationPage() {
		super(false, TxtUMLModelFileCreatorWizard.TITLE);
		this.setTitle(TxtUMLModelFileCreatorWizard.TITLE);
		this.setDescription(TxtUMLModelFileCreatorWizard.DESCRIPTION);
	}

	@Override
	public void createControl(Composite parent) {
		setControl(createCompositeControl(parent));
	}

	private Composite createCompositeControl(Composite parent) {
		initializeDialogUnits(parent);
		Composite composite = new Composite(parent, SWT.NONE);
		composite.setFont(parent.getFont());
		GridLayout layout = new GridLayout();
		layout.numColumns = COLS;
		composite.setLayout(layout);
		createContainerControls(composite, COLS);
		createPackageControls(composite, COLS);
		createSeparator(composite, COLS);
		createTypeNameControls(composite, COLS);
		createSeparator(composite, COLS);
		createFileTypeChoice(composite, COLS);
		return composite;
	}

	private void createFileTypeChoice(Composite composite, int cols2) {
		Group group1 = new Group(composite, SWT.SHADOW_IN);
	    group1.setText("Type of Model");
	    group1.setLayout(new RowLayout(SWT.VERTICAL));
	    group1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 3,1));
	    txt = new Button(group1, SWT.RADIO);
	    txt.setText("standard txtUML Model (Pure Java representation)");
	    txt.setSelection(true);
	    xtxt = new Button(group1, SWT.RADIO);
	    xtxt.setText("XtxtUML Model (Custom modelling syntax)");
	}

	protected void doStatusUpdate() {
		IStatus[] status = new IStatus[] { fContainerStatus, fPackageStatus, fTypeNameStatus };
		updateStatus(status);
	}
	
	@Override
	protected void handleFieldChanged(String fieldName) {
		super.handleFieldChanged(fieldName);
		doStatusUpdate();
	}

	public IFile createNewFile() {
		String extension;
		String content;
		String pack = getPackageFragment().getElementName();
		if(xtxt.getSelection()){
			extension = ".xtxtuml";
			content = "".equals(pack) ? "" : "package "+pack+";"+System.lineSeparator();
			content += System.lineSeparator()
					+"model "+getTypeName()+"{"+System.lineSeparator()
					+"\t"+System.lineSeparator()
					+"}";
		}else{
			extension = ".java";
			content = "".equals(pack) ? "" : "package "+pack+";"+System.lineSeparator();
			content += System.lineSeparator()
					+"import hu.elte.txtuml.api.model.*;"+System.lineSeparator()
					+System.lineSeparator()
					+"class "+getTypeName()+" extends Model{"+System.lineSeparator()
					+"\t"+System.lineSeparator()
					+"}";
		}
		
		if(createFile(content, extension)){
			return (IFile) getResource();
		}else{
			return null;
		}
	}
	
	private IResource getResource() {<commit_msg>misplaced curly braces fixed<commit_after>package hu.elte.txtuml.project.wizards;


import hu.elte.txtuml.eclipseutils.Dialogs;

import java.io.ByteArrayInputStream;
import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.actions.WorkspaceModifyOperation;

public class NewTxtUMLModelCreationPage extends NewTypeWizardPage {
	protected static final int COLS = 4;
	protected Button txt;
	protected Button xtxt;
	protected boolean xtxtuml;
	private IResource resource;
	
	protected NewTxtUMLModelCreationPage() {
		super(false, TxtUMLModelFileCreatorWizard.TITLE);
		this.setTitle(TxtUMLModelFileCreatorWizard.TITLE);
		this.setDescription(TxtUMLModelFileCreatorWizard.DESCRIPTION);
	}

	@Override
	public void createControl(Composite parent) {
		setControl(createCompositeControl(parent));
	}

	private Composite createCompositeControl(Composite parent) {
		initializeDialogUnits(parent);
		Composite composite = new Composite(parent, SWT.NONE);
		composite.setFont(parent.getFont());
		GridLayout layout = new GridLayout();
		layout.numColumns = COLS;
		composite.setLayout(layout);
		createContainerControls(composite, COLS);
		createPackageControls(composite, COLS);
		createSeparator(composite, COLS);
		createTypeNameControls(composite, COLS);
		createSeparator(composite, COLS);
		createFileTypeChoice(composite, COLS);
		return composite;
	}

	private void createFileTypeChoice(Composite composite, int cols2) {
		Group group1 = new Group(composite, SWT.SHADOW_IN);
	    group1.setText("Type of Model");
	    group1.setLayout(new RowLayout(SWT.VERTICAL));
	    group1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 3,1));
	    txt = new Button(group1, SWT.RADIO);
	    txt.setText("standard txtUML Model (Pure Java representation)");
	    txt.setSelection(true);
	    xtxt = new Button(group1, SWT.RADIO);
	    xtxt.setText("XtxtUML Model (Custom modelling syntax)");
	}

	protected void doStatusUpdate() {
		IStatus[] status = new IStatus[] { fContainerStatus, fPackageStatus, fTypeNameStatus };
		updateStatus(status);
	}
	
	@Override
	protected void handleFieldChanged(String fieldName) {
		super.handleFieldChanged(fieldName);
		doStatusUpdate();
	}

	public IFile createNewFile() {
		String extension;
		String content;
		String pack = getPackageFragment().getElementName();
		if(xtxt.getSelection()){
			extension = ".xtxtuml";
			content = "".equals(pack) ? "" : "package "+pack+";"+System.lineSeparator();
			content += System.lineSeparator()
					+"model "+getTypeName()+" {"+System.lineSeparator()
					+"\t"+System.lineSeparator()
					+"}";
		}else{
			extension = ".java";
			content = "".equals(pack) ? "" : "package "+pack+";"+System.lineSeparator();
			content += System.lineSeparator()
					+"import hu.elte.txtuml.api.model.*;"+System.lineSeparator()
					+System.lineSeparator()
					+"class "+getTypeName()+" extends Model {"+System.lineSeparator()
					+"\t"+System.lineSeparator()
					+"}";
		}
		
		if(createFile(content, extension)){
			return (IFile) getResource();
		}else{
			return null;
		}
	}
	
	private IResource getResource() {
{'fraction_non_alphanumeric': 0.12334914732658032, 'fraction_numerical': 0.0025644313373509426, 'mean_word_length': 5.39344262295082, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1225082', 'n_tokens_mistral': 2659, 'n_tokens_neox': 2457, 'n_words': 451}