package org.jcryptool.visual.sig.ui.wizards;

import java.io.File;

import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;

public class InputWizard extends Wizard{
	//The only page of the wizard (for selecting the Hash method)
	private InputWizardPage page;
	private InputEditorWizardPage pageEditor;
	
	private File file;
	private String content;
	
	//Constructor
	public InputWizard() {
		super();
	}	
	
	@Override
	public void addPages() {
		//Create and add pages
		page = new InputWizardPage("Input Wizard");
		addPage(page);
		
		pageEditor = new InputEditorWizardPage("InputEditor Wizard");
		addPage(pageEditor);

	}

	@Override
	public boolean performFinish() {
		if (page.fileChoosen()) {

			String strFile = null;
			FileDialog fd = new FileDialog(Display.getCurrent()
					.getActiveShell(), SWT.OPEN);
			fd.setFilterExtensions(new String[] { "*.txt", "*.*" });
			fd.setText("Open file");
			strFile = fd.open();

			file = new File(strFile);
		} else {
			content = pageEditor.getContent();
		}
		return true;
	}

	public String getContent() {
		return content;
	}
}

@@ -211,16 +211,97 @@
 eDialog;
+%0Aimport org.eclipse.swt.widgets.MessageBox;%0Aimport org.eclipse.swt.widgets.Shell;
 %0A%0Apublic
@@ -337,26 +337,24 @@
 zard
+ 
 %7B%0A%09//
+ 
 The 
-only 
 page
+s
  of 
@@ -368,39 +368,51 @@
 ard 
-(for
+to
  select
-ing the Hash method)
+ a document%0A%09// or to enter a text
 %0A%09pr
@@ -482,17 +482,16 @@
 Editor;%0A
-%09
 %0A%09privat
@@ -501,17 +501,38 @@
 ile file
-;
+ = null; // used later
 %0A%09privat
@@ -553,13 +553,13 @@
 nt;%0A
-%09
 %0A%09//
+ 
 Cons
@@ -603,19 +603,17 @@
 er();%0A%09%7D
-%09%0A%09
+%0A
 %0A%09@Overr
@@ -646,16 +646,17 @@
 ) %7B%0A%09%09//
+ 
 Create a
@@ -731,18 +731,16 @@
 (page);%0A
-%09%09
 %0A%09%09pageE
@@ -819,21 +819,164 @@
 ditor);%0A
-%0A
 %09%7D%0A%0A
+%09// TODO OpenFile-Dialog should appear when user clicks the next button, not%0A%09// the finish button.%0A%09// implemented here only to try the Dialog%0A
 %09@Overri
@@ -1012,16 +1012,17 @@
 ish() %7B%0A
+%0A
 %09%09if (pa
@@ -1041,17 +1041,16 @@
 en()) %7B%0A
-%0A
 %09%09%09Strin
@@ -1156,24 +1156,27 @@
 T.OPEN);%0A%09%09%09
+// 
 fd.setFilter
@@ -1272,17 +1272,16 @@
 open();%0A
-%0A
 %09%09%09file 
@@ -1301,16 +1301,17 @@
 rFile);%0A
+%0A
 %09%09%7D else
@@ -1313,16 +1313,49 @@
  else %7B%0A
+%09%09%09// no content from editor yet%0A
 %09%09%09conte
@@ -1388,12 +1388,14 @@
 ();%0A
+%0A
 %09%09%7D%0A
+%0A
 %09%09re
@@ -1460,10 +1460,11 @@
 ent;%0A%09%7D%0A
+%0A
 %7D%0A

Add comments.