Subversion Repositories svn.mios

Rev

Rev 845 | Rev 850 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 845 Rev 846
Line 33... Line 33...
33
import java.awt.event.ItemListener;
33
import java.awt.event.ItemListener;
34
import java.io.File;
34
import java.io.File;
35
import java.util.Observable;
35
import java.util.Observable;
36
import java.util.Observer;
36
import java.util.Observer;
37
import java.util.StringTokenizer;
37
import java.util.StringTokenizer;
-
 
38
import java.util.LinkedList;
38
39
39
import javax.swing.BorderFactory;
40
import javax.swing.BorderFactory;
40
import javax.swing.JButton;
41
import javax.swing.JButton;
41
import javax.swing.JFileChooser;
42
import javax.swing.JFileChooser;
42
import javax.swing.JLabel;
43
import javax.swing.JLabel;
Line 69... Line 70...
69
70
70
    private SysexSendReceive sysexSendReceive;
71
    private SysexSendReceive sysexSendReceive;
71
72
72
    // GUI components
73
    // GUI components
73
74
74
    private JButton browseButton;
75
    private JButton sendBrowseButton;
-
 
76
    private JTextField sendFileName;
-
 
77
    private JButton sendStartButton;
-
 
78
    private JButton sendStopButton;
-
 
79
    private JButton sendClearButton;
75
80
-
 
81
    private JButton receiveBrowseButton;
76
    private JTextField fileName;
82
    private JTextField receiveFileName;
77
-
 
78
    private JButton startButton;
83
    private JButton receiveStartButton;
79
-
 
80
    private JButton stopButton;
84
    private JButton receiveStopButton;
-
 
85
    private JButton receiveClearButton;
81
86
82
    private JTextPane sysexSendTextArea;
87
    private JTextPane sysexSendTextArea;
83
88
84
    private JTextPane sysexReceiveTextArea;
89
    private JTextPane sysexReceiveTextArea;
85
90
Line 89... Line 94...
89
        super(new BorderLayout());
94
        super(new BorderLayout());
90
95
91
        this.sysexSendReceive = sysexSendReceive;
96
        this.sysexSendReceive = sysexSendReceive;
92
        sysexSendReceive.addObserver(this);
97
        sysexSendReceive.addObserver(this);
93
98
94
        browseButton = new JButton("SysEx File", ImageLoader
99
        sendBrowseButton = new JButton("Open File", ImageLoader
-
 
100
                .getImageIcon("open.png"));
-
 
101
        sendFileName = new JTextField();
-
 
102
        sendFileName.setEditable(false);
-
 
103
        sendBrowseButton.setActionCommand("sendBrowse");
-
 
104
        sendBrowseButton.addActionListener(this);
-
 
105
-
 
106
        sendStartButton = new JButton("Start");
-
 
107
        sendStartButton.setActionCommand("sendStart");
-
 
108
        sendStartButton.addActionListener(this);
-
 
109
        sendStartButton.setAlignmentX(Component.LEFT_ALIGNMENT);
-
 
110
        sendStopButton = new JButton("Stop");
-
 
111
        sendStopButton.addActionListener(this);
-
 
112
        sendStopButton.setActionCommand("sendStop");
-
 
113
        sendStopButton.setAlignmentX(Component.LEFT_ALIGNMENT);
-
 
114
        sendClearButton = new JButton("Clear");
-
 
115
        sendClearButton.addActionListener(this);
-
 
116
        sendClearButton.setActionCommand("sendClear");
-
 
117
        sendClearButton.setAlignmentX(Component.LEFT_ALIGNMENT);
-
 
118
-
 
119
-
 
120
        receiveBrowseButton = new JButton("Save File", ImageLoader
95
                .getImageIcon("open.png"));
121
                .getImageIcon("open.png"));
96
        fileName = new JTextField();
122
        receiveFileName = new JTextField();
97
        fileName.setEditable(false);
123
        receiveFileName.setEditable(false);
98
        browseButton.setActionCommand("browse");
124
        receiveBrowseButton.setActionCommand("receiveBrowse");
99
        browseButton.addActionListener(this);
125
        receiveBrowseButton.addActionListener(this);
100
126
101
        startButton = new JButton("Send/Receive");
127
        receiveStartButton = new JButton("Start");
102
        startButton.setActionCommand("start");
128
        receiveStartButton.setActionCommand("receiveStart");
103
        startButton.addActionListener(this);
129
        receiveStartButton.addActionListener(this);
-
 
130
        receiveStartButton.setAlignmentX(Component.LEFT_ALIGNMENT);
104
        stopButton = new JButton("Stop");
131
        receiveStopButton = new JButton("Stop");
105
        stopButton.addActionListener(this);
132
        receiveStopButton.addActionListener(this);
106
        stopButton.setActionCommand("stop");
133
        receiveStopButton.setActionCommand("receiveStop");
-
 
134
        receiveStopButton.setAlignmentX(Component.LEFT_ALIGNMENT);
-
 
135
        receiveClearButton = new JButton("Clear");
-
 
136
        receiveClearButton.addActionListener(this);
-
 
137
        receiveClearButton.setActionCommand("receiveClear");
-
 
138
        receiveClearButton.setAlignmentX(Component.LEFT_ALIGNMENT);
107
139
108
        startButton.setAlignmentX(Component.LEFT_ALIGNMENT);
-
 
109
        stopButton.setAlignmentX(Component.LEFT_ALIGNMENT);
-
 
110
140
111
        JPanel fileButtonsPanel = new JPanel(new BorderLayout(2, 2));
-
 
112
        fileButtonsPanel.add(browseButton, BorderLayout.WEST);
-
 
113
        fileButtonsPanel.add(fileName, BorderLayout.CENTER);
-
 
114
        fileButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
 
115
141
116
        JPanel controlButtonsPanel = new JPanel(new GridBagLayout());
142
        JPanel sendFileButtonsPanel = new JPanel(new BorderLayout(2, 2));
-
 
143
        sendFileButtonsPanel.add(sendBrowseButton, BorderLayout.WEST);
-
 
144
        sendFileButtonsPanel.add(sendFileName, BorderLayout.CENTER);
-
 
145
        sendFileButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
117
146
-
 
147
        JPanel sendControlButtonsPanel = new JPanel(new GridBagLayout());
118
        GridBagConstraints gbc = new GridBagConstraints();
148
        GridBagConstraints gbc = new GridBagConstraints();
119
        gbc.gridx = 0;
149
        gbc.gridx = 0;
120
        gbc.gridy = 0;
150
        gbc.gridy = 0;
121
        gbc.gridwidth = 1;
151
        gbc.gridwidth = 1;
122
        gbc.gridheight = 1;
152
        gbc.gridheight = 1;
123
153
124
        gbc.insets = new Insets(5, 5, 5, 5);
154
        gbc.insets = new Insets(5, 5, 5, 5);
125
155
126
        controlButtonsPanel.add(startButton, gbc);
156
        sendControlButtonsPanel.add(sendStartButton, gbc);
127
        gbc.gridx++;
157
        gbc.gridx++;
128
158
129
        gbc.insets = new Insets(5, 13, 5, 5);
159
        gbc.insets = new Insets(5, 13, 5, 5);
130
160
131
        controlButtonsPanel.add(stopButton, gbc);
161
        sendControlButtonsPanel.add(sendStopButton, gbc);
-
 
162
        gbc.gridx++;
-
 
163
-
 
164
        gbc.insets = new Insets(5, 13, 5, 5);
-
 
165
-
 
166
        sendControlButtonsPanel.add(sendClearButton, gbc);
132
        gbc.gridx++;
167
        gbc.gridx++;
133
168
134
        gbc.insets = new Insets(2, 2, 2, 2);
169
        gbc.insets = new Insets(2, 2, 2, 2);
135
170
136
        gbc.weightx = 1.0;
171
        gbc.weightx = 1.0;
137
        controlButtonsPanel.add(new JPanel(), gbc);
172
        sendControlButtonsPanel.add(new JPanel(), gbc);
138
        gbc.gridx++;
173
        gbc.gridx++;
139
        gbc.weightx = 0.0;
174
        gbc.weightx = 0.0;
140
175
141
        gbc.fill = GridBagConstraints.NONE;
176
        gbc.fill = GridBagConstraints.NONE;
142
177
143
        JLabel label = new JLabel("Delay between F0 (ms): ");
178
        JLabel label = new JLabel("Delay between SysEx messages (ms): ");
144
        controlButtonsPanel.add(label, gbc);
179
        sendControlButtonsPanel.add(label, gbc);
145
        gbc.gridx++;
180
        gbc.gridx++;
146
181
147
        sendDelayTimeSpinner = new JSpinner(new SpinnerNumberModel(
182
        sendDelayTimeSpinner = new JSpinner(new SpinnerNumberModel(
148
                sysexSendReceive.getSendDelayTime(), 1, 1000, 1));
183
                sysexSendReceive.getSendDelayTime(), 1, 1000, 1));
149
        sendDelayTimeSpinner.addChangeListener(this);
184
        sendDelayTimeSpinner.addChangeListener(this);
150
        controlButtonsPanel.add(sendDelayTimeSpinner, gbc);
185
        sendControlButtonsPanel.add(sendDelayTimeSpinner, gbc);
-
 
186
-
 
187
-
 
188
-
 
189
        JPanel receiveFileButtonsPanel = new JPanel(new BorderLayout(2, 2));
-
 
190
        receiveFileButtonsPanel.add(receiveBrowseButton, BorderLayout.WEST);
-
 
191
        receiveFileButtonsPanel.add(receiveFileName, BorderLayout.CENTER);
-
 
192
        receiveFileButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
 
193
-
 
194
        JPanel receiveControlButtonsPanel = new JPanel(new GridBagLayout());
-
 
195
        gbc.gridx = 0;
-
 
196
        gbc.gridy = 0;
-
 
197
        gbc.gridwidth = 1;
-
 
198
        gbc.gridheight = 1;
-
 
199
-
 
200
        gbc.insets = new Insets(5, 5, 5, 5);
-
 
201
-
 
202
        receiveControlButtonsPanel.add(receiveStartButton, gbc);
-
 
203
        gbc.gridx++;
-
 
204
        gbc.insets = new Insets(5, 13, 5, 5);
-
 
205
        receiveControlButtonsPanel.add(receiveStopButton, gbc);
-
 
206
        gbc.gridx++;
-
 
207
        receiveControlButtonsPanel.add(receiveClearButton, gbc);
-
 
208
-
 
209
151
210
152
        JPanel sendPanel = new JPanel(new GridBagLayout());
211
        JPanel sendPanel = new JPanel(new GridBagLayout());
153
212
154
        gbc.fill = GridBagConstraints.BOTH;
213
        gbc.fill = GridBagConstraints.BOTH;
155
        gbc.weightx = 1.0;
214
        gbc.weightx = 1.0;
Line 176... Line 235...
176
                .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
235
                .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
177
236
178
        // Make preferred width smaller than the other panel's minimum width.
237
        // Make preferred width smaller than the other panel's minimum width.
179
        sysexSendTextAreaScrollPane.setPreferredSize(new Dimension(300, 100));
238
        sysexSendTextAreaScrollPane.setPreferredSize(new Dimension(300, 100));
180
239
-
 
240
        gbc.insets = new Insets(5, 5, 5, 5);
-
 
241
        gbc.gridy = 0;
-
 
242
        gbc.gridx = 0;
181
        sendPanel.add(fileButtonsPanel, gbc);
243
        sendPanel.add(sendFileButtonsPanel, gbc);
-
 
244
        gbc.gridy++;
-
 
245
        gbc.weighty = 1.0;
-
 
246
        sendPanel.add(sendControlButtonsPanel, gbc);
182
        gbc.gridy++;
247
        gbc.gridy++;
183
        gbc.weighty = 1.0;
248
        gbc.weighty = 1.0;
184
        gbc.insets = new Insets(5, 5, 5, 5);
-
 
185
        sendPanel.add(sysexSendTextAreaScrollPane, gbc);
249
        sendPanel.add(sysexSendTextAreaScrollPane, gbc);
-
 
250
186
251
187
        JPanel receivePanel = new JPanel(new GridBagLayout());
252
        JPanel receivePanel = new JPanel(new GridBagLayout());
188
        receivePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
253
        receivePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
189
                .createEmptyBorder(2, 2, 2, 2), BorderFactory
254
                .createEmptyBorder(2, 2, 2, 2), BorderFactory
190
                .createTitledBorder("Receive")));
255
                .createTitledBorder("Receive")));
Line 200... Line 265...
200
265
201
        // Make preferred width smaller than the other panel's minimum width.
266
        // Make preferred width smaller than the other panel's minimum width.
202
        sysexReceiveTextAreaScrollPane
267
        sysexReceiveTextAreaScrollPane
203
                .setPreferredSize(new Dimension(300, 100));
268
                .setPreferredSize(new Dimension(300, 100));
204
269
-
 
270
        gbc.insets = new Insets(5, 5, 5, 5);
205
        gbc.gridy = 0;
271
        gbc.gridy = 0;
-
 
272
        gbc.gridx = 0;
-
 
273
        gbc.weighty = 1.0;
-
 
274
        receivePanel.add(receiveFileButtonsPanel, gbc);
-
 
275
        gbc.gridx = 0;
-
 
276
        gbc.gridy++;
-
 
277
        gbc.weighty = 1.0;
-
 
278
        gbc.fill = GridBagConstraints.NONE;
-
 
279
        gbc.anchor = GridBagConstraints.WEST;
-
 
280
        receivePanel.add(receiveControlButtonsPanel, gbc);
-
 
281
        gbc.anchor = GridBagConstraints.CENTER;
-
 
282
        gbc.fill = GridBagConstraints.BOTH;
-
 
283
        gbc.gridy++;
-
 
284
        gbc.weighty = 1.0;
206
        receivePanel.add(sysexReceiveTextAreaScrollPane, gbc);
285
        receivePanel.add(sysexReceiveTextAreaScrollPane, gbc);
207
286
208
        JPanel mainPanel = new JPanel(new GridBagLayout());
287
        JPanel mainPanel = new JPanel(new GridBagLayout());
209
288
210
        gbc.gridx = 0;
289
        gbc.gridx = 0;
211
        gbc.gridy = 0;
290
        gbc.gridy = 0;
212
        gbc.insets = new Insets(4, 4, 4, 4);
291
        gbc.insets = new Insets(4, 4, 4, 4);
213
-
 
214
        mainPanel.add(controlButtonsPanel, gbc);
-
 
215
        gbc.gridy++;
-
 
216
292
217
        gbc.weighty = 1.0;
293
        gbc.weighty = 1.0;
218
        mainPanel.add(sendPanel, gbc);
294
        mainPanel.add(sendPanel, gbc);
219
        gbc.gridy++;
295
        gbc.gridy++;
220
        mainPanel.add(receivePanel, gbc);
296
        mainPanel.add(receivePanel, gbc);
221
297
222
        add(controlButtonsPanel, BorderLayout.NORTH);
-
 
223
        add(mainPanel, BorderLayout.CENTER);
298
        add(mainPanel, BorderLayout.CENTER);
224
299
225
        UIUpdate();
300
        UIUpdate();
226
    }
301
    }
227
302
228
    public void UIUpdate() {
303
    public void UIUpdate() {
229
        boolean bUploading = (!sysexSendReceive.isCancelled() && !sysexSendReceive.isDone());
304
        boolean bUploading = (!sysexSendReceive.isSendCancelled() && !sysexSendReceive.isSendDone());
-
 
305
        boolean bReceiving = !sysexSendReceive.isReceiveStopped();
230
306
-
 
307
        sendBrowseButton.setEnabled(!bUploading);
231
        startButton.setEnabled(!bUploading);
308
        sendStartButton.setEnabled(!bUploading);
-
 
309
        sendStopButton.setEnabled(bUploading);
232
        browseButton.setEnabled(!bUploading);
310
        sendClearButton.setEnabled(!bUploading);
233
        sendDelayTimeSpinner.setEnabled(!bUploading);
311
        sendDelayTimeSpinner.setEnabled(!bUploading);
234
        stopButton.setEnabled(bUploading);
-
 
235
        sysexSendTextArea.setEnabled(!bUploading);
312
        sysexSendTextArea.setEnabled(!bUploading);
-
 
313
-
 
314
        receiveBrowseButton.setEnabled(!bReceiving);
-
 
315
        receiveStartButton.setEnabled(!bReceiving);
-
 
316
        receiveStopButton.setEnabled(bReceiving);
-
 
317
        //receiveClearButton.setEnabled(!bReceiving); // better to allow clear while receiving
236
        sysexReceiveTextArea.setEnabled(!bUploading);
318
        sysexReceiveTextArea.setEnabled(!bReceiving);
237
    }
319
    }
238
320
239
321
240
    public void actionPerformed(ActionEvent e) {
322
    public void actionPerformed(ActionEvent e) {
241
        if (e.getActionCommand() == "start") {
323
        if (e.getActionCommand() == "sendStart") {
242
            byte[] sysexData = new byte[sysexSendReceive.getSendBufferSize()];
324
            byte[] sysexData = new byte[sysexSendReceive.getSendBufferSize()];
243
            int sysexDataOffset = 0;
325
            int sysexDataOffset = 0;
244
326
245
            StyledDocument doc = sysexSendTextArea.getStyledDocument();
327
            StyledDocument doc = sysexSendTextArea.getStyledDocument();
246
            int len = doc.getLength();
328
            int len = doc.getLength();
Line 287... Line 369...
287
                   
369
                   
288
                    t.start();
370
                    t.start();
289
                }
371
                }
290
            }
372
            }
291
373
292
        } else if (e.getActionCommand() == "stop") {
374
        } else if (e.getActionCommand() == "sendStop") {
293
            sysexSendReceive.cancel();
375
            sysexSendReceive.sendCancel();
294
376
-
 
377
        } else if (e.getActionCommand() == "sendClear") {
-
 
378
            sysexSendTextArea.setText("");
-
 
379
295
        } else if (e.getActionCommand() == "browse") {
380
        } else if (e.getActionCommand() == "sendBrowse") {
296
            onOpenSysexFile();
381
            onOpenSysexFile();
-
 
382
-
 
383
        } else if (e.getActionCommand() == "receiveStart") {
-
 
384
            sysexSendReceive.setReceiveStopped(false);
-
 
385
-
 
386
        } else if (e.getActionCommand() == "receiveStop") {
-
 
387
            sysexSendReceive.setReceiveStopped(true);
-
 
388
-
 
389
        } else if (e.getActionCommand() == "receiveClear") {
-
 
390
            sysexReceiveTextArea.setText("");
-
 
391
-
 
392
        } else if (e.getActionCommand() == "receiveBrowse") {
-
 
393
            onSaveSysexFile();
297
        }
394
        }
298
395
299
        UIUpdate();
396
        UIUpdate();
300
    }
397
    }
301
398
302
    protected void onOpenSysexFile() {
399
    protected void onOpenSysexFile() {
303
400
304
        if (fc == null) {
401
        if (fc == null) {
305
            fc = new JFileChooser(currentDirectory);
402
            fc = new JFileChooser(currentDirectory);
306
            fc.addChoosableFileFilter(new SimpleFileChooserFilter(
403
            fc.addChoosableFileFilter(new SimpleFileChooserFilter(
307
                    "SysEx files (*.syx)", "syx", "Sysex File"));
404
                    "SysEx files (*.syx)", "syx", "SysEx File"));
308
        }
405
        }
309
406
310
        File noFile = new File("");
407
        File noFile = new File("");
311
        File noFiles[] = { noFile };
408
        File noFiles[] = { noFile };
312
        fc.setSelectedFile(noFile);
409
        fc.setSelectedFile(noFile);
Line 314... Line 411...
314
411
315
        int nRetVal = fc.showOpenDialog(this);
412
        int nRetVal = fc.showOpenDialog(this);
316
413
317
        if (nRetVal == JFileChooser.APPROVE_OPTION) {
414
        if (nRetVal == JFileChooser.APPROVE_OPTION) {
318
            File file = fc.getSelectedFile();
415
            File file = fc.getSelectedFile();
319
            sysexSendReceive.setFile(file);
416
            sysexSendReceive.setSendFile(file);
320
            currentDirectory = fc.getCurrentDirectory().toString();
417
            currentDirectory = fc.getCurrentDirectory().toString();
-
 
418
        }
-
 
419
    }
-
 
420
-
 
421
    protected void onSaveSysexFile() {
-
 
422
-
 
423
        if (fc == null) {
-
 
424
            fc = new JFileChooser(currentDirectory);
-
 
425
            fc.addChoosableFileFilter(new SimpleFileChooserFilter(
-
 
426
                    "SysEx files (*.syx)", "syx", "SysEx File"));
-
 
427
        }
-
 
428
-
 
429
        File noFile = new File("");
-
 
430
        File noFiles[] = { noFile };
-
 
431
        fc.setSelectedFile(noFile);
-
 
432
        fc.setSelectedFiles(noFiles);
-
 
433
-
 
434
        int nRetVal = fc.showSaveDialog(this);
-
 
435
-
 
436
        if (nRetVal == JFileChooser.APPROVE_OPTION) {
-
 
437
            File file = fc.getSelectedFile();
-
 
438
            sysexSendReceive.setReceiveFile(file);
-
 
439
            currentDirectory = fc.getCurrentDirectory().toString();
-
 
440
-
 
441
            int maxSysexDataLen = 200000; // TODO: find better method... linked list?
-
 
442
            byte[] sysexData = new byte[maxSysexDataLen];
-
 
443
            int sysexDataOffset = 0;
-
 
444
-
 
445
            StyledDocument doc = sysexReceiveTextArea.getStyledDocument();
-
 
446
            int len = doc.getLength();
-
 
447
-
 
448
            if( len > 0 ) {
-
 
449
                int nleft = len;
-
 
450
                Segment text = new Segment();
-
 
451
                int offs = 0;
-
 
452
                text.setPartialReturn(true);
-
 
453
                while (nleft > 0) {
-
 
454
                    try {
-
 
455
                        doc.getText(offs, nleft, text);
-
 
456
                    } catch (Exception ex) {
-
 
457
                        JOptionPane.showMessageDialog(null, "Error while parsing hex digits!", "Syntax Error", JOptionPane.ERROR_MESSAGE);
-
 
458
                        return;
-
 
459
                    }
-
 
460
-
 
461
                    StringTokenizer st = new StringTokenizer(text.toString());
-
 
462
                    while (st.hasMoreTokens()) {
-
 
463
                        int value;
-
 
464
-
 
465
                        if( sysexDataOffset >= maxSysexDataLen ) {
-
 
466
                            JOptionPane.showMessageDialog(null, "Too many SysEx bytes!", "Parsing Error", JOptionPane.ERROR_MESSAGE);
-
 
467
                            return;
-
 
468
                        }
-
 
469
-
 
470
                        try {
-
 
471
                            value = (int)java.lang.Integer.parseInt(st.nextToken(), 16);
-
 
472
                            sysexData[sysexDataOffset++] = (byte)value;
-
 
473
                        } catch(Exception ex) {
-
 
474
                            JOptionPane.showMessageDialog(null, "Found invalid hexadecimal digit!", "Syntax Error", JOptionPane.ERROR_MESSAGE);
-
 
475
                            return;
-
 
476
                        }
-
 
477
                    }
-
 
478
-
 
479
                    nleft -= text.count;
-
 
480
                    offs += text.count;
-
 
481
                }
-
 
482
-
 
483
                if( sysexDataOffset > 0 ) {
-
 
484
                    if( !sysexSendReceive.writeSysexFile(file, sysexData, sysexDataOffset) ) {
-
 
485
                        JOptionPane.showMessageDialog(null, "Error while writing file!", "File Access Error", JOptionPane.ERROR_MESSAGE);
-
 
486
                        return;
-
 
487
                    }
-
 
488
                }
-
 
489
            }
321
        }
490
        }
322
    }
491
    }
323
492
324
    public void itemStateChanged(ItemEvent e) {
493
    public void itemStateChanged(ItemEvent e) {
325
        UIUpdate();
494
        UIUpdate();
Line 337... Line 506...
337
    }
506
    }
338
507
339
    public void update(Observable observable, Object object) {
508
    public void update(Observable observable, Object object) {
340
        if (observable == sysexSendReceive) {
509
        if (observable == sysexSendReceive) {
341
            if (object == sysexSendReceive.WORKER ) {
510
            if (object == sysexSendReceive.WORKER ) {
342
            } else if (object == sysexSendReceive.getFile()) {
511
            } else if (object == sysexSendReceive.getSendFile()) {
343
                fileName.setText(sysexSendReceive.getFile().getPath());
512
                sendFileName.setText(sysexSendReceive.getSendFile().getPath());
344
                sysexSendTextArea.setText("");
513
                sysexSendTextArea.setText("");
345
                StyledDocument doc = sysexSendTextArea.getStyledDocument();
514
                StyledDocument doc = sysexSendTextArea.getStyledDocument();
346
                try {
515
                try {
347
                    doc
516
                    doc
348
                            .insertString(0, MidiUtils
517
                            .insertString(0, MidiUtils
349
                                    .getHexString(sysexSendReceive
518
                                    .getHexString(sysexSendReceive
350
                                            .getSysexFile().getData()), doc
519
                                            .getSysexFile().getData()), doc
351
                                    .getStyle("regular"));
520
                                    .getStyle("regular"));
352
                } catch (Exception e) {
521
                } catch (Exception e) {
353
-
 
354
                }
522
                }
355
            } else if (object == sysexSendReceive.getReceivedBytes()) {
523
            } else if (object == sysexSendReceive.getReceivedBytes()) {
-
 
524
                StyledDocument doc = sysexReceiveTextArea.getStyledDocument();
-
 
525
-
 
526
                LinkedList l = sysexSendReceive.getReceivedBytes();
-
 
527
                int i;
-
 
528
                for(i=0; i<l.size(); ++i) {
-
 
529
                    byte[] data = (byte[])l.get(i);
-
 
530
                    try {
-
 
531
                        if( doc.getLength() > 0 )
-
 
532
                            doc.insertString(doc.getLength(), "\n", doc.getStyle("regular"));
-
 
533
                        doc.insertString(doc.getLength(), "F0 ", doc.getStyle("regular"));
-
 
534
                        doc.insertString(doc.getLength(), MidiUtils.getHexString(data), doc.getStyle("regular"));
-
 
535
                    } catch (Exception e) {
-
 
536
                    }
-
 
537
                }
-
 
538
                sysexSendReceive.clearReceivedBytes();
356
539
-
 
540
            } else if (object == sysexSendReceive.getReceiveFile()) {
-
 
541
                receiveFileName.setText(sysexSendReceive.getReceiveFile().getPath());
357
            }
542
            }
358
543
359
            UIUpdate();
544
            UIUpdate();
360
        }
545
        }
361
    }
546
    }