📄 permanentclusterinfowizardpage.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.wizard.cluster;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import edu.tsinghua.lumaqq.Colors;
import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.lumaqq.qq.QQ;
import edu.tsinghua.lumaqq.qq.Util;
import edu.tsinghua.lumaqq.ui.tool.AroundBorderPaintListener;
import edu.tsinghua.lumaqq.ui.tool.UITool;
/**
* 固定群信息填写页
*
* @author luma
*/
public class PermanentClusterInfoWizardPage extends WizardPage {
private Button rdoNoAuth, rdoNeedAuth, rdoNoAdd;
private Text textName, textNotice, textDescription;
private CCombo comboCategory;
private ClusterWizard wizard;
/**
* @param pageName
*/
protected PermanentClusterInfoWizardPage(String pageName) {
super(pageName);
setTitle(LumaQQ.getString("permanent.title"));
setMessage(LumaQQ.getString("permanent.message"));
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite control = new Composite(parent, SWT.NONE);
control.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = layout.marginWidth = 15;
layout.verticalSpacing = 8;
control.setLayout(layout);
control.addPaintListener(new AroundBorderPaintListener(new Class[] { Text.class, CCombo.class }));
UITool.setDefaultBackground(control.getBackground());
// 群名称
UITool.createLabel(control, LumaQQ.getString("permanent.name"));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 18;
textName = UITool.createSingleText(control, gd);
textName.setBackground(Colors.WHITE);
textName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
setPageComplete(validatePage());
}
});
// 群分类
UITool.createLabel(control, LumaQQ.getString("permanent.category"));
comboCategory = UITool.createCCombo(control, new GridData(GridData.FILL_HORIZONTAL));
comboCategory.setBackground(Colors.WHITE);
addCategory();
// 群公告
UITool.createLabel(control, LumaQQ.getString("permanent.notice"), new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 50;
textNotice = UITool.createMultiText(control, gd);
textNotice.setBackground(Colors.WHITE);
// 群简介
UITool.createLabel(control, LumaQQ.getString("permanent.description"), new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 50;
textDescription = UITool.createMultiText(control, gd);
textDescription.setBackground(Colors.WHITE);
// 验证组
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
Group authGroup = UITool.createGroup(control, LumaQQ.getString("permanent.auth"), gd, new GridLayout());
rdoNoAuth = UITool.createRadio(authGroup, LumaQQ.getString("permanent.no.auth"));
rdoNeedAuth = UITool.createRadio(authGroup, LumaQQ.getString("permanent.need.auth"));
rdoNoAdd = UITool.createRadio(authGroup, LumaQQ.getString("permanent.no.add"));
rdoNeedAuth.setSelection(true);
setControl(control);
}
/**
* 添加分类
*/
private void addCategory() {
int count = Util.getInt(LumaQQ.getString("permanent.category.number"), 0);
for(int i = 1; i <= count; i++)
comboCategory.add(LumaQQ.getString("permanent.category." + i));
comboCategory.select(0);
}
/**
* 发送创建固定群请求包
*/
public void doCreate() {
wizard.getMainShell().getClient().createPermanentCluster(
getClusterName(),
getClusterNotice(),
getClusterDescription(),
wizard.getMemberQQArray(),
getCategory(),
getAuthType());
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.WizardPage#setWizard(org.eclipse.jface.wizard.IWizard)
*/
public void setWizard(IWizard newWizard) {
super.setWizard(newWizard);
this.wizard = (ClusterWizard)newWizard;
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
*/
public boolean isPageComplete() {
return validatePage();
}
/**
* @return
* true表示用户输入有效
*/
private boolean validatePage() {
if("".equals(textName.getText().trim())) {
setErrorMessage(LumaQQ.getString("error.empty.name"));
return false;
}
setErrorMessage(null);
return true;
}
public String getClusterName() {
return textName.getText().trim();
}
public String getClusterNotice() {
return textNotice.getText();
}
public String getClusterDescription() {
return textDescription.getText();
}
public byte getAuthType() {
if(rdoNoAuth.getSelection())
return QQ.QQ_CLUSTER_NO_AUTH;
else if(rdoNeedAuth.getSelection())
return QQ.QQ_CLUSTER_NEED_AUTH;
else
return QQ.QQ_CLUSTER_NO_ADD;
}
public int getCategory() {
int index = comboCategory.getSelectionIndex();
if(index == -1)
index = 0;
return index;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -