小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

(DM)用戶登陸對話框(LoginDialog)

 jinzq 2007-04-19

package test.test.gc;

import gef.tutorial.stepii.StepiiPlugin;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
//import MyTestPlugin.preferences.PreferenceConstants;
//import MyTestPlugin.util.LayoutUtil;

/** 登錄對話框 */
public class LoginDialog extends TitleAreaDialog {

    /** 用戶名 */
    private Text userName;

    /** 密碼 */
    private Text password;

    public LoginDialog(Shell parentShell) {
        super(parentShell);
    }

    /** 設(shè)置登錄對話框的屬性 */
    protected void configureShell(Shell newShell) {
        //super.configureShell(newShell);
        newShell.setText("用戶登錄");
        newShell.setSize(300, 200);
        newShell.setImage(Display.getDefault().getSystemImage(SWT.ICON_WORKING));
        //newShell.setImage(StepiiPlugin.getImageDescriptor("icons/sample.gif").createImage());
        //LayoutUtil.centerShell(Display.getCurrent(), newShell);
    }

    /** 設(shè)置登錄對話框的內(nèi)容屬性 */
    protected Control createContents(Composite parent) {
        super.createContents(parent);
        this.setTitle("用戶登錄");
        this.setMessage("請輸入用戶名和密碼登錄系統(tǒng)");
        //this.setTitleImage(Image.win32_new (Display.getDefault(), SWT.ICON, 65545));
        return parent;
    }

    /** 設(shè)置登錄對話框內(nèi)容區(qū)的屬性 */
    protected Control createDialogArea(Composite parent) {
        super.createDialogArea(parent);
        Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        GridLayout layout = new GridLayout(2, false);
        composite.setLayout(layout);
        new Label(composite, SWT.NONE).setText("用戶名:");
        userName = new Text(composite, SWT.BORDER);
        userName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        new Label(composite, SWT.NONE).setText("密碼:");
        password = new Text(composite, SWT.BORDER);
        password.setEchoChar(‘*‘);
        password.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        return parent;
    }

    /** 覆蓋父類的方法,當(dāng)單擊按鈕時(shí)調(diào)用 */
    protected void buttonPressed(int buttonId) {
        /** 如果單擊了確定按鈕 */
        if (IDialogConstants.OK_ID == buttonId) {
            /** 用戶名不為空 */
            if (userName.getText().equals("")) {
                this.setErrorMessage("用戶名不為空");
                return;
            }
            /** 密碼不為空 */
            if (password.getText().equals("")) {
               
                //this.setTitleImage(Image.win32_new (Display.getDefault(), SWT.ICON, 65545));
                this.setErrorMessage("密碼不為空!");
                return;
            }
            /**驗(yàn)證用戶名密碼*/
            boolean bValid = checkValid();
            if (!bValid) {
                this.setErrorMessage("用戶名或密碼錯(cuò)誤!");
                return;
            }
            okPressed();
        } else if (IDialogConstants.CANCEL_ID == buttonId)
            cancelPressed();
    }

    /** 判斷驗(yàn)證用戶名和密碼 */
    private boolean checkValid() {
        boolean bValid = false;
        /**將用戶輸入用戶名與首選項(xiàng)中設(shè)置的用戶名和密碼對比,如果正確,則驗(yàn)證成功*/
        //IPreferenceStore store = StepiiPlugin.getDefault().getPreferenceStore();
        //if (userName.getText().equals(store.getString(PreferenceConstants.P_USER_NAME)) && password.getText().equals(store.getString(PreferenceConstants.P_USER_NAME)))
            //bValid = true;
        return bValid;
    }
}


    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多