private JPanel createPanel2() {
    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS));
    panel.setBorder(
        BorderFactory.createCompoundBorder(
            new JideTitledBorder(
                new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH),
                "AutoCompletion with list and tree",
                JideTitledBorder.LEADING,
                JideTitledBorder.ABOVE_TOP),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    // create tree combobox
    final JTextField treeTextField = new JTextField();
    treeTextField.setName("AutoCompletion JTextField with JTree");
    SelectAllUtils.install(treeTextField);
    final JTree tree = new JTree();
    tree.setVisibleRowCount(10);
    final TreeSearchable searchable = new TreeSearchable(tree);
    searchable.setRecursive(true);
    new AutoCompletion(treeTextField, searchable);
    panel.add(new JLabel("AutoCompletion JTextField with JTree"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(treeTextField);
    panel.add(Box.createVerticalStrut(2), JideBoxLayout.FIX);
    panel.add(new JScrollPane(tree));
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    // create font name combobox
    final JTextField fontNameTextField = new JTextField();
    fontNameTextField.setName("AutoCompletion JTextField with JList");
    SelectAllUtils.install(fontNameTextField);
    final JList fontNameList = new JList(_fontNames);
    fontNameList.setVisibleRowCount(10);
    new AutoCompletion(fontNameTextField, new ListSearchable(fontNameList));
    panel.add(new JLabel("AutoCompletion JTextField with JList"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(fontNameTextField);
    panel.add(Box.createVerticalStrut(2), JideBoxLayout.FIX);
    panel.add(new JScrollPane(fontNameList));
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    return panel;
  }
 public void testAutomaticallyNamesTextFieldWithoutName() {
   textField.setName(null);
   new JFrame().getContentPane().add(textField);
   mockRecorder
       .expects(once())
       .method("record")
       .with(eq(new EnterTextEvent("JTextField_1", "abc")));
   recorder.componentShown(textField);
   mockVisibility.stubs().method("isShowingAndHasFocus").will(returnValue(true));
   textField.setText("abc");
 }
 protected void setUp() throws Exception {
   super.setUp();
   textField = new JTextField();
   textField.setName("testTextField");
   mockVisibility = mock(ComponentVisibility.class);
   recorder =
       new TextFieldRecorder(
           (Recorder) mockRecorder.proxy(),
           new DefaultNamingStrategy(),
           (ComponentVisibility) mockVisibility.proxy());
 }
  private JPanel createParameterPanel() {
    JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_parameters")); // $NON-NLS-1$

    parameters = new JTextField(10);
    parameters.setName(BeanShellAssertion.PARAMETERS);
    label.setLabelFor(parameters);

    JPanel parameterPanel = new JPanel(new BorderLayout(5, 0));
    parameterPanel.add(label, BorderLayout.WEST);
    parameterPanel.add(parameters, BorderLayout.CENTER);
    return parameterPanel;
  }
  private JPanel createFilenamePanel() // TODO ought to be a FileChooser ...
      {
    JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); // $NON-NLS-1$

    filename = new JTextField(10);
    filename.setName(BeanShellAssertion.FILENAME);
    label.setLabelFor(filename);

    JPanel filenamePanel = new JPanel(new BorderLayout(5, 0));
    filenamePanel.add(label, BorderLayout.WEST);
    filenamePanel.add(filename, BorderLayout.CENTER);
    return filenamePanel;
  }
  /**
   * Adds a row to a panel.
   *
   * @param panel the panel with a grid bag layout to add the row to
   * @param textField the text input field to add to the row. May be a <code>CheckedTextField</code>
   *     .
   * @param labelText the label text preceding the text field
   * @param toolTip the tool tip text
   */
  private void addRow(
      final JPanel panel,
      final JTextField textField,
      final String labelText,
      final String toolTip) {
    GridBagLayout gridbag = (GridBagLayout) panel.getLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    // Ensure there is always a gap between components.
    constraints.insets = new Insets(2, 2, 2, 2);

    // Build the name row (label and text field).
    JLabel label = new JLabel(labelText);
    constraints.anchor = GridBagConstraints.EAST;
    constraints.gridwidth = 1;
    gridbag.setConstraints(label, constraints);
    panel.add(label);
    textField.setToolTipText(toolTip);
    textField.setName(labelText);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.gridwidth = GridBagConstraints.REMAINDER; // end row
    gridbag.setConstraints(textField, constraints);
    panel.add(textField);
  }
  private JPanel createPanel1() {
    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS));
    panel.setBorder(
        BorderFactory.createCompoundBorder(
            new JideTitledBorder(
                new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH),
                "AutoCompletion combo box and text field",
                JideTitledBorder.LEADING,
                JideTitledBorder.ABOVE_TOP),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    JComboBox autoCompletionComboBox = new AutoCompletionComboBox(_fontNames);
    autoCompletionComboBox.setName("AutoCompletion JComboBox (Strict)");
    autoCompletionComboBox.setToolTipText("AutoCompletion JComboBox (Strict)");
    panel.add(new JLabel("AutoCompletion JComboBox (Strict)"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(autoCompletionComboBox);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    AutoCompletionComboBox autoCompletionComboBoxNotStrict = new AutoCompletionComboBox(_fontNames);
    autoCompletionComboBoxNotStrict.setStrict(false);
    autoCompletionComboBoxNotStrict.setName("AutoCompletion JComboBox (Not strict)");
    autoCompletionComboBoxNotStrict.setToolTipText("AutoCompletion JComboBox (Not strict)");
    panel.add(new JLabel("AutoCompletion JComboBox (Not strict)"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(autoCompletionComboBoxNotStrict);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    // create tree combobox
    final JTextField textField = new JTextField();
    textField.setName("AutoCompletion JTextField with a hidden data");
    SelectAllUtils.install(textField);
    new AutoCompletion(textField, _fontList);
    panel.add(new JLabel("AutoCompletion JTextField with a hidden data"));
    panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    panel.add(textField);
    panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    //        panel.add(Box.createVerticalStrut(24), JideBoxLayout.FIX);
    //        panel.add(new JLabel("As comparisons:"));
    //        panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);
    //
    //        JComboBox searchableComboBox = new JComboBox(_fontNames);
    //        searchableComboBox.setEditable(false);
    //        SearchableUtils.installSearchable(searchableComboBox);
    //        searchableComboBox.setToolTipText("Searchable JComboBox");
    //        panel.add(new JLabel("Searchable JComboBox"));
    //        panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    //        panel.add(searchableComboBox);
    //        panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);
    //
    //        JTextField completionTextField = new JTextField();
    //        new ListCompletion(completionTextField, _fontNames);
    //        completionTextField.setToolTipText("Completion JTextField (not auto-complete)");
    //        panel.add(new JLabel("Completion JTextField (not auto-complete)"));
    //        panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX);
    //        panel.add(completionTextField);
    //        panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX);

    return panel;
  }
  public BiblioSearchLimitPanel(
      DatabankSchema schema, MarcQueryBuilder queryBuilder, int language, SearchUI utils) {
    super(new GridBagLayout(), queryBuilder);
    this.schema = schema;
    this.language = language;
    ButtonGroup g;

    props = PropertyUtils.loadProperties(getClass().getName(), LocaleUtils.getLocale(language));
    GuiUtils.setActionName(dateRangeAction, props.getProperty("date_range.name"));
    GuiUtils.setActionName(yearAction, props.getProperty("year.name"));
    this.utils = utils;

    lblCodingLevel = new JLabel(props.getProperty("coding_level.name"));
    cmCodingLevel = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_17);
    cmCodingLevel.setName("biblioCodingLevel");
    lblCodingLevel.setLabelFor(cmCodingLevel);

    lblCataloguingForm = new JLabel(props.getProperty("cataloguing_form.name"));
    cmCataloguingForm = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_18);
    cmCataloguingForm.setName("biblioCataloguingForm");
    lblCataloguingForm.setLabelFor(cmCataloguingForm);

    rBetween = new JRadioButton(props.getProperty("between.name"));
    rBetween.setName("biblioBetweenYears");
    rLt = new JRadioButton(props.getProperty("lt.name"));
    rLt.setName("biblioLessThanYear");
    rGt = new JRadioButton(props.getProperty("gt.name"));
    rGt.setName("biblioGreaterThanYear");
    txfYear = utils.queryTextField(4);
    txfYear.setName("biblioYearEquals");
    rYear = new JRadioButton(yearAction);
    rYear.setName("biblioYear");
    rDateRange = new JRadioButton(dateRangeAction);
    rDateRange.setName("biblioDateRange");
    lblDoctype = new JLabel(props.getProperty("biblio_doctype.name"));
    lblFrom = new JLabel(props.getProperty("from.name"));
    lblTo = new JLabel(props.getProperty("to.name"));
    lblLanguage = new JLabel(props.getProperty("language.name"));
    lblLocation = new JLabel(props.getProperty("location.name"));
    lblRetriveNo = new JLabel(props.getProperty("retriveNo.name"));
    lblRecType = new JLabel(props.getProperty("rectype.name"));
    lblRecStatus = new JLabel(props.getProperty("recstatus.name"));
    lblCalendar = new JLabel(props.getProperty("calendar.name"));
    lblBiblevel = new JLabel(props.getProperty("biblevel.name"));
    lblHierarchicalLevel = new JLabel(props.getProperty("hierarchical_level.name"));
    cmDoctype = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_DOC_TYPE);
    cmDoctype.setName("biblioDocType");
    cmLocation = utils.constantTableLookup(SearchEngineDocumentModel.LOCATION);
    cmLocation.setName("biblioLocation");
    cmLanguage = utils.constantTableLookup(SearchEngineDocumentModel.LANGUAGE);
    cmLanguage.setName("biblioLanguage");
    cmBiblevel = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_7);
    cmBiblevel.setName("biblioLevel");
    cmHierarchicalLevel = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_8);
    cmHierarchicalLevel.setName("biblioHierarchicalLevel");
    cmRecType = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_6);
    cmRecType.setName("biblioRecType");
    cmRecStatus = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_5);
    cmRecStatus.setName("biblioRecStatus");
    cmCalendar = utils.constantTableLookup(SearchEngineDocumentModel.CALENDAR);
    cmCalendar.setName("biblioCalendar");
    txfFrom = utils.queryTextField(10);
    txfFrom.setName("biblioFromYear");
    txfTo = utils.queryTextField(10);
    txfTo.setName("biblioToYear");
    txfRetriveNo = utils.queryTextField(10);
    txfRetriveNo.setName("retriveNo");
    lblDoctype.setLabelFor(cmDoctype);
    lblLocation.setLabelFor(cmLocation);
    lblLanguage.setLabelFor(cmLanguage);
    lblFrom.setLabelFor(txfFrom);
    lblTo.setLabelFor(txfTo);
    lblRetriveNo.setLabelFor(txfRetriveNo);
    lblTo.setVerticalTextPosition(JLabel.BOTTOM);
    lblCalendar.setHorizontalAlignment(JLabel.TRAILING);
    lblLanguage.setHorizontalAlignment(JLabel.TRAILING);
    lblRecType.setHorizontalAlignment(JLabel.TRAILING);
    lblDoctype.setHorizontalAlignment(JLabel.TRAILING);
    lblLocation.setHorizontalAlignment(JLabel.TRAILING);
    cbHasAttachment = new JCheckBox(props.getProperty("attachment.name"));
    cbIsOpenShelf = new JCheckBox(props.getProperty("openShelf.name"));
    cbIsLendable = new JCheckBox(props.getProperty("lendable.name"));
    rWithAttachment = new JRadioButton(props.getProperty("attachment-present.name"));
    rWithoutAttachment = new JRadioButton(props.getProperty("attachment-notpresent.name"));
    cbHasAttachment.setName("biblioAttachment");
    cbIsOpenShelf.setName("holdingIsOpenShelf");
    cbIsLendable.setName("holdingIsLendable");
    rWithAttachment.setName("biblioAttachmentPresent");
    rWithoutAttachment.setName("biblioAttachmentNotPresent");
    cbHasAttachment.addChangeListener(attachmentChangedListener);
    rWithAttachment.setEnabled(false);
    rWithoutAttachment.setEnabled(false);
    cbHasAttachment.setSelected(false);
    cbIsOpenShelf.setSelected(false);
    cbIsLendable.setSelected(false);
    g = new ButtonGroup();
    g.add(rWithAttachment);
    g.add(rWithoutAttachment);

    g = new ButtonGroup();
    g.add(rBetween);
    g.add(rLt);
    g.add(rGt);
    g = new ButtonGroup();
    g.add(rDateRange);
    g.add(rYear);
    rYear.setSelected(true);
    dateCriteriaChanged();

    lblDescriptionLevel = new JLabel(props.getProperty("level-of-description.name"));
    cmDescriptionLevel =
        utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_ISAD_LEVEL_OF_DESCRIPTION);
    cmDescriptionLevel.setName("biblioDescriptionLevel");
    lblDescriptionLevel.setLabelFor(cmDescriptionLevel);

    lblGMD = new JLabel(props.getProperty("general-material.name"));
    cmGMD = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_GMD_LIST);
    cmGMD.setName("biblioGMD");
    lblGMD.setLabelFor(cmGMD);

    lblLCClass = new JLabel(props.getProperty("lcclass.name"));
    txfLCClass = new JTextField(20);
    GuiUtils.localeSupport(txfLCClass);
    GuiUtils.setComponentOrientation(txfLCClass, ComponentOrientation.LEFT_TO_RIGHT);
    lblLCClass.setLabelFor(txfLCClass);

    LayoutFacility lf = new LayoutFacility(this);
    /*
            lf.add(lblCodingLevel,
                    new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
            lf.add(cmCodingLevel,
                    new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    */
    int y = 0;
    lf.add(
        lblDoctype,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmDoctype,
        new GridBagConstraints(
            1,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblRecType,
        new GridBagConstraints(
            2,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_END,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmRecType,
        new GridBagConstraints(
            3,
            y++,
            GridBagConstraints.REMAINDER,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblGMD,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_END,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmGMD,
        new GridBagConstraints(
            1,
            y++,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    lf.add(
        lblLocation,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmLocation,
        new GridBagConstraints(
            1,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblLanguage,
        new GridBagConstraints(
            2,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmLanguage,
        new GridBagConstraints(
            3,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblBiblevel,
        new GridBagConstraints(
            4,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmBiblevel,
        new GridBagConstraints(
            5,
            y++,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    ////
    lf.add(
        lblCataloguingForm,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmCataloguingForm,
        new GridBagConstraints(
            1,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblHierarchicalLevel,
        new GridBagConstraints(
            2,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmHierarchicalLevel,
        new GridBagConstraints(
            3,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblRecStatus,
        new GridBagConstraints(
            4,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmRecStatus,
        new GridBagConstraints(
            5,
            y++,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    ////
    lf.add(
        lblCodingLevel,
        new GridBagConstraints(
            4,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmCodingLevel,
        new GridBagConstraints(
            5,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        rYear,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        txfYear,
        new GridBagConstraints(
            1,
            y,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblCalendar,
        new GridBagConstraints(
            2,
            y,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmCalendar,
        new GridBagConstraints(
            3,
            y++,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    lf.add(
        rDateRange,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    LayoutFacility datelf = new LayoutFacility(new JPanel());
    datelf.add(
        lblFrom,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 5, 2, 5),
            0,
            0));
    datelf.add(
        txfFrom,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        rGt,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        rBetween,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        rLt,
        new GridBagConstraints(
            5,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        lblTo,
        new GridBagConstraints(
            6,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 5, 2, 5),
            0,
            0));
    datelf.add(
        txfTo,
        new GridBagConstraints(
            7,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        Box.createHorizontalGlue(),
        new GridBagConstraints(
            8,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_END,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    lf.add(
        datelf.container,
        new GridBagConstraints(
            1,
            y++,
            GridBagConstraints.REMAINDER,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    LayoutFacility lcClasslf = new LayoutFacility(new JPanel());
    lcClasslf.add(
        lblLCClass,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 5, 2, 5),
            0,
            0));
    lcClasslf.add(
        txfLCClass,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    lf.add(
        lcClasslf.container,
        new GridBagConstraints(
            0,
            y++,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    LayoutFacility attLf = LayoutFacility.createLayoutFacility();
    int x = 0;
    attLf.add(
        cbHasAttachment,
        new GridBagConstraints(
            x++,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    attLf.add(
        cbIsOpenShelf,
        new GridBagConstraints(
            x++,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    //        attLf.add(cbIsLendable,
    //        		new GridBagConstraints(x++, 0, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START,
    // GridBagConstraints.NONE, new Insets(2, 2, 2, 10), 0, 0));
    attLf.add(
        lblRetriveNo,
        new GridBagConstraints(
            x++,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 20, 2, 2),
            0,
            0));
    attLf.add(
        txfRetriveNo,
        new GridBagConstraints(
            x++,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            25,
            0));

    if (SystemUtils.isISADAvailable()) {
      attLf.add(
          lblDescriptionLevel,
          new GridBagConstraints(
              x++,
              0,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.LINE_START,
              GridBagConstraints.HORIZONTAL,
              new Insets(2, 20, 2, 2),
              0,
              0));
      attLf.add(
          cmDescriptionLevel,
          new GridBagConstraints(
              x++,
              0,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.LINE_START,
              GridBagConstraints.NONE,
              new Insets(2, 2, 2, 2),
              0,
              0));
    }

    /*
            attLf.add(rWithAttachment,
                    new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
            attLf.add(rWithoutAttachment,
                    new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    */

    lf.add(
        attLf.container,
        new GridBagConstraints(
            0,
            y,
            GridBagConstraints.REMAINDER,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    //        lf.add(Box.createHorizontalGlue(),
    //                new GridBagConstraints(1, 4, 0, 1, 0.0, 0.0, GridBagConstraints.LINE_START,
    // GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));

    ChangeListener limitChangeListener =
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            txfFrom.setEditable(!rLt.isSelected() && rDateRange.isSelected());
            txfTo.setEditable(!rGt.isSelected() && rDateRange.isSelected());
          }
        };
    rGt.addChangeListener(limitChangeListener);
    rLt.addChangeListener(limitChangeListener);
    rBetween.addChangeListener(limitChangeListener);
    rGt.setSelected(true);
  }
示例#9
0
 private JTextField usernameField() {
   final JTextField textField = new JTextField();
   textField.setName("description");
   return textField;
 }
  public Component getDemoPanel() {
    final String[] fontNames = DemoData.getFontNames();
    // create file text field
    List<String> urls = null;
    try {
      urls = readUrls();
    } catch (IOException e) {
      //noinspection CallToPrintStackTrace
      e.printStackTrace();
    }

    JTextField urlTextField = new JTextField("http://");
    urlTextField.setName("URL IntelliHint");
    SelectAllUtils.install(urlTextField);
    ListDataIntelliHints intelliHints = new ListDataIntelliHints<String>(urlTextField, urls);
    intelliHints.setCaseSensitive(false);

    JTextField pathTextField = new JTextField();
    SelectAllUtils.install(pathTextField);
    FileIntelliHints fileIntelliHints = new FileIntelliHints(pathTextField);
    fileIntelliHints.setFilter(
        new FilenameFilter() {
          public boolean accept(File dir, String name) {
            return !_applyFileFilter
                || dir.getAbsolutePath().contains("Program")
                || name.contains("Program");
          }
        });
    fileIntelliHints.setFolderOnly(false);
    fileIntelliHints.setFollowCaret(true);
    fileIntelliHints.setShowFullPath(false);

    // create file text field
    JTextField fileTextField = new JTextField();
    fileTextField.setName("File IntelliHint");
    SelectAllUtils.install(fileTextField);
    new FileIntelliHints(fileTextField);

    // create file text field
    JTextArea fileTextArea = new JTextArea();
    new FileIntelliHints(fileTextArea);
    fileTextArea.setRows(4);

    // create file text field
    JTextField fontTextField = new JTextField();
    fontTextField.setName("Font IntelliHint");
    SelectAllUtils.install(fontTextField);
    ListDataIntelliHints fontIntelliHints =
        new ListDataIntelliHints<String>(fontTextField, fontNames);
    fontIntelliHints.setCaseSensitive(false);

    JTextField textField = new JTextField();
    SelectAllUtils.install(textField);
    //noinspection UnusedDeclaration
    new AbstractListIntelliHints(textField) {
      protected JLabel _messageLabel;

      @Override
      public JComponent createHintsComponent() {
        JPanel panel = (JPanel) super.createHintsComponent();
        _messageLabel = new JLabel();
        panel.add(_messageLabel, BorderLayout.BEFORE_FIRST_LINE);
        return panel;
      }

      // update list model depending on the data in textfield
      public boolean updateHints(Object value) {
        if (value == null) {
          return false;
        }
        String s = value.toString();
        s = s.trim();
        if (s.length() == 0) {
          return false;
        }
        try {
          long l = Long.parseLong(s);
          boolean prime = isProbablePrime(l);
          _messageLabel.setText("");
          if (prime) {
            return false;
          } else {
            Vector<Long> list = new Vector<Long>();
            long nextPrime = l;
            for (int i = 0; i < 10; i++) {
              nextPrime = nextPrime(nextPrime);
              list.add(nextPrime);
            }
            setListData(list);
            _messageLabel.setText("Next 10 prime numbers:");
            _messageLabel.setForeground(Color.DARK_GRAY);
            return true;
          }
        } catch (NumberFormatException e) {
          setListData(new Object[0]);
          _messageLabel.setText("Invalid long number");
          setListData(new Object[0]);
          _messageLabel.setForeground(Color.RED);
          return true;
        }
      }
    };

    DefaultTableModel model =
        new DefaultTableModel(0, 1) {
          private static final long serialVersionUID = -2794741068912785630L;

          @Override
          public Class<?> getColumnClass(int columnIndex) {
            return String.class;
          }

          @Override
          public String getColumnName(int column) {
            return "Font";
          }
        };
    model.addRow(new Object[] {"Arial"});
    model.addRow(new Object[] {"Tahoma"});
    SortableTable table = new SortableTable(model);
    table
        .getColumnModel()
        .getColumn(0)
        .setCellEditor(
            new TextFieldCellEditor(String.class) {
              private static final long serialVersionUID = 2023654568542192380L;

              @Override
              protected JTextField createTextField() {
                JTextField cellEditorTextField = new JTextField();
                ListDataIntelliHints fontIntellihints =
                    new ListDataIntelliHints<String>(cellEditorTextField, fontNames);
                fontIntellihints.setCaseSensitive(false);
                return cellEditorTextField;
              }
            });
    table.setPreferredScrollableViewportSize(new Dimension(100, 100));

    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS, 3));
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    panel.add(new JLabel("ListDataIntelliHints TextField for URLs: "));
    panel.add(urlTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    // create path text field
    panel.add(
        new JLabel("FileIntelliHints TextField for paths (folders only, show partial path):"));
    panel.add(pathTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(
        new JLabel("FileIntelliHints TextField for files (files and folders, show full path):"));
    panel.add(fileTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("FileIntelliHints TextArea for files (each line is for a new file):"));
    panel.add(new JScrollPane(fileTextArea));
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("IntelliHints TextField to choose a font:"));
    panel.add(fontTextField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("A custom IntelliHints for prime numbers: "));
    panel.add(textField);
    panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX);

    panel.add(new JLabel("Using IntelliHint in JTable's cell editor"));
    panel.add(new JScrollPane(table), JideBoxLayout.FLEXIBLE);

    panel.add(Box.createGlue(), JideBoxLayout.VARY);

    return panel;
  }
  public ConfigurationPanel(final Project project) {

    serverUrl.setName("serverUrl");
    buildDelay.setName("buildDelay");
    jobRefreshPeriod.setName("jobRefreshPeriod");
    rssRefreshPeriod.setName("rssRefreshPeriod");
    username.setName("_username_");

    passwordField.setName("passwordFile");
    crumbDataField.setName("crumbDataFile");

    testConnexionButton.setName("testConnexionButton");
    connectionStatusLabel.setName("connectionStatusLabel");

    successOrStableCheckBox.setName("successOrStableCheckBox");
    unstableOrFailCheckBox.setName("unstableOrFailCheckBox");
    abortedCheckBox.setName("abortedCheckBox");

    rssStatusFilterPanel.setBorder(IdeBorderFactory.createTitledBorder("Event Log Settings", true));

    debugPanel.setVisible(false);

    initDebugTextPane();

    buildDelay.setDocument(new NumberDocument());
    jobRefreshPeriod.setDocument(new NumberDocument());
    rssRefreshPeriod.setDocument(new NumberDocument());

    uploadPatchSettingsPanel.setBorder(
        IdeBorderFactory.createTitledBorder("Upload a Patch Settings", true));

    passwordField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                myPasswordModified = true;
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                myPasswordModified = true;
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                myPasswordModified = true;
              }
            });

    testConnexionButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            try {
              debugPanel.setVisible(false);

              new NotNullValidator().validate(serverUrl);
              new UrlValidator().validate(serverUrl);

              JenkinsSettings jenkinsSettings = JenkinsSettings.getSafeInstance(project);

              String password =
                  isPasswordModified() ? getPassword() : jenkinsSettings.getPassword();

              RequestManager.getInstance(project)
                  .authenticate(
                      serverUrl.getText(), username.getText(), password, crumbDataField.getText());
              setConnectionFeedbackLabel(CONNECTION_TEST_SUCCESSFUL_COLOR, "Successful");
              setPassword(password);
            } catch (Exception ex) {
              setConnectionFeedbackLabel(CONNECTION_TEST_FAILED_COLOR, "[Fail] " + ex.getMessage());
              if (ex instanceof AuthenticationException) {
                AuthenticationException authenticationException = (AuthenticationException) ex;
                String responseBody = authenticationException.getResponseBody();
                if (StringUtils.isNotBlank(responseBody)) {
                  debugPanel.setVisible(true);
                  debugTextPane.setText(responseBody);
                }
              }
            }
          }
        });

    formValidator =
        FormValidator.init(this)
            .addValidator(
                username,
                new UIValidator<JTextField>() {
                  public void validate(JTextField component) throws ConfigurationException {
                    if (StringUtils.isNotBlank(component.getText())) {
                      String password = getPassword();
                      if (StringUtils.isBlank(password)) {
                        throw new ConfigurationException(
                            String.format("'%s' must be set", passwordField.getName()));
                      }
                    }
                  }
                });
  }