use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.
the class OpcodeListEditPanel method getSelectedUDOs.
/**
* @return
*/
public UserDefinedOpcode[] getSelectedUDOs() {
int[] indexes = table.getSelectedRows();
if (indexes.length == 0) {
return null;
}
UserDefinedOpcode[] udos = new UserDefinedOpcode[indexes.length];
for (int i = 0; i < indexes.length; i++) {
udos[i] = opcodeList.getOpcode(indexes[i]);
}
return udos;
}
use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.
the class OpcodeListEditPanel method importBlueUdo.
protected void importBlueUdo() {
List<File> retVal = FileChooserManager.getDefault().showOpenDialog(IMPORT_BLUE_UDO_DIALOG, SwingUtilities.getRoot(OpcodeListEditPanel.this));
if (retVal != null && retVal.size() == 1) {
File f = retVal.get(0);
if (f.exists()) {
try {
String text = TextUtilities.getTextFromFile(f);
Document d = new Document(f);
UserDefinedOpcode udo = UserDefinedOpcode.loadFromXML(d.getRoot());
opcodeList.addOpcode(udo);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
}
}
use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.
the class UDOTreePopup method addUDO.
private void addUDO(UserDefinedOpcode udo) {
UserDefinedOpcode newUDO = new UserDefinedOpcode(udo);
UDOCategory currentCategory = (UDOCategory) userObj;
instrGUI.iLibrary.addUDO(currentCategory, newUDO);
/*
* BlueUndoManager.setUndoManager("orchestra"); BlueUndoManager.addEdit(
* new AddEdit(orchTableModel, clone, new Integer(iNum)));
*/
}
use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.
the class UDOTreePopup method getSelectedUDO.
public UserDefinedOpcode getSelectedUDO() {
TreePath selectionPath = libraryTree.getSelectionPath();
if (selectionPath == null) {
return null;
}
Object obj = selectionPath.getLastPathComponent();
if (obj instanceof UserDefinedOpcode) {
return (UserDefinedOpcode) obj;
}
return null;
}
use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.
the class UDORepositoryBrowser method loadOpcodeFromXML.
private UserDefinedOpcode loadOpcodeFromXML(Element udoElement) {
String opcodeName = udoElement.getElement("name").getTextString();
String codeText = udoElement.getElement("code").getTextString();
StringBuffer commentBuffer = new StringBuffer();
String shortDescription = udoElement.getElement("shortDescription").getTextString();
String description = udoElement.getElement("description").getTextString();
String syntax = udoElement.getElement("syntax").getTextString();
String initialization = udoElement.getElement("initialization").getTextString();
String performance = udoElement.getElement("performance").getTextString();
String credits = udoElement.getElement("credits").getTextString();
commentBuffer.append(opcodeName).append(" - ").append(shortDescription);
commentBuffer.append("\n\nDESCRIPTION\n").append(description);
commentBuffer.append("\n\nSYNTAX\n").append(syntax);
commentBuffer.append("\n\nINITIALIZATION\n").append(initialization);
commentBuffer.append("\n\nPERFORMANCE\n").append(performance);
commentBuffer.append("\n\nCREDITS\n").append(credits);
UserDefinedOpcode udo = new UserDefinedOpcode();
udo.opcodeName = opcodeName;
udo.comments = commentBuffer.toString();
StringBuffer cleanedCode = new StringBuffer();
int mode = 0;
String[] lines = codeText.split("\n");
for (int i = 0; i < lines.length; i++) {
if (mode == 0) {
String line = lines[i].trim();
line = TextUtilities.stripSingleLineComments(line);
if (line.startsWith("opcode")) {
String[] parts = line.substring(6).split(",");
if (parts.length == 3) {
udo.outTypes = parts[1].trim();
udo.inTypes = parts[2].trim();
}
mode = 1;
}
} else if (mode == 1) {
String line = lines[i];
if (line.contains("endop")) {
break;
}
cleanedCode.append(line).append("\n");
}
}
udo.codeBody = cleanedCode.toString();
return udo;
}
Aggregations