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