<commit_before> /**********************************************************************
 **                                                                   **
 **               This code belongs to the KETTLE project.            **
 **                                                                   **
 ** Kettle, from version 2.2 on, is released into the public domain   **
 ** under the Lesser GNU Public License (LGPL).                       **
 **                                                                   **
 ** For more details, please read the document LICENSE.txt, included  **
 ** in this project                                                   **
 **                                                                   **
 ** http://www.kettle.be                                              **
 ** <EMAIL>                                                    **
 **                                                                   **
 **********************************************************************/

 


package be.ibridge.kettle.core.dialog;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
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.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
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.Tree;
import org.eclipse.swt.widgets.TreeItem;

import be.ibridge.kettle.core.Const;
import be.ibridge.kettle.core.DBCache;
import be.ibridge.kettle.core.LogWriter;
import be.ibridge.kettle.core.Props;
import be.ibridge.kettle.core.Row;
import be.ibridge.kettle.core.WindowProperty;
import be.ibridge.kettle.core.database.Catalog;
import be.ibridge.kettle.core.database.Database;
import be.ibridge.kettle.core.database.DatabaseMeta;
import be.ibridge.kettle.core.database.DatabaseMetaInformation;
import be.ibridge.kettle.core.database.Schema;
import be.ibridge.kettle.core.exception.KettleDatabaseException;
import be.ibridge.kettle.test.EditDatabaseTable;
import be.ibridge.kettle.trans.step.BaseStepDialog;


/**
 * This dialog represents an explorer type of interface on a given database connection.
 * It shows the tables defined in the visible schemas or catalogs on that connection.
 * The interface also allows you to get all kinds of information on those tables.
 * 
 * @author Matt
 * @since 18-05-2003
 *
 */
public class DatabaseExplorerDialog extends Dialog 
{
	private LogWriter log;
	private Props props;
	private DatabaseMeta dbMeta;
	private DBCache dbcache;
	
	private static final String STRING_CATALOG  = Messages.getString("DatabaseExplorerDialog.Catalogs.Label");
	private static final String STRING_SCHEMAS  = Messages.getString("DatabaseExplorerDialog.Schemas.Label");
	private static final String STRING_TABLES   = Messages.getString("DatabaseExplorerDialog.Tables.Label");
	private static final String STRING_VIEWS    = Messages.getString("DatabaseExplorerDialog.Views.Label");
	private static final String STRING_SYNONYMS = Messages.getString("DatabaseExplorerDialog.Synonyms.Label");
	
	private Shell     shell;
	private Tree      wTree;
	private TreeItem  tiTree;
	 
	private Button    wOK;
	private Button    wRefresh;
	private Button    wCancel;
	
	/** This is the return value*/
	private String    tableName; 
	
	private boolean justLook;
    private String  selectedSchema;
	private String  selectedTable;
	private List    databases;
    private boolean splitSchemaAndTable;
    private String schemaName;
    private Composite buttonsComposite;
    private Button bPrev;
    private Button bPrevN;
    private Button bCount;
    private Button bShow;
    private Button bDDL;
    private Button bDDL2;
    private Button bSQL;
    private String activeSchemaTable;
    private Button bTruncate;

    /** @deprecated */
    public DatabaseExplorerDialog(Shell par, Props pr, int style, DatabaseMeta conn, ArrayList databases)
    {
        this(par, style, conn, (List)databases);
    }

    /** @deprecated */
    public DatabaseExplorerDialog(Shell par, Props pr, int style, DatabaseMeta conn, List databases)
    {
        this(par, style, conn, databases);
    }

    /** @deprecated */
    public DatabaseExplorerDialog(Shell par, Props pr, int style, DatabaseMeta conn, ArrayList databases, boolean look)
    {
        this(par, style, conn, databases, look);
    }
    
    /** @deprecated */
    public DatabaseExplorerDialog(Shell par, Props pr, int style, DatabaseMeta conn, List databases, boolean look)
    {
        this(par, style, conn, databases, look);
    }
    
	public DatabaseExplorerDialog(Shell par, int style, DatabaseMeta conn, List databases)
	{
		this(par, style, conn, databases, false, false);
	}

    public DatabaseExplorerDialog(Shell par, int style, DatabaseMeta conn, List databases, boolean look)
    {
        this(par, style, conn, databases, look, false);
    }
    
    public DatabaseExplorerDialog(Shell par, int style, DatabaseMeta conn, List databases, boolean look, boolean splitSchemaAndTable)
    {
        super(par, style);
        this.dbMeta=conn;
        this.databases = databases;
        this.justLook=look;
        this.splitSchemaAndTable = splitSchemaAndTable;
                
        selectedSchema=null;
        selectedTable=null;
    
        props=Props.getInstance();
        log=LogWriter.getInstance();
        dbcache = DBCache.getInstance();
        
    }

	public void setSelectedTable(String selectedTable)
	{
		this.selectedTable = selectedTable;
	}
	
	public Object open() 
	{
		tableName = null;

		Shell parent = getParent();
		shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
 		props.setLook(shell);
		shell.setText(Messages.getString("DatabaseExplorerDialog.Title", dbMeta.toString()));
		
		FormLayout formLayout = new FormLayout ();
		formLayout.marginWidth  = Const.FORM_MARGIN;
		formLayout.marginHeight = Const.FORM_MARGIN;
		
		shell.setLayout (formLayout);
 		
        addButtons();
        refreshButtons(null);
        
 		// Tree
 		wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER /*| (multiple?SWT.CHECK:SWT.NONE)*/);
 		props.setLook( 		wTree);
 				
		if (!getData()) return null;
 		
 		// Buttons
		wOK = new Button(shell, SWT.PUSH); 
		wOK.setText(Messages.getString("System.Button.OK"));

		wRefresh = new Button(shell, SWT.PUSH); 
		wRefresh.setText(Messages.getString("System.Button.Refresh"));
		
		if (!justLook) <commit_msg>CRQ5280<commit_after> /**********************************************************************
 **                                                                   **
 **               This code belongs to the KETTLE project.            **
 **                                                                   **
 ** Kettle, from version 2.2 on, is released into the public domain   **
 ** under the Lesser GNU Public License (LGPL).                       **
 **                                                                   **
 ** For more details, please read the document LICENSE.txt, included  **
 ** in this project                                                   **
 **                                                                   **
 ** http://www.kettle.be                                              **
 ** <EMAIL>                                                    **
 **                                                                   **
 **********************************************************************/

 


package be.ibridge.kettle.core.dialog;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.SWT;
import be.ibridge.kettle.core.GUIResource;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
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.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
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.Tree;
import org.eclipse.swt.widgets.TreeItem;

import be.ibridge.kettle.core.Const;
import be.ibridge.kettle.core.DBCache;
import be.ibridge.kettle.core.LogWriter;
import be.ibridge.kettle.core.Props;
import be.ibridge.kettle.core.Row;
import be.ibridge.kettle.core.WindowProperty;
import be.ibridge.kettle.core.database.Catalog;
import be.ibridge.kettle.core.database.Database;
import be.ibridge.kettle.core.database.DatabaseMeta;
import be.ibridge.kettle.core.database.DatabaseMetaInformation;
import be.ibridge.kettle.core.database.Schema;
import be.ibridge.kettle.core.exception.KettleDatabaseException;
import be.ibridge.kettle.test.EditDatabaseTable;
import be.ibridge.kettle.trans.step.BaseStepDialog;


/**
 * This dialog represents an explorer type of interface on a given database connection.
 * It shows the tables defined in the visible schemas or catalogs on that connection.
 * The interface also allows you to get all kinds of information on those tables.
 * 
 * @author Matt
 * @since 18-05-2003
 *
 */
public class DatabaseExplorerDialog extends Dialog 
{
	private LogWriter log;
	private Props props;
	private DatabaseMeta dbMeta;
	private DBCache dbcache;
	
	private static final String STRING_CATALOG  = Messages.getString("DatabaseExplorerDialog.Catalogs.Label");
	private static final String STRING_SCHEMAS  = Messages.getString("DatabaseExplorerDialog.Schemas.Label");
	private static final String STRING_TABLES   = Messages.getString("DatabaseExplorerDialog.Tables.Label");
	private static final String STRING_VIEWS    = Messages.getString("DatabaseExplorerDialog.Views.Label");
	private static final String STRING_SYNONYMS = Messages.getString("DatabaseExplorerDialog.Synonyms.Label");
	
	private Shell     shell;
	private Tree      wTree;
	private TreeItem  tiTree;
	 
	private Button    wOK;
	private Button    wRefresh;
	private Button    wCancel;
	
	/** This is the return value*/
	private String    tableName; 
	
	private boolean justLook;
    private String  selectedSchema;
	private String  selectedTable;
	private List    databases;
    private boolean splitSchemaAndTable;
    private String schemaName;
    private Composite buttonsComposite;
    private Button bPrev;
    private Button bPrevN;
    private Button bCount;
    private Button bShow;
    private Button bDDL;
    private Button bDDL2;
    private Button bSQL;
    private String activeSchemaTable;
    private Button bTruncate;

    /** @deprecated */
    public DatabaseExplorerDialog(Shell par, Props pr, int style, DatabaseMeta conn, ArrayList databases)
    {
        this(par, style, conn, (List)databases);
    }

    /** @deprecated */
    public DatabaseExplorerDialog(Shell par, Props pr, int style, DatabaseMeta conn, List databases)
    {
        this(par, style, conn, databases);
    }

    /** @deprecated */
    public DatabaseExplorerDialog(Shell par, Props pr, int style, DatabaseMeta conn, ArrayList databases, boolean look)
    {
        this(par, style, conn, databases, look);
    }
    
    /** @deprecated */
    public DatabaseExplorerDialog(Shell par, Props pr, int style, DatabaseMeta conn, List databases, boolean look)
    {
        this(par, style, conn, databases, look);
    }
    
	public DatabaseExplorerDialog(Shell par, int style, DatabaseMeta conn, List databases)
	{
		this(par, style, conn, databases, false, false);
	}

    public DatabaseExplorerDialog(Shell par, int style, DatabaseMeta conn, List databases, boolean look)
    {
        this(par, style, conn, databases, look, false);
    }
    
    public DatabaseExplorerDialog(Shell par, int style, DatabaseMeta conn, List databases, boolean look, boolean splitSchemaAndTable)
    {
        super(par, style);
        this.dbMeta=conn;
        this.databases = databases;
        this.justLook=look;
        this.splitSchemaAndTable = splitSchemaAndTable;
                
        selectedSchema=null;
        selectedTable=null;
    
        props=Props.getInstance();
        log=LogWriter.getInstance();
        dbcache = DBCache.getInstance();
        
    }

	public void setSelectedTable(String selectedTable)
	{
		this.selectedTable = selectedTable;
	}
	
	public Object open() 
	{
		tableName = null;

		Shell parent = getParent();
		shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
 		props.setLook(shell);
		shell.setImage(GUIResource.getInstance().getImageConnection());

		shell.setText(Messages.getString("DatabaseExplorerDialog.Title", dbMeta.toString()));
		
		FormLayout formLayout = new FormLayout ();
		formLayout.marginWidth  = Const.FORM_MARGIN;
		formLayout.marginHeight = Const.FORM_MARGIN;
		
		shell.setLayout (formLayout);
 		
        addButtons();
        refreshButtons(null);
        
 		// Tree
 		wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER /*| (multiple?SWT.CHECK:SWT.NONE)*/);
 		props.setLook( 		wTree);
 				
		if (!getData()) return null;
 		
 		// Buttons
		wOK = new Button(shell, SWT.PUSH); 
		wOK.setText(Messages.getString("System.Button.OK"));

		wRefresh = new Button(shell, SWT.PUSH); 
		wRefresh.setText(Messages.getString("System.Button.Refresh"));
		
		if (!justLook) 
{'fraction_non_alphanumeric': 0.11391426563598032, 'fraction_numerical': 0.0018271257905832748, 'mean_word_length': 2.8214285714285716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5998957', 'n_tokens_mistral': 4133, 'n_tokens_neox': 3869, 'n_words': 953}