📄 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.helper;
import static edu.tsinghua.lumaqq.resource.Messages.*;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import edu.tsinghua.lumaqq.MessageQueue;
import edu.tsinghua.lumaqq.models.Cluster;
import edu.tsinghua.lumaqq.models.Model;
import edu.tsinghua.lumaqq.models.ModelRegistry;
import edu.tsinghua.lumaqq.models.Organization;
import edu.tsinghua.lumaqq.models.User;
import edu.tsinghua.lumaqq.qq.Util;
import edu.tsinghua.lumaqq.qq.packets.InPacket;
import edu.tsinghua.lumaqq.qq.packets.in.ReceiveIMPacket;
import edu.tsinghua.lumaqq.record.RecordEntry;
import edu.tsinghua.lumaqq.ui.BrowserShell;
import edu.tsinghua.lumaqq.ui.CheckUpdateShell;
import edu.tsinghua.lumaqq.ui.IPSeekerWindow;
import edu.tsinghua.lumaqq.ui.InfoManagerWindow;
import edu.tsinghua.lumaqq.ui.MainShell;
import edu.tsinghua.lumaqq.ui.MemberEditShell;
import edu.tsinghua.lumaqq.ui.ReceiveIMWindow;
import edu.tsinghua.lumaqq.ui.ReceiveSystemMessageShell;
import edu.tsinghua.lumaqq.ui.SMSWindow;
import edu.tsinghua.lumaqq.ui.SendClusterIMWindow;
import edu.tsinghua.lumaqq.ui.SendIMTabWindow;
import edu.tsinghua.lumaqq.ui.SendIMWindow;
import edu.tsinghua.lumaqq.ui.SystemMessageListWindow;
import edu.tsinghua.lumaqq.ui.TempSessionIMWindow;
import edu.tsinghua.lumaqq.ui.WeatherWindow;
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.wizard.WizardWindow;
/**
* 用来封装一些打开窗口的方法
*
* @author luma
*/
public class ShellLauncher {
private MainShell main;
public ShellLauncher(MainShell main) {
this.main = main;
}
/**
* 浏览搜索和创建校友录页面
*/
public void goAlumni() {
openBrowserShell(url_alumni, "Search/Create Alumni", NLS.bind(message_box_manual_browse, url_alumni));
}
/**
* 去QQ家园
*/
public void goQQHome() {
openBrowserShell(NLS.bind(url_qqhome, String.valueOf(main.getMyModel().qq), Util.convertByteToHexStringWithoutSpace(main.getClient().getUser().getClientKey())),
"",
message_box_please_set_browser);
}
/**
* 去QQ秀商城
*/
public void goQQShowMall() {
openBrowserShell(NLS.bind(url_qqshow_mall, String.valueOf(main.getMyModel().qq), Util.convertByteToHexStringWithoutSpace(main.getClient().getUser().getClientKey())),
"",
message_box_please_set_browser);
}
/**
* 登录群社区
*/
public void goClusterCommunity() {
openBrowserShell(url_cluster_community, "Group Community", NLS.bind(message_box_manual_browse, url_cluster_community));
}
/**
* 申请免费QQ号
*/
public void goApply() {
openBrowserShell(url_apply, "Apply Free QQ Number", NLS.bind(message_box_manual_browse, url_apply));
}
/**
* 聊天室
*/
public void goChatroom() {
openBrowserShell(url_chatroom, "QQ Chatroom", NLS.bind(message_box_manual_browse, url_chatroom));
}
/**
* QQ游戏
*/
public void goQQGame() {
openBrowserShell(url_game, "QQ Game", NLS.bind(message_box_manual_browse, url_game));
}
/**
* LumaQQ主页
*/
public void goLumaQQ() {
openBrowserShell(url_lumaqq, "LumaQQ HomePage", NLS.bind(message_box_manual_browse, url_lumaqq));
}
/**
* 根据分类搜索群
*
* @param categoryId
* 群分类ID
*/
public void searchCluster(int categoryId) {
String url = NLS.bind(url_search_cluster, String.valueOf(categoryId));
openBrowserShell(url, "Search Cluster By Category", NLS.bind(message_box_manual_browse, url));
}
/**
* 打开天气预报窗口
*
* @return
* 天气预报窗口
*/
public WeatherWindow openWeatherWindow() {
if(main.getShellRegistry().isWeatherWindowOpen()) {
WeatherWindow w = main.getShellRegistry().getWeatherWindow();
w.setMinimized(false);
w.setActive();
return w;
} else {
WeatherWindow w = ShellFactory.createWeatherWindow(main);
w.open();
return w;
}
}
/**
* 打开短信窗口
*
* @param friend
* @return
*/
public SMSWindow openSMSWindow(User friend) {
if(main.getShellRegistry().hasSMSWindow(friend)) {
SMSWindow w = main.getShellRegistry().getSMSWindow(friend);
w.setMinimized(false);
w.setActive();
return w;
} else {
SMSWindow w = ShellFactory.createSMSWindow(main, friend);
w.open();
return w;
}
}
/**
* 打开短信窗口
*
* @param mobile
* @return
*/
public SMSWindow openSMSWindow(String mobile) {
if(main.getShellRegistry().hasSMSWindow(mobile)) {
SMSWindow w = main.getShellRegistry().getSMSWindow(mobile);
w.setMinimized(false);
w.setActive();
return w;
} else {
SMSWindow w = ShellFactory.createSMSWindow(main, mobile);
w.open();
return w;
}
}
/**
* 打开短信窗口
*/
public SMSWindow openSMSWindow() {
if(main.getShellRegistry().hasSMSWindow()) {
SMSWindow w = main.getShellRegistry().getSMSWindow();
w.setMinimized(false);
w.setActive();
return w;
} else {
SMSWindow w = ShellFactory.createSMSWindow(main);
w.open();
return w;
}
}
/**
* 打开系统消息列表窗口
*/
public void openSystemMessageListWindow() {
if(main.getShellRegistry().isSystemMessageListWindowOpened()) {
SystemMessageListWindow smls = main.getShellRegistry().getSystemMessageListWindow();
smls.setMinimized(false);
smls.setActive();
} else {
SystemMessageListWindow smls = ShellFactory.createSystemMessageListWindow(main);
main.getShellRegistry().registerSystemMessageListWindow(smls);
smls.open();
}
}
/**
* 打开搜索用户窗口
*
* @param startPage
* 起始页
*/
public WizardWindow openSearchWizard() {
if(main.getShellRegistry().isSearchWizardOpened()) {
WizardWindow ss = main.getShellRegistry().getSearchWizard();
ss.setMinimized(false);
ss.setActive();
return ss;
} else {
WizardWindow window = ShellFactory.createSearchWizard(main);
main.getShellRegistry().registerSearchWizard(window);
window.open();
return window;
}
}
/**
* 打开群组创建向导
*/
public WizardWindow openClusterWizard() {
if(main.getShellRegistry().isClusterWizardOpened()) {
WizardWindow window = main.getShellRegistry().getClusterWizard();
window.setMinimized(false);
window.setActive();
return window;
} else {
WizardWindow window = ShellFactory.createClusterWizard(main);
main.getShellRegistry().registerClusterWizard(window);
window.open();
return window;
}
}
/**
* 打开系统设置对话框
*
* @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 openCheckUpdateShell() {
if(!main.getShellRegistry().isCheckUpdateShellOpened()) {
CheckUpdateShell cus = ShellFactory.createCheckUpdateShell(main);
main.getShellRegistry().registerCheckUpdateShell(cus);
cus.open();
}
}
/**
* 打开临时群/组织信息修改窗口
*
* @param type
* @param parentCluster
* @param parentOrganization
* @param model
* @return
*/
public MemberEditShell openMemberEditShell(int type, Cluster parentCluster, Organization parentOrganization, Model model) {
ShellRegistry shellRegistry = main.getShellRegistry();
if(model != null && shellRegistry.hasMemberEditShell(model)) {
MemberEditShell shell = shellRegistry.getMemberEditShell(model);
shell.setFocus();
shell.setActive();
return shell;
} else {
MemberEditShell shell = ShellFactory.createMemberEditShell(main, type, parentCluster, parentOrganization);
if(model != null)
shellRegistry.registerMemberEditShell(model, shell);
if(type == MemberEditShell.TEMP_CLUSTER)
shell.setCluster((Cluster)model);
else
shell.setOrganization((Organization)model);
shell.open();
return shell;
}
}
/**
* 打开一个删除模式的查看系统消息窗口
*
* @param f
* 好友model
*/
public void openDeleteReceiveSystemMessageShell(User f) {
ReceiveSystemMessageShell rsms = ShellFactory.createReceiveSystemMessageShell(main);
rsms.setFriendModel(f);
rsms.open(ReceiveSystemMessageShell.DELETE_MODE);
}
/**
* 打开一个添加模式的查看系统消息窗口
*
* @param f
* 好友model
*/
public void openAddReceiveSystemMessageShell(User f) {
ReceiveSystemMessageShell rsms = ShellFactory.createReceiveSystemMessageShell(main);
rsms.setFriendModel(f);
rsms.open(ReceiveSystemMessageShell.ADD_MODE);
}
/**
* 打开一个IP查询窗口
*/
public void openIPSeekerWindow() {
IPSeekerWindow iss = ShellFactory.createIPSeekerWindow(main);
iss.open();
}
/**
* 打开群消息发送窗口
*
* @param c
* 群model
*/
public void openClusterIMWindow(Cluster c) {
// 如果设置了打开标签页消息窗口
if(main.getOptionHelper().isUseTabIMWindow()) {
openIMTabWindow(c);
return;
}
ShellRegistry shellRegistry = main.getShellRegistry();
MessageQueue mq = main.getMessageQueue();
// 如果该群消息窗口已经打开,则直接使用,如果没有,创建一个
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.messageCount = 0;
BlindHelper blindHelper = main.getBlindHelper();
blindHelper.refreshModel(c);
int clusterId = c.clusterId;
if(mq.hasMessage(clusterId)) {
while(mq.hasMessage(clusterId)) {
// 得到消息包
ReceiveIMPacket packet = (ReceiveIMPacket)mq.getMessage(clusterId);
scms.appendMessage(c, packet.clusterIM, false);
}
blindHelper.getViewer(c).stopAnimation(c);
switch(c.clusterType) {
case SUBJECT:
blindHelper.stopBlinkText(c.getParentCluster().getSubjectDummy());
blindHelper.getViewer(c).stopAnimation(c.getParentCluster());
break;
case DIALOG:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -