c7c9658a7ddab4fac6e4fcc9cd9186d0bce1a427
[FinalKeyGui.git] / src / fkgui / NewAccountDialog.java
1 package fkgui;
2
3 import org.eclipse.swt.widgets.Dialog;
4 import org.eclipse.swt.widgets.Display;
5 import org.eclipse.swt.widgets.Shell;
6 import org.eclipse.swt.layout.FormLayout;
7 import org.eclipse.swt.layout.FillLayout;
8 import org.eclipse.swt.SWT;
9 import org.eclipse.swt.layout.FormData;
10 import org.eclipse.swt.layout.FormAttachment;
11 import org.eclipse.swt.widgets.Composite;
12 import org.eclipse.swt.widgets.Control;
13 import org.eclipse.swt.widgets.Label;
14 import org.eclipse.swt.widgets.MessageBox;
15 import org.eclipse.swt.widgets.Text;
16 import org.eclipse.swt.widgets.Button;
17 import org.eclipse.swt.events.ModifyEvent;
18 import org.eclipse.swt.events.ModifyListener;
19 import org.eclipse.swt.events.SelectionAdapter;
20 import org.eclipse.swt.events.SelectionEvent;
21 import org.eclipse.swt.events.SelectionListener;
22 import org.eclipse.swt.widgets.Spinner;
23
24 public class NewAccountDialog extends Dialog implements FkActionEventListener {
25
26         protected Object result;
27         protected Shell shlNewAccount;
28         private Text txtAccountName;
29         private Text txtUserName;
30         private Text txtManPSW;
31         private Text txtSpecials;
32         
33         private enum FkNewAccStep { NAMES, PASSTYPE, PASS_MAN, PASS_AUT, SEPERATOR, REVIEW, CLICKBTN, SAVING };
34         
35         private String strAccountName = ""; //$NON-NLS-1$
36         private String strUserName = ""; //$NON-NLS-1$
37         private String strPassword = ""; //$NON-NLS-1$
38         private String autoPassSpecials = "!@#,.-_()"; //$NON-NLS-1$
39         private Boolean autoPassword = true;
40         private Boolean autoPassAllSpecials = true;
41         private int autoPassLen = 16;
42         private Boolean seperatorTab=true;
43
44         //NamePage
45         Button btnNext0;
46
47         
48         //PassType
49         Button radAutPSW;
50         Button radManPSW;
51         
52         //ManPass
53         Label lblTypeThePassword;
54         Label lblPassword;
55         Button chkShowPsw;
56         Button btnManPassPageNext;
57         
58         //Autopass
59         Button radAllSymbols;
60         Spinner spnLen;
61         
62         //Seperator
63         Button radTabSep;
64         
65         //Saving
66         Label txtBUSYMSG;
67         Animation animation;
68         
69         NewAccountDialog mySelf;
70
71         
72         
73         Composite composite;
74         /**
75          * Create the dialog.
76          * @param parent
77          * @param style
78          */
79         public NewAccountDialog(Shell parent, int style) {
80                 super(parent, style);
81                 
82         }
83
84         /**
85          * Open the dialog.
86          * @return the result
87          */
88         public Object open() {
89                 createContents();
90                 
91                 shlNewAccount.open();
92                 shlNewAccount.layout();
93                 Display display = getParent().getDisplay();
94                 mySelf = this;
95                 while (!shlNewAccount.isDisposed()) {
96                         if (!display.readAndDispatch()) {
97                                 display.sleep();
98                         }
99                 }
100                 return result;
101         }
102         
103         private void checkNamePage()
104         {
105                 if( txtAccountName.getText().length() > 0 && txtUserName.getText().length() > 0 )
106                 {
107                         btnNext0.setVisible(true);
108                 } else {
109                         btnNext0.setVisible(false);
110                 }
111         }
112
113         private void createNamePage()
114         {
115                 composite = new Composite(shlNewAccount, SWT.NONE);
116         //      tbtmStepUsername.setControl(composite);
117                 composite.setLayout(new FormLayout());
118                 
119                 
120                 
121                 Label lblEnterNewName = new Label(composite, SWT.NONE);
122                 FormData fd_lblEnterNewName = new FormData();
123                 fd_lblEnterNewName.bottom = new FormAttachment(0, 112);
124                 fd_lblEnterNewName.right = new FormAttachment(0, 613);
125                 fd_lblEnterNewName.top = new FormAttachment(0, 10);
126                 fd_lblEnterNewName.left = new FormAttachment(0, 10);
127                 lblEnterNewName.setLayoutData(fd_lblEnterNewName);
128                 lblEnterNewName.setText(Messages.NewAccountDialog_4);
129                 Label lblUsername = new Label(composite, SWT.NONE);
130                 FormData fd_lblUsername = new FormData();
131                 lblUsername.setLayoutData(fd_lblUsername);
132                 lblUsername.setText(Messages.NewAccountDialog_5);
133                 
134                 txtAccountName = new Text(composite, SWT.BORDER);
135                 fd_lblUsername.bottom = new FormAttachment(txtAccountName, 0, SWT.BOTTOM);
136                 fd_lblUsername.right = new FormAttachment(txtAccountName, -6);
137                 FormData fd_txtAccountName = new FormData();
138                 fd_txtAccountName.top = new FormAttachment(lblEnterNewName, 6);
139                 fd_txtAccountName.right = new FormAttachment(100, -274);
140                 fd_txtAccountName.left = new FormAttachment(0, 180);
141                 txtAccountName.setLayoutData(fd_txtAccountName);
142                 txtAccountName.setTextLimit(31);
143                 txtAccountName.addModifyListener( new ModifyListener() {
144                         @Override
145                         public void modifyText(ModifyEvent arg0) {
146                                 checkNamePage();
147
148                         }
149                 });
150                 
151                 Label lblNewLabel = new Label(composite, SWT.NONE);
152                 FormData fd_lblNewLabel = new FormData();
153                 fd_lblNewLabel.left = new FormAttachment(0, 10);
154                 fd_lblNewLabel.right = new FormAttachment(100);
155                 fd_lblNewLabel.top = new FormAttachment(lblUsername, 20);
156                 lblNewLabel.setLayoutData(fd_lblNewLabel);
157                 lblNewLabel.setText(Messages.NewAccountDialog_6);
158                 
159                 Label lblUsername_1 = new Label(composite, SWT.NONE);
160                 FormData fd_lblUsername_1 = new FormData();
161                 fd_lblUsername_1.top = new FormAttachment(lblNewLabel, 6);
162                 fd_lblUsername_1.right = new FormAttachment(lblUsername, 0, SWT.RIGHT);
163                 lblUsername_1.setLayoutData(fd_lblUsername_1);
164                 lblUsername_1.setText(Messages.NewAccountDialog_7);
165                 
166                 txtUserName = new Text(composite, SWT.BORDER);
167                 FormData fd_txtUserName = new FormData();
168                 fd_txtUserName.left = new FormAttachment(txtAccountName, 0, SWT.LEFT);
169                 fd_txtUserName.right = new FormAttachment(txtAccountName, 0, SWT.RIGHT);
170                 fd_txtUserName.top = new FormAttachment(lblNewLabel, 6);
171                 txtUserName.setLayoutData(fd_txtUserName);
172                 txtUserName.addModifyListener( new ModifyListener() {
173                         @Override
174                         public void modifyText(ModifyEvent arg0) {
175                                 checkNamePage();
176                         }
177                 });
178                 
179                 Button btnCancel = new Button(composite, SWT.NONE);
180                 btnCancel.addSelectionListener(new SelectionAdapter() {
181                         @Override
182                         public void widgetSelected(SelectionEvent e) {
183                                 shlNewAccount.close();
184                         }
185                 });
186                 FormData fd_btnCancel = new FormData();
187                 fd_btnCancel.bottom = new FormAttachment(100, -10);
188                 fd_btnCancel.left = new FormAttachment(lblEnterNewName, 0, SWT.LEFT);
189                 btnCancel.setLayoutData(fd_btnCancel);
190                 btnCancel.setText(Messages.NewAccountDialog_8);
191                 
192                 btnNext0 = new Button(composite, SWT.NONE);
193                 btnNext0.addSelectionListener(new SelectionAdapter() {
194                         @Override
195                         public void widgetSelected(SelectionEvent e) {
196                                 strAccountName = txtAccountName.getText();
197                                 strUserName = txtUserName.getText();
198                                 updatePage(FkNewAccStep.PASSTYPE);
199                         }
200                 });
201                 btnNext0.setText(Messages.NewAccountDialog_9);
202                 FormData fd_btnNext0 = new FormData();
203                 fd_btnNext0.bottom = new FormAttachment(btnCancel, 0, SWT.BOTTOM);
204                 fd_btnNext0.right = new FormAttachment(lblEnterNewName, 0, SWT.RIGHT);
205                 btnNext0.setLayoutData(fd_btnNext0);
206                 btnNext0.setVisible(false);
207                 
208                 txtUserName.setText( strUserName );
209                 txtAccountName.setText( strAccountName );
210
211         Control[] controls = new Control[] { txtAccountName, txtUserName, btnNext0, btnCancel };
212         composite.setTabList(controls);         
213                 
214         }
215         
216         
217         private void createPassTypePage()
218         {
219                 composite = new Composite(shlNewAccount, SWT.NONE);
220                 composite.setLayout(new FormLayout());
221                 
222                 Label lblNextUpSetting = new Label(composite, SWT.NONE);
223                 FormData fd_lblNextUpSetting = new FormData();
224                 fd_lblNextUpSetting.right = new FormAttachment(0, 603);
225                 fd_lblNextUpSetting.top = new FormAttachment(0, 10);
226                 fd_lblNextUpSetting.left = new FormAttachment(0, 10);
227                 lblNextUpSetting.setLayoutData(fd_lblNextUpSetting);
228                 lblNextUpSetting.setText(Messages.NewAccountDialog_10);
229                 
230                 radAutPSW = new Button(composite, SWT.RADIO);
231                 if( autoPassword )
232                 {
233                         radAutPSW.setSelection(true);
234                 }
235                 FormData fd_radAutPSW = new FormData();
236                 fd_radAutPSW.top = new FormAttachment(lblNextUpSetting, 37);
237                 fd_radAutPSW.left = new FormAttachment(0, 213);
238                 radAutPSW.setLayoutData(fd_radAutPSW);
239                 radAutPSW.setText(Messages.NewAccountDialog_11);
240                 
241                 radManPSW = new Button(composite, SWT.RADIO);
242                 if( !autoPassword )
243                 {
244                         radManPSW.setSelection(true);
245                 }               
246                 FormData fd_radManPSW = new FormData();
247                 fd_radManPSW.top = new FormAttachment(radAutPSW, 6);
248                 fd_radManPSW.left = new FormAttachment(radAutPSW, 0, SWT.LEFT);
249                 radManPSW.setLayoutData(fd_radManPSW);
250                 radManPSW.setText(Messages.NewAccountDialog_12);
251                 
252                 Button btnNext1 = new Button(composite, SWT.NONE);
253                 btnNext1.setText(Messages.NewAccountDialog_13);
254                 FormData fd_btnNext1 = new FormData();
255                 fd_btnNext1.bottom = new FormAttachment(100, -10);
256                 fd_btnNext1.right = new FormAttachment(100, -10);
257                 btnNext1.setLayoutData(fd_btnNext1);
258                 btnNext1.addSelectionListener(new SelectionListener() {
259                         
260                         @Override
261                         public void widgetSelected(SelectionEvent arg0) {
262                                 if( radAutPSW.getSelection() )
263                                 {
264                                         updatePage(FkNewAccStep.PASS_AUT);
265                                         autoPassword = true;
266                                 } else {
267                                         updatePage(FkNewAccStep.PASS_MAN);
268                                         autoPassword = false;
269                                 }
270                         }
271                         
272                         @Override
273                         public void widgetDefaultSelected(SelectionEvent arg0) {
274                                 // TODO Auto-generated method stub
275                                 
276                         }
277                 });
278                 
279                 Button btnBack0 = new Button(composite, SWT.NONE);
280                 btnBack0.setText(Messages.NewAccountDialog_14);
281                 FormData fd_btnBack0 = new FormData();
282                 fd_btnBack0.bottom = new FormAttachment(btnNext1, 0, SWT.BOTTOM);
283                 fd_btnBack0.left = new FormAttachment(lblNextUpSetting, 0, SWT.LEFT);
284                 btnBack0.setLayoutData(fd_btnBack0);
285                 btnBack0.addSelectionListener( new SelectionListener() {
286                         
287                         @Override
288                         public void widgetSelected(SelectionEvent arg0) {
289                                 updatePage( FkNewAccStep.NAMES );
290                                 
291                         }
292                         
293                         @Override
294                         public void widgetDefaultSelected(SelectionEvent arg0) {
295                                 // TODO Auto-generated method stub
296                                 
297                         }
298                 });
299                 
300         Control[] controls = new Control[] { radAutPSW, radManPSW, btnNext1, btnBack0 };
301         composite.setTabList(controls);
302         radAutPSW.setFocus();
303 }
304         
305         void autoPassPageSaveValues()
306         {
307                 autoPassAllSpecials = radAllSymbols.getSelection();
308                 autoPassSpecials = txtSpecials.getText();
309                 autoPassLen = spnLen.getSelection();            
310         }
311         void createPassAutPage()
312         {
313                 composite = new Composite(shlNewAccount, SWT.NONE);
314                 composite.setLayout(new FormLayout());
315                 
316                 Label lblBeforeCreatingA = new Label(composite, SWT.NONE);
317                 FormData fd_lblBeforeCreatingA = new FormData();
318                 fd_lblBeforeCreatingA.top = new FormAttachment(0, 10);
319                 fd_lblBeforeCreatingA.left = new FormAttachment(0, 10);
320                 lblBeforeCreatingA.setLayoutData(fd_lblBeforeCreatingA);
321                 
322                 lblBeforeCreatingA.setText(Messages.NewAccountDialog_15);
323                 
324                 Label lblPasswordLength = new Label(composite, SWT.NONE);
325                 fd_lblBeforeCreatingA.bottom = new FormAttachment(100, -257);
326                 FormData fd_lblPasswordLength = new FormData();
327                 lblPasswordLength.setLayoutData(fd_lblPasswordLength);
328                 lblPasswordLength.setText(Messages.NewAccountDialog_16);
329                 
330                 spnLen = new Spinner(composite, SWT.BORDER);
331                 fd_lblPasswordLength.bottom = new FormAttachment(spnLen, 0, SWT.BOTTOM);
332                 fd_lblPasswordLength.right = new FormAttachment(spnLen, -9);
333                 FormData fd_spnLen = new FormData();
334                 fd_spnLen.top = new FormAttachment(0, 119);
335                 fd_spnLen.left = new FormAttachment(0, 310);
336                 spnLen.setLayoutData(fd_spnLen);
337                 spnLen.setMaximum(128);
338                 spnLen.setSelection(autoPassLen);
339                 
340                 Label lblASafePassword = new Label(composite, SWT.NONE);
341                 FormData fd_lblASafePassword = new FormData();
342                 fd_lblASafePassword.right = new FormAttachment(lblBeforeCreatingA, 0, SWT.RIGHT);
343                 fd_lblASafePassword.top = new FormAttachment(lblPasswordLength, 47);
344                 fd_lblASafePassword.left = new FormAttachment(0, 10);
345                 lblASafePassword.setLayoutData(fd_lblASafePassword);
346                 lblASafePassword.setText(Messages.NewAccountDialog_17);
347                 
348                 radAllSymbols = new Button(composite, SWT.RADIO);
349                 fd_lblASafePassword.bottom = new FormAttachment(100, -100);
350                 FormData fd_radAllSymbols = new FormData();
351                 fd_radAllSymbols.top = new FormAttachment(lblASafePassword, 6);
352                 fd_radAllSymbols.left = new FormAttachment(0, 10);
353                 radAllSymbols.setLayoutData(fd_radAllSymbols);
354                 if( autoPassAllSpecials )
355                 {
356                         radAllSymbols.setSelection(true);
357                 }
358                 radAllSymbols.setText(Messages.NewAccountDialog_18);
359                 radAllSymbols.pack();
360                 
361                 Button radOnlySelected = new Button(composite, SWT.RADIO);
362                 FormData fd_radOnlySelected = new FormData();
363                 fd_radOnlySelected.bottom = new FormAttachment(radAllSymbols, 0, SWT.BOTTOM);
364                 fd_radOnlySelected.right = new FormAttachment(spnLen, 0, SWT.RIGHT);
365                 radOnlySelected.setLayoutData(fd_radOnlySelected);
366                 if( !autoPassAllSpecials )
367                 {
368                         radOnlySelected.setSelection(true);
369                 }
370                 radOnlySelected.setText(Messages.NewAccountDialog_19);
371                 
372                 txtSpecials = new Text(composite, SWT.BORDER);
373                 FormData fd_txtSpecials = new FormData();
374                 fd_txtSpecials.top = new FormAttachment(lblASafePassword, 6);
375                 fd_txtSpecials.left = new FormAttachment(radOnlySelected, 6);
376                 txtSpecials.setLayoutData(fd_txtSpecials);
377                 txtSpecials.setText(autoPassSpecials);
378                 txtSpecials.setBounds(291, 243, 312, 35);
379                 
380                 
381                 Button button_6 = new Button(composite, SWT.NONE);
382                 fd_lblBeforeCreatingA.right = new FormAttachment(button_6, 0, SWT.RIGHT);
383                 button_6.setText(Messages.NewAccountDialog_21);
384                 FormData fd_button_6 = new FormData();
385                 fd_button_6.bottom = new FormAttachment(100, -10);
386                 fd_button_6.right = new FormAttachment(100, -10);
387                 button_6.setLayoutData(fd_button_6);
388                 
389                 button_6.addSelectionListener(new SelectionListener() {
390                         
391                         @Override
392                         public void widgetSelected(SelectionEvent arg0) {
393                                 autoPassPageSaveValues();
394                                 updatePage( FkNewAccStep.SEPERATOR );
395                         }
396                         
397                         @Override
398                         public void widgetDefaultSelected(SelectionEvent arg0) {                                
399                         }
400                 });
401                 
402
403                 Button button_5 = new Button(composite, SWT.NONE);
404                 button_5.setText(Messages.NewAccountDialog_20);
405                 FormData fd_button_5 = new FormData();
406                 fd_button_5.left = new FormAttachment(0, 10);
407
408                 fd_button_5.bottom = new FormAttachment(button_6, 0, SWT.BOTTOM);
409                 button_5.setLayoutData(fd_button_5);
410                 
411                 button_5.addSelectionListener(new SelectionListener() {
412                         
413                         @Override
414                         public void widgetSelected(SelectionEvent arg0) {
415                                 autoPassPageSaveValues();
416                                 updatePage( FkNewAccStep.PASSTYPE );
417                         }
418                         
419                         @Override
420                         public void widgetDefaultSelected(SelectionEvent arg0) {                                
421                         }
422                 });
423                 
424                 
425         Control[] controls = new Control[] { spnLen, radAllSymbols, radOnlySelected, button_6, button_5 };
426         composite.setTabList(controls);                 
427                 spnLen.setFocus();
428
429         }
430         
431         
432         void makePswField(Boolean showPsw)
433         {
434                 txtManPSW = new Text(composite, SWT.BORDER | ((showPsw)?0:SWT.PASSWORD) );
435                 FormData fd_txtManPSW = new FormData();
436                 fd_txtManPSW.right = new FormAttachment(0, 613);
437                 fd_txtManPSW.top = new FormAttachment(0, 62);
438                 fd_txtManPSW.left = new FormAttachment(0, 92);
439                 txtManPSW.setLayoutData(fd_txtManPSW);
440                 txtManPSW.setText(strPassword);
441                 txtManPSW.addModifyListener( new ModifyListener() {
442                         
443                         @Override
444                         public void modifyText(ModifyEvent arg0) {
445                                 strPassword = txtManPSW.getText();
446                                 if( txtManPSW.getText().length() > 0 )
447                                 {
448                                         btnManPassPageNext.setVisible(true);
449                                 } else {
450                                         btnManPassPageNext.setVisible(false);
451                                 }
452                                 
453                         }
454                 });
455                 
456                 chkShowPsw = new Button(composite, SWT.CHECK);
457                 FormData fd_chkShowPsw = new FormData();
458                 fd_chkShowPsw.right = new FormAttachment(0, 613);
459                 fd_chkShowPsw.top = new FormAttachment(0, 103);
460                 fd_chkShowPsw.left = new FormAttachment(0, 92);
461                 chkShowPsw.setLayoutData(fd_chkShowPsw);
462                 chkShowPsw.setText(Messages.NewAccountDialog_22);
463                 chkShowPsw.setSelection(showPsw);
464                 
465                 chkShowPsw.addSelectionListener( new SelectionListener() {
466
467                         @Override
468                         public void widgetSelected(SelectionEvent arg0) {
469                                 Button btnChk = (Button)arg0.getSource();
470
471                                 txtManPSW.dispose();
472                                 
473                                 
474                                 if( btnChk.getSelection() )
475                                 {
476                                         chkShowPsw.dispose();
477                                         makePswField(true);
478                                 } else {
479                                         chkShowPsw.dispose();
480                                         makePswField(false);
481                                 }
482                                 
483                                 
484                         }
485                         
486                         @Override
487                         public void widgetDefaultSelected(SelectionEvent arg0) {
488                         }
489                 });             
490                 composite.layout();
491         }
492         
493
494         
495         void createPassManPage()
496         {
497                 composite = new Composite(shlNewAccount, SWT.NONE);
498                 composite.setLayout(new FormLayout());
499                 
500                 Button BtnBack1 = new Button(composite, SWT.NONE);
501                 FormData fd_BtnBack1 = new FormData();
502                 fd_BtnBack1.bottom = new FormAttachment(100, -10);
503                 BtnBack1.setLayoutData(fd_BtnBack1);
504                 BtnBack1.setText(Messages.NewAccountDialog_23);
505                 BtnBack1.addSelectionListener( new SelectionListener() {
506                         
507                         @Override
508                         public void widgetSelected(SelectionEvent arg0) {
509                                 updatePage(FkNewAccStep.PASSTYPE);
510                         }
511                         
512                         @Override
513                         public void widgetDefaultSelected(SelectionEvent arg0) {
514                                 
515                         }
516                 });
517                 
518                 btnManPassPageNext = new Button(composite, SWT.NONE);
519                 FormData fd_btnManPassPageNext = new FormData();
520                 fd_btnManPassPageNext.bottom = new FormAttachment(BtnBack1, 0, SWT.BOTTOM);
521                 btnManPassPageNext.setLayoutData(fd_btnManPassPageNext);
522                 btnManPassPageNext.setText(Messages.NewAccountDialog_24);
523                 btnManPassPageNext.setVisible(false);
524                 btnManPassPageNext.addSelectionListener( new SelectionListener() {
525                         
526                         @Override
527                         public void widgetSelected(SelectionEvent arg0) {
528                                 updatePage(FkNewAccStep.SEPERATOR);
529                         }
530                         
531                         @Override
532                         public void widgetDefaultSelected(SelectionEvent arg0) {                                
533                         }
534                 });
535                 
536                 lblTypeThePassword = new Label(composite, SWT.NONE);
537                 fd_btnManPassPageNext.right = new FormAttachment(lblTypeThePassword, 0, SWT.RIGHT);
538                 fd_BtnBack1.left = new FormAttachment(lblTypeThePassword, 0, SWT.LEFT);
539                 FormData fd_lblTypeThePassword = new FormData();
540                 fd_lblTypeThePassword.right = new FormAttachment(0, 613);
541                 fd_lblTypeThePassword.top = new FormAttachment(0, 10);
542                 fd_lblTypeThePassword.left = new FormAttachment(0, 10);
543                 lblTypeThePassword.setLayoutData(fd_lblTypeThePassword);
544                 lblTypeThePassword.setText(Messages.NewAccountDialog_25);
545                 
546                 lblPassword = new Label(composite, SWT.NONE);
547                 FormData fd_lblPassword = new FormData();
548                 fd_lblPassword.top = new FormAttachment(0, 74);
549                 fd_lblPassword.left = new FormAttachment(0, 10);
550                 lblPassword.setLayoutData(fd_lblPassword);
551                 lblPassword.setText(Messages.NewAccountDialog_26);
552                 
553                 makePswField(false);
554                 
555                 
556         Control[] controls = new Control[] { txtManPSW, btnManPassPageNext, BtnBack1 };
557         composite.setTabList(controls); 
558         txtManPSW.setFocus();
559                 
560         }
561         
562
563         void createSeperatorPage()
564         {
565                 composite = new Composite(shlNewAccount, SWT.NONE);
566                 composite.setLayout(new FormLayout());
567                 
568                 Label lblToMakeFinalkey = new Label(composite, SWT.NONE);
569                 FormData fd_lblToMakeFinalkey = new FormData();
570                 fd_lblToMakeFinalkey.right = new FormAttachment(0, 613);
571                 fd_lblToMakeFinalkey.top = new FormAttachment(0, 10);
572                 fd_lblToMakeFinalkey.left = new FormAttachment(0, 10);
573                 lblToMakeFinalkey.setLayoutData(fd_lblToMakeFinalkey);
574                 lblToMakeFinalkey.setText(Messages.NewAccountDialog_27);
575                 
576                 radTabSep = new Button(composite, SWT.RADIO);
577                 FormData fd_radTabSep = new FormData();
578                 fd_radTabSep.right = new FormAttachment(0, 613);
579                 fd_radTabSep.top = new FormAttachment(0, 172);
580                 fd_radTabSep.left = new FormAttachment(0, 231);
581                 radTabSep.setLayoutData(fd_radTabSep);
582                 if( seperatorTab )
583                 {
584                         radTabSep.setSelection(true);
585                 }
586                 radTabSep.setText(Messages.NewAccountDialog_28);
587                 
588                 Button radEnterSep = new Button(composite, SWT.RADIO);
589                 FormData fd_radEnterSep = new FormData();
590                 fd_radEnterSep.right = new FormAttachment(0, 613);
591                 fd_radEnterSep.top = new FormAttachment(0, 205);
592                 fd_radEnterSep.left = new FormAttachment(0, 231);
593                 radEnterSep.setLayoutData(fd_radEnterSep);
594                 if( !seperatorTab )
595                 {
596                         radEnterSep.setSelection(true);
597                 }
598                 radEnterSep.setText(Messages.NewAccountDialog_29);
599                 
600                 Button button_7 = new Button(composite, SWT.NONE);
601                 FormData fd_button_7 = new FormData();
602                 fd_button_7.top = new FormAttachment(0, 325);
603                 fd_button_7.left = new FormAttachment(0, 10);
604                 button_7.setLayoutData(fd_button_7);
605                 button_7.setText(Messages.NewAccountDialog_30);
606                 button_7.addSelectionListener(new SelectionListener() {
607                         
608                         @Override
609                         public void widgetSelected(SelectionEvent arg0) {
610                                 seperatorTab = radTabSep.getSelection();
611                                 if( autoPassword )
612                                 {
613                                         updatePage(FkNewAccStep.PASS_AUT);
614                                 } else {
615                                         updatePage(FkNewAccStep.PASS_MAN);
616                                 }
617                         }
618                         
619                         @Override
620                         public void widgetDefaultSelected(SelectionEvent arg0) {
621                         }
622                 });
623                 
624                 Button button_8 = new Button(composite, SWT.NONE);
625                 FormData fd_button_8 = new FormData();
626                 fd_button_8.top = new FormAttachment(0, 325);
627                 fd_button_8.left = new FormAttachment(0, 565);
628                 button_8.setLayoutData(fd_button_8);
629                 button_8.setText(Messages.NewAccountDialog_31);
630                 button_8.addSelectionListener(new SelectionListener() {
631                         
632                         @Override
633                         public void widgetSelected(SelectionEvent arg0) {
634                                 seperatorTab = radTabSep.getSelection();
635                                 updatePage(FkNewAccStep.REVIEW);
636                         }
637                         
638                         @Override
639                         public void widgetDefaultSelected(SelectionEvent arg0) {
640                         }
641                 });
642                 
643
644         Control[] controls = new Control[] { radTabSep, radEnterSep, button_8, button_7 };
645         composite.setTabList(controls);         
646         radTabSep.setFocus();
647                 
648         }
649         
650
651         void createReviewPage()
652         {
653                 composite = new Composite(shlNewAccount, SWT.NONE);
654                 composite.setLayout(new FormLayout());
655                 
656                 Label lblHeresAnOverview = new Label(composite, SWT.NONE);
657                 FormData fd_lblHeresAnOverview = new FormData();
658                 fd_lblHeresAnOverview.right = new FormAttachment(0, 613);
659                 fd_lblHeresAnOverview.top = new FormAttachment(0, 10);
660                 fd_lblHeresAnOverview.left = new FormAttachment(0, 10);
661                 lblHeresAnOverview.setLayoutData(fd_lblHeresAnOverview);
662                 lblHeresAnOverview.setText(Messages.NewAccountDialog_32);
663                 
664                 Label lblAccountName = new Label(composite, SWT.NONE);
665                 lblAccountName.setAlignment(SWT.RIGHT);
666                 FormData fd_lblAccountName = new FormData();
667                 fd_lblAccountName.left = new FormAttachment(0, 10);
668                 fd_lblAccountName.top = new FormAttachment(0, 51);
669                 lblAccountName.setLayoutData(fd_lblAccountName);
670                 lblAccountName.setText(Messages.NewAccountDialog_33);
671                 
672                 Label lblPasswordType = new Label(composite, SWT.NONE);
673                 lblPasswordType.setAlignment(SWT.RIGHT);
674                 FormData fd_lblPasswordType = new FormData();
675                 fd_lblPasswordType.right = new FormAttachment(lblAccountName, 0, SWT.RIGHT);
676                 fd_lblPasswordType.left = new FormAttachment(lblHeresAnOverview, 0, SWT.LEFT);
677                 fd_lblPasswordType.top = new FormAttachment(0, 109);
678                 lblPasswordType.setLayoutData(fd_lblPasswordType);
679                 lblPasswordType.setText(Messages.NewAccountDialog_34);
680                 
681                 Label lblUserName = new Label(composite, SWT.NONE);
682                 lblUserName.setAlignment(SWT.RIGHT);
683                 FormData fd_lblUserName = new FormData();
684                 fd_lblUserName.right = new FormAttachment(lblHeresAnOverview, 220);
685                 fd_lblUserName.left = new FormAttachment(lblHeresAnOverview, 0, SWT.LEFT);
686                 fd_lblUserName.top = new FormAttachment(0, 80);
687                 lblUserName.setLayoutData(fd_lblUserName);
688                 lblUserName.setText(Messages.NewAccountDialog_35);
689                 
690                 Label lblIfEverythingLooks = new Label(composite, SWT.NONE);
691                 FormData fd_lblIfEverythingLooks = new FormData();
692                 fd_lblIfEverythingLooks.bottom = new FormAttachment(0, 287);
693                 fd_lblIfEverythingLooks.right = new FormAttachment(lblHeresAnOverview, 0, SWT.RIGHT);
694                 fd_lblIfEverythingLooks.top = new FormAttachment(0, 181);
695                 fd_lblIfEverythingLooks.left = new FormAttachment(0, 10);
696                 lblIfEverythingLooks.setLayoutData(fd_lblIfEverythingLooks);
697                 lblIfEverythingLooks.setText(Messages.NewAccountDialog_36);
698                 
699                 Label lblSeperator = new Label(composite, SWT.NONE);
700                 lblSeperator.setAlignment(SWT.RIGHT);
701                 FormData fd_lblSeperator = new FormData();
702                 fd_lblSeperator.right = new FormAttachment(0, 230);
703                 fd_lblSeperator.top = new FormAttachment(0, 138);
704                 fd_lblSeperator.left = new FormAttachment(0, 10);
705                 lblSeperator.setLayoutData(fd_lblSeperator);
706                 lblSeperator.setText(Messages.NewAccountDialog_37);
707                 
708                 Button button_9 = new Button(composite, SWT.NONE);
709                 FormData fd_button_9 = new FormData();
710                 fd_button_9.left = new FormAttachment(lblHeresAnOverview, 0, SWT.LEFT);
711                 button_9.setLayoutData(fd_button_9);
712                 button_9.setText(Messages.NewAccountDialog_38);
713                 button_9.addSelectionListener( new SelectionListener() {
714                         
715                         @Override
716                         public void widgetSelected(SelectionEvent arg0) {
717                                 updatePage(FkNewAccStep.SEPERATOR);
718                         }
719                         
720                         @Override
721                         public void widgetDefaultSelected(SelectionEvent arg0) {                
722                         }
723                 });
724                 
725                 Button btnSave = new Button(composite, SWT.NONE);
726                 fd_button_9.bottom = new FormAttachment(btnSave, 0, SWT.BOTTOM);
727                 FormData fd_btnSave = new FormData();
728                 fd_btnSave.bottom = new FormAttachment(100, -10);
729                 fd_btnSave.right = new FormAttachment(lblHeresAnOverview, 0, SWT.RIGHT);
730                 btnSave.setLayoutData(fd_btnSave);
731                 btnSave.setText(Messages.NewAccountDialog_39);
732                 btnSave.setFocus();
733                 
734                 btnSave.addSelectionListener( new SelectionListener() {
735                         
736                         @Override
737                         public void widgetSelected(SelectionEvent arg0) {
738                                 MessageBox dialog = new MessageBox(shlNewAccount, SWT.ICON_INFORMATION | SWT.OK );
739                                 dialog.setText(Messages.NewAccountDialog_40);
740                                 dialog.setMessage(Messages.NewAccountDialog_41);
741                                 dialog.open();
742                                 FkManager.getInstance().createAccount( strAccountName, strUserName, autoPassword, autoPassLen, autoPassAllSpecials, autoPassSpecials, strPassword, seperatorTab, mySelf );
743                                 updatePage(FkNewAccStep.SAVING);
744                         }
745                         
746                         @Override
747                         public void widgetDefaultSelected(SelectionEvent arg0) {
748                                 
749                         }
750                 });
751                 
752                 Label lblAccName = new Label(composite, SWT.NONE);
753                 fd_lblAccountName.right = new FormAttachment(lblAccName, -6);
754                 FormData fd_lblAccName = new FormData();
755                 fd_lblAccName.right = new FormAttachment(0, 603);
756                 fd_lblAccName.top = new FormAttachment(0, 51);
757                 fd_lblAccName.left = new FormAttachment(0, 236);
758                 lblAccName.setLayoutData(fd_lblAccName);
759                 lblAccName.setText(strAccountName);
760                 
761                 Label lblUsrName = new Label(composite, SWT.NONE);
762                 FormData fd_lblUsrName = new FormData();
763                 fd_lblUsrName.right = new FormAttachment(0, 613);
764                 fd_lblUsrName.top = new FormAttachment(0, 80);
765                 fd_lblUsrName.left = new FormAttachment(0, 236);
766                 lblUsrName.setLayoutData(fd_lblUsrName);
767                 lblUsrName.setText(strUserName);
768                 
769                 Label lblPasswordInfo = new Label(composite, SWT.NONE);
770                 FormData fd_lblPasswordInfo = new FormData();
771                 fd_lblPasswordInfo.right = new FormAttachment(0, 603);
772                 fd_lblPasswordInfo.top = new FormAttachment(0, 109);
773                 fd_lblPasswordInfo.left = new FormAttachment(0, 236);
774                 lblPasswordInfo.setLayoutData(fd_lblPasswordInfo);
775                 
776                 String passInfo;
777                 if( autoPassword )
778                 {
779                         passInfo = Messages.NewAccountDialog_42 + autoPassLen + Messages.NewAccountDialog_43;
780                         if( autoPassAllSpecials )
781                         {
782                                 passInfo += Messages.NewAccountDialog_44;
783                         } else {
784                                 passInfo += "{"+autoPassSpecials+ "}"; //$NON-NLS-1$ //$NON-NLS-2$
785                         }
786                         
787                 } else {
788                         passInfo =Messages.NewAccountDialog_47 + strPassword.length() +Messages.NewAccountDialog_48;
789                 }
790                 
791                 lblPasswordInfo.setText(passInfo);
792                 
793                 Label lblSeperatorInfo = new Label(composite, SWT.NONE);
794                 FormData fd_lblSeperatorInfo = new FormData();
795                 fd_lblSeperatorInfo.right = new FormAttachment(0, 603);
796                 fd_lblSeperatorInfo.top = new FormAttachment(0, 138);
797                 fd_lblSeperatorInfo.left = new FormAttachment(0, 236);
798                 lblSeperatorInfo.setLayoutData(fd_lblSeperatorInfo);
799                 
800                 String sepInfo;
801                 if( seperatorTab )
802                 {
803                         sepInfo = Messages.NewAccountDialog_49;
804                 } else {
805                         sepInfo = Messages.NewAccountDialog_50;
806                 }
807                 
808                 lblSeperatorInfo.setText(sepInfo);
809                 
810         Control[] controls = new Control[] { btnSave, button_9 };
811         composite.setTabList(controls);                         
812
813         }
814         
815         void createSavingPage()
816         {
817                 composite = new Composite(shlNewAccount, SWT.NONE);
818                 composite.setLayout(new FormLayout());
819                 
820                 txtBUSYMSG = new Label(composite, SWT.NONE);
821                 FormData fd_txtBUSYMSG = new FormData();
822                 fd_txtBUSYMSG.top = new FormAttachment(0, 10);
823                 fd_txtBUSYMSG.right = new FormAttachment(100, -10);
824                 fd_txtBUSYMSG.left = new FormAttachment(0, 78);
825                 txtBUSYMSG.setLayoutData(fd_txtBUSYMSG);
826                 txtBUSYMSG.setText(Messages.NewAccountDialog_51);
827                 FormData fdAni = new FormData();
828                 fdAni.top = new FormAttachment(txtBUSYMSG);
829                 
830                 animation = new Animation(composite, SWT.NONE, 4);
831                 FormData fd_animation = new FormData();
832                 fd_animation.top = new FormAttachment(0, 10);
833                 fd_animation.left = new FormAttachment(0, 10);
834                 animation.setLayoutData(fd_animation);
835                 animation.setBounds(10, 32, 32, 32);
836                 animation.setVisible(true);
837                 animation.setPlaying(true);
838
839         }
840         
841         
842         private void updatePage(FkNewAccStep curPage)
843         {
844                 if(composite != null && !composite.isDisposed() )
845                 {
846                         composite.dispose();
847                 }
848                 System.out.println(curPage);
849                 
850                 switch(curPage)
851                 {
852                 case CLICKBTN:
853                         break;
854                 case NAMES:
855                         createNamePage();
856                         break;
857                 case PASSTYPE:
858                         createPassTypePage();
859                         break;
860                 case PASS_AUT:
861                         createPassAutPage();
862                         break;
863                 case PASS_MAN:
864                         createPassManPage();
865                         break;
866                 case REVIEW:
867                         createReviewPage();
868                         break;
869                 case SEPERATOR:
870                         createSeperatorPage();
871                         break;
872                 case SAVING:
873                         createSavingPage();
874                         break;
875
876                         
877                 }
878                 
879                 shlNewAccount.layout();
880         }
881         /**
882          * Create contents of the dialog.
883          */
884         private void createContents() {
885                 shlNewAccount = new Shell(getParent(), getStyle());
886                 shlNewAccount.setSize(625, 394);
887                 shlNewAccount.setText(Messages.NewAccountDialog_54);
888                 shlNewAccount.setLayout(new FillLayout(SWT.HORIZONTAL));
889                 
890         //      TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
891                 
892                 //TabItem tbtmStepUsername = new TabItem(tabFolder, SWT.NONE);
893                 //tbtmStepUsername.setText("Name");
894                 
895                 updatePage(FkNewAccStep.NAMES);
896
897         }
898
899         @Override
900         public void fkActionEvent(FkActionEvent event) {
901                 //System.out.println( "Event data:"+ event.data );
902                 MessageBox dialog;
903                 Boolean closeSelf=false;
904                 
905                 switch(event.type)
906                 {
907                 case ACTION_ABORTED:
908                         txtBUSYMSG.setText(Messages.NewAccountDialog_55);
909                         dialog = new MessageBox(shlNewAccount, SWT.ICON_WARNING);
910                         dialog.setText(Messages.NewAccountDialog_56);
911                         dialog.setMessage(Messages.NewAccountDialog_57);
912                         dialog.open();
913                         updatePage(FkNewAccStep.REVIEW);                        
914                         break;
915                 case ACTION_ERROR:
916                         txtBUSYMSG.setText(Messages.NewAccountDialog_58);
917
918                         dialog = new MessageBox(shlNewAccount, SWT.ICON_ERROR);
919                         dialog.setText(Messages.NewAccountDialog_59);
920                         dialog.setMessage(Messages.NewAccountDialog_60);
921                         dialog.open();
922                         closeSelf=true;
923                         break;
924                 case ACTION_OKAY:
925                         txtBUSYMSG.setText(Messages.NewAccountDialog_61);
926                         dialog = new MessageBox(shlNewAccount, SWT.ICON_INFORMATION);
927                         dialog.setText(Messages.NewAccountDialog_62);
928                         dialog.setMessage(Messages.NewAccountDialog_63);
929                         dialog.open();
930                         closeSelf=true;
931                         break;
932                 case ACTION_WAITING:
933                         txtBUSYMSG.setText(Messages.NewAccountDialog_64);
934                         break;
935                 case ACTION_WORKING:
936                         txtBUSYMSG.setText(Messages.NewAccountDialog_65);
937                         animation.setVisible(false);
938                         break;
939                 }
940                 
941                 if( !shlNewAccount.isDisposed() && closeSelf )
942                 {
943                         shlNewAccount.close();
944                 }
945         }
946 }