📄 grouppropertylistener.java
字号:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.events;
import edu.tsinghua.lumaqq.models.GroupModel;
import edu.tsinghua.lumaqq.models.IQQNode;
import edu.tsinghua.lumaqq.ui.MainShell;
import edu.tsinghua.swt.events.PropertyEvent;
import edu.tsinghua.swt.events.PropertyListener;
import edu.tsinghua.swt.widgets.CoolButton;
/**
* 监视组的属性变化
*
* @author 马若劼
*/
public class GroupPropertyListener implements PropertyListener {
private MainShell main;
/**
* 构造函数
* @param main
*/
public GroupPropertyListener(MainShell main) {
this.main = main;
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.PropertyListener#propertyAdded(edu.tsinghua.swt.events.PropertyEvent)
*/
public void propertyAdded(PropertyEvent e) {
if(e.key.equals(IQQNode.ONLINE_USER) || e.key.equals(IQQNode.USERS)) {
int index = main.getModel().indexOf(e.getSource());
refreshGroupStatistics(index);
}
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.PropertyListener#propertyRemoved(edu.tsinghua.swt.events.PropertyEvent)
*/
public void propertyRemoved(PropertyEvent e) {
// 没有什么要做的
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.PropertyListener#propertyModified(edu.tsinghua.swt.events.PropertyEvent)
*/
public void propertyModified(PropertyEvent e) {
if(e.key.equals(IQQNode.VISIBLE)) {
int index = main.getModel().indexOf(e.getSource());
if("true".equals(e.newValue))
main.getShutter().showTab(index, true);
else
main.getShutter().hideTab(index, true);
main.getShutter().layout();
} else if(e.key.equals(IQQNode.ONLINE_USER) || e.key.equals(IQQNode.USERS)) {
int index = main.getModel().indexOf(e.getSource());
refreshGroupStatistics(index);
} else if(e.key.equals(IQQNode.NAME)) {
// 这个功能不再使用,因为LumaQQ会允许不自动更新分组信息,所以,这里搞成自动的会带来问题
//main.getMVCHelper().updateGroupInServer();
}
}
/**
* 刷新组好友统计数据
*
* @param tabIndex
*/
private void refreshGroupStatistics(int tabIndex) {
GroupModel g = (GroupModel)main.getModel().getTab(tabIndex);
CoolButton tab = main.getShutter().getTabControl(tabIndex);
String text = tab.getText();
int i = text.lastIndexOf('(');
if(i != -1)
text = text.substring(0, i - 1);
tab.setText(text + " (" + g.getOnlineUser() + '/' + g.getUsers() + ')');
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -