<commit_before>package be.ibridge.kettle.core.dialog;

import org.eclipse.swt.SWT;
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.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import be.ibridge.kettle.core.Const;
import be.ibridge.kettle.core.Props;
import be.ibridge.kettle.core.WindowProperty;
import be.ibridge.kettle.trans.step.BaseStepDialog;

public class EnterSearchDialog
{
    private static final Props props = Props.getInstance();
    private Shell parentShell;
    private Shell shell;
    
    private boolean retval;
    private Display display;
    
    private boolean searchingSteps;
    private boolean searchingDatabases;
    private boolean searchingNotes;
    private String  filterString;
    
    private Label   wlStep;
    private Button  wStep;

    private Label   wlDB;
    private Button  wDB;
    private Label   wlNote;
    private Button  wNote;

    private Label   wlFilter;
    private Text    wFilter;

    public EnterSearchDialog(Shell parentShell)
    {
        this.parentShell = parentShell;
        this.display = parentShell.getDisplay();
        
        retval=true;
        
        searchingSteps     = true;
        searchingDatabases = true;
        searchingNotes     = true;
    }

    public boolean open()
    {
        shell = new Shell(parentShell,  SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
        props.setLook(shell);
        shell.setText(Messages.getString("EnterSearchDialog.Shell.Title"));
        
        FormLayout formLayout = new FormLayout ();
        formLayout.marginWidth  = Const.FORM_MARGIN;
        formLayout.marginHeight = Const.FORM_MARGIN;
        shell.setLayout(formLayout);

        int middle = props.getMiddlePct();
        int margin = Const.MARGIN;
        
        // Search Steps?...
        wlStep=new Label(shell, SWT.RIGHT);
        wlStep.setText(Messages.getString("EnterSearchDialog.Step.Label"));
        props.setLook(wlStep);
        FormData fdlStep=new FormData();
        fdlStep.left = new FormAttachment(0, 0);
        fdlStep.top  = new FormAttachment(0, 0);
        fdlStep.right= new FormAttachment(middle, -margin);
        wlStep.setLayoutData(fdlStep);
        
        wStep=new Button(shell, SWT.CHECK );
        props.setLook(wStep);
        wStep.setToolTipText(Messages.getString("EnterSearchDialog.Step.Tooltip"));
        FormData fdStep=new FormData();
        fdStep.left = new FormAttachment(middle, 0);
        fdStep.top  = new FormAttachment(0, 0);
        fdStep.right= new FormAttachment(100, 0);
        wStep.setLayoutData(fdStep);

        // Search databases...
        wlDB=new Label(shell, SWT.RIGHT);
        wlDB.setText(Messages.getString("EnterSearchDialog.DB.Label"));
        props.setLook(wlDB);
        FormData fdlDB=new FormData();
        fdlDB.left = new FormAttachment(0, 0);
        fdlDB.top  = new FormAttachment(wStep, margin);
        fdlDB.right= new FormAttachment(middle, -margin);
        wlDB.setLayoutData(fdlDB);
        wDB=new Button(shell, SWT.CHECK );
        props.setLook(wDB);
        wDB.setToolTipText(Messages.getString("EnterSearchDialog.DB.Tooltip"));
        FormData fdDB=new FormData();
        fdDB.left = new FormAttachment(middle, 0);
        fdDB.top  = new FormAttachment(wStep, margin);
        fdDB.right= new FormAttachment(100, 0);
        wDB.setLayoutData(fdDB);

        // Search notes...
        wlNote=new Label(shell, SWT.RIGHT);
        wlNote.setText(Messages.getString("EnterSearchDialog.Note.Label"));
        props.setLook(wlNote);
        FormData fdlNote=new FormData();
        fdlNote.left = new FormAttachment(0, 0);
        fdlNote.top  = new FormAttachment(wDB, margin);
        fdlNote.right= new FormAttachment(middle, -margin);
        wlNote.setLayoutData(fdlNote);
        wNote=new Button(shell, SWT.CHECK );
        props.setLook(wNote);
        wNote.setToolTipText(Messages.getString("EnterSearchDialog.Note.Tooltip"));
        FormData fdNote=new FormData();
        fdNote.left = new FormAttachment(middle, 0);
        fdNote.top  = new FormAttachment(wDB, margin);
        fdNote.right= new FormAttachment(100, 0);
        wNote.setLayoutData(fdNote);

        // Filter line
        wlFilter=new Label(shell, SWT.RIGHT);
        wlFilter.setText(Messages.getString("EnterSearchDialog.FilterSelection.Label")); //Select filter 
        props.setLook(wlFilter);
        FormData fdlFilter=new FormData();
        fdlFilter.left = new FormAttachment(0, 0);
        fdlFilter.right= new FormAttachment(middle, -margin);
        fdlFilter.top  = new FormAttachment(wNote, 3*margin);
        wlFilter.setLayoutData(fdlFilter);
        wFilter=new Text(shell, SWT.SINGLE | SWT.BORDER);
        props.setLook(wFilter);
        FormData fdFilter=new FormData();
        fdFilter.left = new FormAttachment(middle, 0);
        fdFilter.top  = new FormAttachment(wNote, 3*margin);
        fdFilter.right= new FormAttachment(100, 0);
        wFilter.setLayoutData(fdFilter);

        Button wOK = new Button(shell, SWT.PUSH);
        wOK.setText(Messages.getString("System.Button.OK"));
        wOK.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ok(); } } );
        
        Button wCancel = new Button(shell, SWT.PUSH);
        wCancel.setText(Messages.getString("System.Button.Cancel"));
        wCancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { cancel(); } } );
        
        BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, Const.MARGIN, null);
        
        // Detect X or ALT-F4 or something that kills this window...
        shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { dispose(); } } );
        SelectionAdapter lsDef=new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } };
        
        wFilter.addSelectionListener( lsDef );
        
        getData();
        
		BaseStepDialog.setSize(shell);
<commit_msg>Cancel should cancel, not dispose.<commit_after>package be.ibridge.kettle.core.dialog;

import org.eclipse.swt.SWT;
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.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import be.ibridge.kettle.core.Const;
import be.ibridge.kettle.core.Props;
import be.ibridge.kettle.core.WindowProperty;
import be.ibridge.kettle.trans.step.BaseStepDialog;

public class EnterSearchDialog
{
    private static final Props props = Props.getInstance();
    private Shell parentShell;
    private Shell shell;
    
    private boolean retval;
    private Display display;
    
    private boolean searchingSteps;
    private boolean searchingDatabases;
    private boolean searchingNotes;
    private String  filterString;
    
    private Label   wlStep;
    private Button  wStep;

    private Label   wlDB;
    private Button  wDB;
    private Label   wlNote;
    private Button  wNote;

    private Label   wlFilter;
    private Text    wFilter;

    public EnterSearchDialog(Shell parentShell)
    {
        this.parentShell = parentShell;
        this.display = parentShell.getDisplay();
        
        retval=true;
        
        searchingSteps     = true;
        searchingDatabases = true;
        searchingNotes     = true;
    }

    public boolean open()
    {
        shell = new Shell(parentShell,  SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
        props.setLook(shell);
        shell.setText(Messages.getString("EnterSearchDialog.Shell.Title"));
        
        FormLayout formLayout = new FormLayout ();
        formLayout.marginWidth  = Const.FORM_MARGIN;
        formLayout.marginHeight = Const.FORM_MARGIN;
        shell.setLayout(formLayout);

        int middle = props.getMiddlePct();
        int margin = Const.MARGIN;
        
        // Search Steps?...
        wlStep=new Label(shell, SWT.RIGHT);
        wlStep.setText(Messages.getString("EnterSearchDialog.Step.Label"));
        props.setLook(wlStep);
        FormData fdlStep=new FormData();
        fdlStep.left = new FormAttachment(0, 0);
        fdlStep.top  = new FormAttachment(0, 0);
        fdlStep.right= new FormAttachment(middle, -margin);
        wlStep.setLayoutData(fdlStep);
        
        wStep=new Button(shell, SWT.CHECK );
        props.setLook(wStep);
        wStep.setToolTipText(Messages.getString("EnterSearchDialog.Step.Tooltip"));
        FormData fdStep=new FormData();
        fdStep.left = new FormAttachment(middle, 0);
        fdStep.top  = new FormAttachment(0, 0);
        fdStep.right= new FormAttachment(100, 0);
        wStep.setLayoutData(fdStep);

        // Search databases...
        wlDB=new Label(shell, SWT.RIGHT);
        wlDB.setText(Messages.getString("EnterSearchDialog.DB.Label"));
        props.setLook(wlDB);
        FormData fdlDB=new FormData();
        fdlDB.left = new FormAttachment(0, 0);
        fdlDB.top  = new FormAttachment(wStep, margin);
        fdlDB.right= new FormAttachment(middle, -margin);
        wlDB.setLayoutData(fdlDB);
        wDB=new Button(shell, SWT.CHECK );
        props.setLook(wDB);
        wDB.setToolTipText(Messages.getString("EnterSearchDialog.DB.Tooltip"));
        FormData fdDB=new FormData();
        fdDB.left = new FormAttachment(middle, 0);
        fdDB.top  = new FormAttachment(wStep, margin);
        fdDB.right= new FormAttachment(100, 0);
        wDB.setLayoutData(fdDB);

        // Search notes...
        wlNote=new Label(shell, SWT.RIGHT);
        wlNote.setText(Messages.getString("EnterSearchDialog.Note.Label"));
        props.setLook(wlNote);
        FormData fdlNote=new FormData();
        fdlNote.left = new FormAttachment(0, 0);
        fdlNote.top  = new FormAttachment(wDB, margin);
        fdlNote.right= new FormAttachment(middle, -margin);
        wlNote.setLayoutData(fdlNote);
        wNote=new Button(shell, SWT.CHECK );
        props.setLook(wNote);
        wNote.setToolTipText(Messages.getString("EnterSearchDialog.Note.Tooltip"));
        FormData fdNote=new FormData();
        fdNote.left = new FormAttachment(middle, 0);
        fdNote.top  = new FormAttachment(wDB, margin);
        fdNote.right= new FormAttachment(100, 0);
        wNote.setLayoutData(fdNote);

        // Filter line
        wlFilter=new Label(shell, SWT.RIGHT);
        wlFilter.setText(Messages.getString("EnterSearchDialog.FilterSelection.Label")); //Select filter 
        props.setLook(wlFilter);
        FormData fdlFilter=new FormData();
        fdlFilter.left = new FormAttachment(0, 0);
        fdlFilter.right= new FormAttachment(middle, -margin);
        fdlFilter.top  = new FormAttachment(wNote, 3*margin);
        wlFilter.setLayoutData(fdlFilter);
        wFilter=new Text(shell, SWT.SINGLE | SWT.BORDER);
        props.setLook(wFilter);
        FormData fdFilter=new FormData();
        fdFilter.left = new FormAttachment(middle, 0);
        fdFilter.top  = new FormAttachment(wNote, 3*margin);
        fdFilter.right= new FormAttachment(100, 0);
        wFilter.setLayoutData(fdFilter);

        Button wOK = new Button(shell, SWT.PUSH);
        wOK.setText(Messages.getString("System.Button.OK"));
        wOK.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ok(); } } );
        
        Button wCancel = new Button(shell, SWT.PUSH);
        wCancel.setText(Messages.getString("System.Button.Cancel"));
        wCancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { cancel(); } } );
        
        BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, Const.MARGIN, null);
        
        // Detect X or ALT-F4 or something that kills this window...
        shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } } );
        SelectionAdapter lsDef=new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } };
        
        wFilter.addSelectionListener( lsDef );
        
        getData();
        
		BaseStepDialog.setSize(shell);

{'fraction_non_alphanumeric': 0.10949131513647643, 'fraction_numerical': 0.005428039702233251, 'mean_word_length': 2.875300480769231, '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': '5392712', 'n_tokens_mistral': 3886, 'n_tokens_neox': 3803, 'n_words': 754}