From d6fa96b4cd67cf4fa18b5b9b6739f9bc2494a9f4 Mon Sep 17 00:00:00 2001 From: guest Date: Tue, 23 Sep 2008 21:29:27 +0000 Subject: initial import git-svn-id: http://manut.eu/svn/yalp/trunk@1 f059d3a0-6783-47b7-97ff-1fe0bbf25129 --- src/YalpClients/SwtClient/GUI/StartDialog.java | 236 +++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 src/YalpClients/SwtClient/GUI/StartDialog.java (limited to 'src/YalpClients/SwtClient/GUI/StartDialog.java') diff --git a/src/YalpClients/SwtClient/GUI/StartDialog.java b/src/YalpClients/SwtClient/GUI/StartDialog.java new file mode 100644 index 0000000..11ecc7f --- /dev/null +++ b/src/YalpClients/SwtClient/GUI/StartDialog.java @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2006 Manuel Traut and Volker Dahnke + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: Manuel Traut and Volker Dahnke + */ + +package YalpClients.SwtClient.GUI; + +import YalpClients.SwtClient.Model; +import YalpInterfaces.AccessRights; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.*; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.layout.*; +import org.eclipse.swt.widgets.*; + +/* + * Class StartDialog + * + * + * + * @author Volker Dahnke / Manuel Traut + * + * @version 1 02-04-2006
+ */ +public class StartDialog extends Composite { + + { + //Register as a resource user - SWTResourceManager will + //handle the obtaining and disposing of resources + SWTResourceManager.registerResourceUser(this); + } + private Display display; + private CLabel cLabel1; + private CLabel LogoLabel; + private Model model; + private Composite parent; + private Composite composite; + private CLabel logonLable; + private Button ok; + private Text passwd; + private Text username; + private CLabel passwdLable; + private CLabel usernameLable; + + + public StartDialog(Composite parent,Model model, int style) { + super(parent, style); + + this.parent=parent; + this.model=model; + this.display=Display.getDefault(); + initStartDialog(); + } + + private void initStartDialog(){ + GridLayout thisLayout = new GridLayout(); + thisLayout.makeColumnsEqualWidth = true; + this.setLayout(thisLayout); + this.setSize(300,150); + Listener listener =new Listener() { + public void handleEvent(org.eclipse.swt.widgets.Event evt) { + if (evt.character==SWT.CR){ + OkPressed(); + } + } + }; + addListener(SWT.KeyDown,listener); + { + composite = new Composite(this, SWT.NONE); + FormLayout compositeLayout = new FormLayout(); + composite.setLayout(compositeLayout); + GridData compositeLData = new GridData(); + compositeLData.widthHint = 287; + compositeLData.heightHint = 140; + composite.setLayoutData(compositeLData); + composite.setVisible(true); + composite.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent evt) { + if (evt.character==SWT.CR){ + OkPressed(); + } + } + }); + { + cLabel1 = new CLabel(composite, SWT.NONE); + FormData cLabel1LData = new FormData(); + cLabel1LData.width = 120; + cLabel1LData.height = 20; + cLabel1LData.left = new FormAttachment(0, 1000, 93); + cLabel1LData.top = new FormAttachment(0, 1000, 40); + cLabel1.setLayoutData(cLabel1LData); + Color col =display.getSystemColor(SWT.COLOR_RED); + cLabel1.setForeground(col); + cLabel1.setFont(SWTResourceManager.getFont("Times", 10, 1, false, false)); + } + { + LogoLabel = new CLabel(composite, SWT.NONE); + FormData LogoLabelLData = new FormData(); + LogoLabelLData.width = 70; + LogoLabelLData.height = 42; + LogoLabelLData.left = new FormAttachment(0, 1000, 77); + LogoLabelLData.top = new FormAttachment(0, 1000, 0); + LogoLabelLData.right = new FormAttachment(1000, 1000, -140); + LogoLabelLData.bottom = new FormAttachment(1000, 1000, -98); + LogoLabel.setLayoutData(LogoLabelLData); + LogoLabel.setImage(new Image(this.getDisplay(),"img/yalpV2_mittel.gif")); + } + { + logonLable = new CLabel(composite, SWT.BEGINNING); + logonLable.setText("Login"); + FormData logonLableLData = new FormData(); + logonLableLData.width = 70; + logonLableLData.height = 28; + logonLableLData.left = new FormAttachment(0, 1000, 147); + logonLableLData.top = new FormAttachment(0, 1000, 5); + logonLable.setLayoutData(logonLableLData); + logonLable.setFont(SWTResourceManager.getFont("Times", 14, 1, false, false)); + } + { + username = new Text(composite, SWT.NONE); + FormData usernameLData = new FormData(); + usernameLData.width = 117; + usernameLData.height = 15; + usernameLData.left = new FormAttachment(0, 1000, 120); + usernameLData.top = new FormAttachment(0, 1000, 65); + username.setLayoutData(usernameLData); + username.setFocus(); + username.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent evt) { + if (evt.character==SWT.CR){ + OkPressed(); + } + } + }); + } + { + passwd = new Text(composite, SWT.PASSWORD); + FormData passwdLData = new FormData(); + passwdLData.width = 117; + passwdLData.height = 15; + passwdLData.left = new FormAttachment(0, 1000, 120); + passwdLData.top = new FormAttachment(0, 1000, 88); + passwd.setLayoutData(passwdLData); + passwd.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent evt) { + if (evt.character==SWT.CR){ + OkPressed(); + } + } + }); + } + { + ok = new Button(composite, SWT.PUSH | SWT.CENTER); + ok.setText("OK"); + FormData okLData = new FormData(); + okLData.width = 65; + okLData.height = 21; + okLData.left = new FormAttachment(0, 1000, 110); + okLData.top = new FormAttachment(0, 1000, 115); + ok.setLayoutData(okLData); + ok.setFont(SWTResourceManager.getFont("Times", 10, 1, false, false)); + ok.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + OkPressed(); + } + }); + } + { + passwdLable = new CLabel(composite, SWT.NONE); + passwdLable.setText("Password:"); + FormData passwdLableLData = new FormData(); + passwdLableLData.width = 70; + passwdLableLData.height = 20; + passwdLableLData.left = new FormAttachment(0, 1000, 35); + passwdLableLData.top = new FormAttachment(0, 1000, 83); + passwdLable.setLayoutData(passwdLableLData); + passwdLable.setFont(SWTResourceManager.getFont("Times", 10, 0, false, false)); + } + { + usernameLable = new CLabel(composite, SWT.NONE); + usernameLable.setText("Username:"); + FormData usernameLableLData = new FormData(); + usernameLableLData.width = 70; + usernameLableLData.height = 20; + usernameLableLData.left = new FormAttachment(0, 1000, 35); + usernameLableLData.top = new FormAttachment(0, 1000, 60); + usernameLable.setLayoutData(usernameLableLData); + usernameLable.setFont(SWTResourceManager.getFont("Times", 10, 0, false, false)); + } + } + this.layout(); + + } + private void OkPressed(){ + AccessRights kind; + kind = model.userVerify(username.getText(), passwd.getText()); + + if (kind.value() == AccessRights._NO_YALP_SERVER ) { + cLabel1.setText("Server offline"); + } else if (kind.value() == AccessRights._DENY ){ + cLabel1.setText("Access Denied"); + username.setText(""); + passwd.setText(""); + username.setFocus(); + } else { + display.close(); + InitGUI gui = new InitGUI(model, kind); + } + + } + + public void show(){ + ((Shell)this.parent).setImage(new Image(display,"img/yalpV2_klein.gif")); + ((Shell)this.parent).setText("yalp"); + Point size = this.getSize(); + java.awt.Dimension screen = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + Rectangle shellBounds = this.parent.computeTrim((screen.width-size.x)/2,(screen.height-size.y)/2,size.x,size.y); + this.parent.setLayout(new FillLayout()); + this.parent.layout(); + this.parent.setBounds(shellBounds); + ((Shell)this.parent).open(); + while (!this.parent.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + + +} -- cgit v1.2.3