Search in sources :

Example 11 with ParseException

use of electric.xml.ParseException in project blue by kunstmusik.

the class CodeRepositoryDialog method setupTree.

private void setupTree() {
    try {
        TreeNode rootNode = CodeRepositoryManager.getCodeRepositoryTreeNode(true);
        codeTree = new JTree(rootNode);
        treeModel = (DefaultTreeModel) codeTree.getModel();
        treeModel.setAsksAllowsChildren(true);
        codeTree.setEditable(true);
        codeTree.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                int row = codeTree.getClosestRowForLocation(e.getX(), e.getY());
                TreePath path = codeTree.getClosestPathForLocation(e.getX(), e.getY());
                if (row == -1) {
                    cards.show(editPanel, "disabled");
                    selected = null;
                    return;
                }
                CodeRepositoryTreeNode tempNode = (CodeRepositoryTreeNode) path.getLastPathComponent();
                ElementHolder tempElem = (ElementHolder) tempNode.getUserObject();
                if (UiUtilities.isRightMouseButton(e)) {
                    showPopup(tempNode, tempElem, e.getX(), e.getY());
                } else {
                    if (tempElem.isGroup) {
                        cards.show(editPanel, "disabled");
                        selected = null;
                    } else {
                        cards.show(editPanel, "enabled");
                        selected = tempElem;
                        code1Text.setText(tempElem.text);
                    }
                    undo.discardAllEdits();
                    ;
                }
            }
        });
    } catch (ParseException pe) {
        System.out.println("[blue.gui.OpcodePopup] There was an error trying to open or parse opcodes.xml or codeRepository.xml");
        pe.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : JTree(javax.swing.JTree) MouseEvent(java.awt.event.MouseEvent) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MouseAdapter(java.awt.event.MouseAdapter) ParseException(electric.xml.ParseException) ParseException(electric.xml.ParseException)

Example 12 with ParseException

use of electric.xml.ParseException in project blue by kunstmusik.

the class EffectImportPane method importEffect.

private void importEffect() {
    EffectOption effectOption = iTableModel.getInstrumentOption(instrumentTable.getSelectedRow());
    if (effectOption == null) {
        return;
    }
    try {
        Effect effect = BlueShareRemoteCaller.getEffect(effectOption);
        if (effect == null) {
            String error = BlueSystem.getString("blueShare.effect.importError");
            JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
            return;
        }
        // data.getOrchestra().addInstrument(instrument);
        // instrumentTreeModel.reload();
        // InstrumentLibrary instrLib =
        // BlueSystem.getUserInstrumentLibrary();
        EffectsLibrary library = EffectsLibrary.getInstance();
        library.importEffect(effect);
        library.save();
        String message = BlueSystem.getString("blueShare.effect.importSuccess");
        JOptionPane.showMessageDialog(null, message, BlueSystem.getString("common.success"), JOptionPane.PLAIN_MESSAGE);
    } catch (ParseException pe) {
        String error = BlueSystem.getString("blueShare.selectServer.couldNotReadResponse");
        JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
        return;
    } catch (XmlRpcException xre) {
        String error = "Error: " + xre.getLocalizedMessage();
        JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
        return;
    } catch (IOException ioe) {
        String error = "Error: " + ioe.getLocalizedMessage();
        JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
        return;
    }
}
Also used : EffectsLibrary(blue.ui.core.mixer.EffectsLibrary) Effect(blue.mixer.Effect) ParseException(electric.xml.ParseException) IOException(java.io.IOException) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 13 with ParseException

use of electric.xml.ParseException in project blue by kunstmusik.

the class ScriptLibrary method getInstance.

public static ScriptLibrary getInstance() {
    if (library == null) {
        String scriptLibFileName = BlueSystem.getUserConfigurationDirectory() + File.separator + "scriptLibrary.xml";
        File f = new File(scriptLibFileName);
        if (f.exists()) {
            boolean error = false;
            try {
                Document doc = new Document(f);
                library = ScriptLibrary.loadFromXML(doc.getRoot());
            } catch (ParseException e1) {
                e1.printStackTrace();
                error = true;
            } catch (Exception e) {
                e.printStackTrace();
                error = true;
            }
            if (error) {
                JOptionPane.showMessageDialog(null, "There was an error loading " + f.getAbsolutePath() + "\nPlease fix this file or remove it and restart blue.", "Error", JOptionPane.ERROR_MESSAGE);
                System.exit(0);
            }
        }
        if (library == null) {
            library = new ScriptLibrary();
            System.out.println("Creating new Script Library");
        }
    }
    return library;
}
Also used : ParseException(electric.xml.ParseException) Document(electric.xml.Document) ParseException(electric.xml.ParseException)

Example 14 with ParseException

use of electric.xml.ParseException in project blue by kunstmusik.

the class BlueSystem method getSoundObjectLibrary.

public static Library<SoundObject> getSoundObjectLibrary() {
    if (soundObjectLibrary == null) {
        String userInstrFileName = BlueSystem.getUserConfigurationDirectory() + File.separator + "soundObjectLibrary.xml";
        File f = new File(userInstrFileName);
        if (f.exists()) {
            boolean error = false;
            try {
                Document doc = new Document(f);
                Map<String, Object> objRefMap = new HashMap<>();
                soundObjectLibrary = Library.loadLibrary(doc.getRoot(), elem -> {
                    try {
                        return (SoundObject) ObjectUtilities.loadFromXML(elem, objRefMap);
                    } catch (Exception ex) {
                        throw new RuntimeException(ex);
                    }
                });
            } catch (ParseException e1) {
                e1.printStackTrace();
                error = true;
            } catch (Exception e) {
                e.printStackTrace();
                error = true;
            }
            if (error) {
                JOptionPane.showMessageDialog(null, "There was an error loading " + f.getAbsolutePath() + "\nPlease fix this file or remove it and restart blue.", "Error", JOptionPane.ERROR_MESSAGE);
                System.exit(0);
            }
        } else {
            soundObjectLibrary = Library.createLibrary("SoundObjects");
        }
    }
    return soundObjectLibrary;
}
Also used : Library(blue.library.Library) PrintWriter(java.io.PrintWriter) Document(electric.xml.Document) UDOLibrary(blue.udo.UDOLibrary) Image(java.awt.Image) FileUtilities(blue.utility.FileUtilities) SoundObject(blue.soundObject.SoundObject) FileWriter(java.io.FileWriter) MissingResourceException(java.util.MissingResourceException) EnvironmentVars(blue.utility.EnvironmentVars) IOException(java.io.IOException) HashMap(java.util.HashMap) JOptionPane(javax.swing.JOptionPane) File(java.io.File) ResourceBundle(java.util.ResourceBundle) JMenuItem(javax.swing.JMenuItem) Locale(java.util.Locale) Map(java.util.Map) ParseException(electric.xml.ParseException) ObjectUtilities(blue.utility.ObjectUtilities) Toolkit(java.awt.Toolkit) HashMap(java.util.HashMap) SoundObject(blue.soundObject.SoundObject) ParseException(electric.xml.ParseException) Document(electric.xml.Document) File(java.io.File) MissingResourceException(java.util.MissingResourceException) IOException(java.io.IOException) ParseException(electric.xml.ParseException)

Example 15 with ParseException

use of electric.xml.ParseException in project blue by kunstmusik.

the class BlueSystem method getUDOLibrary.

public static UDOLibrary getUDOLibrary() {
    if (udoLibrary == null) {
        String userInstrFileName = BlueSystem.getUserConfigurationDirectory() + File.separator + "udoLibrary.xml";
        File f = new File(userInstrFileName);
        if (f.exists()) {
            boolean error = false;
            try {
                Document doc = new Document(f);
                udoLibrary = udoLibrary.loadFromXML(doc.getRoot());
            } catch (ParseException e1) {
                e1.printStackTrace();
                error = true;
            } catch (Exception e) {
                e.printStackTrace();
                error = true;
            }
            if (error) {
                JOptionPane.showMessageDialog(null, "There was an error loading " + f.getAbsolutePath() + "\nPlease fix this file or remove it and restart blue.", "Error", JOptionPane.ERROR_MESSAGE);
                System.exit(0);
            }
        } else {
            udoLibrary = new UDOLibrary();
        }
    }
    return udoLibrary;
}
Also used : UDOLibrary(blue.udo.UDOLibrary) ParseException(electric.xml.ParseException) Document(electric.xml.Document) File(java.io.File) MissingResourceException(java.util.MissingResourceException) IOException(java.io.IOException) ParseException(electric.xml.ParseException)

Aggregations

ParseException (electric.xml.ParseException)20 Document (electric.xml.Document)14 IOException (java.io.IOException)14 XmlRpcException (org.apache.xmlrpc.XmlRpcException)9 File (java.io.File)7 Element (electric.xml.Element)5 Vector (java.util.Vector)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 SoundObject (blue.soundObject.SoundObject)3 Elements (electric.xml.Elements)3 MissingResourceException (java.util.MissingResourceException)3 TreeNode (javax.swing.tree.TreeNode)3 Effect (blue.mixer.Effect)2 Instrument (blue.orchestra.Instrument)2 UDOLibrary (blue.udo.UDOLibrary)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 InstrumentLibrary (blue.InstrumentLibrary)1 Library (blue.library.Library)1 EffectsLibrary (blue.ui.core.mixer.EffectsLibrary)1 EnvironmentVars (blue.utility.EnvironmentVars)1