📄 userdetailsoverviewpanel.java
字号:
package openicq.gui;import java.awt.Font;import javax.swing.*;import javax.swing.border.Border;import openicq.Start;import openicq.data.Default;import openicq.data.Resource;import openicq.net.*;import org.javalib.gui.SpringToolkit;import org.javalib.gui.model.SettingsDisplayPanel;import JOscarLib.Management.Contact;/** * The <code>UserDetailsOverviewPanel</code> class is a panel to show the user * details of any contact. * @author Hansgeorg Schwibbe * @copyright 2004 */public class UserDetailsOverviewPanel extends SettingsDisplayPanel{ private UserDetailsDialog userDialog; private JLabel jLabelNickNameDesc = new JLabel(); private JLabel jLabelFirstNameDesc = new JLabel(); private JLabel jLabelLastNameDesc = new JLabel(); private JLabel jLabelEmailDesc = new JLabel(); private JLabel jLabelNickNameValue = new JLabel(); private JLabel jLabelFirstNameValue = new JLabel(); private JLabel jLabelLastNameValue = new JLabel(); private JLabel jLabelEmailValue = new JLabel(); /** * Initializes a new instance of the class * <code>UserDetailsOverviewPanel</code>. * @param parent the parent dialog */ public UserDetailsOverviewPanel(JDialog parent) { super(); String text; userDialog = (UserDetailsDialog) parent; jLabelNickNameDesc.setFont(new Font(null, Font.BOLD, 11)); jLabelFirstNameDesc.setFont(new Font(null, Font.BOLD, 11)); jLabelLastNameDesc.setFont(new Font(null, Font.BOLD, 11)); jLabelEmailDesc.setFont(new Font(null, Font.BOLD, 11)); text = ((String[]) UserDetailsDialog.localized.get("contactDetails"))[1]; jLabelNickNameDesc.setText(text); text = ((String[]) UserDetailsDialog.localized.get("contactDetails"))[2]; jLabelFirstNameDesc.setText(text); text = ((String[]) UserDetailsDialog.localized.get("contactDetails"))[3]; jLabelLastNameDesc.setText(text); text = ((String[]) UserDetailsDialog.localized.get("contactDetails"))[4]; jLabelEmailDesc.setText(text); Border innerBorder = BorderFactory.createEmptyBorder(12, 12, 12, 12); Border outerBorder = BorderFactory.createLoweredBevelBorder(); this.setBorder(BorderFactory.createCompoundBorder(innerBorder, outerBorder)); this.setLayout(new SpringLayout()); this.add(jLabelNickNameDesc); this.add(jLabelNickNameValue); this.add(jLabelFirstNameDesc); this.add(jLabelFirstNameValue); this.add(jLabelLastNameDesc); this.add(jLabelLastNameValue); this.add(jLabelEmailDesc); this.add(jLabelEmailValue); SpringToolkit.makeCompactGrid(this, 4, 2, 5, 5, 5, 5); } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#getContinueWithoutSavingMessage() */ public String getContinueWithoutSavingMessage() { return ((String[]) UserDetailsDialog.localized.get("warningMessages"))[0] + "\n" + ((String[]) UserDetailsDialog.localized.get("questionMessages"))[0]; } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#getContinueWithoutSavingTitle() */ public String getContinueWithoutSavingTitle() { return ((String[]) UserDetailsDialog.localized.get("messageTitles"))[2]; } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#getListIconPath() */ public String getListIconPath() { return Resource.ICON_SOURCE_DETAILS[0]; } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#getListName() */ public String getListName() { return ((String[]) UserDetailsDialog.localized.get("detailsDialogList"))[0]; } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#getSaveButtonText() */ public String getSaveButtonText() { return ((String[]) UserDetailsDialog.localized.get("detailsDialog"))[1]; } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#getSaveSettingsErrorTitle() */ public String getSaveSettingsErrorTitle() { return ((String[]) UserDetailsDialog.localized.get("messageTitles"))[0]; } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#hasChanged() */ public boolean hasChanged() { Contact contact = userDialog.contact; if (contact != null) { if (!jLabelNickNameValue.getText().equals(contact.getNickName()) || !jLabelFirstNameValue.getText().equals(contact.getFirstName()) || !jLabelLastNameValue.getText().equals(contact.getLastName()) || !jLabelEmailValue.getText().equals(contact.getEmail())) { return true; } } return false; } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#loadSettings() */ public synchronized void loadSettings() { if (userDialog.contact != null) { jLabelNickNameValue.setText(userDialog.contact.getNickName()); jLabelFirstNameValue.setText(userDialog.contact.getFirstName()); jLabelLastNameValue.setText(userDialog.contact.getLastName()); jLabelEmailValue.setText(userDialog.contact.getEmail()); } } /** * (non-Javadoc) * @see org.javalib.gui.model.SettingsDisplayPanel#saveSettings() */ public synchronized void saveSettings() throws Exception { synchronized (Start.env) { int ownId = Integer.parseInt(Start.env.getOwnContact().getContactId()); int searchId = Integer.parseInt(userDialog.contact.getContactId()); new ShortUserInfoRequest(Start.env.getConnection(), ownId, searchId) { public void onResponse(ShortUserInfo shortInfo) { if (shortInfo.getSuccessByte() != Flag.SUCCESS) { String msg, title; msg = ((String[]) UserDetailsDialog.localized.get("errorMessages"))[25]; title = ((String[]) UserDetailsDialog.localized.get("messageTitles"))[0]; JOptionPane.showMessageDialog(userDialog, msg, title, JOptionPane.ERROR_MESSAGE); return; } int size; String path; try { userDialog.contact.setNickName(shortInfo.getNickName()); userDialog.contact.setFirstName(shortInfo.getFirstName()); userDialog.contact.setLastName(shortInfo.getLastName()); userDialog.contact.setEmail(shortInfo.getEmail()); userDialog.setContact(userDialog.contact); String knownId, msg; synchronized (Start.env) { size = Start.env.getKnownList().getContactListSize(); for (int index = 0; index < size; index++) { knownId = Start.env.getKnownList().get(index).getContactId(); if (knownId.equals(userDialog.contact.getContactId())) { Start.env.setKnownList(Start.env.sortContactList(Start.env.getKnownList())); userDialog.mainFrame.contactPanel.initContacts(); SettingsDisplayPanel[] dspPnls = userDialog.getDisplayPanels(); userDialog.setDisplayPanels(dspPnls, 0); try { path = Default.FOLDER_NAME_HOME + "/" + Start.env.getOwnContact().getContactId() + "/" + Default.FILE_NAME_KNOWN_LIST; Start.env.saveContactList(path, Start.env.getKnownList()); } catch (Exception ex) { msg = ((String[]) UserDetailsDialog.localized.get("errorMessages"))[9]; throw new Exception(msg); } return; } } size = Start.env.getUnknownList().getContactListSize(); for (int index = 0; index < size; index++) { knownId = Start.env.getUnknownList().get(index).getContactId(); if (knownId.equals(userDialog.contact.getContactId())) { Start.env.setUnknownList(Start.env.sortContactList(Start.env.getUnknownList())); userDialog.mainFrame.contactPanel.initContacts(); SettingsDisplayPanel[] dspPnls = userDialog.getDisplayPanels(); userDialog.setDisplayPanels(dspPnls, 0); try { path = Default.FOLDER_NAME_HOME + "/" + Start.env.getOwnContact().getContactId() + "/" + Default.FILE_NAME_UNKNOWN_LIST; Start.env.saveContactList(path, Start.env.getUnknownList()); } catch (Exception ex) { msg = ((String[]) UserDetailsDialog.localized.get("errorMessages"))[14]; throw new Exception(msg); } return; } } } } catch (Exception ex) { System.err.println(this.getClass().getName() + ": " + ex.toString()); } } }; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -