📄 shelllauncher.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.ui.tool;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.lumaqq.MessageQueue;
import edu.tsinghua.lumaqq.models.ClusterModel;
import edu.tsinghua.lumaqq.models.FriendModel;
import edu.tsinghua.lumaqq.models.IQQNode;
import edu.tsinghua.lumaqq.models.MobileModel;
import edu.tsinghua.lumaqq.qq.QQClient;
import edu.tsinghua.lumaqq.qq.Util;
import edu.tsinghua.lumaqq.qq.packets.BasicInPacket;
import edu.tsinghua.lumaqq.qq.packets.in.ReceiveIMPacket;
import edu.tsinghua.lumaqq.ui.BatchDetectHiddenShell;
import edu.tsinghua.lumaqq.ui.BrowserShell;
import edu.tsinghua.lumaqq.ui.CheckUpdateShell;
import edu.tsinghua.lumaqq.ui.DetectHiddenShell;
import edu.tsinghua.lumaqq.ui.IPSeekerShell;
import edu.tsinghua.lumaqq.ui.MainShell;
import edu.tsinghua.lumaqq.ui.ReceiveIMWindow;
import edu.tsinghua.lumaqq.ui.ReceiveSMSShell;
import edu.tsinghua.lumaqq.ui.ReceiveSystemMessageShell;
import edu.tsinghua.lumaqq.ui.SendClusterIMWindow;
import edu.tsinghua.lumaqq.ui.SendIMWindow;
import edu.tsinghua.lumaqq.ui.SendSMSShell;
import edu.tsinghua.lumaqq.ui.SystemMessageListShell;
import edu.tsinghua.lumaqq.ui.config.cluster.ClusterInfoWindow;
import edu.tsinghua.lumaqq.ui.config.face.FaceWindow;
import edu.tsinghua.lumaqq.ui.config.sys.SystemOptionWindow;
import edu.tsinghua.lumaqq.ui.config.user.UserInfoWindow;
import edu.tsinghua.lumaqq.ui.helper.MVCHelper;
import edu.tsinghua.lumaqq.ui.wizard.WizardWindow;
import edu.tsinghua.lumaqq.ui.wizard.search.SearchWizard;
import edu.tsinghua.lumaqq.utils.OptionUtil;
import edu.tsinghua.swt.widgets.CoolButton;
/**
* 用来封装一些打开窗口的方法
*
* @author luma
*/
public class ShellLauncher {
private MainShell main;
public ShellLauncher(MainShell main) {
this.main = main;
}
/**
* 浏览搜索和创建校友录页面
*/
public void goAlumni() {
openBrowserShell(LumaQQ.getString("url.alumni"), "Search/Create Alumni", LumaQQ.getString("message.box.manual.alumni"));
}
/**
* 去QQ家园
*/
public void goQQHome() {
openBrowserShell(LumaQQ.getString("url.qqhome", new Object[] { String.valueOf(main.getMyModel().getQQ()), Util.convertByteToHexStringWithoutSpace(main.getClient().getUser().getClientKey()) }),
"",
LumaQQ.getString("message.box.please.set.browser"));
}
/**
* 去QQ秀商城
*/
public void goQQShowMall() {
openBrowserShell(LumaQQ.getString("url.qqshow.mall", new Object[] { String.valueOf(main.getMyModel().getQQ()), Util.convertByteToHexStringWithoutSpace(main.getClient().getUser().getClientKey()) }),
"",
LumaQQ.getString("message.box.please.set.browser"));
}
/**
* 登录群社区
*/
public void goClusterCommunity() {
openBrowserShell(LumaQQ.getString("url.cluster.community"), "Group Community", LumaQQ.getString("message.box.manual.community"));
}
/**
* 申请免费QQ号
*/
public void goApply() {
openBrowserShell(LumaQQ.getString("url.apply"), "Apply Free QQ Number", LumaQQ.getString("message.box.manual.apply"));
}
/**
* 聊天室
*/
public void goChatroom() {
openBrowserShell(LumaQQ.getString("url.chatroom"), "QQ Chatroom", LumaQQ.getString("message.box.manual.chat"));
}
/**
* QQ游戏
*/
public void goQQGame() {
openBrowserShell(LumaQQ.getString("url.game"), "QQ Game", LumaQQ.getString("message.box.manual.game"));
}
/**
* LumaQQ主页
*/
public void goLumaQQ() {
openBrowserShell(LumaQQ.getString("url.lumaqq"), "LumaQQ HomePage", LumaQQ.getString("message.box.manual.homepage"));
}
/**
* 打开系统消息列表窗口
*/
public void openSystemMessageListShell() {
if(main.getShellRegistry().isSystemMessageListShellOpened()) {
SystemMessageListShell smls = main.getShellRegistry().getSystemMessageListShell();
smls.setMinimized(false);
smls.setActive();
} else {
SystemMessageListShell smls = ShellFactory.createSystemMessageListShell(main);
main.getShellRegistry().registerSystemMessageListShell(smls);
smls.open();
}
}
/**
* 打开搜索用户窗口
*/
public void openSearchWizard() {
openSearchWizard(SearchWizard.SEARCH_WHAT);
}
/**
* 打开搜索用户窗口
*
* @param startPage
* 起始页
*/
public void openSearchWizard(String startPage) {
if(main.getShellRegistry().isSearchWizardOpened()) {
WizardWindow ss = main.getShellRegistry().getSearchWizard();
ss.setMinimized(false);
ss.setActive();
} else {
WizardWindow window = ShellFactory.createSearchWizard(main, startPage);
main.getShellRegistry().registerSearchWizard(window);
window.open();
}
}
/**
* 打开群组创建向导
*/
public void openClusterWizard() {
if(main.getShellRegistry().isClusterWizardOpened()) {
WizardWindow ccs = main.getShellRegistry().getClusterWizard();
ccs.setMinimized(false);
ccs.setActive();
} else {
WizardWindow window = ShellFactory.createClusterWizard(main);
main.getShellRegistry().registerClusterWizard(window);
window.open();
}
}
/**
* 打开系统设置对话框
*
* @return
* 系统设置窗口对象
*/
public SystemOptionWindow openSystemOptionWindow() {
SystemOptionWindow sos = null;
if(main.getShellRegistry().isSystemOptionWindowOpened()) {
sos = main.getShellRegistry().getSystemOptionWindow();
sos.setMinimized(false);
sos.setActive();
} else {
sos = ShellFactory.createSystemOptionWindow(main);
main.getShellRegistry().registerSystemOptionWindow(sos);
sos.open();
}
return sos;
}
/**
* 打开接收短消息窗口
*/
public void openReceiveSMSShell() {
MessageQueue mq = main.getMessageQueue();
// 得到短消息包
ReceiveIMPacket packet = (ReceiveIMPacket)mq.getSMS();
if(packet == null)
return;
// 如果没有短消息了,停止闪烁
if(!mq.hasSMS())
main.stopBlinkSMSIcon();
// 调整tray icon的闪烁状态
main.getUIHelper().resetTrayImageEffect();
// 打开查看短消息窗口
ReceiveSMSShell rsms = null;
if(main.getShellRegistry().isReceiveSMSShellOpened()) {
rsms = main.getShellRegistry().getReceiveSMSShell();
rsms.setMinimized(false);
rsms.setActive();
rsms.setFocus();
} else {
rsms = ShellFactory.createReceiveSMSShell(main);
main.getShellRegistry().registerReceiveSMSShell(rsms);
rsms.open();
}
rsms.setSMS(packet);
rsms.setNextButtonEnabled(mq.hasSMS());
}
/**
* 打开一个检测更新窗口
*/
public void openCheckUpdateShell() {
if(!main.getShellRegistry().isCheckUpdateShellOpened()) {
CheckUpdateShell cus = ShellFactory.createCheckUpdateShell(main);
main.getShellRegistry().registerCheckUpdateShell(cus);
cus.open();
}
}
/**
* 打开一个如来神掌窗口
*
* @param f
* 好友model
*/
public void openDetectHiddenShell(FriendModel f) {
DetectHiddenShell dhs = ShellFactory.createDetectHiddenShell(main, f);
dhs.open();
}
/**
* 打开一个如来神掌之乱舞窗口
*/
public void openBatchDetectHiddenShell() {
BatchDetectHiddenShell bdhs = ShellFactory.createBatchDetectHiddenShell(main);
bdhs.open();
}
/**
* 打开一个删除模式的查看系统消息窗口
*
* @param f
* 好友model
*/
public void openDeleteReceiveSystemMessageShell(FriendModel f) {
ReceiveSystemMessageShell rsms = ShellFactory.createReceiveSystemMessageShell(main);
rsms.setFriendModel(f);
rsms.open(ReceiveSystemMessageShell.DELETE_MODE);
}
/**
* 打开一个添加模式的查看系统消息窗口
*
* @param f
* 好友model
*/
public void openAddReceiveSystemMessageShell(FriendModel f) {
ReceiveSystemMessageShell rsms = ShellFactory.createReceiveSystemMessageShell(main);
rsms.setFriendModel(f);
rsms.open(ReceiveSystemMessageShell.ADD_MODE);
}
/**
* 打开一个IP查询窗口
*/
public void openIPSeekerShell() {
IPSeekerShell iss = ShellFactory.createIPSeekerShell(main);
iss.open();
}
/**
* 打开群消息发送窗口
*
* @param c
* 群model
*/
public void openClusterIMWindow(ClusterModel c) {
ShellRegistry shellRegistry = main.getShellRegistry();
MessageQueue mq = main.getMessageQueue();
QQClient client = main.getClient();
// 如果该群消息窗口已经打开,则直接使用,如果没有,创建一个
SendClusterIMWindow scms = null;
if(shellRegistry.hasSendClusterIMWindow(c)) {
scms = shellRegistry.getSendClusterIMWindow(c);
scms.setMinimized(false);
scms.setActive();
} else {
scms = ShellFactory.createSendClusterIMWindow(main, c);
shellRegistry.addSendClusterIMWindow(c, scms);
scms.open();
}
// 群消息数清0
c.resetMessageCount();
int clusterId = c.getClusterId();
if(mq.hasMessage(clusterId)) {
while(mq.hasMessage(clusterId)) {
// 得到消息包
ReceiveIMPacket packet = (ReceiveIMPacket)mq.getMessage(clusterId);
scms.appendMessage(c, packet.clusterIM, false);
}
CoolButton viewPart = main.getMVCHelper().getClusterViewPart(clusterId);
// 停止群头像的跳动
viewPart.stopBounceImage();
// 得到群的组索引和组的view part,重设组的图标特效状态
main.getUIHelper().resetGroupImageEffect(main.getMVCHelper().getFirstClusterGroup());
// 重设系统托盘区的图标特效状态
main.getUIHelper().resetTrayImageEffect();
}
}
/**
* 打开群消息发送窗口
*
* @param viewPart
* 群的View部分,一个CoolButton控件
*/
public void openClusterIMWindow(CoolButton viewPart) {
openClusterIMWindow((ClusterModel)viewPart.getData());
}
/**
* 打开一个发送短消息窗口
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -