Пример #1
0
  /** test a prop for existance */
  /*package*/ void test(
      Property prop, TagPath trigger, List<ViewContext> issues, ReportValidate report) {

    // check for property by path1
    Property prop1 = prop.getProperty(path1);
    if (prop1 == null) return;

    // then check for property by path2
    Property prop2 = prop.getProperty(path2);
    if (prop2 != null) return;

    // found path1 but not path2!
    String text =
        report.translate(
            "err.exists.without", Gedcom.getName(prop1.getTag()), Gedcom.getName(path2.getLast()));
    issues.add(new ViewContext(prop1).setText(text));
  }
Пример #2
0
  /** Finish editing a property through proxy */
  @Override
  protected void commitImpl(Property property) {

    PropertyName p = (PropertyName) property;

    // ... calc texts
    String first = cFirst.getText().trim();
    String last = cLast.getText().trim();
    String suff = tSuff.getText().trim();
    String nick = tNick.getText().trim();

    Gedcom ged = p.getGedcom();
    if (ged != null) {
      switch (Options.getInstance().correctName) {
          // John DOE
        case 2:
          last = last.toUpperCase(ged.getLocale());
          cLast.setText(last);
          // John Doe
        case 1:
          if (first.length() > 0) {
            first =
                Character.toString(first.charAt(0)).toUpperCase(ged.getLocale())
                    + first.substring(1);
            cFirst.setText(first);
          }
      }
    }

    // ... store changed value
    p.setName(first, last, suff, cAll.isSelected());
    p.setNick(nick);

    // start fresh
    setPropertyImpl(p);

    // Done
  }
Пример #3
0
  public NameBean() {

    setLayout(LAYOUT.copy());

    cLast = new ChoiceWidget();
    cLast.addChangeListener(changeSupport);
    cLast.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            String msg = getReplaceAllMsg();
            if (msg != null) {
              cAll.setVisible(true);
              cAll.setToolTipText(msg);
            }
          }
        });
    cLast.setIgnoreCase(true);
    cFirst = new ChoiceWidget();
    cFirst.addChangeListener(changeSupport);
    cFirst.setIgnoreCase(true);
    tSuff = new TextFieldWidget("", 10);
    tSuff.addChangeListener(changeSupport);
    tNick = new TextFieldWidget("", 10);
    tNick.addChangeListener(changeSupport);

    cAll = new JCheckBox();
    cAll.setBorder(new EmptyBorder(1, 1, 1, 1));
    cAll.setVisible(false);
    cAll.setRequestFocusEnabled(false);

    add(new JLabel(PropertyName.getLabelForFirstName()));
    add(cFirst);

    add(new JLabel(PropertyName.getLabelForLastName()));
    add(cLast);
    add(cAll);

    add(new JLabel(PropertyName.getLabelForSuffix()));
    add(tSuff);

    add(new JLabel(Gedcom.getName("NICK")));
    add(tNick);

    // listen to selection of global and ask for confirmation
    cAll.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String msg = getReplaceAllMsg();
            if (msg != null && cAll.isSelected()) {
              int rc =
                  DialogHelper.openDialog(
                      RESOURCES.getString("choice.global.enable"),
                      DialogHelper.QUESTION_MESSAGE,
                      msg,
                      Action2.yesNo(),
                      NameBean.this);
              cAll.setSelected(rc == 0);
            }
          }
        });

    // we're done aside from declaring the default focus
    defaultFocus = cFirst;
  }