/**
   * Creates a player selector panel.
   *
   * @param title title for this selector
   * @param humanSet select the human player by default
   */
  public UciPlayerSelector(final String title, final boolean humanSet) {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JLabel label = new JLabel(title);
    add(label);

    /* Set up widgets. */
    ButtonGroup group = new ButtonGroup();
    group.add(human);
    group.add(computer);
    human.setSelected(humanSet);
    computer.setSelected(!humanSet);
    ai.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ai.setSelectedIndex(DEFAULT_AI);
    ai.setEnabled(!humanSet);

    /* Set up widget alignment. */
    human.setAlignmentX(Component.LEFT_ALIGNMENT);
    computer.setAlignmentX(Component.LEFT_ALIGNMENT);
    ai.setAlignmentX(Component.LEFT_ALIGNMENT);

    /* Set up list enable/disable. */
    human.addActionListener(
        new ActionListener() {
          public final void actionPerformed(final ActionEvent e) {
            ai.setEnabled(!human.isSelected());
          }
        });
    computer.addActionListener(
        new ActionListener() {
          public final void actionPerformed(final ActionEvent e) {
            ai.setEnabled(computer.isSelected());
          }
        });

    add(human);
    add(computer);
    add(ai);
    setBorder(BorderFactory.createEmptyBorder(H_PADDING, V_PADDING, H_PADDING, V_PADDING));
  }
Example #2
0
  public SearchPanel(ApplicationContext _context, JTable _table) {
    setLayout(new BorderLayout());
    myContext = _context;
    myTable = _table;
    myOptions = new Vector();

    JPanel optionSetPanel = new JPanel();
    optionSetPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    optionSetPanel.setLayout(new BoxLayout(optionSetPanel, BoxLayout.Y_AXIS));

    myStandardSeach = new JRadioButton("Standard Search");
    myStandardSeach.setAlignmentX(0.0f);
    myAdvancedSearch = new JRadioButton("Advanced Search");
    myAdvancedSearch.setAlignmentX(0.0f);
    ButtonGroup optionsGroup = new ButtonGroup();
    optionsGroup.add(myStandardSeach);
    optionsGroup.add(myAdvancedSearch);
    myStandardSeach.addChangeListener(new StandardSearchListener());

    JPanel optionsPanel = new JPanel();
    optionsPanel.setAlignmentX(0.0f);
    optionsPanel.setLayout(new GridLayout(0, 1));
    optionsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    addOption(optionsPanel, new TextOption("Title", DatabaseTags.TITLE_TAG));
    addOption(optionsPanel, new TextOption("Artist", DatabaseTags.ARTIST_TAG));
    addOption(optionsPanel, new TextOption("Source", DatabaseTags.SOURCE_TAG));
    addOption(optionsPanel, new TextOption("Genre", DatabaseTags.GENRE_TAG));
    addOption(optionsPanel, new TextOption("Year", DatabaseTags.YEAR_TAG));

    JPanel advancedPanel = new JPanel();
    advancedPanel.setAlignmentX(0.0f);
    advancedPanel.setLayout(new GridLayout(0, 1));
    advancedPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    myAdvancedTextField = new JTextField();
    advancedPanel.add(myAdvancedTextField);

    JButton searchButton = new JButton("Search");
    searchButton.addActionListener(new SearchListener());

    JButton saveResultsButton = new JButton("Save");
    saveResultsButton.addActionListener(new SaveResultsListener());

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout());
    buttonsPanel.add(searchButton);
    buttonsPanel.add(saveResultsButton);
    buttonsPanel.setAlignmentX(0.0f);

    optionSetPanel.add(myStandardSeach);
    optionSetPanel.add(optionsPanel, BorderLayout.NORTH);
    optionSetPanel.add(myAdvancedSearch);
    optionSetPanel.add(advancedPanel);
    //    optionSetPanel.add(myFindContainerPlaylists);
    //    optionSetPanel.add(Box.createVerticalStrut(10));
    if (_table != null) {
      optionSetPanel.add(Box.createVerticalStrut(10));
      optionSetPanel.add(buttonsPanel);
    }
    add(optionSetPanel, BorderLayout.NORTH);

    myStandardSeach.setSelected(true);
  }
  public ProceedDialog(long id, int numberOfDirectionErrors, int numberOfRoadTypeErrors) {

    panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    JLabel label1 =
        new JLabel(tr("PT_Assistant plugin found that this relation (id={0}) has errors:", id));
    panel.add(label1);
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);

    if (true) {
      JLabel label2 =
          new JLabel(
              "     "
                  + trn(
                      "{0} direction error",
                      "{0} direction errors", numberOfDirectionErrors, numberOfDirectionErrors));
      panel.add(label2);
      label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    }

    if (numberOfRoadTypeErrors != 0) {
      JLabel label3 =
          new JLabel(
              "     "
                  + trn(
                      "{0} road type error",
                      "{0} road type errors", numberOfRoadTypeErrors, numberOfRoadTypeErrors));
      panel.add(label3);
      label3.setAlignmentX(Component.LEFT_ALIGNMENT);
    }

    JLabel label4 = new JLabel(tr("How do you want to proceed?"));
    panel.add(label4);
    label4.setAlignmentX(Component.LEFT_ALIGNMENT);

    radioButtonFixAutomatically = new JRadioButton("Fix all errors automatically and proceed");
    radioButtonFixManually =
        new JRadioButton("I will fix the errors manually and click the button to proceed");
    radioButtonDontFix =
        new JRadioButton("Do not fix anything and proceed with further tests", true);
    ButtonGroup fixOptionButtonGroup = new ButtonGroup();
    fixOptionButtonGroup.add(radioButtonFixAutomatically);
    fixOptionButtonGroup.add(radioButtonFixManually);
    fixOptionButtonGroup.add(radioButtonDontFix);
    panel.add(radioButtonFixAutomatically);
    // panel.add(radioButtonFixManually);
    panel.add(radioButtonDontFix);
    radioButtonFixAutomatically.setAlignmentX(Component.LEFT_ALIGNMENT);
    radioButtonFixManually.setAlignmentX(Component.LEFT_ALIGNMENT);
    radioButtonDontFix.setAlignmentX(Component.LEFT_ALIGNMENT);

    checkbox = new JCheckBox(tr("Remember my choice and do not ask me again in this session"));
    panel.add(checkbox);
    checkbox.setAlignmentX(Component.LEFT_ALIGNMENT);

    options = new String[2];
    options[0] = "OK";
    options[1] = "Cancel & stop testing";

    selectedOption = Integer.MIN_VALUE;
  }
Example #4
0
  public ContextEditor(Context cntxt) {
    super("Edit User Context: " + localFileName(cntxt));
    ctxt = cntxt;
    windowNum = ctxt.languageName + " Context Editor";
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    listener = new CEListener(this);

    JPanel nameBox = new JPanel();
    nameBox.setLayout(new BoxLayout(nameBox, BoxLayout.LINE_AXIS));
    name = new JTextField(ctxt.languageName, 28);
    name.setMaximumSize(new Dimension(225, 22));
    name.addFocusListener(
        new java.awt.event.FocusAdapter() {

          public void focusLost(java.awt.event.FocusEvent evt) {
            nameFocusLost(evt);
          }
        });

    JLabel nameLabel = new JLabel("Language Name: ");
    nameBox.add(nameLabel);
    nameBox.add(name);

    JPanel folderBox = new JPanel();
    folderBox.setLayout(new BoxLayout(folderBox, BoxLayout.LINE_AXIS));
    folder = new JTextField(ctxt.editDirectory);
    folder.setMaximumSize(new Dimension(225, 22));
    //        folder.addActionListener(listener);
    //        folder.setActionCommand("folder edit");
    folder.addFocusListener(
        new java.awt.event.FocusAdapter() {

          public void focusLost(java.awt.event.FocusEvent evt) {
            folderFocusLost(evt);
          }
        });

    JLabel folderLabel = new JLabel("SILK file folder: ");
    folderBox.add(folderLabel);
    folderBox.add(folder);

    JPanel nameFolderBox = new JPanel();
    nameFolderBox.setLayout(new BoxLayout(nameFolderBox, BoxLayout.PAGE_AXIS));
    nameBox.setAlignmentX(0.5f);
    nameFolderBox.add(nameBox);
    nameFolderBox.add(Box.createRigidArea(new Dimension(0, 4)));
    nameFolderBox.add(folderBox);
    nameFolderBox.setAlignmentX(0.5f);

    buildPopulationBox();

    JPanel btnBoxUDPs = new JPanel(), subBoxUDP = new JPanel();
    btnBoxUDPs.setLayout(new BoxLayout(btnBoxUDPs, BoxLayout.PAGE_AXIS));
    subBoxUDP.setLayout(new BoxLayout(subBoxUDP, BoxLayout.LINE_AXIS));
    int numUDPs = 0;
    if (ctxt.userDefinedProperties != null) {
      numUDPs = ctxt.userDefinedProperties.size();
    }
    String plur = "ies";
    if (numUDPs == 1) {
      plur = "y";
    }
    JLabel udpLabel = new JLabel("Has " + numUDPs + " User-Defined Propert" + plur);
    subBoxUDP.add(udpLabel);
    JButton addUDP = new JButton("Add UDP");
    addUDP.setActionCommand("add UDP");
    addUDP.addActionListener(listener);
    subBoxUDP.add(addUDP);
    btnBoxUDPs.add(subBoxUDP);
    if (numUDPs > 0) {
      Dimension sizer = new Dimension(250, 50);
      String[] udpMenu = genUDPMenu();
      UDPick = new JComboBox(udpMenu);
      UDPick.addActionListener(listener);
      UDPick.setActionCommand("view/edit UDP");
      UDPick.setMinimumSize(sizer);
      UDPick.setMaximumSize(sizer);
      UDPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit UDPs"));
      btnBoxUDPs.add(UDPick);
    } //  end of if-any-UDPs-exist

    JPanel domThs = new JPanel();
    domThs.setLayout(new BoxLayout(domThs, BoxLayout.PAGE_AXIS));
    domThs.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Kinship System Domain Theories"));
    domThs.setAlignmentX(0.5f);
    JPanel dtRefBtnBox = new JPanel();
    dtRefBtnBox.setLayout(new BoxLayout(dtRefBtnBox, BoxLayout.LINE_AXIS));
    dtRefBtnBox.setAlignmentX(0.0f);
    JLabel dtRefLabel = new JLabel("Terms of Reference ");
    dtRefBtnBox.add(dtRefLabel);
    if (ctxt.domTheoryRefExists()) {
      JButton dtRefEdit = new JButton("Edit Theory");
      dtRefEdit.setActionCommand("edit dtRef");
      dtRefEdit.addActionListener(listener);
      dtRefBtnBox.add(dtRefEdit);
      //            JButton dtRefDelete = new JButton("Delete Theory");
      //            dtRefDelete.setActionCommand("dtRef delete");
      //            dtRefDelete.addActionListener(listener);
      //            dtRefBtnBox.add(dtRefDelete);
    } //  end of if-dt-exists
    else { //  if does not exist
      JLabel dtRefNone = new JLabel("< None >");
      dtRefBtnBox.add(dtRefNone);
      //            JButton dtRefAdd = new JButton("Add Theory");
      //            dtRefAdd.setActionCommand("dtRef add");
      //            dtRefAdd.addActionListener(listener);
      //            dtRefBtnBox.add(dtRefAdd);
    } //  end of does-not-exist
    domThs.add(dtRefBtnBox);

    JPanel dtAddrBtnBox = new JPanel();
    dtAddrBtnBox.setLayout(new BoxLayout(dtAddrBtnBox, BoxLayout.LINE_AXIS));
    dtAddrBtnBox.setAlignmentX(0.0f);
    JLabel dtAddrLabel = new JLabel("Terms of Address ");
    dtAddrBtnBox.add(dtAddrLabel);
    if (ctxt.domTheoryAdrExists()) {
      JButton dtAddrEdit = new JButton("Edit Theory");
      dtAddrEdit.setActionCommand("edit dtAddr");
      dtAddrEdit.addActionListener(listener);
      dtAddrBtnBox.add(dtAddrEdit);
      //            JButton dtAddrViewList = new JButton("Delete Theory");
      //            dtAddrViewList.setActionCommand("dtAddr delete");
      //            dtAddrViewList.addActionListener(listener);
      //            dtAddrBtnBox.add(dtAddrViewList);
    } //  end of if-dt-exists
    else { //  if does not exist
      JLabel dtAddrNone = new JLabel("< None >");
      dtAddrBtnBox.add(dtAddrNone);
      //            JButton dtAddrAdd = new JButton("Add Theory");
      //            dtAddrAdd.setActionCommand("dtAddr add");
      //            dtAddrAdd.addActionListener(listener);
      //            dtAddrBtnBox.add(dtAddrAdd);
    } //  end of does-not-exist
    domThs.add(dtAddrBtnBox);
    // End of the left hand portion
    // Right hand portion follows. it is narrower.

    JPanel polyBox = new JPanel();
    polyBox.setLayout(new BoxLayout(polyBox, BoxLayout.PAGE_AXIS));
    polyBox.setAlignmentX(0.5f);
    JLabel polyLabelA = new JLabel("Polygamy");
    JLabel polyLabelB = new JLabel("Permitted?");
    JRadioButton yesPoly = new JRadioButton("Yes");
    yesPoly.setActionCommand("polygamy yes");
    yesPoly.addActionListener(listener);
    JRadioButton noPoly = new JRadioButton("No");
    noPoly.setActionCommand("polygamy no");
    noPoly.addActionListener(listener);
    if (cntxt.polygamyPermit) {
      yesPoly.setSelected(true);
    } else {
      noPoly.setSelected(true);
    }
    ButtonGroup polyBtns = new ButtonGroup();
    polyBtns.add(yesPoly);
    polyBtns.add(noPoly);
    polyBox.add(polyLabelA);
    polyBox.add(polyLabelB);
    polyBox.add(yesPoly);
    polyBox.add(noPoly);

    JPanel matrixBox = new JPanel();
    matrixBox.setLayout(new BoxLayout(matrixBox, BoxLayout.PAGE_AXIS));
    matrixBox.setAlignmentX(0.5f);
    JLabel matrixLabelA = new JLabel("Kin Term Matrix");
    JLabel matrixLabelC = new JLabel(ctxt.indSerNumGen + " rows");
    JLabel matrixLabelD = new JLabel(ctxt.ktm.numberOfKinTerms() + " terms");
    matrixLabelA.setAlignmentX(0.5f);
    matrixLabelC.setAlignmentX(0.5f);
    matrixLabelD.setAlignmentX(0.5f);
    JButton matrixEditBtn = new JButton("Edit Matrix");
    matrixEditBtn.setEnabled(false);
    matrixEditBtn.setActionCommand("edit matrix");
    matrixEditBtn.addActionListener(listener);
    matrixEditBtn.setAlignmentX(0.5f);
    matrixBox.add(matrixLabelA);
    matrixBox.add(matrixLabelC);
    matrixBox.add(matrixLabelD);
    matrixBox.add(matrixEditBtn);

    JPanel distinctBox = new JPanel();
    distinctBox.setLayout(new BoxLayout(distinctBox, BoxLayout.PAGE_AXIS));
    distinctBox.setAlignmentX(0.5f);
    JLabel distinctLabelA = new JLabel("Distinct Terms");
    JLabel distinctLabelB = new JLabel("of Address");
    distinctLabelA.setAlignmentX(0.5f);
    distinctLabelB.setAlignmentX(0.5f);
    JRadioButton yesDistinct = new JRadioButton("Yes");
    yesDistinct.setActionCommand("distinct yes");
    yesDistinct.addActionListener(listener);
    JRadioButton noDistinct = new JRadioButton("No");
    noDistinct.setActionCommand("distinct no");
    noDistinct.addActionListener(listener);
    yesDistinct.setAlignmentX(0.5f);
    noDistinct.setAlignmentX(0.5f);
    if (ctxt.distinctAdrTerms) {
      yesDistinct.setSelected(true);
    } else {
      noDistinct.setSelected(true);
    }
    ButtonGroup distinctBtns = new ButtonGroup();
    distinctBtns.add(yesDistinct);
    distinctBtns.add(noDistinct);
    distinctBox.add(distinctLabelA);
    distinctBox.add(distinctLabelB);
    distinctBox.add(yesDistinct);
    distinctBox.add(noDistinct);

    /*
     * NOTE: It should be possible to put all these elements directly into
     * the ContentPane. But that doesn't work; the layout is truly ugly and
     * stuff gets stacked on top of other stuff. What works is to put
     * everything into a JPanel with BoxLayout. Then put the JPanel into
     * ContentPane.
     */
    JPanel leftCol = new JPanel();
    leftCol.setLayout(new BoxLayout(leftCol, BoxLayout.PAGE_AXIS));
    leftCol.add(nameFolderBox);
    leftCol.add(Box.createRigidArea(new Dimension(0, 4)));
    leftCol.add(populationBox);
    leftCol.add(Box.createRigidArea(new Dimension(0, 8)));
    leftCol.add(btnBoxUDPs);
    leftCol.add(Box.createRigidArea(new Dimension(0, 8)));
    leftCol.add(domThs);
    leftCol.add(new JLabel(" "));

    JPanel rightCol = new JPanel();
    rightCol.setLayout(new BoxLayout(rightCol, BoxLayout.PAGE_AXIS));
    rightCol.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue), "Options"));
    rightCol.add(Box.createRigidArea(new Dimension(0, 20)));
    rightCol.add(polyBox);
    rightCol.add(Box.createRigidArea(new Dimension(0, 20)));
    rightCol.add(matrixBox);
    int high = (numUDPs > 0 ? 120 : 20);
    rightCol.add(Box.createRigidArea(new Dimension(0, high)));
    rightCol.add(distinctBox);

    JPanel commentBox = new JPanel();
    commentBox.setLayout(new BoxLayout(commentBox, BoxLayout.PAGE_AXIS));
    commentBox.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Notes on this culture:"));
    JScrollPane commentsPane = new JScrollPane();
    comments = new JTextArea();
    comments.setColumns(20);
    comments.setEditable(true);
    comments.setRows(3);
    comments.setText(PersonPanel.restoreLineBreaks(ctxt.comments));
    comments.getDocument().addDocumentListener(new CommentListener());
    commentsPane.setViewportView(comments);
    commentBox.add(commentsPane);

    JPanel guts = new JPanel(); // Holds the guts of this window
    guts.setLayout(new BoxLayout(guts, BoxLayout.LINE_AXIS));
    guts.add(leftCol);
    guts.add(Box.createRigidArea(new Dimension(10, 4)));
    guts.add(rightCol);

    JPanel wholeThing = new JPanel();
    wholeThing.setLayout(new BoxLayout(wholeThing, BoxLayout.PAGE_AXIS));
    wholeThing.add(Box.createRigidArea(new Dimension(0, 4)));
    wholeThing.add(guts);
    wholeThing.add(Box.createRigidArea(new Dimension(0, 8)));
    wholeThing.add(commentBox);
    wholeThing.add(Box.createRigidArea(new Dimension(0, 4)));

    getContentPane().add(wholeThing);

    addInternalFrameListener(this);
    setSize(600, 620);
    setVisible(true);
  } //  end of ContextEditor constructor