77import org .eclipse .swt .layout .GridLayout ;
88import org .eclipse .swt .widgets .Button ;
99import org .eclipse .swt .widgets .Display ;
10+ import org .eclipse .swt .widgets .Label ;
1011import org .eclipse .swt .widgets .List ;
1112import org .eclipse .swt .widgets .Shell ;
1213import org .eclipse .swt .widgets .Text ;
@@ -23,6 +24,11 @@ public class UserInterface {
2324 private Text userIdText ;
2425 private Text projectNameText ;
2526 private Text upvoteText ;
27+ private Text usernameText ;
28+ private Text passwordText ;
29+
30+ private Label passwordLabel ;
31+ private Label usernameLabel ;
2632
2733 private Display display ;
2834 private Controller controller ;
@@ -38,16 +44,34 @@ public void initUi() {
3844 GridData gridData ;
3945 display = new Display ();
4046 Shell shell = new Shell (display );
41- shell .setSize (400 , 300 );
42-
47+ shell .setSize (500 , 400 );
48+
4349 GridLayout gridLayout = new GridLayout ();
44- gridLayout .numColumns = 3 ;
50+ gridLayout .numColumns = 4 ;
4551 shell .setLayout (gridLayout );
4652
53+ usernameLabel = new Label (shell , SWT .NONE );
54+ usernameLabel .setText ("Username:" );
55+ gridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
56+ usernameLabel .setLayoutData (gridData );
57+
58+ usernameText = new Text (shell , SWT .NONE );
59+ gridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
60+ usernameText .setLayoutData (gridData );
61+
62+ passwordLabel = new Label (shell , SWT .NONE );
63+ passwordLabel .setText ("Password:" );
64+ gridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
65+ passwordLabel .setLayoutData (gridData );
66+
67+ passwordText = new Text (shell , SWT .PASSWORD );
68+ gridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
69+ passwordText .setLayoutData (gridData );
70+
4771 allChangesButton = new Button (shell , SWT .PUSH );
4872 allChangesButton .setText ("Get all changes" );
4973 gridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
50- gridData .horizontalSpan = 3 ;
74+ gridData .horizontalSpan = 4 ;
5175 allChangesButton .setLayoutData (gridData );
5276 allChangesButton .addSelectionListener (new SelectionAdapter () {
5377 @ Override
@@ -64,6 +88,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
6488 changes = new List (shell , SWT .NONE );
6589 gridData = new GridData (SWT .FILL , SWT .FILL , true , true );
6690 gridData .verticalSpan = 4 ;
91+ gridData .horizontalSpan = 2 ;
6792 changes .setLayoutData (gridData );
6893 changes .addSelectionListener (new SelectionAdapter () {
6994
@@ -139,7 +164,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
139164
140165 @ Override
141166 public void widgetSelected (SelectionEvent e ) {
142- controller .upvote (changes .getSelectionIndex ());
167+ controller .upvote (usernameText . getText (), passwordText . getText (), changes .getSelectionIndex ());
143168 }
144169
145170 @ Override
0 commit comments