/** This method is used to change the dynamically label of an object in this JInvidChooser. */
  public void relabelObject(Invid invid, String newLabel) {
    MutableComboBoxModel model = (MutableComboBoxModel) getModel();

    synchronized (model) {
      for (int i = 0; i < model.getSize(); i++) {
        listHandle lh = (listHandle) model.getElementAt(i);

        if (lh != null && lh.getObject() != null && lh.getObject().equals(invid)) {
          model.removeElementAt(i);
          lh.setLabel(newLabel);
          model.insertElementAt(lh, i);
          repaint();
          break;
        }
      }
    }
  }
  public Invid getSelectedInvid() {
    listHandle lh = (listHandle) getSelectedItem();

    if (lh == null) {
      return null;
    }

    if (editor != null && editor.theField != null) {
      if (!lh.toString().equals(editor.theField.getText())) {
        System.err.println(
            "JInvidChooser: " + lh.toString() + " does not equal " + editor.theField.getText());
        return null;
      }
    }

    return (Invid) lh.getObject();
  }
  /**
   * ActionListener method
   *
   * @see java.awt.event.ActionListener
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == view) {
      listHandle lh = (listHandle) getSelectedItem();

      if (lh != null) {
        Invid invid = (Invid) lh.getObject();

        if (invid == null) {
          /* XXX I don't think this can ever occur.. */

          // "You don''t have permission to view {0}."
          showErrorMessage(ts.l("actionPerformed.permissions_error", lh));
        } else {
          cp.gc.viewObject(invid);
        }
      }
    }
  }
  public JDefaultOwnerDialog(gclient gc, Vector groups) {
    // "Select Default Owner"
    super(gc, ts.l("init.title"), StandardDialog.ModalityType.DOCUMENT_MODAL);

    this.gc = gc;

    getContentPane().setLayout(new BorderLayout());

    // "Select default owner for newly created objects"
    JLabel dialog_banner = new JLabel(ts.l("init.label"));
    dialog_banner.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    getContentPane().add("North", dialog_banner);

    // did we previously have a list of chosen owner group invid's
    // selected?

    this.chosen = new Vector<Invid>();
    Vector<listHandle> handleVector = null;

    synchronized (JDefaultOwnerDialog.last_chosen_lock) {
      if (JDefaultOwnerDialog.last_chosen != null) {
        handleVector = new Vector<listHandle>();

        for (listHandle lh : JDefaultOwnerDialog.last_chosen) {
          Invid element_invid = (Invid) lh.getObject();

          handleVector.add(lh);
          this.chosen.add(element_invid);
        }
      }
    }

    ss = new StringSelector(this, true, true, true);
    ss.update(groups, true, null, handleVector, true, null);
    ss.setCallback(this);
    getContentPane().add("Center", ss);

    ok = new JButton(StringDialog.getDefaultOk());
    ok.addActionListener(this);

    cancel = new JButton(StringDialog.getDefaultCancel());
    cancel.addActionListener(this);

    if (glogin.isRunningOnMac()) {
      JPanel p = new JPanel();
      p.add(cancel);
      p.add(ok);

      JPanel macPanel = new JPanel();
      macPanel.setLayout(new BorderLayout());
      macPanel.add(p, BorderLayout.EAST);

      macPanel.setBorder(gc.raisedBorder);

      getContentPane().add("South", macPanel);
    } else {
      JPanel p = new JPanel();
      p.add(ok);
      p.add(cancel);
      p.setBorder(gc.raisedBorder);

      getContentPane().add("South", p);
    }

    setBounds(50, 50, 50, 50);
    pack();
  }