Fixed bug in new-account, added error dialogs.
[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.bottom = new FormAttachment(btnCancel, 0, SWT.BOTTOM);
214                 fd_btnNext0.right = new FormAttachment(lblEnterNewName, 0, SWT.RIGHT);
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.bottom = new FormAttachment(100, -10);
266                 fd_btnNext1.right = new FormAttachment(100, -10);
267                 btnNext1.setLayoutData(fd_btnNext1);
268                 btnNext1.addSelectionListener(new SelectionListener() {
269                         
270                         @Override
271                         public void widgetSelected(SelectionEvent arg0) {
272                                 if( radAutPSW.getSelection() )
273                                 {
274                                         updatePage(FkNewAccStep.PASS_AUT);
275                                         autoPassword = true;
276                                 } else {
277                                         updatePage(FkNewAccStep.PASS_MAN);
278                                         autoPassword = false;
279                                 }
280                         }
281                         
282                         @Override
283                         public void widgetDefaultSelected(SelectionEvent arg0) {
284                                 // TODO Auto-generated method stub
285                                 
286                         }
287                 });
288                 
289                 Button btnBack0 = new Button(composite, SWT.NONE);
290                 btnBack0.setText(Messages.NewAccountDialog_14);
291                 FormData fd_btnBack0 = new FormData();
292                 fd_btnBack0.bottom = new FormAttachment(btnNext1, 0, SWT.BOTTOM);
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.top = new FormAttachment(0, 10);
329                 fd_lblBeforeCreatingA.left = new FormAttachment(0, 10);
330                 lblBeforeCreatingA.setLayoutData(fd_lblBeforeCreatingA);
331                 
332                 lblBeforeCreatingA.setText(Messages.NewAccountDialog_15);
333                 
334                 Label lblPasswordLength = new Label(composite, SWT.NONE);
335                 fd_lblBeforeCreatingA.bottom = new FormAttachment(100, -257);
336                 FormData fd_lblPasswordLength = new FormData();
337                 lblPasswordLength.setLayoutData(fd_lblPasswordLength);
338                 lblPasswordLength.setText(Messages.NewAccountDialog_16);
339                 
340                 spnLen = new Spinner(composite, SWT.BORDER);
341                 fd_lblPasswordLength.bottom = new FormAttachment(spnLen, 0, SWT.BOTTOM);
342                 fd_lblPasswordLength.right = new FormAttachment(spnLen, -9);
343                 FormData fd_spnLen = new FormData();
344                 fd_spnLen.top = new FormAttachment(0, 119);
345                 fd_spnLen.left = new FormAttachment(0, 310);
346                 spnLen.setLayoutData(fd_spnLen);
347                 spnLen.setMaximum(128);
348                 spnLen.setSelection(autoPassLen);
349                 
350                 Label lblASafePassword = new Label(composite, SWT.NONE);
351                 FormData fd_lblASafePassword = new FormData();
352                 fd_lblASafePassword.right = new FormAttachment(lblBeforeCreatingA, 0, SWT.RIGHT);
353                 fd_lblASafePassword.top = new FormAttachment(lblPasswordLength, 47);
354                 fd_lblASafePassword.left = new FormAttachment(0, 10);
355                 lblASafePassword.setLayoutData(fd_lblASafePassword);
356                 lblASafePassword.setText(Messages.NewAccountDialog_17);
357                 
358                 radAllSymbols = new Button(composite, SWT.RADIO);
359                 fd_lblASafePassword.bottom = new FormAttachment(100, -100);
360                 FormData fd_radAllSymbols = new FormData();
361                 fd_radAllSymbols.top = new FormAttachment(lblASafePassword, 6);
362                 fd_radAllSymbols.left = new FormAttachment(0, 10);
363                 radAllSymbols.setLayoutData(fd_radAllSymbols);
364                 if( autoPassAllSpecials )
365                 {
366                         radAllSymbols.setSelection(true);
367                 }
368                 radAllSymbols.setText(Messages.NewAccountDialog_18);
369                 radAllSymbols.pack();
370                 
371                 Button radOnlySelected = new Button(composite, SWT.RADIO);
372                 FormData fd_radOnlySelected = new FormData();
373                 fd_radOnlySelected.bottom = new FormAttachment(radAllSymbols, 0, SWT.BOTTOM);
374                 fd_radOnlySelected.right = new FormAttachment(spnLen, 0, SWT.RIGHT);
375                 radOnlySelected.setLayoutData(fd_radOnlySelected);
376                 if( !autoPassAllSpecials )
377                 {
378                         radOnlySelected.setSelection(true);
379                 }
380                 radOnlySelected.setText(Messages.NewAccountDialog_19);
381                 
382                 txtSpecials = new Text(composite, SWT.BORDER);
383                 FormData fd_txtSpecials = new FormData();
384                 fd_txtSpecials.top = new FormAttachment(lblASafePassword, 6);
385                 fd_txtSpecials.left = new FormAttachment(radOnlySelected, 6);
386                 txtSpecials.setLayoutData(fd_txtSpecials);
387                 txtSpecials.setText(autoPassSpecials);
388                 txtSpecials.setBounds(291, 243, 312, 35);
389                 
390                 
391                 Button button_6 = new Button(composite, SWT.NONE);
392                 fd_lblBeforeCreatingA.right = new FormAttachment(button_6, 0, SWT.RIGHT);
393                 button_6.setText(Messages.NewAccountDialog_21);
394                 FormData fd_button_6 = new FormData();
395                 fd_button_6.bottom = new FormAttachment(100, -10);
396                 fd_button_6.right = new FormAttachment(100, -10);
397                 button_6.setLayoutData(fd_button_6);
398                 
399                 button_6.addSelectionListener(new SelectionListener() {
400                         
401                         @Override
402                         public void widgetSelected(SelectionEvent arg0) {
403                                 autoPassPageSaveValues();
404                                 updatePage( FkNewAccStep.SEPERATOR );
405                         }
406                         
407                         @Override
408                         public void widgetDefaultSelected(SelectionEvent arg0) {                                
409                         }
410                 });
411                 
412
413                 Button button_5 = new Button(composite, SWT.NONE);
414                 button_5.setText(Messages.NewAccountDialog_20);
415                 FormData fd_button_5 = new FormData();
416                 fd_button_5.left = new FormAttachment(0, 10);
417
418                 fd_button_5.bottom = new FormAttachment(button_6, 0, SWT.BOTTOM);
419                 button_5.setLayoutData(fd_button_5);
420                 
421                 button_5.addSelectionListener(new SelectionListener() {
422                         
423                         @Override
424                         public void widgetSelected(SelectionEvent arg0) {
425                                 autoPassPageSaveValues();
426                                 updatePage( FkNewAccStep.PASSTYPE );
427                         }
428                         
429                         @Override
430                         public void widgetDefaultSelected(SelectionEvent arg0) {                                
431                         }
432                 });
433                 
434                 
435         Control[] controls = new Control[] { spnLen, radAllSymbols, radOnlySelected, button_6, button_5 };
436         composite.setTabList(controls);                 
437                 spnLen.setFocus();
438
439         }
440         
441         
442         void makePswField(Boolean showPsw)
443         {
444                 txtManPSW = new Text(composite, SWT.BORDER | ((showPsw)?0:SWT.PASSWORD) );
445                 FormData fd_txtManPSW = new FormData();
446                 fd_txtManPSW.right = new FormAttachment(0, 613);
447                 fd_txtManPSW.top = new FormAttachment(0, 62);
448                 fd_txtManPSW.left = new FormAttachment(0, 92);
449                 txtManPSW.setLayoutData(fd_txtManPSW);
450                 txtManPSW.setText(strPassword);
451                 txtManPSW.addModifyListener( new ModifyListener() {
452                         
453                         @Override
454                         public void modifyText(ModifyEvent arg0) {
455                                 strPassword = txtManPSW.getText();
456                                 if( txtManPSW.getText().length() > 0 )
457                                 {
458                                         btnManPassPageNext.setVisible(true);
459                                 } else {
460                                         btnManPassPageNext.setVisible(false);
461                                 }
462                                 
463                         }
464                 });
465                 
466                 chkShowPsw = new Button(composite, SWT.CHECK);
467                 FormData fd_chkShowPsw = new FormData();
468                 fd_chkShowPsw.right = new FormAttachment(0, 613);
469                 fd_chkShowPsw.top = new FormAttachment(0, 103);
470                 fd_chkShowPsw.left = new FormAttachment(0, 92);
471                 chkShowPsw.setLayoutData(fd_chkShowPsw);
472                 chkShowPsw.setText(Messages.NewAccountDialog_22);
473                 chkShowPsw.setSelection(showPsw);
474                 
475                 chkShowPsw.addSelectionListener( new SelectionListener() {
476
477                         @Override
478                         public void widgetSelected(SelectionEvent arg0) {
479                                 Button btnChk = (Button)arg0.getSource();
480
481                                 txtManPSW.dispose();
482                                 
483                                 
484                                 if( btnChk.getSelection() )
485                                 {
486                                         chkShowPsw.dispose();
487                                         makePswField(true);
488                                 } else {
489                                         chkShowPsw.dispose();
490                                         makePswField(false);
491                                 }
492                                 
493                                 
494                         }
495                         
496                         @Override
497                         public void widgetDefaultSelected(SelectionEvent arg0) {
498                         }
499                 });             
500                 composite.layout();
501         }
502         
503
504         
505         void createPassManPage()
506         {
507                 composite = new Composite(shlNewAccount, SWT.NONE);
508                 composite.setLayout(new FormLayout());
509                 
510                 Button BtnBack1 = new Button(composite, SWT.NONE);
511                 FormData fd_BtnBack1 = new FormData();
512                 fd_BtnBack1.bottom = new FormAttachment(100, -10);
513                 BtnBack1.setLayoutData(fd_BtnBack1);
514                 BtnBack1.setText(Messages.NewAccountDialog_23);
515                 BtnBack1.addSelectionListener( new SelectionListener() {
516                         
517                         @Override
518                         public void widgetSelected(SelectionEvent arg0) {
519                                 updatePage(FkNewAccStep.PASSTYPE);
520                         }
521                         
522                         @Override
523                         public void widgetDefaultSelected(SelectionEvent arg0) {
524                                 
525                         }
526                 });
527                 
528                 btnManPassPageNext = new Button(composite, SWT.NONE);
529                 FormData fd_btnManPassPageNext = new FormData();
530                 fd_btnManPassPageNext.bottom = new FormAttachment(BtnBack1, 0, SWT.BOTTOM);
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_btnManPassPageNext.right = new FormAttachment(lblTypeThePassword, 0, SWT.RIGHT);
548                 fd_BtnBack1.left = new FormAttachment(lblTypeThePassword, 0, SWT.LEFT);
549                 FormData fd_lblTypeThePassword = new FormData();
550                 fd_lblTypeThePassword.right = new FormAttachment(0, 613);
551                 fd_lblTypeThePassword.top = new FormAttachment(0, 10);
552                 fd_lblTypeThePassword.left = new FormAttachment(0, 10);
553                 lblTypeThePassword.setLayoutData(fd_lblTypeThePassword);
554                 lblTypeThePassword.setText(Messages.NewAccountDialog_25);
555                 
556                 lblPassword = new Label(composite, SWT.NONE);
557                 FormData fd_lblPassword = new FormData();
558                 fd_lblPassword.top = new FormAttachment(0, 74);
559                 fd_lblPassword.left = new FormAttachment(0, 10);
560                 lblPassword.setLayoutData(fd_lblPassword);
561                 lblPassword.setText(Messages.NewAccountDialog_26);
562                 
563                 makePswField(false);
564                 
565                 
566         Control[] controls = new Control[] { txtManPSW, btnManPassPageNext, BtnBack1 };
567         composite.setTabList(controls); 
568         txtManPSW.setFocus();
569                 
570         }
571         
572
573         void createSeperatorPage()
574         {
575                 composite = new Composite(shlNewAccount, SWT.NONE);
576                 composite.setLayout(new FormLayout());
577                 
578                 Label lblToMakeFinalkey = new Label(composite, SWT.NONE);
579                 FormData fd_lblToMakeFinalkey = new FormData();
580                 fd_lblToMakeFinalkey.right = new FormAttachment(0, 613);
581                 fd_lblToMakeFinalkey.top = new FormAttachment(0, 10);
582                 fd_lblToMakeFinalkey.left = new FormAttachment(0, 10);
583                 lblToMakeFinalkey.setLayoutData(fd_lblToMakeFinalkey);
584                 lblToMakeFinalkey.setText(Messages.NewAccountDialog_27);
585                 
586                 radTabSep = new Button(composite, SWT.RADIO);
587                 FormData fd_radTabSep = new FormData();
588                 fd_radTabSep.right = new FormAttachment(0, 613);
589                 fd_radTabSep.top = new FormAttachment(0, 172);
590                 fd_radTabSep.left = new FormAttachment(0, 231);
591                 radTabSep.setLayoutData(fd_radTabSep);
592                 if( seperatorTab )
593                 {
594                         radTabSep.setSelection(true);
595                 }
596                 radTabSep.setText(Messages.NewAccountDialog_28);
597                 
598                 Button radEnterSep = new Button(composite, SWT.RADIO);
599                 FormData fd_radEnterSep = new FormData();
600                 fd_radEnterSep.right = new FormAttachment(0, 613);
601                 fd_radEnterSep.top = new FormAttachment(0, 205);
602                 fd_radEnterSep.left = new FormAttachment(0, 231);
603                 radEnterSep.setLayoutData(fd_radEnterSep);
604                 if( !seperatorTab )
605                 {
606                         radEnterSep.setSelection(true);
607                 }
608                 radEnterSep.setText(Messages.NewAccountDialog_29);
609                 
610                 Button button_7 = new Button(composite, SWT.NONE);
611                 FormData fd_button_7 = new FormData();
612                 fd_button_7.top = new FormAttachment(0, 325);
613                 fd_button_7.left = new FormAttachment(0, 10);
614                 button_7.setLayoutData(fd_button_7);
615                 button_7.setText(Messages.NewAccountDialog_30);
616                 button_7.addSelectionListener(new SelectionListener() {
617                         
618                         @Override
619                         public void widgetSelected(SelectionEvent arg0) {
620                                 seperatorTab = radTabSep.getSelection();
621                                 if( autoPassword )
622                                 {
623                                         updatePage(FkNewAccStep.PASS_AUT);
624                                 } else {
625                                         updatePage(FkNewAccStep.PASS_MAN);
626                                 }
627                         }
628                         
629                         @Override
630                         public void widgetDefaultSelected(SelectionEvent arg0) {
631                         }
632                 });
633                 
634                 Button button_8 = new Button(composite, SWT.NONE);
635                 FormData fd_button_8 = new FormData();
636                 fd_button_8.top = new FormAttachment(0, 325);
637                 fd_button_8.left = new FormAttachment(0, 565);
638                 button_8.setLayoutData(fd_button_8);
639                 button_8.setText(Messages.NewAccountDialog_31);
640                 button_8.addSelectionListener(new SelectionListener() {
641                         
642                         @Override
643                         public void widgetSelected(SelectionEvent arg0) {
644                                 seperatorTab = radTabSep.getSelection();
645                                 updatePage(FkNewAccStep.REVIEW);
646                         }
647                         
648                         @Override
649                         public void widgetDefaultSelected(SelectionEvent arg0) {
650                         }
651                 });
652                 
653
654         Control[] controls = new Control[] { radTabSep, radEnterSep, button_8, button_7 };
655         composite.setTabList(controls);         
656         radTabSep.setFocus();
657                 
658         }
659         
660
661         void createReviewPage()
662         {
663                 composite = new Composite(shlNewAccount, SWT.NONE);
664                 composite.setLayout(new FormLayout());
665                 
666                 Label lblHeresAnOverview = new Label(composite, SWT.NONE);
667                 FormData fd_lblHeresAnOverview = new FormData();
668                 fd_lblHeresAnOverview.right = new FormAttachment(0, 613);
669                 fd_lblHeresAnOverview.top = new FormAttachment(0, 10);
670                 fd_lblHeresAnOverview.left = new FormAttachment(0, 10);
671                 lblHeresAnOverview.setLayoutData(fd_lblHeresAnOverview);
672                 lblHeresAnOverview.setText(Messages.NewAccountDialog_32);
673                 
674                 Label lblAccountName = new Label(composite, SWT.NONE);
675                 lblAccountName.setAlignment(SWT.RIGHT);
676                 FormData fd_lblAccountName = new FormData();
677                 fd_lblAccountName.left = new FormAttachment(0, 10);
678                 fd_lblAccountName.top = new FormAttachment(0, 51);
679                 lblAccountName.setLayoutData(fd_lblAccountName);
680                 lblAccountName.setText(Messages.NewAccountDialog_33);
681                 
682                 Label lblPasswordType = new Label(composite, SWT.NONE);
683                 lblPasswordType.setAlignment(SWT.RIGHT);
684                 FormData fd_lblPasswordType = new FormData();
685                 fd_lblPasswordType.right = new FormAttachment(lblAccountName, 0, SWT.RIGHT);
686                 fd_lblPasswordType.left = new FormAttachment(lblHeresAnOverview, 0, SWT.LEFT);
687                 fd_lblPasswordType.top = new FormAttachment(0, 109);
688                 lblPasswordType.setLayoutData(fd_lblPasswordType);
689                 lblPasswordType.setText(Messages.NewAccountDialog_34);
690                 
691                 Label lblUserName = new Label(composite, SWT.NONE);
692                 lblUserName.setAlignment(SWT.RIGHT);
693                 FormData fd_lblUserName = new FormData();
694                 fd_lblUserName.right = new FormAttachment(lblHeresAnOverview, 220);
695                 fd_lblUserName.left = new FormAttachment(lblHeresAnOverview, 0, SWT.LEFT);
696                 fd_lblUserName.top = new FormAttachment(0, 80);
697                 lblUserName.setLayoutData(fd_lblUserName);
698                 lblUserName.setText(Messages.NewAccountDialog_35);
699                 
700                 Label lblIfEverythingLooks = new Label(composite, SWT.NONE);
701                 FormData fd_lblIfEverythingLooks = new FormData();
702                 fd_lblIfEverythingLooks.bottom = new FormAttachment(0, 287);
703                 fd_lblIfEverythingLooks.right = new FormAttachment(lblHeresAnOverview, 0, SWT.RIGHT);
704                 fd_lblIfEverythingLooks.top = new FormAttachment(0, 181);
705                 fd_lblIfEverythingLooks.left = new FormAttachment(0, 10);
706                 lblIfEverythingLooks.setLayoutData(fd_lblIfEverythingLooks);
707                 lblIfEverythingLooks.setText(Messages.NewAccountDialog_36);
708                 
709                 Label lblSeperator = new Label(composite, SWT.NONE);
710                 lblSeperator.setAlignment(SWT.RIGHT);
711                 FormData fd_lblSeperator = new FormData();
712                 fd_lblSeperator.right = new FormAttachment(0, 230);
713                 fd_lblSeperator.top = new FormAttachment(0, 138);
714                 fd_lblSeperator.left = new FormAttachment(0, 10);
715                 lblSeperator.setLayoutData(fd_lblSeperator);
716                 lblSeperator.setText(Messages.NewAccountDialog_37);
717                 
718                 Button button_9 = new Button(composite, SWT.NONE);
719                 FormData fd_button_9 = new FormData();
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                 fd_button_9.bottom = new FormAttachment(btnSave, 0, SWT.BOTTOM);
737                 FormData fd_btnSave = new FormData();
738                 fd_btnSave.bottom = new FormAttachment(100, -10);
739                 fd_btnSave.right = new FormAttachment(lblHeresAnOverview, 0, SWT.RIGHT);
740                 btnSave.setLayoutData(fd_btnSave);
741                 btnSave.setText(Messages.NewAccountDialog_39);
742                 btnSave.setFocus();
743                 
744                 btnSave.addSelectionListener( new SelectionListener() {
745                         
746                         @Override
747                         public void widgetSelected(SelectionEvent arg0) {
748                                 MessageBox dialog = new MessageBox(shlNewAccount, SWT.ICON_INFORMATION | SWT.OK );
749                                 dialog.setText(Messages.NewAccountDialog_40);
750                                 dialog.setMessage(Messages.NewAccountDialog_41);
751                                 dialog.open();
752                                 FkManager.getInstance().createAccount( strAccountName, strUserName, autoPassword, autoPassLen, autoPassAllSpecials, autoPassSpecials, strPassword, seperatorTab, mySelf );
753                                 updatePage(FkNewAccStep.SAVING);
754                         }
755                         
756                         @Override
757                         public void widgetDefaultSelected(SelectionEvent arg0) {
758                                 
759                         }
760                 });
761                 
762                 Label lblAccName = new Label(composite, SWT.NONE);
763                 fd_lblAccountName.right = new FormAttachment(lblAccName, -6);
764                 FormData fd_lblAccName = new FormData();
765                 fd_lblAccName.right = new FormAttachment(0, 603);
766                 fd_lblAccName.top = new FormAttachment(0, 51);
767                 fd_lblAccName.left = new FormAttachment(0, 236);
768                 lblAccName.setLayoutData(fd_lblAccName);
769                 lblAccName.setText(strAccountName);
770                 
771                 Label lblUsrName = new Label(composite, SWT.NONE);
772                 FormData fd_lblUsrName = new FormData();
773                 fd_lblUsrName.right = new FormAttachment(0, 613);
774                 fd_lblUsrName.top = new FormAttachment(0, 80);
775                 fd_lblUsrName.left = new FormAttachment(0, 236);
776                 lblUsrName.setLayoutData(fd_lblUsrName);
777                 lblUsrName.setText(strUserName);
778                 
779                 Label lblPasswordInfo = new Label(composite, SWT.NONE);
780                 FormData fd_lblPasswordInfo = new FormData();
781                 fd_lblPasswordInfo.right = new FormAttachment(0, 603);
782                 fd_lblPasswordInfo.top = new FormAttachment(0, 109);
783                 fd_lblPasswordInfo.left = new FormAttachment(0, 236);
784                 lblPasswordInfo.setLayoutData(fd_lblPasswordInfo);
785                 
786                 String passInfo;
787                 if( autoPassword )
788                 {
789                         passInfo = Messages.NewAccountDialog_42 + autoPassLen + Messages.NewAccountDialog_43;
790                         if( autoPassAllSpecials )
791                         {
792                                 passInfo += Messages.NewAccountDialog_44;
793                         } else {
794                                 passInfo += "{"+autoPassSpecials+ "}"; //$NON-NLS-1$ //$NON-NLS-2$
795                         }
796                         
797                 } else {
798                         passInfo =Messages.NewAccountDialog_47 + strPassword.length() +Messages.NewAccountDialog_48;
799                 }
800                 
801                 lblPasswordInfo.setText(passInfo);
802                 
803                 Label lblSeperatorInfo = new Label(composite, SWT.NONE);
804                 FormData fd_lblSeperatorInfo = new FormData();
805                 fd_lblSeperatorInfo.right = new FormAttachment(0, 603);
806                 fd_lblSeperatorInfo.top = new FormAttachment(0, 138);
807                 fd_lblSeperatorInfo.left = new FormAttachment(0, 236);
808                 lblSeperatorInfo.setLayoutData(fd_lblSeperatorInfo);
809                 
810                 String sepInfo;
811                 if( seperatorTab )
812                 {
813                         sepInfo = Messages.NewAccountDialog_49;
814                 } else {
815                         sepInfo = Messages.NewAccountDialog_50;
816                 }
817                 
818                 lblSeperatorInfo.setText(sepInfo);
819                 
820         Control[] controls = new Control[] { btnSave, button_9 };
821         composite.setTabList(controls);                         
822
823         }
824         
825         void createSavingPage()
826         {
827                 composite = new Composite(shlNewAccount, SWT.NONE);
828                 composite.setLayout(new FormLayout());
829                 
830                 txtBUSYMSG = new Label(composite, SWT.NONE);
831                 FormData fd_txtBUSYMSG = new FormData();
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                 //System.out.println(curPage);
859                 
860                 switch(curPage)
861                 {
862                 case CLICKBTN:
863                         break;
864                 case NAMES:
865                         createNamePage();
866                         break;
867                 case PASSTYPE:
868                         createPassTypePage();
869                         break;
870                 case PASS_AUT:
871                         createPassAutPage();
872                         break;
873                 case PASS_MAN:
874                         createPassManPage();
875                         break;
876                 case REVIEW:
877                         createReviewPage();
878                         break;
879                 case SEPERATOR:
880                         createSeperatorPage();
881                         break;
882                 case SAVING:
883                         createSavingPage();
884                         break;
885
886                         
887                 }
888                 
889                 shlNewAccount.layout();
890         }
891         /**
892          * Create contents of the dialog.
893          */
894         private void createContents() {
895                 shlNewAccount = new Shell(getParent(), getStyle());
896                 shlNewAccount.setSize(625, 394);
897                 shlNewAccount.setText(Messages.NewAccountDialog_54);
898                 shlNewAccount.setLayout(new FillLayout(SWT.HORIZONTAL));
899                 
900         //      TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
901                 
902                 //TabItem tbtmStepUsername = new TabItem(tabFolder, SWT.NONE);
903                 //tbtmStepUsername.setText("Name");
904                 
905                 updatePage(FkNewAccStep.NAMES);
906
907         }
908
909         @Override
910         public void fkActionEvent(FkActionEvent event) {
911                 //System.out.println( "Event data:"+ event.data );
912                 MessageBox dialog;
913                 Boolean closeSelf=false;
914                 
915                 switch(event.type)
916                 {
917                 case ACTION_ABORTED:
918                         txtBUSYMSG.setText(Messages.NewAccountDialog_55);
919                         dialog = new MessageBox(shlNewAccount, SWT.ICON_WARNING);
920                         dialog.setText(Messages.NewAccountDialog_56);
921                         dialog.setMessage(Messages.NewAccountDialog_57);
922                         dialog.open();
923                         updatePage(FkNewAccStep.REVIEW);                        
924                         break;
925                 case ACTION_ERROR:
926                         txtBUSYMSG.setText(Messages.NewAccountDialog_58);
927                         dialog = new MessageBox(shlNewAccount, SWT.ICON_ERROR);
928                         dialog.setText(Messages.NewAccountDialog_59);
929                         dialog.setMessage(Messages.NewAccountDialog_60);
930                         dialog.open();
931                         closeSelf=true;
932                         break;
933                 case ACTION_OKAY:
934                         txtBUSYMSG.setText(Messages.NewAccountDialog_61);
935                         dialog = new MessageBox(shlNewAccount, SWT.ICON_INFORMATION);
936                         dialog.setText(Messages.NewAccountDialog_62);
937                         dialog.setMessage(Messages.NewAccountDialog_63);
938                         dialog.open();
939                         closeSelf=true;
940                         break;
941                 case ACTION_WAITING:
942                         txtBUSYMSG.setText(Messages.NewAccountDialog_64);
943                         break;
944                 case ACTION_WORKING:
945                         txtBUSYMSG.setText(Messages.NewAccountDialog_65);
946                         animation.setVisible(false);
947                         break;
948                 case STATE_ERROR:
949                         txtBUSYMSG.setText(Messages.NewAccountDialog_0);
950                         dialog = new MessageBox(shlNewAccount, SWT.ICON_ERROR);
951                         dialog.setText(Messages.NewAccountDialog_1);
952                         dialog.setMessage(Messages.NewAccountDialog_2);
953                         dialog.open();
954                         closeSelf=true;
955                         break;
956
957                 }
958                 
959                 if( !shlNewAccount.isDisposed() && closeSelf )
960                 {
961                         shlNewAccount.close();
962                 }
963         }
964 }