Search in sources :

Example 6 with UserDefinedOpcode

use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.

the class OpcodeListEditPanel method addUDO.

/**
 */
protected void addUDO() {
    if (opcodeList != null) {
        UserDefinedOpcode udo = new UserDefinedOpcode();
        udo.opcodeName += opcodeList.size();
        opcodeList.addOpcode(udo);
    }
}
Also used : UserDefinedOpcode(blue.udo.UserDefinedOpcode)

Example 7 with UserDefinedOpcode

use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.

the class OpcodeListEditPanel method exportBlueUdo.

protected void exportBlueUdo() {
    UserDefinedOpcode[] selected = getSelectedUDOs();
    if (selected == null || selected.length != 1) {
        return;
    }
    File retVal = FileChooserManager.getDefault().showSaveDialog(EXPORT_BLUE_UDO_DIALOG, SwingUtilities.getRoot(OpcodeListEditPanel.this));
    if (retVal != null) {
        File f = retVal;
        if (f.exists()) {
            int overWrite = JOptionPane.showConfirmDialog(SwingUtilities.getRoot(OpcodeListEditPanel.this), "Please confirm you would like to overwrite this file.");
            if (overWrite != JOptionPane.OK_OPTION) {
                return;
            }
        }
        Element node = selected[0].saveAsXML();
        try (PrintWriter out = new PrintWriter(new FileWriter(f))) {
            out.print(node.toString());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
Also used : UserDefinedOpcode(blue.udo.UserDefinedOpcode) Element(electric.xml.Element) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) Point(java.awt.Point) PrintWriter(java.io.PrintWriter)

Example 8 with UserDefinedOpcode

use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.

the class OpcodeListEditPanel method handlePaste.

private void handlePaste(Object obj) {
    if (obj instanceof UserDefinedOpcode) {
        opcodeList.addOpcode(new UserDefinedOpcode((UserDefinedOpcode) obj));
    } else if (obj instanceof UserDefinedOpcode[]) {
        UserDefinedOpcode[] udos = (UserDefinedOpcode[]) obj;
        UserDefinedOpcode[] copies = new UserDefinedOpcode[udos.length];
        for (int i = 0; i < udos.length; i++) {
            copies[i] = new UserDefinedOpcode(udos[i]);
        }
        opcodeList.addOpcodes(copies);
    } else if (obj instanceof UDOCategory) {
        UDOCategory cat = (UDOCategory) obj;
        ArrayList<UserDefinedOpcode> udos = cat.getAllUserDefinedOpcodes();
        UserDefinedOpcode[] copies = new UserDefinedOpcode[udos.size()];
        for (int i = 0; i < udos.size(); i++) {
            copies[i] = new UserDefinedOpcode(udos.get(i));
        }
        opcodeList.addOpcodes(copies);
    }
}
Also used : UDOCategory(blue.udo.UDOCategory) UserDefinedOpcode(blue.udo.UserDefinedOpcode) Point(java.awt.Point)

Example 9 with UserDefinedOpcode

use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.

the class OpcodeListEditPanel method exportCsoundUdo.

protected void exportCsoundUdo() {
    UserDefinedOpcode[] selected = getSelectedUDOs();
    if (selected == null || selected.length != 1) {
        return;
    }
    File retVal = FileChooserManager.getDefault().showSaveDialog(EXPORT_CSOUND_UDO_DIALOG, SwingUtilities.getRoot(OpcodeListEditPanel.this));
    if (retVal != null) {
        File f = retVal;
        if (f.exists()) {
            int overWrite = JOptionPane.showConfirmDialog(SwingUtilities.getRoot(OpcodeListEditPanel.this), "Please confirm you would like to overwrite this file.");
            if (overWrite != JOptionPane.OK_OPTION) {
                return;
            }
        }
        String udoText = selected[0].generateCode();
        try (PrintWriter out = new PrintWriter(new FileWriter(f))) {
            out.print(udoText);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
Also used : UserDefinedOpcode(blue.udo.UserDefinedOpcode) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) Point(java.awt.Point) PrintWriter(java.io.PrintWriter)

Example 10 with UserDefinedOpcode

use of blue.udo.UserDefinedOpcode in project blue by kunstmusik.

the class UDOTreePopup method addUDO.

private void addUDO() {
    UserDefinedOpcode newUDO = new UserDefinedOpcode();
    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)

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