loginview.java

来自「用Eclipse开发的桥吊无线管理系统.希望对大家有帮助:)」· Java 代码 · 共 515 行 · 第 1/2 页

JAVA
515
字号
/*
 * Zjg's New Class Files
 * 
 * Created On 2005-7-15
 * Copyright 2005 The Linkingstar Developement Team
 */
package login_QD.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
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.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.part.ViewPart;

import bridge_data_access.BriCraLogonTaskStr;
import bridge_data_access.StaticData;
import dialogs_QD.LogonFalseDialog;

public class LoginView extends ViewPart {

    public static IWorkbenchWindow wd;

    public static final String ID = "login_QD.view.LoginView";

    public Shell shell;

    public static IWorkbenchPartSite vp;

    public void createPartControl(Composite parent) {
        shell = this.getSite().getShell();
        vp = super.getSite();

        GridLayout gridlayout = new GridLayout(4, false);
        gridlayout.verticalSpacing = 8;
        parent.setLayout(gridlayout);

        final Color bkColor = new Color(Display.getCurrent(), 155, 155, 255);
        parent.setBackground(bkColor);

        Label l1 = new Label(parent, SWT.CENTER);
        final Font font = new Font(Display.getCurrent(), "隶书", 26, SWT.CENTER);
        l1.setFont(font);
        l1.setText("无线桥吊调度管理系统");
        l1.setForeground(Display.getCurrent().getSystemColor(
                SWT.COLOR_DARK_BLUE));
        l1.setBackground(new Color(Display.getCurrent(), 155, 155, 255));
        GridData gd = new GridData(GridData.GRAB_HORIZONTAL
                | GridData.HORIZONTAL_ALIGN_FILL);
        gd.horizontalSpan = 4;
        gd.heightHint = 40;
        gd.widthHint = 20;
        l1.setLayoutData(gd);

        ButtonComposite bc = new ButtonComposite(parent);
        bc.setBackground(new Color(Display.getCurrent(), 155, 165, 155));
        gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        gd.horizontalSpan = 4;
        gd.verticalSpan = 5;
        bc.setLayoutData(gd);
    }

    public class ButtonComposite extends Composite {
        final Text text1, text2, text3;

        int textState;

        public ButtonComposite(Composite c) {
            super(c, SWT.BORDER);
            GridLayout gl = new GridLayout();
            gl.verticalSpacing = 2;
            gl.makeColumnsEqualWidth = true;
            gl.numColumns = 6;
            this.setLayout(gl);

            Label l2 = new Label(this, SWT.CENTER);
            final Font fontLabel = new Font(null, "华文新魏", 16, SWT.NORMAL);
            l2.setFont(fontLabel);
            l2.setText("请输入工号:");
            l2.setForeground(Display.getCurrent().getSystemColor(
                    SWT.COLOR_DARK_RED));
            l2.setBackground(new Color(Display.getCurrent(), 155, 165, 155));

            final Font fontText = new Font(null, "黑体", 18, SWT.NORMAL);
            text1 = new Text(this, SWT.SINGLE | SWT.BORDER);
            text1.setFont(fontText);
            text1.setForeground(Display.getCurrent().getSystemColor(
                    SWT.COLOR_DARK_GREEN));
            text1.setTabs(7);
            text1.setFocus();
            final Color bkColor1 = new Color(Display.getCurrent(), 200, 200,
                    240);
            text1.setBackground(bkColor1);
            GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
            gd.heightHint = 30;
            text1.setLayoutData(gd);

            Label l3 = new Label(this, SWT.CENTER);
            l3.setFont(fontLabel);
            l3.setForeground(Display.getCurrent().getSystemColor(
                    SWT.COLOR_DARK_RED));
            l3.setBackground(new Color(Display.getCurrent(), 155, 165, 155));
            l3.setText("请输入仓号:");

            text2 = new Text(this, SWT.SINGLE | SWT.BORDER);
            text2.setFont(fontText);
            text2.setTabs(8);
            text2.setForeground(Display.getCurrent().getSystemColor(
                    SWT.COLOR_DARK_GREEN));
            text2.setBackground(bkColor1);
            text2.setLayoutData(gd);

            Label l4 = new Label(this, SWT.CENTER);
            l4.setFont(fontLabel);
            l4.setForeground(Display.getCurrent().getSystemColor(
                    SWT.COLOR_DARK_RED));
            l4.setText("请输入终端号:");
            text3 = new Text(this, SWT.SINGLE | SWT.BORDER);
            text3.setFont(fontText);
            text3.setTabs(9);
            text3.setForeground(Display.getCurrent().getSystemColor(
                    SWT.COLOR_DARK_GREEN));
            l4.setBackground(new Color(Display.getCurrent(), 155, 165, 155));
            text3.setBackground(bkColor1);
            text3.setLayoutData(gd);

            Font font2 = new Font(null, "Arial Black", 40, SWT.NORMAL);
            final Button b1 = new Button(this, SWT.BORDER);
            b1.setFont(font2);
            b1.setText("1");
            b1
                    .setForeground(Display.getCurrent().getSystemColor(
                            SWT.COLOR_RED));
            // b1.setImage(new Image(Display.getCurrent(),"icons/eclipse.gif"));
            final Button b2 = new Button(this, SWT.BORDER);
            b2.setFont(font2);
            b2.setText("2");
            final Button b3 = new Button(this, SWT.BORDER);
            b3.setFont(font2);
            b3.setText("3");
            final Button b4 = new Button(this, SWT.BORDER);
            b4.setFont(font2);
            b4.setText("4");
            final Button b5 = new Button(this, SWT.BORDER);
            b5.setFont(font2);
            b5.setText("5");
            final Button b6 = new Button(this, SWT.BORDER);
            b6.setFont(font2);
            b6.setText("6");
            final Button b7 = new Button(this, SWT.BORDER);
            b7.setFont(font2);
            b7.setText("7");
            final Button b8 = new Button(this, SWT.BORDER);
            b8.setFont(font2);
            b8.setText("8");
            final Button b9 = new Button(this, SWT.BORDER);
            b9.setFont(font2);
            b9.setText("9");
            final Button b0 = new Button(this, SWT.BORDER);
            b0.setFont(font2);
            b0.setText("0");
            final Button bBS = new Button(this, SWT.BORDER);
            bBS.setFont(font2);
            bBS.setText("<---");
            bBS.setEnabled(false);
            final Button bOK = new Button(this, SWT.BORDER);
            bOK.setFont(new Font(Display.getCurrent(), "隶书", 40, SWT.NORMAL));
            bOK.setText("确定");
            // bOK.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN));

            final Label l5 = new Label(this, SWT.FLAT | SWT.CENTER);
            gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
            gd.horizontalSpan = 6;
            gd.heightHint = 30;
            gd.widthHint = 20;
            l5.setLayoutData(gd);
            l5.setForeground(Display.getCurrent().getSystemColor(
                    SWT.COLOR_DARK_GREEN));
            l5.setFont(new Font(Display.getCurrent(), "华文琥珀", 18, SWT.NORMAL));

            final ProgressBar pb = new ProgressBar(this, SWT.HORIZONTAL);
            gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
            gd.horizontalSpan = 6;
            gd.heightHint = 30;
            gd.widthHint = 20;
            pb.setLayoutData(gd);
            gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
            gd.horizontalSpan = 2;
            gd.heightHint = 50;
            gd.widthHint = 20;

            b1.setLayoutData(gd);

            b2.setLayoutData(gd);

            b3.setLayoutData(gd);

            b4.setLayoutData(gd);

            b5.setLayoutData(gd);

            b6.setLayoutData(gd);

            b7.setLayoutData(gd);

            b8.setLayoutData(gd);

            b9.setLayoutData(gd);

            b0.setLayoutData(gd);

            bBS.setLayoutData(gd);

            bOK.setLayoutData(gd);

            final Label l6 = new Label(this, SWT.CENTER);
            gd = new GridData(GridData.GRAB_HORIZONTAL
                    | GridData.HORIZONTAL_ALIGN_FILL);
            gd.horizontalSpan = 6;
            gd.heightHint = 30;
            gd.widthHint = 20;
            l6.setLayoutData(gd);
            l6
                    .setForeground(Display.getCurrent().getSystemColor(
                            SWT.COLOR_RED));
            l6.setFont(new Font(Display.getCurrent(), "黑体", 17, SWT.NORMAL));

            b1.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    if (textState == 7) {
                        text1.append(b1.getText());
                        bBS.setEnabled(true);
                    } else if (textState == 8) {
                        text2.append(b1.getText());
                        bBS.setEnabled(true);
                    } else if (textState == 9) {
                        text3.append(b1.getText());
                        bBS.setEnabled(true);
                    }
                }
            });
            b2.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {

⌨️ 快捷键说明

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