Search in sources :

Example 16 with UserDefinedOpcode

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;
}
Also used : UserDefinedOpcode(blue.udo.UserDefinedOpcode) Point(java.awt.Point)

Example 17 with UserDefinedOpcode

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);
            }
        }
    }
}
Also used : UserDefinedOpcode(blue.udo.UserDefinedOpcode) Document(electric.xml.Document) File(java.io.File) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) ParseException(electric.xml.ParseException) IOException(java.io.IOException)

Example 18 with UserDefinedOpcode

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)));
         */
}
Also used : UDOCategory(blue.udo.UDOCategory) UserDefinedOpcode(blue.udo.UserDefinedOpcode)

Example 19 with UserDefinedOpcode

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;
}
Also used : TreePath(javax.swing.tree.TreePath) UserDefinedOpcode(blue.udo.UserDefinedOpcode)

Example 20 with UserDefinedOpcode

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;
}
Also used : UserDefinedOpcode(blue.udo.UserDefinedOpcode)

Aggregations

UserDefinedOpcode (blue.udo.UserDefinedOpcode)22 UDOCategory (blue.udo.UDOCategory)6 Point (java.awt.Point)6 IOException (java.io.IOException)4 File (java.io.File)3 TreePath (javax.swing.tree.TreePath)3 OpcodeList (blue.udo.OpcodeList)2 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 HashMap (java.util.HashMap)2 Arrangement (blue.Arrangement)1 Parameter (blue.automation.Parameter)1 GenericInstrument (blue.orchestra.GenericInstrument)1 BSBCompilationUnit (blue.orchestra.blueSynthBuilder.BSBCompilationUnit)1 UDOLibrary (blue.udo.UDOLibrary)1 Document (electric.xml.Document)1 Element (electric.xml.Element)1 ParseException (electric.xml.ParseException)1 Rectangle (java.awt.Rectangle)1