[Webfunds-commits] java/webfunds/client/contracts/wizard ContractEdit.java ContractFile.java FinishEnd.java FinishSig.java KeyContract.java KeyPanel.java KeyServer.java KeyTop.java Wizard.java WizardData.java WizardPanel.java
Edwin Woudt
edwin@cypherpunks.ai
Mon, 21 Aug 2000 04:24:22 -0400 (AST)
edwin 00/08/21 04:24:22
Modified: webfunds/client SignContractWizard.java
webfunds/client/contracts/wizard ContractEdit.java
ContractFile.java FinishEnd.java FinishSig.java
KeyContract.java KeyPanel.java KeyServer.java
KeyTop.java Wizard.java WizardData.java
WizardPanel.java
Log:
- Enable cancelbutton
- Hard code window title to 'Sign Contract Wizard'
- Add instructions to remove the signature and the [keys] section
- Start browsing in current directory
- Read files relative to the current directory
- Add instructions to use the contract browser afterwards to load the contract
- Add the possibility to save the edited unsigned contract (without keys)
- Automagicall fill the file name fields in the last screen based on the
filename given in the firstscreen.
- Use .txt for the unsigned contract and .asc for the signed contract.
- Check for validity of the entered filename before starting the signing
process.
- Changed the instructions to mention filename instead of location.
- Convert line endings to local format.
- Close the streams after writing is finished.
- Added export instructions for GnuPG.
- Added a confirm dialog.
Revision Changes Path
1.2 +4 -3 java/webfunds/client/SignContractWizard.java
Index: SignContractWizard.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/SignContractWizard.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SignContractWizard.java 2000/08/08 18:20:42 1.1
+++ SignContractWizard.java 2000/08/21 08:24:19 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: SignContractWizard.java,v 1.1 2000/08/08 18:20:42 edwin Exp $
+ * $Id: SignContractWizard.java,v 1.2 2000/08/21 08:24:19 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -22,7 +22,7 @@
* implementation used by this class.</p>
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class SignContractWizard
@@ -84,9 +84,10 @@
{
JFrame frame = new JFrame();
- frame.getContentPane().add(new Wizard());
+ frame.getContentPane().add(new Wizard(frame));
frame.setSize(640,450);
+ frame.setTitle("Sign Contract Wizard");
frame.show();
}
1.3 +7 -4 java/webfunds/client/contracts/wizard/ContractEdit.java
Index: ContractEdit.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/ContractEdit.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContractEdit.java 2000/08/15 23:22:34 1.2
+++ ContractEdit.java 2000/08/21 08:24:20 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: ContractEdit.java,v 1.2 2000/08/15 23:22:34 edwin Exp $
+ * $Id: ContractEdit.java,v 1.3 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -16,7 +16,7 @@
* Panel that allows the user to do final adjustments to the panel.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class ContractEdit extends WizardPanel {
@@ -66,7 +66,10 @@
c.insets = new Insets(5, 5, 15, 5);
lab = new JLabel("<html><font size='-1'><b>"+
"In this step you can make any final adjustments to "+
- "the contract."+
+ "the contract. Note that if you edit an existing "+
+ "contract here, you should remove the signature and "+
+ "the [keys] section, as these will be added in the "+
+ "following steps of this wizard." +
"</b></font></html>");
gridbag.setConstraints(lab,c); add(lab);
@@ -98,4 +101,4 @@
}
-}
\ No newline at end of file
+}
1.3 +10 -5 java/webfunds/client/contracts/wizard/ContractFile.java
Index: ContractFile.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/ContractFile.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContractFile.java 2000/08/15 23:22:34 1.2
+++ ContractFile.java 2000/08/21 08:24:20 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: ContractFile.java,v 1.2 2000/08/15 23:22:34 edwin Exp $
+ * $Id: ContractFile.java,v 1.3 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -9,9 +9,10 @@
import java.io.DataInputStream;
-import java.io.IOException;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
@@ -22,7 +23,7 @@
* Panel that asks for the filename of the contract.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class ContractFile extends WizardPanel
@@ -127,6 +128,7 @@
fc.setDialogTitle("Open Contract");
fc.setDialogType(fc.OPEN_DIALOG);
fc.setFileSelectionMode(fc.FILES_ONLY);
+ fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
@@ -156,7 +158,9 @@
public boolean next() {
if (!txtFile.getText().equals("")) {
try {
- FileInputStream fis = new FileInputStream(txtFile.getText());
+ String filename = txtFile.getText();
+ File f = new File(System.getProperty("user.dir"), filename);
+ FileInputStream fis = new FileInputStream(f);
DataInputStream dis = new DataInputStream(fis);
byte[] contr = new byte[fis.available()];
@@ -164,6 +168,7 @@
String s = new String(contr,"ISO8859-1");
data.setUnsignedContract(s);
+ data.setContractFilename(txtFile.getText());
return true;
} catch (IOException ioe) {
@@ -184,4 +189,4 @@
}
-}
\ No newline at end of file
+}
1.3 +9 -8 java/webfunds/client/contracts/wizard/FinishEnd.java
Index: FinishEnd.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/FinishEnd.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FinishEnd.java 2000/08/15 23:22:34 1.2
+++ FinishEnd.java 2000/08/21 08:24:20 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: FinishEnd.java,v 1.2 2000/08/15 23:22:34 edwin Exp $
+ * $Id: FinishEnd.java,v 1.3 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -19,7 +19,7 @@
* Final 'congratulations' panel.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class FinishEnd extends WizardPanel {
@@ -67,11 +67,12 @@
c.insets = new Insets(5, 5, 15, 5);
lab = new JLabel("<html><font size='-1'><b>"+
"You now have a signed contract. "+
- "The next steps now are to load WebFunds and check "+
- "whether it accepts the contract and you can do a "+
- "zero spend to yourself. If it doesn't: correct the "+
- "errors and run this wizard again. If it does: good "+
- "luck with your new contract. "+
+ "The next steps now are to load the contract in "+
+ "WebFunds using the ContractBrowser in the plugins "+
+ "menu and check whether it accepts the contract and "+
+ "you can do a zero spend to yourself. If it doesn't: "+
+ "correct the errors and run this wizard again. If it "+
+ "does: good luck with your new contract!"+
"</b></font></html>");
gridbag.setConstraints(lab,c); add(lab);
@@ -103,4 +104,4 @@
}
-}
\ No newline at end of file
+}
1.6 +164 -14 java/webfunds/client/contracts/wizard/FinishSig.java
Index: FinishSig.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/FinishSig.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FinishSig.java 2000/08/16 18:43:51 1.5
+++ FinishSig.java 2000/08/21 08:24:20 1.6
@@ -1,5 +1,5 @@
/*
- * $Id: FinishSig.java,v 1.5 2000/08/16 18:43:51 iang Exp $
+ * $Id: FinishSig.java,v 1.6 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -17,6 +17,7 @@
import java.io.DataOutputStream;
+import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -35,13 +36,13 @@
* Panel that does the actual signing.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class FinishSig extends WizardPanel
implements ActionListener {
- JTextField txtFile, txtPass;
+ JTextField txtFile, txtFileUnsigned, txtPass;
WizardData data;
@@ -87,7 +88,7 @@
lab = new JLabel("<html><font size='-1'><b>"+
"You have now collected all the information that is "+
"needed to sign the contract. Please specify the "+
- "location where you want the signed contract to be "+
+ "filename where you want the signed contract to be "+
"stored. "+
"</b></font></html>");
gridbag.setConstraints(lab,c); add(lab);
@@ -99,7 +100,7 @@
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.EAST;
c.insets = new Insets(5, 5, 5, 5);
- txtFile = new JTextField("");
+ txtFile = new JTextField("hopsadieee");
gridbag.setConstraints(txtFile,c); add(txtFile);
@@ -122,13 +123,51 @@
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(5, 5, 15, 5);
lab = new JLabel("<html><font size='-1'><b>"+
+ "Optionally, you may want to save the cleaned up "+
+ "unsigned contract, such that you can easily redo "+
+ "this process if needed. In that case, please enter "+
+ "the filename below. If you do not want to save it, "+
+ "leave the box below empty. "+
+ "</b></font></html>");
+ gridbag.setConstraints(lab,c); add(lab);
+
+
+ c.gridheight = 1; c.gridwidth = 1;
+ c.gridy = 4; c.gridx = 0;
+ c.weighty = 0; c.weightx = 1;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.EAST;
+ c.insets = new Insets(5, 5, 5, 5);
+ txtFileUnsigned = new JTextField("hopsadieee");
+ gridbag.setConstraints(txtFileUnsigned,c); add(txtFileUnsigned);
+
+
+ c.gridheight = 1; c.gridwidth = 1;
+ c.gridy = 4; c.gridx = 1;
+ c.weighty = 0; c.weightx = 0;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(5, 5, 5, 5);
+ but = new JButton("Browse");
+ but.addActionListener(this);
+ but.setActionCommand("browse2");
+ gridbag.setConstraints(but,c); add(but);
+
+
+ c.gridheight = 1; c.gridwidth = 2;
+ c.gridy = 5; c.gridx = 0;
+ c.weighty = 0; c.weightx = 1;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(5, 5, 15, 5);
+ lab = new JLabel("<html><font size='-1'><b>"+
"Enter the passphrase for the contract key: "+
"</b></font></html>");
gridbag.setConstraints(lab,c); add(lab);
c.gridheight = 1; c.gridwidth = 2;
- c.gridy = 4; c.gridx = 0;
+ c.gridy = 6; c.gridx = 0;
c.weighty = 0; c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.EAST;
@@ -138,7 +177,7 @@
c.gridheight = 1; c.gridwidth = 2;
- c.gridy = 5; c.gridx = 0;
+ c.gridy = 7; c.gridx = 0;
c.weighty = 0; c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
@@ -153,7 +192,7 @@
// Filler, makes sure the whole thing is aligned to the top
c.gridheight = 1; c.gridwidth = 2;
- c.gridy = 6; c.gridx = 0;
+ c.gridy = 8; c.gridx = 0;
c.weighty = 1; c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
@@ -170,9 +209,10 @@
JFileChooser fc = new JFileChooser();
- fc.setDialogTitle("Open Contract");
+ fc.setDialogTitle("Save signed contract");
fc.setDialogType(fc.OPEN_DIALOG);
fc.setFileSelectionMode(fc.FILES_ONLY);
+ fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
@@ -184,11 +224,57 @@
}
+ if (e.getActionCommand().equals("browse2")) {
+
+ JFileChooser fc = new JFileChooser();
+
+ fc.setDialogTitle("Save unsigned contract");
+ fc.setDialogType(fc.OPEN_DIALOG);
+ fc.setFileSelectionMode(fc.FILES_ONLY);
+ fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
+
+ if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
+
+ try {
+ txtFileUnsigned.setText(
+ fc.getSelectedFile().getCanonicalPath());
+ } catch (IOException ioe) { }
+
+ }
+
+ }
+
}
public void enter() {
- // do nothing
+
+ if (txtFile.getText().equals("hopsadieee")) {
+ String uname = data.getContractFilename();
+
+ String name = data.getContractFilename();
+ int extpos = name.lastIndexOf(".");
+ if (extpos >= 0) {
+ name = name.substring(0,extpos);
+ }
+ name = name + ".asc";
+
+ // unsigned file had .asc, let's change it to .txt
+ if (uname.equals(name)) {
+ extpos = uname.lastIndexOf(".");
+ uname = uname.substring(0,extpos);
+ uname = uname + ".txt";
+ }
+
+ if (uname.equals("")) {
+ uname="mycontract.txt";
+ name ="mycontract.asc";
+ }
+
+ txtFile.setText(name);
+ txtFileUnsigned.setText(uname);
+ }
+
}
public boolean leave() {
@@ -199,7 +285,47 @@
public boolean next() {
byte[] signedBytes;
-
+
+ // test for validness of signed contract output file
+ String n = txtFile.getText();
+ File f = new File(System.getProperty("user.dir"), n);
+ if (f.exists()) {
+ if (!confirm("File "+n+" already exists! Overwrite?")) return false;
+ } else {
+ try {
+ if (!f.createNewFile()) {
+ error("Could not create output file "+n+".", null);
+ return false;
+ }
+ } catch (IOException ioe) {
+ error("Could not create output file"+n+".", ioe);
+ return false;
+ }
+ }
+
+
+ // test for validness of unsigned contract output file
+ n = txtFileUnsigned.getText();
+ if (! n.equals("")) {
+ f = new File(System.getProperty("user.dir"), n);
+ if (f.exists()) {
+ if (!confirm("File "+n+" already exists! Overwrite?"))
+ return false;
+ } else {
+ try {
+ if (!f.createNewFile()) {
+ error("Could not create output file "+n+".", null);
+ return false;
+ }
+ } catch (IOException ioe) {
+ error("Could not create output file"+n+".", ioe);
+ return false;
+ }
+ }
+ }
+
+
+
try {
// parse the armoured key
@@ -254,6 +380,11 @@
// prepare and sign contract
String signedContract = PGPMessage.clearSign(all, skey);
+
+ // Convert line endings to local format and convert the result into
+ // bytes.
+ PGPArmoury.fixLineEndings(signedContract,
+ System.getProperty("line.separator"));
signedBytes = signedContract.getBytes("ISO8859-1");
} catch (IOException ioe) {
@@ -262,14 +393,33 @@
}
- // write the contract
+ // write the signed contract
try {
- FileOutputStream fos = new FileOutputStream(txtFile.getText());
+ f = new File(System.getProperty("user.dir"),txtFile.getText());
+ FileOutputStream fos = new FileOutputStream(f);
DataOutputStream dos = new DataOutputStream(fos);
dos.write(signedBytes);
+ dos.close();
+ fos.close();
} catch (IOException ioe) {
- error("Error writing contract file",ioe);
+ error("Error writing signed contract file",ioe);
return false;
+ }
+
+ // write the unsigned contract
+ if (! txtFileUnsigned.getText().equals("")) {
+ try {
+ f = new File(System.getProperty("user.dir"),
+ txtFileUnsigned.getText());
+ FileOutputStream fos = new FileOutputStream(f);
+ DataOutputStream dos = new DataOutputStream(fos);
+ dos.write(data.getUnsignedContract().getBytes("ISO8859-1"));
+ dos.close();
+ fos.close();
+ } catch (IOException ioe) {
+ error("Error writing unsignedcontract file",ioe);
+ return false;
+ }
}
if (!sanityCheckContract(signedBytes))
1.4 +36 -9 java/webfunds/client/contracts/wizard/KeyContract.java
Index: KeyContract.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/KeyContract.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- KeyContract.java 2000/08/16 00:57:57 1.3
+++ KeyContract.java 2000/08/21 08:24:20 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: KeyContract.java,v 1.3 2000/08/16 00:57:57 edwin Exp $
+ * $Id: KeyContract.java,v 1.4 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -9,9 +9,10 @@
import java.io.DataInputStream;
-import java.io.IOException;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
@@ -22,7 +23,7 @@
* Panel that asks for the contract key
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class KeyContract extends KeyPanel
@@ -89,7 +90,7 @@
c.weighty = 0; c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
- c.insets = new Insets(5, 5, 5, 5);
+ c.insets = new Insets(5, 5, 0, 5);
lab = new JLabel("The public key:");
gridbag.setConstraints(lab,c); add(lab);
@@ -121,7 +122,7 @@
c.weighty = 0; c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
- c.insets = new Insets(5, 5, 5, 5);
+ c.insets = new Insets(5, 5, 0, 5);
lab = new JLabel("The secret key:");
gridbag.setConstraints(lab,c); add(lab);
@@ -153,7 +154,7 @@
c.weighty = 0; c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
- c.insets = new Insets(5, 5, 5, 5);
+ c.insets = new Insets(5, 5, 0, 5);
lab = new JLabel("Export instructions for PGP 6.5 on Windows:");
gridbag.setConstraints(lab,c); add(lab);
@@ -163,7 +164,7 @@
c.weighty = 0; c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
- c.insets = new Insets(5, 5, 15, 5);
+ c.insets = new Insets(5, 5, 10, 5);
lab = new JLabel("<html><font size='-1'><b>"+
"In PGPKeys, click with the right mouse button on "+
"key and select the 'Export' option. You will have "+
@@ -173,13 +174,37 @@
gridbag.setConstraints(lab,c); add(lab);
- // Filler, makes sure the whole thing is aligned to the top
c.gridheight = 1; c.gridwidth = 2;
c.gridy = 8; c.gridx = 0;
+ c.weighty = 0; c.weightx = 0;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(5, 5, 0, 5);
+ lab = new JLabel("Export instructions for GnuPG:");
+ gridbag.setConstraints(lab,c); add(lab);
+
+
+ c.gridheight = 1; c.gridwidth = 2;
+ c.gridy = 9; c.gridx = 0;
+ c.weighty = 0; c.weightx = 1;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(5, 5, 0, 5);
+ lab = new JLabel("<html><font size='-1'><b>"+
+ "Public key: 'gpg -a --export name > key.asc'<br>"+
+ "Secret key: 'gpg -a --export-secret-key name > "+
+ "skey.asc' "+
+ "</b></font></html>");
+ gridbag.setConstraints(lab,c); add(lab);
+
+
+ // Filler, makes sure the whole thing is aligned to the top
+ c.gridheight = 1; c.gridwidth = 2;
+ c.gridy = 10; c.gridx = 0;
c.weighty = 1; c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
- c.insets = new Insets(5, 5, 5, 5);
+ c.insets = new Insets(0, 5, 0, 5);
lab = new JLabel("");
gridbag.setConstraints(lab,c); add(lab);
@@ -195,6 +220,7 @@
fc.setDialogTitle("Open Contract");
fc.setDialogType(fc.OPEN_DIALOG);
fc.setFileSelectionMode(fc.FILES_ONLY);
+ fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
@@ -213,6 +239,7 @@
fc.setDialogTitle("Open Contract");
fc.setDialogType(fc.OPEN_DIALOG);
fc.setFileSelectionMode(fc.FILES_ONLY);
+ fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
1.3 +6 -3 java/webfunds/client/contracts/wizard/KeyPanel.java
Index: KeyPanel.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/KeyPanel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- KeyPanel.java 2000/08/16 00:57:57 1.2
+++ KeyPanel.java 2000/08/21 08:24:20 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: KeyPanel.java,v 1.2 2000/08/16 00:57:57 edwin Exp $
+ * $Id: KeyPanel.java,v 1.3 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -18,6 +18,7 @@
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -28,7 +29,7 @@
* Abstract superclass for all panels in a wizard.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public abstract class KeyPanel extends WizardPanel {
@@ -40,7 +41,9 @@
// read file
String key;
try {
- FileInputStream fis = new FileInputStream(filename);
+ // open file relative to current dir
+ File f = new File(System.getProperty("user.dir"), filename);
+ FileInputStream fis = new FileInputStream(f);
DataInputStream dis = new DataInputStream(fis);
byte[] contr = new byte[fis.available()];
1.4 +5 -3 java/webfunds/client/contracts/wizard/KeyServer.java
Index: KeyServer.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/KeyServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- KeyServer.java 2000/08/16 00:57:57 1.3
+++ KeyServer.java 2000/08/21 08:24:20 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: KeyServer.java,v 1.3 2000/08/16 00:57:57 edwin Exp $
+ * $Id: KeyServer.java,v 1.4 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -9,9 +9,10 @@
import java.io.DataInputStream;
-import java.io.IOException;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.awt.*;
import java.awt.event.*;
@@ -22,7 +23,7 @@
* Panel that asks for the server certification key
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class KeyServer extends KeyPanel
@@ -124,6 +125,7 @@
fc.setDialogTitle("Open Contract");
fc.setDialogType(fc.OPEN_DIALOG);
fc.setFileSelectionMode(fc.FILES_ONLY);
+ fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
1.4 +27 -3 java/webfunds/client/contracts/wizard/KeyTop.java
Index: KeyTop.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/KeyTop.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- KeyTop.java 2000/08/16 00:57:57 1.3
+++ KeyTop.java 2000/08/21 08:24:20 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: KeyTop.java,v 1.3 2000/08/16 00:57:57 edwin Exp $
+ * $Id: KeyTop.java,v 1.4 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -8,6 +8,7 @@
package webfunds.client.contracts.wizard;
+import java.io.File;
import java.io.IOException;
import java.awt.*;
@@ -19,7 +20,7 @@
* Panel that asks for the toplevel certification key
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class KeyTop extends KeyPanel
@@ -124,9 +125,31 @@
gridbag.setConstraints(lab,c); add(lab);
- // Filler, makes sure the whole thing is aligned to the top
c.gridheight = 1; c.gridwidth = 2;
c.gridy = 5; c.gridx = 0;
+ c.weighty = 0; c.weightx = 0;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(5, 5, 5, 5);
+ lab = new JLabel("Export instructions for GnuPG:");
+ gridbag.setConstraints(lab,c); add(lab);
+
+
+ c.gridheight = 1; c.gridwidth = 2;
+ c.gridy = 6; c.gridx = 0;
+ c.weighty = 0; c.weightx = 1;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(5, 5, 15, 5);
+ lab = new JLabel("<html><font size='-1'><b>"+
+ "Use 'gpg -a --export key name > key.asc' "+
+ "</b></font></html>");
+ gridbag.setConstraints(lab,c); add(lab);
+
+
+ // Filler, makes sure the whole thing is aligned to the top
+ c.gridheight = 1; c.gridwidth = 2;
+ c.gridy = 7; c.gridx = 0;
c.weighty = 1; c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
@@ -146,6 +169,7 @@
fc.setDialogTitle("Open Contract");
fc.setDialogType(fc.OPEN_DIALOG);
fc.setFileSelectionMode(fc.FILES_ONLY);
+ fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
1.4 +12 -5 java/webfunds/client/contracts/wizard/Wizard.java
Index: Wizard.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/Wizard.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Wizard.java 2000/08/15 23:22:34 1.3
+++ Wizard.java 2000/08/21 08:24:20 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: Wizard.java,v 1.3 2000/08/15 23:22:34 edwin Exp $
+ * $Id: Wizard.java,v 1.4 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -20,7 +20,7 @@
* Main class for the wizard
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class Wizard extends JPanel
@@ -28,6 +28,7 @@
final WizardData data = new WizardData();
+ private JFrame window;
ImageIcon iconNot = new ImageIcon("iconnot.gif");
ImageIcon iconYes = new ImageIcon("iconyes.gif");
@@ -51,8 +52,10 @@
JTree tree;
- public Wizard() {
-
+ public Wizard(JFrame window) {
+
+ this.window = window;
+
// GridBagLayout is the most flexible (also the most difficult
// to use) LayoutManager.
GridBagLayout gridbag = new GridBagLayout();
@@ -259,6 +262,10 @@
tree.setSelectionRow(tmp);
}
+ } else if (e.getActionCommand().equals("Cancel")) {
+
+ window.dispose();
+
}
}
@@ -368,7 +375,7 @@
public static void main(String[] arg) {
JFrame frame = new JFrame();
- frame.getContentPane().add(new Wizard());
+ frame.getContentPane().add(new Wizard(frame));
frame.setSize(640,450);
frame.show();
1.3 +6 -3 java/webfunds/client/contracts/wizard/WizardData.java
Index: WizardData.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/WizardData.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WizardData.java 2000/08/15 23:22:35 1.2
+++ WizardData.java 2000/08/21 08:24:20 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: WizardData.java,v 1.2 2000/08/15 23:22:35 edwin Exp $
+ * $Id: WizardData.java,v 1.3 2000/08/21 08:24:20 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -12,7 +12,7 @@
* Contains most of data for the wizard.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class WizardData {
@@ -24,6 +24,7 @@
private String secretcontractKey = "";
private String serverKey = "";
private String signedContract = "";
+ private String contractFilename = "";
public String getUnsignedContract () { return unsignedContract; }
@@ -32,6 +33,7 @@
public String getSecretContractKey () { return secretcontractKey; }
public String getServerKey () { return serverKey; }
public String getSignedContract () { return signedContract; }
+ public String getContractFilename () { return contractFilename; }
public void setUnsignedContract (String x) { unsignedContract = x; }
public void setTopLevelKey (String x) { toplevelKey = x; }
@@ -39,6 +41,7 @@
public void setSecretContractKey (String x) { secretcontractKey = x; }
public void setServerKey (String x) { serverKey = x; }
public void setSignedContract (String x) { signedContract = x; }
+ public void setContractFilename (String x) { contractFilename = x; }
private boolean[] invalid = { false, false, false,
@@ -54,4 +57,4 @@
public boolean getInvalid (int row) { return invalid [row]; }
public boolean getCompleted (int row) { return completed[row]; }
-}
\ No newline at end of file
+}
1.4 +16 -2 java/webfunds/client/contracts/wizard/WizardPanel.java
Index: WizardPanel.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/WizardPanel.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WizardPanel.java 2000/08/16 18:42:28 1.3
+++ WizardPanel.java 2000/08/21 08:24:21 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: WizardPanel.java,v 1.3 2000/08/16 18:42:28 iang Exp $
+ * $Id: WizardPanel.java,v 1.4 2000/08/21 08:24:21 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -15,7 +15,7 @@
* Abstract superclass for all panels in a wizard.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public abstract class WizardPanel extends JPanel {
@@ -55,6 +55,20 @@
if (e != null) { e.printStackTrace(); message += "\n\n\""+e+"\""; }
JOptionPane.showMessageDialog(this, message, "Error",
JOptionPane.ERROR_MESSAGE);
+ }
+
+ /**
+ * Convenience method that displays an yes/no dialog box with the given
+ * message.
+ *
+ * @param message a descriptive message that will be displayed in the popup
+ * box.
+ * @return true if Yes is selected by the user, false otherwise
+ */
+ protected boolean confirm(String message) {
+ int result = JOptionPane.showConfirmDialog(this, message, "Confirm",
+ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+ return (result == JOptionPane.YES_OPTION);
}
}