⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userinfoshell.java

📁 用java实现的
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			}
		);
		// 网络安全按钮
		ShutterLabel btnSecurity = new ShutterLabel(shell, MySWT.FLAT | MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("user.info.button.security"), null);
        btnSecurity.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
        btnSecurity.setBackground(switchButtonColor);
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.top = new FormAttachment(btnDetail, 0, SWT.BOTTOM);
		fd.right = new FormAttachment(0, 105);
		btnSecurity.setLayoutData(fd);
		btnSecurity.addMouseListener(
			new MouseAdapter() {
				public void mouseDown(MouseEvent e) {
					showPanel(SECURITY);
				}
			}
		);
		// 备注按钮
		ShutterLabel btnRemark = new ShutterLabel(shell, MySWT.FLAT | MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("user.info.button.remark"), null);
		btnRemark.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
		btnRemark.setBackground(switchButtonColor);
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.top = new FormAttachment(btnDetail, 0, SWT.BOTTOM);
		fd.right = new FormAttachment(0, 105);
		btnRemark.setLayoutData(fd);
		btnRemark.addMouseListener(
			new MouseAdapter() {
				public void mouseDown(MouseEvent e) {
					showPanel(REMARK);
					btnUpdate.setText(LumaQQ.getResourceString("user.info.button.modify"));
				}
			}
		);
		// 加入按钮到数组中
		buttons[BASIC] = btnBasic;
		buttons[DETAIL] = btnDetail;
		buttons[CONTACT] = btnContact;
		buttons[SECURITY] = btnSecurity;
		buttons[REMARK] = btnRemark;
		// 初始化基本资料面板
		initBasicPanel();
		// 初始化联系方法面板
		initContactPanel();
		// 初始化详细资料面板
		initDetailPanel();
		// 初始化网络安全面板
		initSecurityPanel();
		// 初始化备注面板
		initRemarkPanel();
		// 关闭按钮
		ShutterLabel btnClose = new ShutterLabel(shell, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("user.info.button.close"), null);
		btnClose.setBackground(commonButtonColor);
		fd = new FormData();
		fd.right = new FormAttachment(100, -5);
		fd.left = new FormAttachment(100, -65);
		fd.top = new FormAttachment(composites[0], 8, SWT.BOTTOM);
		btnClose.setLayoutData(fd);
		btnClose.addMouseListener(
			new MouseAdapter() {
				public void mouseUp(MouseEvent e) {
					close();
				}
			}
		);
		// 更新按钮
		btnUpdate = new ShutterLabel(shell, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("user.info.button.update"), null);
		btnUpdate.setBackground(commonButtonColor);
		fd = new FormData();
		fd.right = new FormAttachment(btnClose, -10, SWT.LEFT);
		fd.left = new FormAttachment(btnClose, -70, SWT.LEFT);
		fd.top = new FormAttachment(btnClose, 0, SWT.TOP);
		btnUpdate.setLayoutData(fd);
		btnUpdate.addMouseListener(
			new MouseAdapter() {
				public void mouseUp(MouseEvent e) {
					if(prevPanel == REMARK) {
						// 如果当前处于备注面板,则保存备注
						saveToXML(createRemarkElement());
						btnUpdate.setEnabled(false);
					} else {
						// 	请求用户信息
						main.client.getUserInfo(qqNum);
					}
				}
			}
		);		
		// 修改按钮
		btnModify = new ShutterLabel(shell, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("user.info.button.modify"), null);
		btnModify.setBackground(commonButtonColor);
		fd = new FormData();
		fd.right = new FormAttachment(btnClose, -10, SWT.LEFT);
		fd.left = new FormAttachment(btnClose, -70, SWT.LEFT);
		fd.top = new FormAttachment(btnClose, 0, SWT.TOP);
		btnModify.setLayoutData(fd);
		btnModify.addMouseListener(
			new MouseAdapter() {
				public void mouseUp(MouseEvent e) {
					if(chkChangePassword.getSelection()) {
						if(!checkOldPassword()) {
							MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
							box.setText(LumaQQ.getResourceString("message.box.change.password.title"));
							box.setMessage(LumaQQ.getResourceString("error.old.password.wrong"));
							box.open();
						} else if(!checkNewPassword()) {
							MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
							box.setText(LumaQQ.getResourceString("message.box.change.password.title"));
							box.setMessage(LumaQQ.getResourceString("error.two.password.differ"));
							box.open();
						} else
							main.client.modifyInfo(textOldPassword.getText(), textNewPassword.getText(), assembleContactInfo());
					} else {
						main.client.modifyInfo(null, null, assembleContactInfo());
					}
				}
			}
		);
	}	

	// 初始化备注面板
	private void initRemarkPanel() {
		Composite remark = createPanel();
		remark.setVisible(false);
		composites[REMARK] = remark;
		// banner
		Label remarkBanner = new Label(remark, SWT.NONE);
		remarkBanner.setBackground(bannerBackground);
		remarkBanner.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
		FormData fd = new FormData();
		fd.left = fd.top = new FormAttachment(0, 0);
		fd.right = new FormAttachment(100, 0);
		fd.bottom = new FormAttachment(0, 24);
		remarkBanner.setLayoutData(fd);
		remarkBanner.addPaintListener(new BannerPaintListener(LumaQQ.getResourceString("user.info.banner.remark")));
		// 用户姓名标签
		Label lblName = new Label(remark, SWT.NONE);
		lblName.setBackground(panelBackground);
		lblName.setText(LumaQQ.getResourceString("user.info.remark.name"));
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(20, 0);
		fd.top = new FormAttachment(remarkBanner, 5, SWT.BOTTOM);
		lblName.setLayoutData(fd);
		// 用户姓名文本框
		textRemarkName = new Text(remark, SWT.SINGLE | SWT.BORDER);
		textRemarkName.setBackground(controlBackground);
		textRemarkName.addModifyListener(rtml);
		fd = new FormData();
		fd.left = new FormAttachment(lblName, 3, SWT.RIGHT);
		fd.right = new FormAttachment(50, 0);
		fd.top = new FormAttachment(remarkBanner, 5, SWT.BOTTOM);
		textRemarkName.setLayoutData(fd);
		// 邮政编码标签
		Label lblZipcode = new Label(remark, SWT.NONE);
		lblZipcode.setBackground(panelBackground);
		lblZipcode.setText(LumaQQ.getResourceString("user.info.remark.zipcode"));
		fd = new FormData();
		fd.left = new FormAttachment(50, 5);
		fd.right = new FormAttachment(70, 0);
		fd.top = new FormAttachment(remarkBanner, 5, SWT.BOTTOM);
		lblZipcode.setLayoutData(fd);
		// 邮政编码文本框
		textRemarkZipcode = new Text(remark, SWT.SINGLE | SWT.BORDER);
		textRemarkZipcode.setBackground(controlBackground);
		textRemarkZipcode.addModifyListener(rtml);
		fd = new FormData();
		fd.left = new FormAttachment(lblZipcode, 3, SWT.RIGHT);
		fd.right = new FormAttachment(100, -5);
		fd.top = new FormAttachment(remarkBanner, 5, SWT.BOTTOM);
		textRemarkZipcode.setLayoutData(fd);
		// 常用电话标签
		Label lblTelephone = new Label(remark, SWT.NONE);
		lblTelephone.setBackground(panelBackground);
		lblTelephone.setText(LumaQQ.getResourceString("user.info.remark.telephone"));
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(20, 0);
		fd.top = new FormAttachment(remarkBanner, 30, SWT.BOTTOM);
		lblTelephone.setLayoutData(fd);
		// 常用电话文本框
		textRemarkTelephone = new Text(remark, SWT.SINGLE | SWT.BORDER);
		textRemarkTelephone.setBackground(controlBackground);
		textRemarkTelephone.addModifyListener(rtml);
		fd = new FormData();
		fd.left = new FormAttachment(lblTelephone, 3, SWT.RIGHT);
		fd.right = new FormAttachment(50, 0);
		fd.top = new FormAttachment(remarkBanner, 30, SWT.BOTTOM);
		textRemarkTelephone.setLayoutData(fd);
		// 手机号码标签
		Label lblMobile = new Label(remark, SWT.NONE);
		lblMobile.setBackground(panelBackground);
		lblMobile.setText(LumaQQ.getResourceString("user.info.remark.mobile"));
		fd = new FormData();
		fd.left = new FormAttachment(50, 5);
		fd.right = new FormAttachment(70, 0);
		fd.top = new FormAttachment(remarkBanner, 30, SWT.BOTTOM);
		lblMobile.setLayoutData(fd);
		// 手机号码文本框
		textRemarkMobile = new Text(remark, SWT.SINGLE | SWT.BORDER);
		textRemarkMobile.setBackground(controlBackground);
		textRemarkMobile.addModifyListener(rtml);
		fd = new FormData();
		fd.left = new FormAttachment(lblMobile, 3, SWT.RIGHT);
		fd.right = new FormAttachment(100, -5);
		fd.top = new FormAttachment(remarkBanner, 30, SWT.BOTTOM);
		textRemarkMobile.setLayoutData(fd);
		// 电子邮箱标签
		Label lblEmail = new Label(remark, SWT.NONE);
		lblEmail.setBackground(panelBackground);
		lblEmail.setText(LumaQQ.getResourceString("user.info.remark.email"));
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(20, 0);
		fd.top = new FormAttachment(remarkBanner, 55, SWT.BOTTOM);
		lblEmail.setLayoutData(fd);
		// 电子邮箱文本框
		textRemarkEmail = new Text(remark, SWT.SINGLE | SWT.BORDER);
		textRemarkEmail.setBackground(controlBackground);
		textRemarkEmail.addModifyListener(rtml);
		fd = new FormData();
		fd.left = new FormAttachment(lblEmail, 3, SWT.RIGHT);
		fd.right = new FormAttachment(100, -5);
		fd.top = new FormAttachment(remarkBanner, 55, SWT.BOTTOM);
		textRemarkEmail.setLayoutData(fd);
		// 联系地址标签
		Label lblAddress = new Label(remark, SWT.NONE);
		lblAddress.setBackground(panelBackground);
		lblAddress.setText(LumaQQ.getResourceString("user.info.remark.address"));
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(20, 0);
		fd.top = new FormAttachment(remarkBanner, 80, SWT.BOTTOM);
		lblAddress.setLayoutData(fd);
		// 联系地址文本框
		textRemarkAddress = new Text(remark, SWT.SINGLE | SWT.BORDER);
		textRemarkAddress.setBackground(controlBackground);
		textRemarkAddress.addModifyListener(rtml);
		fd = new FormData();
		fd.left = new FormAttachment(lblAddress, 3, SWT.RIGHT);
		fd.right = new FormAttachment(100, -5);
		fd.top = new FormAttachment(remarkBanner, 80, SWT.BOTTOM);
		textRemarkAddress.setLayoutData(fd);
		// 备注标签
		Label lblNote = new Label(remark, SWT.NONE);
		lblNote.setBackground(panelBackground);
		lblNote.setText(LumaQQ.getResourceString("user.info.remark.note"));
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(20, 0);
		fd.top = new FormAttachment(remarkBanner, 105, SWT.BOTTOM);
		lblNote.setLayoutData(fd);
		// 备注文本框
		textRemarkNote = new Text(remark, SWT.BORDER | SWT.MULTI | SWT.WRAP);
		textRemarkNote.setBackground(controlBackground);
		textRemarkNote.addModifyListener(rtml);
		fd = new FormData();
		fd.left = new FormAttachment(lblAddress, 3, SWT.RIGHT);
		fd.right = new FormAttachment(100, -5);
		fd.top = new FormAttachment(remarkBanner, 105, SWT.BOTTOM);
		fd.bottom = new FormAttachment(100, -5);
		textRemarkNote.setLayoutData(fd);
		// 上传备注按钮
		btnUploadRemark = new ShutterLabel(remark, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("user.info.remark.button.upload"), null);
		btnUploadRemark.setBackground(commonButtonColor);
		fd = new FormData();
		fd.left = new FormAttachment(0, 1);
		fd.bottom = new FormAttachment(100, -5);
		btnUploadRemark.setLayoutData(fd);
		btnUploadRemark.addMouseListener(
			new MouseAdapter() {
				public void mouseUp(MouseEvent e) {
					uploadFriendRemark();
				}
			}
		);
		// 下载备注按钮
		btnDownloadRemark = new ShutterLabel(remark, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("user.info.remark.button.download"), null);
		btnDownloadRemark.setBackground(commonButtonColor);
		fd = new FormData();
		fd.left = new FormAttachment(0, 1);
		fd.bottom = new FormAttachment(btnUploadRemark, -5, SWT.TOP);
		btnDownloadRemark.setLayoutData(fd);
		btnDownloadRemark.addMouseListener(
			new MouseAdapter() {
				public void mouseUp(MouseEvent e) {
					btnDownloadRemark.setEnabled(false);
					main.client.downloadFriendRemark(qqNum);
				}
			}
		);
	}
	
	// 上传好友备注信息,上传的同时会保存到xml中
	protected void uploadFriendRemark() {
		Remark remark = createRemarkElement();
		// 创建FriendRemark对象
		FriendRemark fr = new FriendRemark();
		fr.name = remark.getName();
		fr.zipcode = remark.getZipcode();
		fr.telephone = remark.getTelephone();
		fr.mobile = remark.getMobile();
		fr.email = remark.getEmail();
		fr.address = remark.getAddress();
		fr.note = remark.getNote();
		// 保存到xml
		saveToXML(remark);
		// 上传
		main.client.uploadFriendRemark(qqNum, fr);
	}
	
	/**
	 * 创建Remark元素对象
	 */
	private Remark createRemarkElement() {
		// 创建Remark元素对象
		Remark remark = new RemarkImpl();
		remark.setName(textRemarkName.getText());
		remark.setZipcode(textRemarkZipcode.getText());
		remark.setTelephone(textRemarkTelephone.getText());
		remark.setMobile(textRemarkMobile.getText());
		remark.setEmail(textRemarkEmail.getText());
		remark.setAddress(textRemarkAddress.getText());
		remark.setNote(textRemarkNote.getText());
		remark.setQqNum(String.valueOf(qqNum));
		return remark;
	}
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -