⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchuseradvancedwizardpage.java

📁 java写的qq代码实现qq的部分功能
💻 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.search;

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.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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 edu.tsinghua.lumaqq.Colors;
import edu.tsinghua.lumaqq.LumaQQ;
import edu.tsinghua.lumaqq.ui.helper.BeanHelper;
import edu.tsinghua.lumaqq.ui.tool.AroundBorderPaintListener;
import edu.tsinghua.lumaqq.ui.tool.UITool;

/**
 * 高级搜索页
 * 
 * @author luma
 */
public class SearchUserAdvancedWizardPage extends WizardPage {
    private Button chkOnline, chkHasCam;
    private CCombo comboProvince, comboCity, comboAge, comboGender;
    private SearchWizard wizard;
    
    /**
     * @param pageName
     */
    public SearchUserAdvancedWizardPage(String pageName) {
        super(pageName);
        setTitle(LumaQQ.getString("search.user.advanced.title"));
        setMessage(LumaQQ.getString("search.user.advanced.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, true);
        layout.marginHeight = layout.marginWidth = 15;
        layout.verticalSpacing = 8;
        layout.horizontalSpacing = 30;
        control.setLayout(layout);      

        UITool.setDefaultBackground(control.getBackground());
        
        // 在线用户        
        chkOnline = UITool.createCheckbox(control, LumaQQ.getString("search.user.advanced.online"), new GridData(GridData.HORIZONTAL_ALIGN_END));
        chkOnline.setSelection(true);
        chkOnline.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                if(!chkOnline.getSelection())
                    chkHasCam.setSelection(false);
            }
        });
        // 有摄像头
        chkHasCam = UITool.createCheckbox(control, LumaQQ.getString("search.user.advanced.cam"), new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        chkHasCam.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                chkOnline.setSelection(chkHasCam.getSelection());
            }
        });
        
        // 基本条件组
        layout = new GridLayout(2, false);
        layout.marginHeight = layout.marginWidth = 15;        
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        Group basicGroup = UITool.createGroup(control, LumaQQ.getString("search.user.advanced.basic"), gd, layout);
        basicGroup.addPaintListener(new AroundBorderPaintListener(new Class[] { CCombo.class }));
        
        // 省份
        UITool.createLabel(basicGroup, LumaQQ.getString("search.user.advanced.province"));
        gd = new GridData();
        gd.widthHint = 150;
        comboProvince = UITool.createCCombo(basicGroup, gd);    
        comboProvince.setBackground(Colors.WHITE);        
        add(comboProvince, BeanHelper.PROVINCE);
        comboProvince.select(0);
        comboProvince.setVisibleItemCount(13);
        comboProvince.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                comboCity.removeAll();
                int index = comboProvince.getSelectionIndex();
                add(comboCity, BeanHelper.getCitys(index + 1));
                comboCity.select(0);
            }
        });
        // 城市
        UITool.createLabel(basicGroup, LumaQQ.getString("search.user.advanced.city"));
        gd = new GridData();
        gd.widthHint = 150;
        comboCity = UITool.createCCombo(basicGroup, gd);
        comboCity.setBackground(Colors.WHITE);
        add(comboCity, BeanHelper.getCitys(1));
        comboCity.setVisibleItemCount(11);
        comboCity.select(0);
        // 年龄
        UITool.createLabel(basicGroup, LumaQQ.getString("search.user.advanced.age"));
        gd = new GridData();
        gd.widthHint = 150;
        comboAge = UITool.createCCombo(basicGroup, gd);
        comboAge.setBackground(Colors.WHITE);
        add(comboAge, BeanHelper.AGE);
        comboAge.setVisibleItemCount(6);
        comboAge.select(0);
        // 性别
        UITool.createLabel(basicGroup, LumaQQ.getString("search.user.advanced.gender"));
        gd = new GridData();
        gd.widthHint = 150;
        comboGender = UITool.createCCombo(basicGroup, gd);
        comboGender.setBackground(Colors.WHITE);
        add(comboGender, BeanHelper.GENDER);
        comboGender.setVisibleItemCount(3);
        comboGender.select(0);
        
        setControl(control);
    }
    
    private void add(CCombo combo, String[] items) {
        for(int i = 0; i < items.length; i++)
            combo.add(items[i]);
    }
    
    /* (non-Javadoc)
     * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
     */
    public void setVisible(boolean visible) {
        super.setVisible(visible);
        if(visible) {
            wizard.setEnterResultPage(true);
            wizard.setSearchMode(SearchWizard.ADVANCED);
        }
    }
    
    /* (non-Javadoc)
     * @see org.eclipse.jface.wizard.WizardPage#setWizard(org.eclipse.jface.wizard.IWizard)
     */
    public void setWizard(IWizard newWizard) {
        super.setWizard(newWizard);
        wizard = (SearchWizard)newWizard;
    }
    
    /* (non-Javadoc)
     * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
     */
    public boolean isPageComplete() {
        return true;
    }
    
    /**
     * 高级搜索
     * 
     * @param page
     * 		页号
     * @return
     * 		包序号
     */
    public char doSearch(int page) {
        /*
         * Note: 省份里面的"不限"是0,但是不限之后的北京却是,鬼才知道是为什么
         */
        int province = comboProvince.getSelectionIndex(); 
        if(province > 0)
            province++;
        return wizard.getMainShell().getClient().searchUserAdvanced(
                page,
                chkOnline.getSelection(),
                chkHasCam.getSelection(),
                province,
                comboCity.getSelectionIndex(),
                comboAge.getSelectionIndex(),
                comboGender.getSelectionIndex());
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -