📄 searchshell.java
字号:
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(30, 0);
group.setLayoutData(fd);
group.setLayout(new GridLayout());
// 搜索示范群
radioDemo = new Button(group, SWT.RADIO);
radioDemo.setText(LumaQQ.getResourceString("search.search.demo.cluster"));
radioDemo.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
lblId.setEnabled(false);
textId.setEnabled(false);
}
}
);
// 根据群号码查找
radioById = new Button(group, SWT.RADIO);
radioById.setText(LumaQQ.getResourceString("search.search.cluster.by.id"));
radioById.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
lblId.setEnabled(true);
textId.setEnabled(true);
textId.setText("");
textId.setFocus();
}
}
);
// 群号码标签
lblId = new Label(group, SWT.NONE);
lblId.setText(LumaQQ.getResourceString("search.label.cluster.id"));
GridData gd = new GridData();
gd.horizontalIndent = 20;
lblId.setLayoutData(gd);
// 群号码文本框
textId = new Text(group, SWT.BORDER | SWT.SINGLE);
gd = new GridData();
gd.horizontalIndent = 20;
gd.widthHint = 120;
textId.setLayoutData(gd);
}
// 初始化强力搜索面板
private void initPowerPanel() {
power = createPanel();
power.setVisible(false);
}
// 初始化自定义搜索参数输入面板
private void initCustomPanel() {
custom = createPanel();
custom.setVisible(false);
// 提示标签
Label lblHint = new Label(custom, SWT.WRAP);
lblHint.setText(LumaQQ.getResourceString("search.label.custom.hint"));
FormData fd = new FormData();
fd.left = fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
lblHint.setLayoutData(fd);
// 通过对方QQ号标签
Label lblQQ = new Label(custom, SWT.NONE);
lblQQ.setText(LumaQQ.getResourceString("search.label.custom.qq"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(30, 0);
fd.right = new FormAttachment(100, 0);
lblQQ.setLayoutData(fd);
// qq号码文本框
textQQ = new Text(custom, SWT.SINGLE | SWT.BORDER);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lblQQ, 5, SWT.BOTTOM);
fd.right = new FormAttachment(50, 0);
textQQ.setLayoutData(fd);
// 通过昵称标签
Label lblNick = new Label(custom, SWT.NONE);
lblNick.setText(LumaQQ.getResourceString("search.label.custom.nick"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(textQQ, 10, SWT.BOTTOM);
fd.right = new FormAttachment(100, 0);
lblNick.setLayoutData(fd);
// 昵称文本框
textNick = new Text(custom, SWT.SINGLE | SWT.BORDER);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lblNick, 5, SWT.BOTTOM);
fd.right = new FormAttachment(50, 0);
textNick.setLayoutData(fd);
// email标签
Label lblEmail = new Label(custom, SWT.NONE);
lblEmail.setText(LumaQQ.getResourceString("search.label.custom.email"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(textNick, 10, SWT.BOTTOM);
fd.right = new FormAttachment(100, 0);
lblEmail.setLayoutData(fd);
// email文本框
textEmail = new Text(custom, SWT.SINGLE | SWT.BORDER);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lblEmail, 5, SWT.BOTTOM);
fd.right = new FormAttachment(50, 0);
textEmail.setLayoutData(fd);
// 完全匹配check box
chkEntire = new Button(custom, SWT.CHECK);
chkEntire.setText(LumaQQ.getResourceString("search.button.custom.matchentire"));
fd = new FormData();
fd.left = new FormAttachment(textEmail, 10, SWT.RIGHT);
fd.top = new FormAttachment(textEmail, 0, SWT.TOP);
fd.right = new FormAttachment(100, 0);
chkEntire.setLayoutData(fd);
}
// 初始化添加用户面板
private void initAddPanel() {
add = createPanel();
add.setVisible(false);
// 添加group
Group addGroup = new Group(add, SWT.SHADOW_ETCHED_IN);
addGroup.setText(LumaQQ.getResourceString("search.group.add"));
FormData fd = new FormData();
fd.left = fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(50, 0);
addGroup.setLayoutData(fd);
addGroup.setLayout(new GridLayout());
// 头像按钮
btnFace = new ShutterLabel(addGroup, MySWT.FLAT | MySWT.IMAGE_HOVER | SWT.BOTTOM, null, null);
btnFace.setShowSmallImage(false);
GridData gd = new GridData(GridData.FILL_BOTH);
btnFace.setLayoutData(gd);
// 昵称标签
lblNick = new Label(addGroup, SWT.CENTER);
gd = new GridData(GridData.FILL_HORIZONTAL);
lblNick.setLayoutData(gd);
// 地点标签
lblPlace = new Label(addGroup, SWT.CENTER);
gd = new GridData(GridData.FILL_HORIZONTAL);
lblPlace.setLayoutData(gd);
// 等待组
waitGroup = new Group(add, SWT.SHADOW_ETCHED_IN);
waitGroup.setText(LumaQQ.getResourceString("search.group.wait"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(50, 0);
fd.right = fd.bottom = new FormAttachment(100, 0);
waitGroup.setLayoutData(fd);
waitGroup.setLayout(new FormLayout());
// 等待标签,提示标签
lblHint = new Label(waitGroup, SWT.WRAP);
lblHint.setText(LumaQQ.getResourceString("search.label.processing"));
fd = new FormData();
fd.left = fd.top = new FormAttachment(0, 5);
fd.right = new FormAttachment(100, -5);
fd.bottom = new FormAttachment(40, 0);
lblHint.setLayoutData(fd);
// 认证信息输入文本框
textAuth = new Text(waitGroup, SWT.MULTI | SWT.BORDER | SWT.WRAP);
textAuth.setVisible(false);
fd = new FormData();
fd.left = new FormAttachment(0, 5);
fd.top = new FormAttachment(lblHint, 3, SWT.BOTTOM);
fd.right = new FormAttachment(80, 0);
fd.bottom = new FormAttachment(100, -5);
textAuth.setLayoutData(fd);
// 发送按钮
btnSend = new Button(waitGroup, SWT.PUSH);
btnSend.setVisible(false);
btnSend.setText(LumaQQ.getResourceString("search.button.send"));
fd = new FormData();
fd.left = new FormAttachment(textAuth, 3, SWT.RIGHT);
fd.top = new FormAttachment(lblHint, 3, SWT.BOTTOM);
fd.right = new FormAttachment(100, -5);
fd.bottom = new FormAttachment(100, -5);
btnSend.setLayoutData(fd);
btnSend.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
btnSend.setEnabled(false);
btnPrevious.setEnabled(false);
btnFace.startAnimate(frames);
if(mode == CLUSTER)
main.client.requestJoinCluster(clusterId, textAuth.getText());
else
main.client.sendAddFriendAuth(qqNum, textAuth.getText());
}
}
);
}
// 初始化用户列表面板
private void initListPanel() {
list = createPanel();
list.setVisible(false);
// 当前页数标签
lblPage = new Label(list, SWT.HORIZONTAL | SWT.WRAP);
lblPage.setText(LumaQQ.getResourceString("search.label.page", new Object[] { String.valueOf(page + 1) }));
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
lblPage.setLayoutData(fd);
// 全部按钮
btnAll = new ShutterLabel(list, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("search.button.all"), null);
fd = new FormData();
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(lblPage, -3, SWT.TOP);
btnAll.setLayoutData(fd);
btnAll.addMouseListener(
new MouseAdapter() {
public void mouseUp(MouseEvent e) {
userTable.removeAll();
lblPage.setText(LumaQQ.getResourceString("search.label.showall"));
showAll = true;
int size = pages.size();
for(int i = 1; i <= size; i++) {
parseUserList((List)pages.get(new Integer(i)));
}
}
}
);
// 详细资料按钮
btnDetail = new ShutterLabel(list, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("search.button.detail"), null);
fd = new FormData();
fd.top = new FormAttachment(btnAll, 0, SWT.TOP);
fd.right = new FormAttachment(btnAll, 0, SWT.LEFT);
btnDetail.setLayoutData(fd);
btnDetail.addMouseListener(
new MouseAdapter() {
public void mouseUp(MouseEvent e) {
int index = userTable.getSelectionIndex();
if(index == -1)
openMessageBox(LumaQQ.getResourceString("message.box.please.select.user"));
else {
TableItem ti = userTable.getItem(index);
OnlineUser user = (OnlineUser)ti.getData();
FriendModel f = new FriendModel(user.qqNum);
f.addProperty("face", new Integer(user.face));
qqNum = user.qqNum;
main.openUserInfoShell(f, false);
main.client.getUserInfo(qqNum);
}
}
}
);
// 下页按钮
btnNextPage = new ShutterLabel(list, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("search.button.next.page"), null);
fd = new FormData();
fd.top = new FormAttachment(btnDetail, 0, SWT.TOP);
fd.right = new FormAttachment(btnDetail, 0, SWT.LEFT);
btnNextPage.setLayoutData(fd);
btnNextPage.addMouseListener(
new MouseAdapter() {
public void mouseUp(MouseEvent e) {
if(page >= pages.size()) {
if(mode == ALL)
searchAll();
else if(mode == CUSTOM)
searchCustom(textQQ.getText().trim(), textNick.getText().trim(), textEmail.getText().trim(), chkEntire.getSelection());
} else {
userTable.removeAll();
parseUserList((List)pages.get(new Integer(++page)));
setControlState();
}
showAll = false;
}
}
);
// 上页按钮
btnPreviousPage = new ShutterLabel(list, MySWT.HOVER | SWT.CENTER, LumaQQ.getResourceString("search.button.previous.page"), null);
fd = new FormData();
fd.top = new FormAttachment(btnNextPage, 0, SWT.TOP);
fd.right = new FormAttachment(btnNextPage, 0, SWT.LEFT);
btnPreviousPage.setLayoutData(fd);
btnPreviousPage.addMouseListener(
new MouseAdapter() {
public void mouseUp(MouseEvent e) {
userTable.removeAll();
parseUserList((List)pages.get(new Integer(--page)));
setControlState();
showAll = false;
}
}
);
// table控件
userTable = new Table(list, SWT.SINGLE | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
userTable.setHeaderVisible(true);
fd = new FormData();
fd.left = fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(btnPreviousPage, -3, SWT.TOP);
userTable.setLayoutData(fd);
// 表的header, 1. QQ号码, 2.昵称, 3.来自何处
TableColumn tc = new TableColumn(userTable, SWT.CENTER);
tc.setText(LumaQQ.getResourceString("search.table.column.qq"));
tc.setWidth(80);
tc.addSelectionListener(new TableColumnListener(new QQNumComparator()));
tc = new TableColumn(userTable, SWT.CENTER);
tc.setText(LumaQQ.getResourceString("search.table.column.nick"));
tc.setWidth(120);
tc.addSelectionListener(new TableColumnListener(new NickComparator()));
tc = new TableColumn(userTable, SWT.CENTER);
tc.setText(LumaQQ.getResourceString("search.table.column.place"));
tc.setWidth(80);
tc.addSelectionListener(new TableColumnListener(new ProvinceComparator()));
}
// 初始化搜索首页面板
private void initFirstPanel() {
first = createPanel();
prevPanel = first;
// 提示标签
Label lblHint = new Label(first, SWT.NONE);
lblHint.setText(LumaQQ.getResourceString("search.label.hint"));
FormData fd = new FormData();
fd.left = fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
lblHint.setLayoutData(fd);
// 选择组
Group group = new Group(first, SWT.SHADOW_ETCHED_IN);
group.setText(LumaQQ.getResourceString("search.group.select"));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(lblHint, 5, SWT.BOTTOM);
fd.right = new FormAttachment(100, 0);
group.setLayoutData(fd);
group.setLayout(new GridLayout());
// 组内radio button
// 查找所有
Button radioAll = new Button(group, SWT.RADIO);
radioAll.setSelection(true);
radioAll.setText(LumaQQ.getResourceString("search.search.all"));
radioAll.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
mode = ALL;
}
}
);
// 自定义查找
Button radioCustom = new Button(group, SWT.RADIO);
radioCustom.setText(LumaQQ.getResourceString("search.search.custom"));
radioCustom.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
mode = CUSTOM;
}
}
);
// 强力搜索,暂时注释掉
/*Button radioPower = new Button(group, SWT.RADIO);
radioPower.setText(LumaQQ.getResourceString("search.search.power"));
radioPower.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
mode = POWER;
}
}
);*/
// 查找群
Button radioCluster = new Button(group, SWT.RADIO);
radioCluster.setText(LumaQQ.getResourceString("search.search.cluster"));
radioCluster.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
mode = CLUSTER;
}
}
);
// 目前在线人数标签
lblOnline = new Label(first, SWT.NONE);
lblOnline.setText(LumaQQ.getResourceString("search.label.online", new Object[] { main.currentOnlineNumber }));
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(group, 5, SWT.BOTTOM);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -