<commit_before>/*
 * eXist Open Source Native XML Database
 *
 * Copyright (C) 2001-06 <NAME> <EMAIL>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id:$
 */
package org.exist.client;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;

import javax.swing.Box;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

import org.exist.storage.DBBroker;
import org.exist.xmldb.XmldbURI;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.XMLDBException;

/**
 * Dialog for viewing and editing Triggers in the Admin Client 
 * 
 * @author <NAME> <<EMAIL>>
 * @serial 2006-08-25
 * @version 1.0
 */
class TriggersDialog extends JFrame {
	
	private CollectionXConf cx = null;
	
	private JComboBox cmbCollections;
	
	private JTable tblTriggers;
	private TriggersTableModel triggersModel;
	private TableColumn colStoreDocument;
	private TableColumn colUpdateDocument;
	private TableColumn colRemoveDocument;
	private TableColumn colCreateCollection;
	private TableColumn colRenameCollection;
	private TableColumn colDeleteCollection;
	
	private InteractiveClient client;
	
	
	public TriggersDialog(String title, InteractiveClient client) 
	{
		super(title);
		this.client = client;
		
		this.setPreferredSize(new Dimension(500, 300));
		
		//capture the frame's close event
		WindowListener windowListener = new WindowAdapter()
		{
			public void windowClosing (WindowEvent e)
			{
				saveChanges();
				
				TriggersDialog.this.setVisible(false);
				TriggersDialog.this.dispose();
			}
		};
		this.addWindowListener(windowListener);
		
		//draw the GUI
		setupComponents();
		
		JTableHeader tblTriggersHeader = tblTriggers.getTableHeader();
       	tblTriggersHeader.setPreferredSize(new Dimension(tblTriggersHeader.getWidth(), tblTriggersHeader.getHeight() * 2));
		
		//Get the indexes for the root collection
		actionGetTriggers(DBBroker.ROOT_COLLECTION);
	}

	private void setupComponents()
	{
		//Dialog Content Panel
		GridBagLayout grid = new GridBagLayout();
		getContentPane().setLayout(grid);
		
		//Constraints for Layout<commit_msg>Fixed JDK 1.4 incompatibility<commit_after>/*
 * eXist Open Source Native XML Database
 *
 * Copyright (C) 2001-06 <NAME> <EMAIL>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id:$
 */
package org.exist.client;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;

import javax.swing.Box;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

import org.exist.storage.DBBroker;
import org.exist.xmldb.XmldbURI;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.XMLDBException;

/**
 * Dialog for viewing and editing Triggers in the Admin Client 
 * 
 * @author <NAME> <<EMAIL>>
 * @serial 2006-08-25
 * @version 1.0
 */
class TriggersDialog extends JFrame {
	
	private CollectionXConf cx = null;
	
	private JComboBox cmbCollections;
	
	private JTable tblTriggers;
	private TriggersTableModel triggersModel;
	private TableColumn colStoreDocument;
	private TableColumn colUpdateDocument;
	private TableColumn colRemoveDocument;
	private TableColumn colCreateCollection;
	private TableColumn colRenameCollection;
	private TableColumn colDeleteCollection;
	
	private InteractiveClient client;
	
	
	public TriggersDialog(String title, InteractiveClient client) 
	{
		super(title);
		this.client = client;
		
		this.setSize(new Dimension(500, 300));
		
		//capture the frame's close event
		WindowListener windowListener = new WindowAdapter()
		{
			public void windowClosing (WindowEvent e)
			{
				saveChanges();
				
				TriggersDialog.this.setVisible(false);
				TriggersDialog.this.dispose();
			}
		};
		this.addWindowListener(windowListener);
		
		//draw the GUI
		setupComponents();
		
		JTableHeader tblTriggersHeader = tblTriggers.getTableHeader();
       	tblTriggersHeader.setPreferredSize(new Dimension(tblTriggersHeader.getWidth(), tblTriggersHeader.getHeight() * 2));
		
		//Get the indexes for the root collection
		actionGetTriggers(DBBroker.ROOT_COLLECTION);
	}

	private void setupComponents()
	{
		//Dialog Content Panel
		GridBagLayout grid = new GridBagLayout();
		getContentPane().setLayout(grid);
		
		//Constraints for Layout
{'fraction_non_alphanumeric': 0.08539866874380399, 'fraction_numerical': 0.009347117971958646, 'mean_word_length': 4.699757869249395, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '7545170', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2018, 'n_words': 622}