📄 clusterinfoshell.java
字号:
radioRecord.setBackground(panelBackground);
radioRecord.setText(LumaQQ.getResourceString("cluster.info.message.record"));
radioRecord.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
messageOption = "record";
}
}
);
// 阻止一切消息
radioBlock = new Button(group, SWT.RADIO);
radioBlock.setBackground(panelBackground);
radioBlock.setText(LumaQQ.getResourceString("cluster.info.message.block"));
radioBlock.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
messageOption = "block";
}
}
);
}
/**
* 关闭窗口
*/
protected void close() {
if(shell != null && !shell.isDisposed())
shell.close();
}
// 显示一个资料面板
private void showPanel(int panel) {
if(panel == prevPanel) return;
else {
prevButton.setImage(null);
prevComposite.setVisible(false);
prevPanel = panel;
buttons[panel].setImage(icons.getResource(IconHolder.icoArrow));
composites[panel].setVisible(true);
prevButton = buttons[panel];
prevComposite = composites[panel];
}
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
*/
public void widgetDisposed(DisposeEvent e) {
bannerBackground.dispose();
controlBackground.dispose();
panelBackground.dispose();
commonButtonColor.dispose();
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.ShellListener#shellClosed(org.eclipse.swt.events.ShellEvent)
*/
public void shellClosed(ShellEvent e) {
main.client.removeQQListener(this);
main.removeMeFromCISMap(c);
// 设置群的头像
Image image = icons.getClusterFace(c.getFaceId());
c.addProperty("image", image);
main.refreshSCMSImage(c, image);
}
/**
* 窗口激活
*/
public void setActive() {
shell.setActive();
}
/**
* 设置最小化状态
* @param b
*/
public void setMinimized(boolean b) {
shell.setMinimized(b);
}
// 打开shell
public void open() {
// 打开shell
shell.layout();
// set dialog to center of screen
Rectangle dialogRect = shell.getBounds();
Rectangle displayRect = display.getBounds();
shell.setLocation((displayRect.width - dialogRect.width) / 2, (displayRect.height - dialogRect.height) / 2);
shell.open();
// 把自己加为QQListener
main.client.addQQListener(this);
}
/**
* 设置群model
* @param c
*/
public void setClusterModel(ClusterModel c) {
this.c = c;
refreshValue();
}
/**
* 刷新各控件的值
*/
private void refreshValue() {
ClusterInfo info = (ClusterInfo)c.getProperty("info");
// 基本资料面板
if(info != null) {
// id
textId.setText(String.valueOf(info.externalId));
// creator
textCreator.setText(String.valueOf(info.creator));
// name
textName.setText(info.name);
// notice
textNotice.setText(info.notice);
// description
textDescription.setText(info.description);
// category
comboCategory.select(info.category);
// authType
authType = info.authType;
if(authType == QQ.QQ_CLUSTER_NO_AUTH) {
radioNoAuth.setSelection(true);
radioNeedAuth.setSelection(false);
radioNoAdd.setSelection(false);
} else if(authType == QQ.QQ_CLUSTER_NEED_AUTH) {
radioNoAuth.setSelection(false);
radioNeedAuth.setSelection(true);
radioNoAdd.setSelection(false);
} else {
radioNoAuth.setSelection(false);
radioNeedAuth.setSelection(false);
radioNoAdd.setSelection(true);
}
}
// face
face = c.getFaceId();
btnFace.setImage(icons.getClusterFace(face));
// 成员列表面板
table.removeAll();
Hashtable members = (Hashtable)c.getProperty("members");
if(members != null) {
Iterator iter = members.values().iterator();
while(iter.hasNext()) {
FriendModel f = (FriendModel)iter.next();
TableItem ti = new TableItem(table, SWT.NONE);
// qq
ti.setText(0, ((Integer)f.getProperty("qq")).toString());
// name
ti.setText(1, (String)f.getProperty("name"));
// gender & age
ContactInfo contact = (ContactInfo)f.getProperty("contact");
if(contact != null) {
// gender
ti.setText(2, contact.infos[contact.gender]);
// age
ti.setText(3, contact.infos[contact.age]);
}
// set image
ti.setImage(icons.getSmallFace(f.getFaceId()));
// set data
ti.setData(f);
}
}
// 消息设定面板
messageOption = (String)c.getProperty("message");
if(messageOption != null) {
if("accept".equals(messageOption)) {
radioAccept.setSelection(true);
radioEject.setSelection(false);
radioRecord.setSelection(false);
radioBlock.setSelection(false);
} else if("eject".equals(messageOption)) {
radioAccept.setSelection(false);
radioEject.setSelection(true);
radioRecord.setSelection(false);
radioBlock.setSelection(false);
} else if("record".equals(messageOption)) {
radioAccept.setSelection(false);
radioEject.setSelection(false);
radioRecord.setSelection(true);
radioBlock.setSelection(false);
} else {
radioAccept.setSelection(false);
radioEject.setSelection(false);
radioRecord.setSelection(false);
radioBlock.setSelection(true);
}
}
}
/**
* 设置是否可以修改群的资料
* @param b
*/
public void setCanModified(boolean b) {
if(b) {
btnRemoveMember.setVisible(true);
btnSetMember.setEnabled(true);
btnUpdate.setVisible(false);
btnModify.setVisible(true);
authGroup.setEnabled(true);
radioNoAuth.setEnabled(true);
radioNeedAuth.setEnabled(true);
radioNoAdd.setEnabled(true);
} else {
btnRemoveMember.setVisible(false);
btnSetMember.setEnabled(false);
btnUpdate.setVisible(true);
btnModify.setVisible(false);
authGroup.setEnabled(false);
radioNoAuth.setEnabled(false);
radioNeedAuth.setEnabled(false);
radioNoAdd.setEnabled(false);
}
}
/**
* 设置窗口只显示出基本资料面板,这主要是用在搜索的时候,要查看资料,其他两个面板是没有的
*/
public void showBasicOnly() {
buttons[MEMBER].setVisible(false);
buttons[MESSAGE].setVisible(false);
authGroup.setEnabled(false);
radioNoAuth.setSelection(false);
radioNeedAuth.setSelection(false);
radioNoAdd.setSelection(false);
btnUpdate.setVisible(false);
btnModify.setVisible(false);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.events.FriendSelectionListener#friendSelected(edu.tsinghua.lumaqq.events.FriendSelectionEvent)
*/
public void friendSelected(FriendSelectionEvent e) {
List list = (List)e.getSource();
Iterator iter = list.iterator();
while(iter.hasNext()) {
FriendModel f = (FriendModel)iter.next();
TableItem ti = new TableItem(table, SWT.NONE);
// qq
ti.setText(0, ((Integer)f.getProperty("qq")).toString());
// name
ti.setText(1, (String)f.getProperty("name"));
// gender & age
ContactInfo contact = (ContactInfo)f.getProperty("contact");
if(contact != null) {
// gender
ti.setText(2, contact.infos[contact.gender]);
// age
ti.setText(3, contact.infos[contact.age]);
}
// set image
ti.setImage(icons.getSmallFace(f.getFaceId()));
// set data
ti.setData(f);
}
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.events.FriendSelectionListener#friendDeselected(edu.tsinghua.lumaqq.events.FriendSelectionEvent)
*/
public void friendDeselected(FriendSelectionEvent e) {
List list = (List)e.getSource();
Iterator iter = list.iterator();
while(iter.hasNext())
removeMember((FriendModel)iter.next());
}
/**
* 删除一个member
* @param f
*/
private void removeMember(FriendModel f) {
if(f == null) return;
int size = table.getItemCount();
for(int i = 0; i < size; i++) {
TableItem ti = table.getItem(i);
FriendModel f2 = (FriendModel)ti.getData();
if(f2.equals(f)) {
table.remove(i);
break;
}
}
}
/**
* 把当前窗口的数据应用到ClusterModel中,在调用这个方法之前,所做的修改都不会生效
*/
public void modifyInfo() {
ClusterInfo info = (ClusterInfo)c.getProperty("info");
c.addProperty("name", textName.getText());
c.addProperty("notice", textNotice.getText());
c.addProperty("description", textDescription.getText());
c.addProperty("face", new Integer(face));
c.addProperty("message", messageOption);
info.name = textName.getText();
info.notice = textNotice.getText();
info.description = textDescription.getText();
info.category = (char)comboCategory.getSelectionIndex();
info.authType = authType;
Hashtable members = (Hashtable)c.getProperty("members");
members.clear();
TableItem[] tis = table.getItems();
for(int i = 0; i < tis.length; i++) {
FriendModel f = (FriendModel)tis[i].getData();
members.put(f, f);
}
}
/**
* @return shell
*/
public Shell getShell() {
return shell;
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.qq.events.QQListener#qqEvent(edu.tsinghua.lumaqq.qq.events.QQEvent)
*/
public void qqEvent(QQEvent e) {
switch(e.type) {
case QQEvent.QQ_GET_CLUSTER_INFO_FAIL:
processGetClusterInfoFail(e);
break;
}
}
/**
* 处理群命令失败事件,如果错误信息表示自己已经不是群成员,则删除这个群
* @param e
*/
private void processGetClusterInfoFail(QQEvent e) {
final ClusterCommandReplyPacket packet = (ClusterCommandReplyPacket)e.getSource();
if(packet.clusterId == c.getClusterId()) {
main.display.asyncExec(
new Runnable() {
public void run() {
MessageBox box = new MessageBox(main.getShell(), SWT.ICON_ERROR | SWT.OK);
box.setText(LumaQQ.getResourceString("message.box.common.fail.title"));
box.setMessage(packet.errorMessage);
box.open();
if(packet.replyCode == QQ.QQ_CLUSTER_CMD_REPLY_NOT_MEMBER) {
main.removeCluster(c.getClusterId());
}
}
}
);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -