~vcs-imports/jhylafax/head

« back to all changes in this revision

Viewing changes to src/java/net/sf/jhylafax/EditDialog.java

  • Committer: squig
  • Date: 2005-04-18 16:37:19 UTC
  • Revision ID: Arch-1:unnamed@bazaar.ubuntu.com%series--4272--patch-10
added i18n support and password querying

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
package net.sf.jhylafax;
21
21
 
22
22
import gnu.hylafax.HylaFAXClient;
23
 
import javax.swing.JLabel;
24
 
import javax.swing.JTextField;
25
23
import org.apache.commons.logging.Log;
26
24
import org.apache.commons.logging.LogFactory;
27
25
import org.xnap.commons.gui.ErrorDialog;
31
29
 
32
30
public class EditDialog extends AbstractFaxDialog {
33
31
 
34
 
        private final static Log logger = LogFactory.getLog(QueuePanel.class);
35
 
        private static final int DEFAULT_COLUMNS = 20;
36
 
        
37
 
        private JTextField numberTextField;
38
 
        private JLabel numberLabel;
 
32
        private final static Log logger = LogFactory.getLog(EditDialog.class);
39
33
        
40
34
        public EditDialog(HylaFAXJob job) {
41
 
                numberTextField = new JTextField();
42
 
                numberLabel = builder.append("", numberTextField, 4);
43
 
                builder.nextLine();
44
 
                                
45
 
                addDateButtons();
 
35
                addNumberTextField();
 
36
                addDateControls();
46
37
                
47
38
                setJob(job);
48
39
                revert();
53
44
        
54
45
        @Override
55
46
        public boolean apply() {
56
 
                super.apply();
57
 
                
58
 
                getJob().setNumber(numberTextField.getText());
59
 
                
 
47
                if (!super.apply()) {
 
48
                        return false;
 
49
                }
 
50
        
60
51
                Job<?> ioJob = new Job() {
61
52
                        @Override
62
53
                        public Object run(ProgressMonitor monitor) throws Exception
63
54
                        {
64
55
                                monitor.setTotalSteps(4);
65
56
                                
66
 
                                HylaFAXClient client = JHylaFAX.getInstance().getConnection();
 
57
                                HylaFAXClient client = JHylaFAX.getInstance().getConnection(monitor);
67
58
                                monitor.work(1);
68
59
                                
69
60
                                gnu.hylafax.Job editJob = client.getJob(getJob().getID());
80
71
                
81
72
                try {
82
73
                        JHylaFAX.getInstance().runJob(ioJob);
83
 
                }
84
 
                catch (Exception e) {
 
74
                } catch (UserAbortException e) {
 
75
                        return false;
 
76
                } catch (Exception e) {
85
77
                        logger.debug("Error setting job parameter", e);
86
 
                        ErrorDialog.show(this, I18n.tr("Error setting job parameter"), e.getLocalizedMessage(), e);
 
78
                        ErrorDialog.showError(this, I18n.tr("Could not set job parameter"), 
 
79
                                        I18n.tr("JHylaFAX Error"),
 
80
                                        e);
87
81
                        return false;
88
82
                }
89
83
                return true;
90
84
        }
91
85
 
92
 
        @Override
93
 
        public void revert() {
94
 
                super.revert();
95
 
                numberTextField.setText(getJob().getNumber());
96
 
        }
97
 
 
98
86
        public void updateLabels() {
99
87
                super.updateLabels();
100
88
                
101
89
                setTitle(I18n.tr("Edit Job"));
102
 
                numberLabel.setText(I18n.tr("Number"));
103
90
        }
104
91
 
105
92
}