📄 lumaqqmodellistener.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 org.eclipse.swt.SWT;
import edu.tsinghua.lumaqq.models.ClusterModel;
import edu.tsinghua.lumaqq.models.FriendModel;
import edu.tsinghua.lumaqq.shells.*;
import edu.tsinghua.swt.events.GeneralModelEvent;
import edu.tsinghua.swt.events.ShutterModelEvent;
import edu.tsinghua.swt.events.ShutterModelListener;
import edu.tsinghua.swt.models.INode;
import edu.tsinghua.swt.widgets.ShutterLabel;
/**
* model的事件监听器
* 在添加了一个好友时,根据好友的属性设置view part的状态,比如会员用红字显示
*
* @author 马若劼
*/
public class LumaQQModelListener implements ShutterModelListener {
private MainShell main;
/**
* 构造函数
* @param main
*/
public LumaQQModelListener(MainShell main) {
this.main = main;
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.ShutterModelListener#itemAdded(edu.tsinghua.swt.events.ShutterModelEvent)
*/
public void itemAdded(ShutterModelEvent e) {
// 判断当前的model是否是ClusterModel,对于新添加的组,没有太多需要做的工作
INode node = main.model.getItem(e.tabIndex, e.itemIndex);
if(node instanceof ClusterModel) {
ClusterModel c = (ClusterModel)node;
ShutterLabel control = main.shutter.getItemControl(e.tabIndex, e.itemIndex);
if(c.isPermanent())
control.setForeground(main.display.getSystemColor(SWT.COLOR_RED));
} else {
// 如果不是ClusterModel,那肯定是FriendModel,继续
FriendModel f = (FriendModel)node;
ShutterLabel control = main.shutter.getItemControl(e.tabIndex, e.itemIndex);
if(control == null) return;
// 判断是否会员
boolean member = f.isMember();
// 设置头像
control.setImage(main.getFaceByStatus(f));
// 开始判断在线状态,是会员的颜色设成红的,等等
if("online".equals(f.getProperty("status"))) {
if(member)
control.setForeground(main.display.getSystemColor(SWT.COLOR_RED));
} else if("away".equals(f.getProperty("status"))) {
control.setForeground(main.display.getSystemColor(SWT.COLOR_BLUE));
} else {
if(member)
control.setForeground(main.display.getSystemColor(SWT.COLOR_BLACK));
}
}
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.ShutterModelListener#itemRemoved(edu.tsinghua.swt.events.ShutterModelEvent)
*/
public void itemRemoved(ShutterModelEvent e) {
// 没有什么要做的
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.GeneralModelListener#modelAdded(edu.tsinghua.swt.events.GeneralModelEvent)
*/
public void modelAdded(GeneralModelEvent e) {
// 没有什么要做的
}
/* (non-Javadoc)
* @see edu.tsinghua.swt.events.GeneralModelListener#modelRemoved(edu.tsinghua.swt.events.GeneralModelEvent)
*/
public void modelRemoved(GeneralModelEvent e) {
// 没有什么要做的
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -