<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package org.apache.jmeter.protocol.ldap.config.gui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.Iterator;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableCellEditor;

import org.apache.jmeter.config.gui.AbstractConfigGui;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.ObjectTableModel;
import org.apache.jorphan.reflect.Functor;

/**
 * A GUI panel allowing the user to enter name-value argument pairs. These
 * arguments (or parameters) are usually used to provide configuration values
 * for some other component.
 * 
 * author <NAME>(<EMAIL>) created Aug 09 2003 11:00 AM
 * company Siemens Netherlands N.V..
 * 
 * Based on the work of:
 * 
 * author <NAME>
 */

public class LDAPArgumentsPanel extends AbstractConfigGui implements ActionListener {
	/** Logging. */
	//private static final Logger log = LoggingManager.getLoggerForClass();

	/** The title label for this component. */
	private JLabel tableLabel;

	/** The table containing the list of arguments. */
	private transient JTable table;

	/** The model for the arguments table. */
	protected transient ObjectTableModel tableModel;

	/** A button for adding new arguments to the table. */
	private JButton add;

	/** A button for removing arguments from the table. */
	private JButton delete;

	/** Command for adding a row to the table. */
	private static final String ADD = "add"; //$NON-NLS-1$

	/** Command for removing a row from the table. */
	private static final String DELETE = "delete"; //$NON-NLS-1$

	private static final String[] COLUMN_NAMES = {
		    JMeterUtils.getResString("attribute"), //$NON-NLS-1$
			JMeterUtils.getResString("value"),  //$NON-NLS-1$
			JMeterUtils.getResString("opcode"),  //$NON-NLS-1$
			JMeterUtils.getResString("metadata") }; //$NON-NLS-1$

	/**
	 * Create a new LDAPArgumentsPanel, using the default title.
	 */
	public LDAPArgumentsPanel() {
		this(JMeterUtils.getResString("paramtable")); //$NON-NLS-1$
	}

	/**
	 * Create a new LDAPArgumentsPanel, using the specified title.
	 * 
	 * @param label
	 *            the title of the component
	 */
	public LDAPArgumentsPanel(String label) {
		tableLabel = new JLabel(label);
		init();
	}

	/**
	 * This is the list of menu categories this gui component will be available
	 * under. The LDAPArgumentsPanel is not intended to be used as a standalone
	 * component, so this inplementation returns null.
	 * 
	 * @return a Collection of Strings, where each element is one of the
	 *         constants defined in MenuFactory
	 */
	public Collection getMenuCategories() {
		return null;
	}

	public String getStaticLabel() {
		return ""; // This is not an independently displayable item
	}

	public String getLabelResource() {
		return "unused";// TODO use constant
	}

	/* Implements JMeterGUIComponent.createTestElement() */
	public TestElement createTestElement() {
		LDAPArguments args = new LDAPArguments();
		modifyTestElement(args);
		// TODO: Why do we clone the return value? This is the only reference
		// to it (right?) so we shouldn't need a separate copy.
		return (TestElement) args.clone();
	}

	/* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
	public void modifyTestElement(TestElement args) {
		stopTableEditing();
		Iterator modelData = tableModel.iterator();
		LDAPArguments arguments = null;
		if (args instanceof LDAPArguments) {
			arguments = (LDAPArguments) args;<commit_msg>Use same label as parent GUI (not used except for testing)<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package org.apache.jmeter.protocol.ldap.config.gui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.Iterator;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableCellEditor;

import org.apache.jmeter.config.gui.AbstractConfigGui;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.ObjectTableModel;
import org.apache.jorphan.reflect.Functor;

/**
 * A GUI panel allowing the user to enter name-value argument pairs. These
 * arguments (or parameters) are usually used to provide configuration values
 * for some other component.
 * 
 */

public class LDAPArgumentsPanel extends AbstractConfigGui implements ActionListener {
	/** Logging. */
	//private static final Logger log = LoggingManager.getLoggerForClass();

	/** The title label for this component. */
	private JLabel tableLabel;

	/** The table containing the list of arguments. */
	private transient JTable table;

	/** The model for the arguments table. */
	protected transient ObjectTableModel tableModel;

	/** A button for adding new arguments to the table. */
	private JButton add;

	/** A button for removing arguments from the table. */
	private JButton delete;

	/** Command for adding a row to the table. */
	private static final String ADD = "add"; //$NON-NLS-1$

	/** Command for removing a row from the table. */
	private static final String DELETE = "delete"; //$NON-NLS-1$

	private static final String[] COLUMN_NAMES = {
		    JMeterUtils.getResString("attribute"), //$NON-NLS-1$
			JMeterUtils.getResString("value"),  //$NON-NLS-1$
			JMeterUtils.getResString("opcode"),  //$NON-NLS-1$
			JMeterUtils.getResString("metadata") }; //$NON-NLS-1$

	/**
	 * Create a new LDAPArgumentsPanel, using the default title.
	 */
	public LDAPArgumentsPanel() {
		this(JMeterUtils.getResString("paramtable")); //$NON-NLS-1$
	}

	/**
	 * Create a new LDAPArgumentsPanel, using the specified title.
	 * 
	 * @param label
	 *            the title of the component
	 */
	public LDAPArgumentsPanel(String label) {
		tableLabel = new JLabel(label);
		init();
	}

	/**
	 * This is the list of menu categories this gui component will be available
	 * under. The LDAPArgumentsPanel is not intended to be used as a standalone
	 * component, so this inplementation returns null.
	 * 
	 * @return a Collection of Strings, where each element is one of the
	 *         constants defined in MenuFactory
	 */
	public Collection getMenuCategories() {
		return null;
	}

	public String getLabelResource() {
		return "ldapext_sample_title"; // $NON-NLS-1$
	}

	/* Implements JMeterGUIComponent.createTestElement() */
	public TestElement createTestElement() {
		LDAPArguments args = new LDAPArguments();
		modifyTestElement(args);
		// TODO: Why do we clone the return value? This is the only reference
		// to it (right?) so we shouldn't need a separate copy.
		return (TestElement) args.clone();
	}

	/* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
	public void modifyTestElement(TestElement args) {
		stopTableEditing();
		Iterator modelData = tableModel.iterator();
		LDAPArguments arguments = null;
		if (args instanceof LDAPArguments) {
			arguments = (LDAPArguments) args;
{'fraction_non_alphanumeric': 0.09657728362764334, 'fraction_numerical': 0.0035971223021582736, 'mean_word_length': 4.041208791208791, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5664436', 'n_tokens_mistral': 2692, 'n_tokens_neox': 2539, 'n_words': 923}