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