<commit_before>/*
 * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * California 95054, U.S.A. All rights reserved.
 * 
 * This library 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.1 of the License, or (at your option)
 * any later version.
 * 
 * This library 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 library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */
package org.jdesktop.swingx;

import java.awt.Component;
import java.awt.Container;
import java.awt.LayoutManager;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.logging.Logger;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SpinnerDateModel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.JSpinner.DefaultEditor;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.text.DateFormatter;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.JTextComponent;

import org.jdesktop.swingx.action.AbstractActionExt;
import org.jdesktop.swingx.calendar.DateSelectionModel;
import org.jdesktop.swingx.calendar.DaySelectionModel;
import org.jdesktop.swingx.calendar.SingleDaySelectionModel;
import org.jdesktop.swingx.calendar.DateSelectionModel.SelectionMode;
import org.jdesktop.test.VerticalLayoutPref;

/**
 * Simple tests to ensure that the {@code JXDatePicker} can be instantiated and
 * displayed.<p>
 * 
 * JW: being lazy - added visuals for <code>JXMonthView</code> as well.
 * 
 * @author <NAME>
 */
public class JXDatePickerVisualCheck extends InteractiveTestCase {
    @SuppressWarnings("all")
    private static final Logger LOG = Logger
            .getLogger(JXDatePickerVisualCheck.class.getName());
    @SuppressWarnings("unused")
    private Calendar calendar;
    /** flag to decide if the menubar should be created */
    private boolean showMenu;

    public JXDatePickerVisualCheck() {
        super("JXDatePicker Test");
    }

    public static void main(String[] args) throws Exception {
       UIManager.put("JXDatePicker.forceZoomable", Boolean.TRUE);
//         setSystemLF(true);
        JXDatePickerVisualCheck test = new JXDatePickerVisualCheck();
        
        try {
//            test.runInteractiveTests();
//            test.runInteractiveTests("interactive.*PrefSize.*");
//            test.runInteractiveTests("interactive.*Keep.*");
//          test.runInteractiveTests("interactive.*Multiple.*");
//            test.runInteractiveTests("interactive.*Editable.*");
//            test.runInteractiveTests("interactive.*Enable.*");
            test.runInteractiveTests("interactive.*Popup.*");
//            test.runInteractiveTests("interactive.*Event.*");
        } catch (Exception e) {
            System.err.println("exception when executing interactive tests:");
            e.printStackTrace();
        }
    }

    /**
     * Issue #1393-swingx: inherited popup not shown on editor/arrow button.
     * Issue #1427-swingx: right click on arrow must not open monthView
     * Issue ??: tooltip on children - okay (JW, Mar 2011).
     */
    public void interactiveParentPopup() {
        JXDatePicker picker = new JXDatePicker(new Date());
        picker.setToolTipText("picker toolTip");
        picker.setInheritsPopupMenu(true);
        JComboBox compareBox = new JComboBox(new Object[]{"some", "items", "are ", "better ....."});
        compareBox.setToolTipText("combo toolTip");
        compareBox.setInheritsPopupMenu(true);
        JComboBox compareBoxEditable = new JComboBox(new Object[]{"some", "items", "are ", "better ....."});
        compareBoxEditable.setToolTipText("editable combo toolTip");
        compareBoxEditable.setEditable(true);
        compareBoxEditable.setInheritsPopupMenu(true);
        JTextField compareField = new JTextField("just for comparing");
        compareField.setInheritsPopupMenu(true);
        JPanel panel = new JPanel();
        JPopupMenu menu = new JPopupMenu();
        menu.add("dummy");
        panel.setComponentPopupMenu(menu);
        panel.add(picker);
        panel.add(compareBoxEditable);
        panel.add(compareBox);
        panel.add(compareField);
        JXFrame frame = wrapInFrame(panel, "inherited popup");
        addEnabledToggleWithChildren(frame, panel);
        addStatusMessage(frame, "right click in components to show parent popup");<commit_msg>OPEN - issue SWINGX-1329: JXDatePicker border doesn't match JTextField border  https://java.net/jira/browse/SWINGX-1329 - added border printout action to visual test <commit_after>/*
 * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * California 95054, U.S.A. All rights reserved.
 * 
 * This library 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.1 of the License, or (at your option)
 * any later version.
 * 
 * This library 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 library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */
package org.jdesktop.swingx;

import java.awt.Component;
import java.awt.Container;
import java.awt.LayoutManager;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.logging.Logger;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SpinnerDateModel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.JSpinner.DefaultEditor;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.text.DateFormatter;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.JTextComponent;

import org.jdesktop.swingx.action.AbstractActionExt;
import org.jdesktop.swingx.calendar.DateSelectionModel;
import org.jdesktop.swingx.calendar.DaySelectionModel;
import org.jdesktop.swingx.calendar.SingleDaySelectionModel;
import org.jdesktop.swingx.calendar.DateSelectionModel.SelectionMode;
import org.jdesktop.test.VerticalLayoutPref;

/**
 * Simple tests to ensure that the {@code JXDatePicker} can be instantiated and
 * displayed.<p>
 * 
 * JW: being lazy - added visuals for <code>JXMonthView</code> as well.
 * 
 * @author <NAME>
 */
public class JXDatePickerVisualCheck extends InteractiveTestCase {
    @SuppressWarnings("all")
    private static final Logger LOG = Logger
            .getLogger(JXDatePickerVisualCheck.class.getName());
    @SuppressWarnings("unused")
    private Calendar calendar;
    /** flag to decide if the menubar should be created */
    private boolean showMenu;

    public JXDatePickerVisualCheck() {
        super("JXDatePicker Test");
    }

    public static void main(String[] args) throws Exception {
       UIManager.put("JXDatePicker.forceZoomable", Boolean.TRUE);
//         setSystemLF(true);
        JXDatePickerVisualCheck test = new JXDatePickerVisualCheck();
        
        try {
//            test.runInteractiveTests();
//            test.runInteractiveTests("interactive.*PrefSize.*");
//            test.runInteractiveTests("interactive.*Keep.*");
//          test.runInteractiveTests("interactive.*Multiple.*");
//            test.runInteractiveTests("interactive.*Editable.*");
//            test.runInteractiveTests("interactive.*Enable.*");
            test.runInteractiveTests("interactive.*Popup.*");
//            test.runInteractiveTests("interactive.*Event.*");
        } catch (Exception e) {
            System.err.println("exception when executing interactive tests:");
            e.printStackTrace();
        }
    }

    /**
     * Issue #1393-swingx: inherited popup not shown on editor/arrow button.
     * Issue #1427-swingx: right click on arrow must not open monthView
     * Issue ??: tooltip on children - okay (JW, Mar 2011).
     * Issue #1329-swingx: editor border different from textfield border in win7
     */
    public void interactiveParentPopup() {
        final JXDatePicker picker = new JXDatePicker(new Date());
        picker.setToolTipText("picker toolTip");
        picker.setInheritsPopupMenu(true);
        JComboBox compareBox = new JComboBox(new Object[]{"some", "items", "are ", "better ....."});
        compareBox.setToolTipText("combo toolTip");
        compareBox.setInheritsPopupMenu(true);
        JComboBox compareBoxEditable = new JComboBox(new Object[]{"some", "items", "are ", "better ....."});
        compareBoxEditable.setToolTipText("editable combo toolTip");
        compareBoxEditable.setEditable(true);
        compareBoxEditable.setInheritsPopupMenu(true);
        JTextField compareField = new JTextField("just for comparing");
        compareField.setInheritsPopupMenu(true);
        JPanel panel = new JPanel();
        JPopupMenu menu = new JPopupMenu();
        menu.add("dummy");
        panel.setComponentPopupMenu(menu);
        panel.add(picker);
        panel.add(compareBoxEditable);
        panel.add(compareBox);
        panel.add(compareField);
        JXFrame frame = wrapInFrame(panel, "inherited popup");
        Action printBorder = new AbstractAction("print borders ") {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                String text = "picker border: " + picker.getBorder() 
                + "\n editor border: " + picker.getEditor().getBorder()
                    + "\n FormattedTextField border: " + new JFormattedTextField().getBorder()
                ;    
                LOG.info(text);
            }
        };
        addAction(frame, printBorder);
        addEnabledToggleWithChildren(frame, panel);
        addStatusMessage(frame, "right click in components to show parent popup");
{'fraction_non_alphanumeric': 0.10320538187574199, 'fraction_numerical': 0.00704392560348239, 'mean_word_length': 3.713166728832525, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '3525257', 'n_tokens_mistral': 3567, 'n_tokens_neox': 3480, 'n_words': 916}