From 4d7b45b75f87a60c296c45dae9da2b05552a79d3 Mon Sep 17 00:00:00 2001 From: jinxuesong Date: Wed, 28 Apr 2021 11:51:56 +0800 Subject: [PATCH] loginDialog --- .../edu/hit/education/dialog/LoginDialog.java | 154 ++++++++++++++++++ src/educationschedule/Application.java | 9 + 2 files changed, 163 insertions(+) create mode 100644 src/cn/edu/hit/education/dialog/LoginDialog.java diff --git a/src/cn/edu/hit/education/dialog/LoginDialog.java b/src/cn/edu/hit/education/dialog/LoginDialog.java new file mode 100644 index 0000000..580020d --- /dev/null +++ b/src/cn/edu/hit/education/dialog/LoginDialog.java @@ -0,0 +1,154 @@ +/** + * Copyright © 2018 HIT akeil. Tech Ltd. All rights reserved. + * + * 功能描述: + * @Package: com.akeil.ui.dialogs + * @author: snow + * @date: 2018年6月27日 上午8:19:59 + */ +package cn.edu.hit.education.dialog; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + + +/** + * Copyright: Copyright (c) 2018 HIT akeil + * + * @ClassName: LicenseDialog.java + * @Description: 该类的功能描述 + * + * @version: v1.0.0 + * @author: snow + * @date: 2018年6月27日 上午8:19:59 + * + * Modification History: Date Author Version Description + * ---------------------------------------------------------* 2018年6月27日 + * snow v1.0.0 修改原因 + */ +public class LoginDialog extends TitleAreaDialog { + private Text textPassword; + private Text textUsername; + + public LoginDialog(Shell parentShell) { + super(parentShell); + // TODO Auto-generated constructor stub + } + + @Override + protected void configureShell(Shell newShell) { + // TODO 自动生成的方法存根 + super.configureShell(newShell); + newShell.setText("登录系统"); + } + + @Override + protected Control createDialogArea(Composite parent) { + // TODO Auto-generated method stub + Composite composite = (Composite) super.createDialogArea(parent); + // 自定义要创建的内容 + + createContentPane(composite); + return composite; + } + + private void createContentPane(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + //gd_composite.widthHint = 174; + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + // 采用三列的GridLayout + Label label_remark; + + composite.setLayout(new FormLayout()); + + final Label label_name = new Label(composite, SWT.NONE); + final FormData formData = new FormData(); + formData.top = new FormAttachment(0, 27); + formData.left = new FormAttachment(0, 10); + formData.right = new FormAttachment(0, 60); + label_name.setLayoutData(formData); + label_name.setText("系统用户"); + + textUsername = new Text(composite, SWT.BORDER); + final FormData fd_textUsername = new FormData(); + fd_textUsername.top = new FormAttachment(0, 25); + fd_textUsername.left = new FormAttachment(label_name, 5); + fd_textUsername.right = new FormAttachment(100, -38); + textUsername.setLayoutData(fd_textUsername); + + textPassword = new Text(composite, SWT.BORDER | SWT.PASSWORD); + fd_textUsername.bottom = new FormAttachment(textPassword, -24); + textPassword.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + //cec110f7fd2deb32d36bb868239b0e3c + checkValid(); + } + }); + final FormData fd_textPassword = new FormData(); + fd_textPassword.bottom = new FormAttachment(100, -41); + fd_textPassword.right = new FormAttachment(100, -38); + fd_textPassword.top = new FormAttachment(0, 75); + fd_textPassword.left = new FormAttachment(0, 65); + textPassword.setLayoutData(fd_textPassword); + label_remark = new Label(composite, SWT.NONE); + formData.bottom = new FormAttachment(label_remark, -25); + final FormData formData_3 = new FormData(); + formData_3.left = new FormAttachment(0, 30); + formData_3.right = new FormAttachment(textPassword, -5); + formData_3.bottom = new FormAttachment(100, -125); + formData_3.top = new FormAttachment(0, 78); + label_remark.setLayoutData(formData_3); + label_remark.setText("密码"); + + Label label = new Label(composite, SWT.NONE); + FormData fd_label = new FormData(); + fd_label.top = new FormAttachment(label_name, 25); + fd_label.left = new FormAttachment(label_name, 0, SWT.LEFT); + label.setLayoutData(fd_label); + label.setText("用户密码"); + + + this.setTitle("请输入系统用户名和密码"); + this.setMessage("系统用户名和密码",IMessageProvider.INFORMATION); + } + + public Text getText_remark() { + return textPassword; + } + + public void setText_remark(Text text_remark) { + this.textPassword = text_remark; + } + + public Text getText_name() { + return textUsername; + } + + public void setText_name(Text text_name) { + this.textUsername = text_name; + } + + protected void checkValid(){ + } + + @Override + protected Point getInitialSize() { + // TODO 自动生成的方法存根 + return new Point(360,300); + } + +} diff --git a/src/educationschedule/Application.java b/src/educationschedule/Application.java index 1d9b7df..376cf93 100644 --- a/src/educationschedule/Application.java +++ b/src/educationschedule/Application.java @@ -2,12 +2,15 @@ package educationschedule; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import cn.edu.hit.education.dialog.LoginDialog; + /** * This class controls all aspects of the application's execution */ @@ -18,6 +21,12 @@ public class Application implements IApplication { * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) */ public Object start(IApplicationContext context) { + //¼֤ + LoginDialog loginDialog = new LoginDialog(null); + if(!(IDialogConstants.OK_ID == loginDialog.open())){ + return null; + } + // Display display = PlatformUI.createDisplay(); try { int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); -- Gitee