1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.jhylafax;
21
22 import static net.sf.jhylafax.JHylaFAX.i18n;
23 import gnu.hylafax.HylaFAXClient;
24 import javax.swing.JFrame;
25 import net.sf.jhylafax.fax.FaxJob;
26 import net.sf.jhylafax.fax.HylaFAXClientHelper;
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.xnap.commons.gui.ErrorDialog;
30 import org.xnap.commons.io.Job;
31 import org.xnap.commons.io.ProgressMonitor;
32 import org.xnap.commons.io.UserAbortException;
33
34 public class EditDialog extends AbstractFaxDialog {
35
36 private final static Log logger = LogFactory.getLog(EditDialog.class);
37
38 public EditDialog(JFrame owner, FaxJob job) {
39 super(owner);
40
41 addNumberTextField();
42 addDateControls();
43
44 setJob(job);
45 revert();
46
47 updateLabels();
48 pack();
49 }
50
51 @Override
52 public boolean apply() {
53 if (!super.apply()) {
54 return false;
55 }
56
57 Job<?> ioJob = new Job() {
58 public Object run(ProgressMonitor monitor) throws Exception
59 {
60 monitor.setTotalSteps(4);
61
62 HylaFAXClient client = JHylaFAX.getInstance().getConnection(monitor);
63 monitor.work(1);
64
65 gnu.hylafax.Job editJob = client.getJob(getJob().getID());
66 client.suspend(editJob);
67 HylaFAXClientHelper.applyParameter(editJob, getJob());
68 monitor.work(1);
69
70 client.submit(editJob);
71 monitor.work(2);
72
73 return null;
74 }
75 };
76
77 try {
78 JHylaFAX.getInstance().runJob(EditDialog.this, ioJob);
79 JHylaFAX.getInstance().updateTables();
80 } catch (UserAbortException e) {
81 return false;
82 } catch (Exception e) {
83 logger.debug("Error setting job parameter", e);
84 ErrorDialog.showError(this, i18n.tr("Could not set job parameter"),
85 i18n.tr("JHylaFAX Error"),
86 e);
87 return false;
88 }
89 return true;
90 }
91
92 public void updateLabels() {
93 super.updateLabels();
94
95 setTitle(i18n.tr("Edit Job"));
96 }
97
98 }