View Javadoc

1   package org.eparapher.rcp.wizards;
2   
3   import org.eclipse.jface.wizard.IWizardPage;
4   import org.eclipse.jface.wizard.WizardPage;
5   import org.eclipse.swt.SWT;
6   import org.eclipse.swt.events.KeyEvent;
7   import org.eclipse.swt.events.KeyListener;
8   import org.eclipse.swt.layout.GridData;
9   import org.eclipse.swt.layout.GridLayout;
10  import org.eclipse.swt.widgets.Button;
11  import org.eclipse.swt.widgets.Composite;
12  import org.eclipse.swt.widgets.Label;
13  import org.eclipse.swt.widgets.Text;
14  import org.eparapher.core.signature.PDFSignatureParameters;
15  import org.eparapher.rcp.tools.GUIIcons;
16  
17  
18  public class PDFSigningWizardPageFour
19  			extends WizardPage
20  			implements IWizardPage {
21  
22  	private Text reason;
23  	private Text location;
24  	private Composite container;
25  	private Button insertCRLs;
26  	private Button insertTimestamp;
27  	
28  	private PDFSignatureParameters pdfsignatureparams;
29  	
30  	protected PDFSigningWizardPageFour(PDFSignatureParameters mpdfsignatureparams) {
31  		super("PDF Signing");
32  		setTitle("PDF signing wizard Page 4/4");
33  		setDescription("Please Configure your PDF Signature informations.");
34  		setImageDescriptor(GUIIcons.WIZARD_SIGN_IMG);
35  		pdfsignatureparams = mpdfsignatureparams;
36  	}
37  
38  	public void createControl(Composite parent) {
39  		
40  		container = new Composite(parent, SWT.NULL);
41  		container.setLayout(new GridLayout(2,false));
42  		container.setLayoutData(new GridData(GridData.FILL_BOTH));
43  		
44  		Label labelReason = new Label(container, SWT.NULL);
45  		labelReason.setText("Reason : ");
46  		labelReason.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
47  		reason = new Text(container, SWT.BORDER | SWT.SINGLE);
48  		reason.setText(pdfsignatureparams.getReason());
49  		reason.addKeyListener( new KeyListenerValidator() );
50  		reason.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
51  
52  		Label labelLocation = new Label(container, SWT.NULL);
53  		labelLocation.setText("Location : ");
54  		labelLocation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
55  		location = new Text(container, SWT.BORDER | SWT.SINGLE);
56  		location.setText(pdfsignatureparams.getLocation());
57  		location.addKeyListener( new KeyListenerValidator() );
58  		location.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
59  
60  		Label labelInsertCRLs = new Label(container, SWT.NULL);
61  		labelInsertCRLs.setText("Insert CRLs in signature : ");
62  		labelInsertCRLs.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
63  		insertCRLs = new Button(container, SWT.CHECK);
64  		insertCRLs.setToolTipText("Insert CRL");
65  		insertCRLs.setSelection (pdfsignatureparams.isInsertCRLs());
66  		insertCRLs.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
67  		insertCRLs.setEnabled(false);
68  
69  		Label labelInsertTimestamp = new Label(container, SWT.NULL);
70  		labelInsertTimestamp.setText("Insert TimeStamp in signature : ");
71  		labelInsertTimestamp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
72  		insertTimestamp = new Button(container, SWT.CHECK);
73  		insertTimestamp.setToolTipText("Insert Timestamp");
74  		insertTimestamp.setSelection (pdfsignatureparams.isInsertCRLs());
75  		insertTimestamp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
76  		insertTimestamp.setEnabled(false);
77  		
78  		// Required to avoid an error in the system
79  		setControl(container);
80  		
81  		if (reason.getText().equals("") || location.getText().equals(""))
82  			setPageComplete(false);
83  		else
84  			setPageComplete(true);
85  	}
86  
87  	
88  	class KeyListenerValidator implements KeyListener {
89  		public KeyListenerValidator() { super(); }
90  		public void keyPressed(KeyEvent e) {
91  		}
92  		public void keyReleased(KeyEvent e) {
93  			if (!reason.getText().equals("") &&
94  				!location.getText().equals("")) {
95  				setMessage("Please Configure your PDF Signature informations.");
96  				setPageComplete(true);
97  			} else {
98  				setErrorMessage("Please fill this field");
99  				setPageComplete(false);
100 			}
101 		}
102 	}
103 	
104 	public boolean isCRLsInSignature() {
105 		return insertCRLs.getSelection();
106 	}
107 
108 	public boolean isTimestampInSignature() {
109 		return insertTimestamp.getSelection();
110 	}
111 	public String getReason() {
112 		return reason.getText();
113 	}
114 	public String getLocation() {
115 		return location.getText();
116 	}
117 	
118 }