1 package org
.argeo
.cms
.e4
.rap
;
3 import java
.util
.concurrent
.atomic
.AtomicBoolean
;
5 import org
.eclipse
.e4
.ui
.workbench
.lifecycle
.PostContextCreate
;
6 import org
.eclipse
.swt
.SWT
;
7 import org
.eclipse
.swt
.events
.SelectionAdapter
;
8 import org
.eclipse
.swt
.events
.SelectionEvent
;
9 import org
.eclipse
.swt
.graphics
.Point
;
10 import org
.eclipse
.swt
.graphics
.Rectangle
;
11 import org
.eclipse
.swt
.layout
.GridData
;
12 import org
.eclipse
.swt
.layout
.GridLayout
;
13 import org
.eclipse
.swt
.widgets
.Button
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
15 import org
.eclipse
.swt
.widgets
.Display
;
16 import org
.eclipse
.swt
.widgets
.Label
;
17 import org
.eclipse
.swt
.widgets
.Shell
;
18 import org
.eclipse
.swt
.widgets
.Text
;
20 @SuppressWarnings("restriction")
21 public class LoginLifcecycle
{
23 boolean login(Display d
) {
24 final AtomicBoolean rv
= new AtomicBoolean(false);
25 final Shell s
= new Shell(d
);
27 s
.setLayout(new GridLayout(2, false));
30 Label l
= new Label(s
, SWT
.NONE
);
31 l
.setText("Username");
33 Text t
= new Text(s
, SWT
.BORDER
);
34 t
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
38 Label l
= new Label(s
, SWT
.NONE
);
39 l
.setText("Password");
41 Text t
= new Text(s
, SWT
.BORDER
| SWT
.PASSWORD
);
42 t
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
46 Composite buttonContainer
= new Composite(s
, SWT
.NONE
);
47 buttonContainer
.setLayout(new GridLayout(2, true));
48 buttonContainer
.setLayoutData(new GridData(SWT
.TRAIL
, SWT
.CENTER
, false, false, 2, 1));
51 Button b
= new Button(buttonContainer
, SWT
.PUSH
);
53 b
.addSelectionListener(new SelectionAdapter() {
55 public void widgetSelected(SelectionEvent e
) {
63 Button b
= new Button(buttonContainer
, SWT
.PUSH
);
65 b
.addSelectionListener(new SelectionAdapter() {
67 public void widgetSelected(SelectionEvent e
) {
75 s
.setSize(300, s
.getSize().y
+ 10);
76 Rectangle bounds
= d
.getPrimaryMonitor().getBounds();
78 Point size
= s
.getSize();
79 s
.setLocation(bounds
.width
/ 2 - size
.x
/ 2, bounds
.height
/ 2 - size
.y
/ 2);
82 while (!s
.isDisposed() && !d
.isDisposed()) {
83 if (!d
.readAndDispatch()) {