<commit_before>/**
 * 
 */
package org.teagle.vcttool.view;

import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabFolder2Adapter;
import org.eclipse.swt.custom.CTabFolderEvent;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.teagle.vcttool.control.VctController;

import teagle.vct.model.Vct;

/**
 * @author sim
 *
 */
public class VctToolView {

	abstract class VctToolViewSelectionAdapter extends SelectionAdapter
	{
		@Override
		public void widgetSelected(SelectionEvent event)
		{
			//tabFolderVcts.
			CTabItem tab = tabFolderVcts.getSelection();
			Vct vct = ((VctController)tab.getData()).getVct();
			
			fireEvent(vct);
		}
		
		protected abstract void fireEvent(Vct vct);
	}
	
	class SaveAdapter extends VctToolViewSelectionAdapter 
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireSaveEvent(vct);
		}
	}
	
	class SaveAsAdapter extends VctToolViewSelectionAdapter 
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireSaveAsEvent(vct);
		}
	}
	
	class BookAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingBookEvent(vct);
		}
		
	}
	
	class ExportXmlAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingExportXmlEvent(vct);
		}
	}
	
	class BookingRefreshStateAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingRefreshStateEvent(vct);
		}
	}
	
	class BookingShowStateAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingShowStateEvent(vct);
		}
	}
	
	class BookingCloneAsUnprovisionedAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingCloneUnprovisionedEvent(vct);
		}
	}
	
	class DeleteAdapter extends SelectionAdapter
	{
		
		@Override
		public void widgetSelected(SelectionEvent event)
		{
			CTabItem tab = tabFolderVcts.getSelection();
			VctView view = (VctView)tab.getControl();
			Vct vct = ((VctController)tab.getData()).getVct();
			
			fireDeleteVctEvent(vct, view, tab);
		}
		
	}

	class StartAdapter extends SelectionAdapter
	{
		
		@Override
		public void widgetSelected(SelectionEvent event)
		{
			CTabItem tab = tabFolderVcts.getSelection();
			VctView view = (VctView)tab.getControl();
			Vct vct = ((VctController)tab.getData()).getVct();
			
			fireStartVctEvent(vct, view, tab);
		}
		
	}


	class StopAdapter extends SelectionAdapter
	{
		
		@Override
		public void widgetSelected(SelectionEvent event)
		{
			CTabItem tab = tabFolderVcts.getSelection();
			VctView view = (VctView)tab.getControl();
			Vct vct = ((VctController)tab.getData()).getVct();
			
			fireStopVctEvent(vct, view, tab);
		}
		
	}

	private Shell shell;
	
	private SashForm sashForm;
	
	private CTabFolder tabFolderVcts;
	
	private CTabFolder tabFolderSelection;
	
	private Set<CommandListener> commandListeners = new CopyOnWriteArraySet<CommandListener>();
	private Set<BookingListener> bookingListeners = new CopyOnWriteArraySet<BookingListener>();
	
	
	public VctToolView() {
		
		Display display = new Display();
		shell = new Shell(display);
		shell.setText("Teagle VCT");
		shell.setSize(900, 500);
		
		GridLayout layout = new GridLayout(1, false);
		shell.setLayout(layout);

		shell.setImage(new Image(shell.getDisplay(), getClass().getResourceAsStream("/icons/openteagle.png")));
		
		shell.addShellListener(new ShellAdapter() {
			@Override
			public void shellClosed(ShellEvent event) {
				fireExitEvent(event.data);
			}
		});
		
		Menu mainMenu = new Menu(shell, SWT.BAR);
		shell.setMenuBar(mainMenu);

		MenuItem menuItemFile = new MenuItem(mainMenu, SWT.CASCADE);
		menuItemFile.setText("&File");
		
		Menu menuFile = createFileMenu();
		menuItemFile.setMenu(menuFile);<commit_msg>Renamed window<commit_after>/**
 * 
 */
package org.teagle.vcttool.view;

import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabFolder2Adapter;
import org.eclipse.swt.custom.CTabFolderEvent;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.teagle.vcttool.control.VctController;

import teagle.vct.model.Vct;

/**
 * @author sim
 *
 */
public class VctToolView {

	abstract class VctToolViewSelectionAdapter extends SelectionAdapter
	{
		@Override
		public void widgetSelected(SelectionEvent event)
		{
			//tabFolderVcts.
			CTabItem tab = tabFolderVcts.getSelection();
			Vct vct = ((VctController)tab.getData()).getVct();
			
			fireEvent(vct);
		}
		
		protected abstract void fireEvent(Vct vct);
	}
	
	class SaveAdapter extends VctToolViewSelectionAdapter 
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireSaveEvent(vct);
		}
	}
	
	class SaveAsAdapter extends VctToolViewSelectionAdapter 
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireSaveAsEvent(vct);
		}
	}
	
	class BookAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingBookEvent(vct);
		}
		
	}
	
	class ExportXmlAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingExportXmlEvent(vct);
		}
	}
	
	class BookingRefreshStateAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingRefreshStateEvent(vct);
		}
	}
	
	class BookingShowStateAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingShowStateEvent(vct);
		}
	}
	
	class BookingCloneAsUnprovisionedAdapter extends VctToolViewSelectionAdapter
	{
		@Override
		protected void fireEvent(Vct vct) 
		{
			fireBookingCloneUnprovisionedEvent(vct);
		}
	}
	
	class DeleteAdapter extends SelectionAdapter
	{
		
		@Override
		public void widgetSelected(SelectionEvent event)
		{
			CTabItem tab = tabFolderVcts.getSelection();
			VctView view = (VctView)tab.getControl();
			Vct vct = ((VctController)tab.getData()).getVct();
			
			fireDeleteVctEvent(vct, view, tab);
		}
		
	}

	class StartAdapter extends SelectionAdapter
	{
		
		@Override
		public void widgetSelected(SelectionEvent event)
		{
			CTabItem tab = tabFolderVcts.getSelection();
			VctView view = (VctView)tab.getControl();
			Vct vct = ((VctController)tab.getData()).getVct();
			
			fireStartVctEvent(vct, view, tab);
		}
		
	}


	class StopAdapter extends SelectionAdapter
	{
		
		@Override
		public void widgetSelected(SelectionEvent event)
		{
			CTabItem tab = tabFolderVcts.getSelection();
			VctView view = (VctView)tab.getControl();
			Vct vct = ((VctController)tab.getData()).getVct();
			
			fireStopVctEvent(vct, view, tab);
		}
		
	}

	private Shell shell;
	
	private SashForm sashForm;
	
	private CTabFolder tabFolderVcts;
	
	private CTabFolder tabFolderSelection;
	
	private Set<CommandListener> commandListeners = new CopyOnWriteArraySet<CommandListener>();
	private Set<BookingListener> bookingListeners = new CopyOnWriteArraySet<BookingListener>();
	
	
	public VctToolView() {
		
		Display display = new Display();
		shell = new Shell(display);
		shell.setText("OpenTeagle Controller | VCTTool");
		shell.setSize(900, 500);
		
		GridLayout layout = new GridLayout(1, false);
		shell.setLayout(layout);

		shell.setImage(new Image(shell.getDisplay(), getClass().getResourceAsStream("/icons/openteagle.png")));
		
		shell.addShellListener(new ShellAdapter() {
			@Override
			public void shellClosed(ShellEvent event) {
				fireExitEvent(event.data);
			}
		});
		
		Menu mainMenu = new Menu(shell, SWT.BAR);
		shell.setMenuBar(mainMenu);

		MenuItem menuItemFile = new MenuItem(mainMenu, SWT.CASCADE);
		menuItemFile.setText("&File");
		
		Menu menuFile = createFileMenu();
		menuItemFile.setMenu(menuFile);
{'fraction_non_alphanumeric': 0.10242221758195866, 'fraction_numerical': 0.0016704948841094174, 'mean_word_length': 4.524221453287197, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4149547', 'n_tokens_mistral': 3570, 'n_tokens_neox': 3132, 'n_words': 581}