<commit_before>package ch.elexis.core.ui.views;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar;
import org.slf4j.LoggerFactory;

import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.ui.icons.Images;
import ch.elexis.core.ui.text.Messages;
import ch.elexis.core.ui.util.viewers.DefaultLabelProvider;
import ch.elexis.data.Anwender;
import ch.elexis.data.PersistentObject;
import ch.elexis.data.dto.MakroDTO;
import ch.rgw.io.SqlSettings;
import ch.rgw.tools.JdbcLink;

public class MakrosComposite extends Composite {
	
	private TableViewer viewer;
	private MakroDetailComposite detailComposite;
	
	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public MakrosComposite(Composite parent, int style){
		super(parent, style);
		setLayout(new GridLayout(1, false));
		
		CLabel lblHeader = new CLabel(this, SWT.NONE);
		lblHeader.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		lblHeader.setText("Makros des Anwender " + CoreHub.getLoggedInContact().getLabel());

		
		SashForm sash = new SashForm(this, SWT.HORIZONTAL);
		sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		Composite selectionComposite = new Composite(sash, SWT.NONE);
		selectionComposite.setLayout(new GridLayout(1, true));
		ToolBarManager toolbar = new ToolBarManager();
		ToolBar toolbarControl = toolbar.createControl(selectionComposite);
		toolbarControl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
		
		viewer = new TableViewer(selectionComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
		viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		viewer.setContentProvider(new ArrayContentProvider());
		viewer.setLabelProvider(new DefaultLabelProvider());
		viewer.setInput(getUserMakros(CoreHub.getLoggedInContact()));
		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
			@Override
			public void selectionChanged(SelectionChangedEvent event){
				StructuredSelection selection = (StructuredSelection) viewer.getSelection();
				if (selection != null && !selection.isEmpty()) {
					detailComposite.setMakro((MakroDTO) selection.getFirstElement());
				} else {
					detailComposite.setMakro(null);
				}
			}
		});
		viewer.setComparator(new ViewerComparator());
		
		MenuManager menuManager = new MenuManager();
		menuManager.add(new RemoveMakroAction(viewer));
		MenuManager subMenu = new MenuManager("Marko zu Anwender kopieren");
		subMenu.setRemoveAllWhenShown(true);
		subMenu.addMenuListener(new IMenuListener() {
			@Override
			public void menuAboutToShow(IMenuManager manager){
				addCopyToUserActions(manager);<commit_msg>[20685] Fix typo in MakrosComposite<commit_after>package ch.elexis.core.ui.views;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar;
import org.slf4j.LoggerFactory;

import ch.elexis.core.data.activator.CoreHub;
import ch.elexis.core.ui.icons.Images;
import ch.elexis.core.ui.text.Messages;
import ch.elexis.core.ui.util.viewers.DefaultLabelProvider;
import ch.elexis.data.Anwender;
import ch.elexis.data.PersistentObject;
import ch.elexis.data.dto.MakroDTO;
import ch.rgw.io.SqlSettings;
import ch.rgw.tools.JdbcLink;

public class MakrosComposite extends Composite {
	
	private TableViewer viewer;
	private MakroDetailComposite detailComposite;
	
	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public MakrosComposite(Composite parent, int style){
		super(parent, style);
		setLayout(new GridLayout(1, false));
		
		CLabel lblHeader = new CLabel(this, SWT.NONE);
		lblHeader.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		lblHeader.setText("Makros des Anwender " + CoreHub.getLoggedInContact().getLabel());

		
		SashForm sash = new SashForm(this, SWT.HORIZONTAL);
		sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		Composite selectionComposite = new Composite(sash, SWT.NONE);
		selectionComposite.setLayout(new GridLayout(1, true));
		ToolBarManager toolbar = new ToolBarManager();
		ToolBar toolbarControl = toolbar.createControl(selectionComposite);
		toolbarControl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
		
		viewer = new TableViewer(selectionComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
		viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		viewer.setContentProvider(new ArrayContentProvider());
		viewer.setLabelProvider(new DefaultLabelProvider());
		viewer.setInput(getUserMakros(CoreHub.getLoggedInContact()));
		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
			@Override
			public void selectionChanged(SelectionChangedEvent event){
				StructuredSelection selection = (StructuredSelection) viewer.getSelection();
				if (selection != null && !selection.isEmpty()) {
					detailComposite.setMakro((MakroDTO) selection.getFirstElement());
				} else {
					detailComposite.setMakro(null);
				}
			}
		});
		viewer.setComparator(new ViewerComparator());
		
		MenuManager menuManager = new MenuManager();
		menuManager.add(new RemoveMakroAction(viewer));
		MenuManager subMenu = new MenuManager("Makro zu Anwender kopieren");
		subMenu.setRemoveAllWhenShown(true);
		subMenu.addMenuListener(new IMenuListener() {
			@Override
			public void menuAboutToShow(IMenuManager manager){
				addCopyToUserActions(manager);
{'fraction_non_alphanumeric': 0.11227890284542424, 'fraction_numerical': 0.002435273006921302, 'mean_word_length': 5.802964254577158, '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': '3837340', 'n_tokens_mistral': 2700, 'n_tokens_neox': 2535, 'n_words': 437}