Subversion Repositories svn.mios

Compare Revisions

Regard whitespace Rev 846 → Rev 850

/trunk/java/org/midibox/midi/gui/SysexSendReceiveGUI.java
32,40 → 32,56
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Observable;
import java.util.Observer;
import java.util.StringTokenizer;
import java.util.LinkedList;
import java.util.Vector;
 
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.text.Segment;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
import javax.swing.text.Segment;
 
import org.midibox.midi.MidiUtils;
import org.midibox.midi.SysexSendReceive;
import org.midibox.utils.gui.ImageLoader;
import org.midibox.utils.gui.SimpleFileChooserFilter;
import org.midibox.utils.gui.SplitButton;
 
public class SysexSendReceiveGUI extends JPanel implements ActionListener,
ItemListener, ChangeListener, Observer {
 
private JPopupMenu MRUPopupMenu;
 
private SplitButton openMRUButton;
 
private static int maxMRU = 10;
 
private static String currentDirectory = "";
 
private static Vector MRU = new Vector();
 
private static JFileChooser fc = null;
 
private SysexSendReceive sysexSendReceive;
77,12 → 93,12
private JButton sendStartButton;
private JButton sendStopButton;
private JButton sendClearButton;
private JButton sendSaveButton;
 
private JButton receiveBrowseButton;
private JTextField receiveFileName;
private JButton receiveStartButton;
private JButton receiveStopButton;
private JButton receiveClearButton;
private JButton receiveSaveButton;
 
private JTextPane sysexSendTextArea;
 
91,12 → 107,14
private JSpinner sendDelayTimeSpinner;
 
public SysexSendReceiveGUI(SysexSendReceive sysexSendReceive) {
 
super(new BorderLayout());
 
this.sysexSendReceive = sysexSendReceive;
 
sysexSendReceive.addObserver(this);
 
sendBrowseButton = new JButton("Open File", ImageLoader
sendBrowseButton = new JButton("SysEx File", ImageLoader
.getImageIcon("open.png"));
sendFileName = new JTextField();
sendFileName.setEditable(false);
116,14 → 134,10
sendClearButton.setActionCommand("sendClear");
sendClearButton.setAlignmentX(Component.LEFT_ALIGNMENT);
 
sendSaveButton = new JButton("", ImageLoader.getImageIcon("save.png"));
sendSaveButton.setActionCommand("sendSave");
sendSaveButton.addActionListener(this);
 
receiveBrowseButton = new JButton("Save File", ImageLoader
.getImageIcon("open.png"));
receiveFileName = new JTextField();
receiveFileName.setEditable(false);
receiveBrowseButton.setActionCommand("receiveBrowse");
receiveBrowseButton.addActionListener(this);
 
receiveStartButton = new JButton("Start");
receiveStartButton.setActionCommand("receiveStart");
receiveStartButton.addActionListener(this);
136,13 → 150,38
receiveClearButton.addActionListener(this);
receiveClearButton.setActionCommand("receiveClear");
receiveClearButton.setAlignmentX(Component.LEFT_ALIGNMENT);
receiveSaveButton = new JButton("", ImageLoader
.getImageIcon("save.png"));
receiveSaveButton.setActionCommand("receiveSave");
receiveSaveButton.addActionListener(this);
 
JPanel sendFileButtonsPanel = new JPanel(new BorderLayout(2, 2));
 
MRUPopupMenu = new JPopupMenu();
MRUPopupMenu.addPopupMenuListener(new PopupMenuListener() {
 
JPanel sendFileButtonsPanel = new JPanel(new BorderLayout(2, 2));
sendFileButtonsPanel.add(sendBrowseButton, BorderLayout.WEST);
public void popupMenuCanceled(PopupMenuEvent e) {
 
}
 
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
 
}
 
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
 
SysexSendReceiveGUI.this.buildMRUMenu(MRUPopupMenu);
 
}
});
 
openMRUButton = new SplitButton(sendBrowseButton, MRUPopupMenu);
openMRUButton.setRollover(true);
 
sendFileButtonsPanel.add(openMRUButton, BorderLayout.WEST);
sendFileButtonsPanel.add(sendFileName, BorderLayout.CENTER);
sendFileButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
sendFileButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5,
5));
 
JPanel sendControlButtonsPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
166,6 → 205,9
sendControlButtonsPanel.add(sendClearButton, gbc);
gbc.gridx++;
 
sendControlButtonsPanel.add(sendSaveButton, gbc);
gbc.gridx++;
 
gbc.insets = new Insets(2, 2, 2, 2);
 
gbc.weightx = 1.0;
184,13 → 226,6
sendDelayTimeSpinner.addChangeListener(this);
sendControlButtonsPanel.add(sendDelayTimeSpinner, gbc);
 
 
 
JPanel receiveFileButtonsPanel = new JPanel(new BorderLayout(2, 2));
receiveFileButtonsPanel.add(receiveBrowseButton, BorderLayout.WEST);
receiveFileButtonsPanel.add(receiveFileName, BorderLayout.CENTER);
receiveFileButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
 
JPanel receiveControlButtonsPanel = new JPanel(new GridBagLayout());
gbc.gridx = 0;
gbc.gridy = 0;
205,9 → 240,9
receiveControlButtonsPanel.add(receiveStopButton, gbc);
gbc.gridx++;
receiveControlButtonsPanel.add(receiveClearButton, gbc);
gbc.gridx++;
receiveControlButtonsPanel.add(receiveSaveButton, gbc);
 
 
 
JPanel sendPanel = new JPanel(new GridBagLayout());
 
gbc.fill = GridBagConstraints.BOTH;
229,6 → 264,13
doc.addStyle("regular", def);
StyleConstants.setFontFamily(def, "Monospaced");
 
sysexSendTextArea.setLogicalStyle(def);
 
if (sysexSendReceive.getSendFile() != null) {
 
loadSysexSendFile();
}
 
JScrollPane sysexSendTextAreaScrollPane = new JScrollPane(
sysexSendTextArea);
sysexSendTextAreaScrollPane
248,7 → 290,6
gbc.weighty = 1.0;
sendPanel.add(sysexSendTextAreaScrollPane, gbc);
 
 
JPanel receivePanel = new JPanel(new GridBagLayout());
receivePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
.createEmptyBorder(2, 2, 2, 2), BorderFactory
258,6 → 299,17
sysexReceiveTextArea.setBackground(Color.WHITE);
 
sysexReceiveTextArea.setEditable(true);
 
doc = sysexReceiveTextArea.getStyledDocument();
 
def = StyleContext.getDefaultStyleContext().getStyle(
StyleContext.DEFAULT_STYLE);
 
doc.addStyle("regular", def);
StyleConstants.setFontFamily(def, "Monospaced");
 
sysexReceiveTextArea.setLogicalStyle(def);
 
JScrollPane sysexReceiveTextAreaScrollPane = new JScrollPane(
sysexReceiveTextArea);
sysexReceiveTextAreaScrollPane
271,10 → 323,6
gbc.gridy = 0;
gbc.gridx = 0;
gbc.weighty = 1.0;
receivePanel.add(receiveFileButtonsPanel, gbc);
gbc.gridx = 0;
gbc.gridy++;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
receivePanel.add(receiveControlButtonsPanel, gbc);
301,7 → 349,8
}
 
public void UIUpdate() {
boolean bUploading = (!sysexSendReceive.isSendCancelled() && !sysexSendReceive.isSendDone());
boolean bUploading = (!sysexSendReceive.isSendCancelled() && !sysexSendReceive
.isSendDone());
boolean bReceiving = !sysexSendReceive.isReceiveStopped();
 
sendBrowseButton.setEnabled(!bUploading);
311,14 → 360,14
sendDelayTimeSpinner.setEnabled(!bUploading);
sysexSendTextArea.setEnabled(!bUploading);
 
receiveBrowseButton.setEnabled(!bReceiving);
receiveSaveButton.setEnabled(!bReceiving);
receiveStartButton.setEnabled(!bReceiving);
receiveStopButton.setEnabled(bReceiving);
//receiveClearButton.setEnabled(!bReceiving); // better to allow clear while receiving
// receiveClearButton.setEnabled(!bReceiving); // better to allow clear
// while receiving
sysexReceiveTextArea.setEnabled(!bReceiving);
}
 
 
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "sendStart") {
byte[] sysexData = new byte[sysexSendReceive.getSendBufferSize()];
336,7 → 385,9
try {
doc.getText(offs, nleft, text);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Error while parsing hex digits!", "Syntax Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null,
"Error while parsing hex digits!",
"Syntax Error", JOptionPane.ERROR_MESSAGE);
return;
}
 
345,10 → 396,13
int value;
 
try {
value = (int)java.lang.Integer.parseInt(st.nextToken(), 16);
value = (int) java.lang.Integer.parseInt(st
.nextToken(), 16);
sysexData[sysexDataOffset++] = (byte)value;
} catch(Exception ex) {
JOptionPane.showMessageDialog(null, "Found invalid hexadecimal digit!", "Syntax Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null,
"Found invalid hexadecimal digit!",
"Syntax Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
363,7 → 417,8
 
Thread t = new Thread() {
public void run() {
sysexSendReceive.startSend(finalSysexData, finalSysexDataOffset);
sysexSendReceive.startSend(finalSysexData,
finalSysexDataOffset);
}
};
389,8 → 444,11
} else if (e.getActionCommand() == "receiveClear") {
sysexReceiveTextArea.setText("");
 
} else if (e.getActionCommand() == "receiveBrowse") {
onSaveSysexFile();
} else if (e.getActionCommand() == "receiveSave") {
onSaveSysexFile(sysexReceiveTextArea.getStyledDocument());
 
} else if (e.getActionCommand() == "sendSave") {
onSaveSysexFile(sysexSendTextArea.getStyledDocument());
}
 
UIUpdate();
412,13 → 470,16
int nRetVal = fc.showOpenDialog(this);
 
if (nRetVal == JFileChooser.APPROVE_OPTION) {
 
File file = fc.getSelectedFile();
sysexSendReceive.setSendFile(file);
 
openSysexSendFile(file);
 
currentDirectory = fc.getCurrentDirectory().toString();
}
}
 
protected void onSaveSysexFile() {
protected void onSaveSysexFile(StyledDocument doc) {
 
if (fc == null) {
fc = new JFileChooser(currentDirectory);
438,11 → 499,11
sysexSendReceive.setReceiveFile(file);
currentDirectory = fc.getCurrentDirectory().toString();
 
int maxSysexDataLen = 200000; // TODO: find better method... linked list?
int maxSysexDataLen = 200000; // TODO: find better method... linked
// list?
byte[] sysexData = new byte[maxSysexDataLen];
int sysexDataOffset = 0;
 
StyledDocument doc = sysexReceiveTextArea.getStyledDocument();
int len = doc.getLength();
 
if( len > 0 ) {
454,7 → 515,9
try {
doc.getText(offs, nleft, text);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Error while parsing hex digits!", "Syntax Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null,
"Error while parsing hex digits!",
"Syntax Error", JOptionPane.ERROR_MESSAGE);
return;
}
 
463,15 → 526,20
int value;
 
if( sysexDataOffset >= maxSysexDataLen ) {
JOptionPane.showMessageDialog(null, "Too many SysEx bytes!", "Parsing Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null,
"Too many SysEx bytes!", "Parsing Error",
JOptionPane.ERROR_MESSAGE);
return;
}
 
try {
value = (int)java.lang.Integer.parseInt(st.nextToken(), 16);
value = (int) java.lang.Integer.parseInt(st
.nextToken(), 16);
sysexData[sysexDataOffset++] = (byte)value;
} catch(Exception ex) {
JOptionPane.showMessageDialog(null, "Found invalid hexadecimal digit!", "Syntax Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null,
"Found invalid hexadecimal digit!",
"Syntax Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
481,8 → 549,11
}
 
if( sysexDataOffset > 0 ) {
if( !sysexSendReceive.writeSysexFile(file, sysexData, sysexDataOffset) ) {
JOptionPane.showMessageDialog(null, "Error while writing file!", "File Access Error", JOptionPane.ERROR_MESSAGE);
if (!sysexSendReceive.writeSysexFile(file, sysexData,
sysexDataOffset)) {
JOptionPane.showMessageDialog(null,
"Error while writing file!",
"File Access Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
499,7 → 570,8
Object source = e.getSource();
 
if (source == sendDelayTimeSpinner) {
sysexSendReceive.setSendDelayTime(((Integer) sendDelayTimeSpinner.getValue()).intValue());
sysexSendReceive.setSendDelayTime(((Integer) sendDelayTimeSpinner
.getValue()).intValue());
}
 
UIUpdate();
506,39 → 578,38
}
 
public void update(Observable observable, Object object) {
 
if (observable == sysexSendReceive) {
 
if (object == sysexSendReceive.WORKER ) {
} else if (object == sysexSendReceive.getSendFile()) {
sendFileName.setText(sysexSendReceive.getSendFile().getPath());
sysexSendTextArea.setText("");
StyledDocument doc = sysexSendTextArea.getStyledDocument();
try {
doc
.insertString(0, MidiUtils
.getHexString(sysexSendReceive
.getSysexFile().getData()), doc
.getStyle("regular"));
} catch (Exception e) {
}
} else if (object == sysexSendReceive.getReceivedBytes()) {
 
} else if (object == sysexSendReceive.SEND_SYSEX_FILE) {
 
loadSysexSendFile();
 
} else if (object == sysexSendReceive.RECEIVE_SYSEX_FILE) {
 
StyledDocument doc = sysexReceiveTextArea.getStyledDocument();
 
LinkedList l = sysexSendReceive.getReceivedBytes();
 
int i;
 
for(i=0; i<l.size(); ++i) {
byte[] data = (byte[])l.get(i);
try {
if( doc.getLength() > 0 )
doc.insertString(doc.getLength(), "\n", doc.getStyle("regular"));
doc.insertString(doc.getLength(), "F0 ", doc.getStyle("regular"));
doc.insertString(doc.getLength(), MidiUtils.getHexString(data), doc.getStyle("regular"));
doc.insertString(doc.getLength(), "\n", doc
.getStyle("regular"));
doc.insertString(doc.getLength(), "F0 ", doc
.getStyle("regular"));
doc.insertString(doc.getLength(), MidiUtils
.getHexString(data), doc.getStyle("regular"));
} catch (Exception e) {
}
}
 
sysexSendReceive.clearReceivedBytes();
 
} else if (object == sysexSendReceive.getReceiveFile()) {
receiveFileName.setText(sysexSendReceive.getReceiveFile().getPath());
}
 
UIUpdate();
545,6 → 616,60
}
}
 
private void buildMRUMenu(JComponent menu) {
 
menu.removeAll();
 
Iterator it = MRU.iterator();
 
while (it.hasNext()) {
 
final JMenuItem menuItem = new JMenuItem((String) it.next());
 
menuItem.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent ae) {
 
File file = new File(menuItem.getText());
 
openSysexSendFile(file);
}
});
 
menu.add(menuItem, 0);
}
}
 
protected void openSysexSendFile(File file) {
 
if (file.exists()) {
 
sysexSendReceive.setSendFile(file);
 
saveMRU(file.getPath());
 
} else {
JOptionPane.showMessageDialog(this, "Hex file no longer exists",
"File does not exist", JOptionPane.ERROR_MESSAGE);
}
}
 
public static void saveMRU(String file) {
 
MRU.remove(file);
 
MRU.add(file);
 
for (int i = MRU.size() - maxMRU; i > 0; i--) {
 
MRU.removeElementAt(i - 1);
}
}
 
public static Vector getMRU() {
return MRU;
}
 
public SysexSendReceive getSysexSendReceive() {
return sysexSendReceive;
}
557,4 → 682,19
SysexSendReceiveGUI.currentDirectory = currentDirectory;
}
 
private void loadSysexSendFile() {
 
sendFileName.setText(sysexSendReceive.getSendFile().getPath());
 
sysexSendTextArea.setText("");
 
StyledDocument doc = sysexSendTextArea.getStyledDocument();
 
try {
doc.insertString(0, MidiUtils.getHexString(sysexSendReceive
.getSysexFile().getData()), doc.getStyle("regular"));
} catch (Exception e) {
 
}
}
}
/trunk/java/org/midibox/midi/xml/SysexSendReceiveManagerXML.java
11,9 → 11,9
 
public class SysexSendReceiveManagerXML extends XMLUtils {
 
public final static String TAG_ROOT_ELEMENT = "hexFileUploadManager";
public final static String TAG_ROOT_ELEMENT = "sysexSendReceiveManager";
 
public final static String TAG_HEX_FILE_UPLOADS = "hexFileUploads";
public final static String TAG_SYSEX_SEND_RECEIVES = "sysexSendReceives";
 
protected SysexSendReceiveManager sysexSendReceiveManager;
 
25,7 → 25,7
 
this.sysexSendReceiveManager = sysexSendReceiveManager;
 
addTag(TAG_HEX_FILE_UPLOADS);
addTag(TAG_SYSEX_SEND_RECEIVES);
addTag(SysexSendReceiveXML.TAG_ROOT_ELEMENT);
}
 
37,7 → 37,7
 
if (name == rootElementTag) {
 
} else if (name == TAG_HEX_FILE_UPLOADS) {
} else if (name == TAG_SYSEX_SEND_RECEIVES) {
 
Iterator it = ((Vector) sysexSendReceiveManager
.getSysexSendReceives().clone()).iterator();
58,7 → 58,7
SysexSendReceiveXML sysexSendReceiveXML = new SysexSendReceiveXML(
sysexSendReceive, SysexSendReceiveXML.TAG_ROOT_ELEMENT);
 
sysexSendReceiveManager.newSysexSendReceive();
sysexSendReceiveManager.addSysexSendReceive(sysexSendReceive);
 
sysexSendReceiveXML.loadXML(element);
}
69,7 → 69,7
super.saveXML(node);
 
Element hexFileUploadDevicesElement = document
.createElement(TAG_HEX_FILE_UPLOADS);
.createElement(TAG_SYSEX_SEND_RECEIVES);
 
rootElement.appendChild(hexFileUploadDevicesElement);
 
/trunk/java/org/midibox/midi/xml/SysexSendReceiveXML.java
1,7 → 1,10
package org.midibox.midi.xml;
 
import java.io.File;
 
import org.midibox.midi.SysexSendReceive;
import org.midibox.utils.xml.XMLUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
 
public class SysexSendReceiveXML extends XMLUtils {
8,6 → 11,10
 
public final static String TAG_ROOT_ELEMENT = "sysexSendReceive";
 
public final static String TAG_SEND_FILE = "sendSysexFile";
 
public final static String ATTR_SEND_DELAY_TIME = "sendDelayTime";
 
protected SysexSendReceive sysexSendReceive;
 
public SysexSendReceiveXML(SysexSendReceive sysexSendReceive,
16,10 → 23,52
super(rootElementTag);
 
this.sysexSendReceive = sysexSendReceive;
 
addTag(TAG_SEND_FILE);
}
 
protected void parseElement(Element element) {
 
super.parseElement(element);
 
String name = element.getNodeName();
 
if (name == rootElementTag) {
 
if (element.getAttribute(ATTR_SEND_DELAY_TIME) != "") {
 
sysexSendReceive.setSendDelayTime(stringToInt(element
.getAttribute(ATTR_SEND_DELAY_TIME)));
}
}
 
if (name == TAG_SEND_FILE) {
 
File file = new File(element.getTextContent());
 
if (file.exists()) {
 
sysexSendReceive.setSendFile(file);
}
}
}
 
public void saveXML(Node node) {
 
super.saveXML(node);
 
rootElement.setAttribute(ATTR_SEND_DELAY_TIME,
intToString(sysexSendReceive.getSendDelayTime()));
 
File file = sysexSendReceive.getSendFile();
 
if (file != null) {
 
Element fileElement = document.createElement(TAG_SEND_FILE);
 
rootElement.appendChild(fileElement);
 
fileElement.setTextContent(file.getAbsolutePath());
}
}
}
/trunk/java/org/midibox/midi/SysexSendReceiveManager.java
35,13 → 35,18
 
SysexSendReceive sysexSendReceive = new SysexSendReceive(null);
 
addSysexSendReceive(sysexSendReceive);
 
return sysexSendReceive;
}
 
public void addSysexSendReceive(SysexSendReceive sysexSendReceive) {
 
sysexSendReceives.add(sysexSendReceive);
 
setChanged();
notifyObservers(sysexSendReceive);
clearChanged();
 
return sysexSendReceive;
}
 
public void removeSysexSendReceive(SysexSendReceive sysexSendReceive) {
/trunk/java/org/midibox/midi/SysexSendReceive.java
22,7 → 22,6
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.LinkedList;
import java.util.Observable;
36,6 → 35,14
 
public final static Object WORKER = new Object();
 
public final static Object SEND_SYSEX_FILE = new Object();
 
public final static Object RECEIVE_SYSEX_FILE = new Object();
 
public final static Object SEND_DELAY_TIME = new Object();
 
public final static Object RECEIVED_BYTES = new Object();
 
protected Receiver receiver;
 
protected File sendFile;
45,8 → 52,6
 
protected SysexFile sysexFile;
 
protected SysexSendReceiveWorkerTask sysexSendReceiveWorkerTask;
 
protected int sendBufferSize;
 
protected int sendDelayTime;
61,7 → 66,9
public SysexSendReceive(Receiver receiver) {
super();
this.receiver = receiver;
sendBufferSize = 100000; // TK: shouldn't be changed by user since Java doesn't allow to split SysEx streams properly
sendBufferSize = 100000; // TK: shouldn't be changed by user since Java
// doesn't allow to split SysEx streams
// properly
sendDelayTime = 750; // delay between F0
receivedBytes = new LinkedList();
}
75,13 → 82,15
}
 
public void setSendFile(File file) {
 
this.sendFile = file;
 
sendFileLastModified = sendFile.lastModified();
 
readSysexFile();
 
setChanged();
notifyObservers(sendFile);
notifyObservers(SEND_SYSEX_FILE);
clearChanged();
}
 
92,22 → 101,19
}
}
 
 
public File getReceiveFile() {
return receiveFile;
}
 
public void setReceiveFile(File file) {
 
this.receiveFile = file;
 
setChanged();
notifyObservers(receiveFile);
notifyObservers(RECEIVE_SYSEX_FILE);
clearChanged();
}
 
 
 
 
public SysexFile getSysexFile() {
return sysexFile;
}
121,19 → 127,22
}
 
public void setSendDelayTime(int sendDelayTime) {
 
this.sendDelayTime = sendDelayTime;
 
setChanged();
notifyObservers(SEND_DELAY_TIME);
clearChanged();
}
 
 
 
public LinkedList getReceivedBytes() {
return receivedBytes;
}
 
public void clearReceivedBytes() {
receivedBytes.clear();
}
 
 
public boolean writeSysexFile(File file, byte[] data, int dataLen) {
// could also be located in SysexFile.java?
 
148,7 → 157,6
return true;
}
 
 
public boolean isSendDone() {
return sendDone;
}
174,7 → 182,6
this.receiveStopped = receiveStopped;
}
 
 
public void close() {
 
}
183,14 → 190,6
this.receiver = receiver;
}
 
public class SysexSendReceiveWorkerTask extends Thread {
 
public void run() {
 
}
}
 
 
public void send(MidiMessage message, long timestamp) {
if (!isReceiveStopped()) {
if (message instanceof SysexMessage) {
197,18 → 196,16
receivedBytes.add(((SysexMessage) message).getData());
 
setChanged();
notifyObservers(receivedBytes);
notifyObservers(RECEIVED_BYTES);
clearChanged();
}
}
}
 
 
/////////////////////////////////////////////////////////////////////////////////
// SysEx File Sender Functions
/////////////////////////////////////////////////////////////////////////////////
 
 
public void startSend(byte[] sysexData, int sysexDataLen) {
int offset = 0;
 
226,7 → 223,8
notifyObservers(WORKER);
clearChanged();
 
for(i=1; i<sendBufferSize && (i+offset)<sysexDataLen && sysexData[i+offset] != (byte)0xf0; ++i) {
for (i = 1; i < sendBufferSize && (i + offset) < sysexDataLen
&& sysexData[i + offset] != (byte) 0xf0; ++i) {
++sendLen;
}
 
/trunk/java/org/midibox/apps/miosstudio/xml/MIOSStudioXML.java
31,7 → 31,7
 
public static final String TAG_MIDI_KEYBOARD_CONTROLLER = "midiKeyboardController";
 
public static final String TAG_SYSEX_SEND_RECEIVE_MANAGER = "sysexSendReciveManager";
public static final String TAG_SYSEX_SEND_RECEIVE_MANAGER = "sysexSendReceiveManager";
 
public static final String TAG_HEX_FILE_UPLOAD_MANAGER = "hexFileUploadManager";
 
/trunk/java/org/midibox/apps/miosstudio/gui/xml/MIOSStudioGUIXML.java
395,7 → 395,16
} else if (name == TAG_HEX_FILE_UPLOAD_GUI_MRU) {
 
HexFileUploadGUI.saveMRU(element.getTextContent());
 
} else if (name == TAG_SYSEX_SEND_RECEIVE_GUI_MRU_LIST) {
 
HexFileUploadGUI.getMRU().removeAllElements();
 
} else if (name == TAG_SYSEX_SEND_RECEIVE_GUI_MRU) {
 
SysexSendReceiveGUI.saveMRU(element.getTextContent());
}
 
}
 
public void saveXML(Node node) {
555,6 → 564,23
sysexSendReceiveCurrentDirectoryElement
.setTextContent(SysexSendReceiveGUI.getCurrentDirectory());
 
Element mruListElement = document
.createElement(TAG_SYSEX_SEND_RECEIVE_GUI_MRU_LIST);
 
sysexSendReceiveDeviceManagerGUIelement.appendChild(mruListElement);
 
Iterator it = SysexSendReceiveGUI.getMRU().iterator();
 
while (it.hasNext()) {
 
Element mru = document
.createElement(TAG_SYSEX_SEND_RECEIVE_GUI_MRU);
 
mruListElement.appendChild(mru);
 
mru.setTextContent((String) it.next());
}
 
Element hexFileCurrentDirectoryElement = document
.createElement(TAG_HEX_FILE_UPLOAD_GUI_CURRENT_DIRECTORY);
 
571,12 → 597,12
hexFileCurrentDirectoryElement.setTextContent(HexFileUploadGUI
.getCurrentDirectory());
 
Element mruListElement = document
mruListElement = document
.createElement(TAG_HEX_FILE_UPLOAD_GUI_MRU_LIST);
 
hexFileUploadDeviceManagerGUIelement.appendChild(mruListElement);
 
Iterator it = HexFileUploadGUI.getMRU().iterator();
it = HexFileUploadGUI.getMRU().iterator();
 
while (it.hasNext()) {
 
/trunk/java/org/midibox/mios/HexFile.java
25,7 → 25,6
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import java.util.LinkedList;
 
274,7 → 273,6
// Addendum2: block addresses are stored in a HashMap now
// this speeds up hex load significantly! :-)
 
 
long lByteAddress = newBlock.lAddress;
 
int nBlockSize = BLOCK_SIZE_DEFAULT;
307,7 → 305,6
}
}
 
 
int nBytePos;
for (nBytePos = 0; nBytePos < newBlock.axData.length; ++nBytePos, ++lByteAddress) {
byte bData = newBlock.axData[nBytePos];
314,7 → 311,8
 
Long lBigBlockAddress = lByteAddress / nBlockSize * nBlockSize;
 
Integer nBigBlockIndex = (Integer)_block_address_map.get(lBigBlockAddress);
Integer nBigBlockIndex = (Integer) _block_address_map
.get(lBigBlockAddress);
if (nBigBlockIndex == null) {
Block newBigBlock = new Block();
newBigBlock.axData = new byte[nBlockSize];