use of org.jivesoftware.spark.ui.VCardViewer in project Spark by igniterealtime.
the class VCardEditor method displayProfile.
/**
* Displays a users profile.
*
* @param jid
* the jid of the user.
* @param vcard
* the users vcard.
* @param parent
* the parent component, used for location handling.
*/
public void displayProfile(final String jid, VCard vcard, JComponent parent) {
VCardViewer viewer = new VCardViewer(jid);
final JFrame dlg = new JFrame(Res.getString("title.view.profile.for", jid));
avatarLabel = new JLabel();
avatarLabel.setHorizontalAlignment(JButton.RIGHT);
avatarLabel.setBorder(BorderFactory.createBevelBorder(0, Color.white, Color.lightGray));
// The user should only be able to close this dialog.
Object[] options = { Res.getString("button.view.profile"), Res.getString("close") };
final JOptionPane pane = new JOptionPane(viewer, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
// mainPanel.add(pane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
// GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5,
// 5, 5), 0, 0));
dlg.setIconImage(SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_16x16).getImage());
dlg.pack();
dlg.setSize(350, 250);
dlg.setResizable(true);
dlg.setContentPane(pane);
dlg.setLocationRelativeTo(parent);
PropertyChangeListener changeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (pane.getValue() instanceof Integer) {
pane.removePropertyChangeListener(this);
dlg.dispose();
return;
}
String value = (String) pane.getValue();
if (Res.getString("close").equals(value)) {
pane.removePropertyChangeListener(this);
dlg.dispose();
} else if (Res.getString("button.view.profile").equals(value)) {
pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
SparkManager.getVCardManager().viewFullProfile(jid, pane);
}
}
};
pane.addPropertyChangeListener(changeListener);
dlg.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent keyEvent) {
if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) {
dlg.dispose();
}
}
});
dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
}
Aggregations