<commit_before>/*
 * Copyright 2002-2005 the original author or authors.
 * 
 * Licensed 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.springframework.richclient.form;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Comparator;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableModel;

import org.springframework.beans.support.PropertyComparator;
import org.springframework.binding.form.HierarchicalFormModel;
import org.springframework.richclient.form.binding.swing.SwingBindingFactory;
import org.springframework.richclient.form.builder.TableFormBuilder;
import org.springframework.richclient.table.support.GlazedTableModel;
import org.springframework.richclient.util.PopupMenuMouseListener;

import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.FilterList;
import ca.odell.glazedlists.Matcher;
import ca.odell.glazedlists.SortedList;
import ca.odell.glazedlists.matchers.MatcherEditor;
import ca.odell.glazedlists.swing.EventSelectionModel;
import ca.odell.glazedlists.swing.TableComparatorChooser;

/**
 * This is an abstract implementation of AbstractMasterForm that uses a GlazedTableModel
 * and JTable to represent the master information.
 * <p>
 * Derived types must implement:
 * <p>
 * <dt>{@link #getColumnPropertyNames()}</dt>
 * <dd>To specify the properties for the table columns</dd>
 * <dt>{@link AbstractMasterForm#createDetailForm}</dt>
 * <dd>To construct the detail half of this master/detail form pair</dd>
 * 
 * @author <NAME>
 */
public abstract class AbstractTableMasterForm extends AbstractMasterForm {

    private EventList _eventList;
    private JTable _masterTable;
    private Matcher _matcher;
    private MatcherEditor _matcherEditor;
    private Comparator _comparator;

    /**
     * Construct a new AbstractTableMasterForm using the given parent form model and
     * property path. The form model for this class will be constructed by getting the
     * value model of the specified property from the parent form model and constructing a
     * DeepCopyBufferedCollectionValueModel on top of it. Unless
     * {@link AbstractMasterForm#getListListModel()} has been overriden, the table will
     * contain all the elements in the domain object referenced by <code>property</code>.
     * 
     * @param parentFormModel Parent form model to access for this form's data
     * @param property Property containing this forms data (must be a collection or an
     *            array)
     * @param formId Id of this form
     * @param detailType Type of detail object managed by this master form
     */
    public AbstractTableMasterForm(HierarchicalFormModel parentFormModel, String property, String formId,
            Class detailType) {
        super( parentFormModel, property, formId, detailType );
    }

    /**
     * Set the <code>Matcher</code> to be used in filtering the elements of the master
     * set. Note that only one of a Matcher or MatcherEditor may be used, not both. If
     * both are specified, then the Matcher will take precedence.
     * 
     * @param matcher The Matcher to use to filter elements in the master set.
     */
    public void setFilterMatcher(Matcher matcher) {
        _matcher = matcher;
    }

    /**
     * Get the <code>Matcher</code> to be used in filtering the elements of the master
     * set.
     * 
     * @return matcher
     */
    public Matcher getFilterMatcher() {
        return _matcher;<commit_msg>Add constructor to allow caller to control how detail elements are compared for changed.<commit_after>/*
 * Copyright 2002-2005 the original author or authors.
 * 
 * Licensed 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.springframework.richclient.form;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Comparator;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableModel;

import org.springframework.beans.support.PropertyComparator;
import org.springframework.binding.form.HierarchicalFormModel;
import org.springframework.richclient.form.binding.swing.SwingBindingFactory;
import org.springframework.richclient.form.builder.TableFormBuilder;
import org.springframework.richclient.table.support.GlazedTableModel;
import org.springframework.richclient.util.PopupMenuMouseListener;

import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.FilterList;
import ca.odell.glazedlists.Matcher;
import ca.odell.glazedlists.SortedList;
import ca.odell.glazedlists.matchers.MatcherEditor;
import ca.odell.glazedlists.swing.EventSelectionModel;
import ca.odell.glazedlists.swing.TableComparatorChooser;

/**
 * This is an abstract implementation of AbstractMasterForm that uses a GlazedTableModel
 * and JTable to represent the master information.
 * <p>
 * Derived types must implement:
 * <p>
 * <dt>{@link #getColumnPropertyNames()}</dt>
 * <dd>To specify the properties for the table columns</dd>
 * <dt>{@link AbstractMasterForm#createDetailForm}</dt>
 * <dd>To construct the detail half of this master/detail form pair</dd>
 * 
 * @author <NAME>
 */
public abstract class AbstractTableMasterForm extends AbstractMasterForm {

    private EventList _eventList;
    private JTable _masterTable;
    private Matcher _matcher;
    private MatcherEditor _matcherEditor;
    private Comparator _comparator;

    /**
     * Construct a new AbstractTableMasterForm using the given parent form model and
     * property path. The form model for this class will be constructed by getting the
     * value model of the specified property from the parent form model and constructing a
     * DeepCopyBufferedCollectionValueModel on top of it. Unless
     * {@link AbstractMasterForm#getListListModel()} has been overriden, the table will
     * contain all the elements in the domain object referenced by <code>property</code>.
     * <p>
     * This constructor will rely on the <code>equals</code> method to detect differences in the
     * collection elements.
     * 
     * @param parentFormModel Parent form model to access for this form's data
     * @param property Property containing this forms data (must be a collection or an
     *            array)
     * @param formId Id of this form
     * @param detailType Type of detail object managed by this master form
     */
    public AbstractTableMasterForm(HierarchicalFormModel parentFormModel, String property, String formId,
            Class detailType) {
        this( parentFormModel, property, formId, detailType, false );
    }

    /**
     * Construct a new AbstractTableMasterForm using the given parent form model and
     * property path. The form model for this class will be constructed by getting the
     * value model of the specified property from the parent form model and constructing a
     * DeepCopyBufferedCollectionValueModel on top of it. Unless
     * {@link AbstractMasterForm#getListListModel()} has been overriden, the table will
     * contain all the elements in the domain object referenced by <code>property</code>.
     * <p>
     * The <code>changeUsesEquivalence</code> parameter controls how the constructued
     * value model will detect changes in the buffered collection. If it is
     * <code>false</code>, then the <code>equals</code> method will be used to detect
     * changes/differences in the detail elements. If it is <code>true</code>, then the
     * comparison will be forced to use object equivalence instead of <code>equals</code>.
     * You would only need to use this setting if the detail objects have an equals method
     * that can not detect changes that can be made by the detail form. If this is the
     * case, then you should pass <code>true</code>.
     * 
     * @param parentFormModel Parent form model to access for this form's data
     * @param property Property containing this forms data (must be a collection or an
     *            array)
     * @param formId Id of this form
     * @param detailType Type of detail object managed by this master form
     */
    public AbstractTableMasterForm(HierarchicalFormModel parentFormModel, String property, String formId,
            Class detailType, boolean changeUsesEquivalence) {
        super( parentFormModel, property, formId, detailType, changeUsesEquivalence );
    }

    /**
     * Set the <code>Matcher</code> to be used in filtering the elements of the master
     * set. Note that only one of a Matcher or MatcherEditor may be used, not both. If
     * both are specified, then the Matcher will take precedence.
     * 
     * @param matcher The Matcher to use to filter elements in the master set.
     */
    public void setFilterMatcher(Matcher matcher) {
        _matcher = matcher;
    }

    /**
     * Get the <code>Matcher</code> to be used in filtering the elements of the master
     * set.
     * 
     * @return matcher
     */
    public Matcher getFilterMatcher() {
        return _matcher;
{'fraction_non_alphanumeric': 0.07169405320813771, 'fraction_numerical': 0.002347417840375587, 'mean_word_length': 3.766899766899767, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, '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': '19505', 'n_tokens_mistral': 2682, 'n_tokens_neox': 2636, 'n_words': 1045}