Search in sources :

Example 31 with Document

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

the class WindowSettingManager method save.

public void save() {
    updateSettings();
    Document doc = new Document();
    Element root = doc.setRoot("windowSettings");
    for (Element node : settings.values()) {
        root.addElement(node);
    }
    String userDir = BlueSystem.getUserConfigurationDirectory();
    String settingsFile = userDir + File.separator + SETTINGS_FILE_NAME;
    try {
        try (FileOutputStream out = new FileOutputStream(settingsFile)) {
            doc.write(out);
            out.flush();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Element(electric.xml.Element) FileOutputStream(java.io.FileOutputStream) Document(electric.xml.Document) ParseException(electric.xml.ParseException)

Example 32 with Document

use of electric.xml.Document 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 33 with Document

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

the class UDORepositoryBrowser method populateUDOList.

/**
 * @param tempCat
 */
protected void populateUDOList(UDOItem tempCat) {
    if (tempCat.itemId >= 0) {
        String result = null;
        Vector<Integer> v = new Vector<>();
        v.add(tempCat.itemId);
        try {
            result = (String) xrpc.execute("udo.getUDOList", v);
        } catch (XmlRpcException | IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (result == null) {
            System.out.println("Null List");
            return;
        }
        Document doc = null;
        try {
            doc = new Document(result);
        } catch (ParseException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        if (doc == null) {
            return;
        }
        // System.out.println(doc.toString());
        Element root = doc.getRoot();
        DefaultListModel<UDOItem> listItems = new DefaultListModel<>();
        Elements nodes = root.getElements();
        while (nodes.hasMoreElements()) {
            Element node = nodes.next();
            UDOItem item = new UDOItem();
            item.itemId = Integer.parseInt(node.getAttributeValue("udoId"));
            item.itemName = node.getAttributeValue("name");
            listItems.addElement(item);
        }
        udoList.setModel(listItems);
    }
}
Also used : Element(electric.xml.Element) DefaultListModel(javax.swing.DefaultListModel) IOException(java.io.IOException) Document(electric.xml.Document) Elements(electric.xml.Elements) ParseException(electric.xml.ParseException) Vector(java.util.Vector) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 34 with Document

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

the class EffectsLibrary method getInstance.

public static EffectsLibrary getInstance() {
    if (library == null) {
        String effectLibFileName = BlueSystem.getUserConfigurationDirectory() + File.separator + "effectsLibrary.xml";
        File f = new File(effectLibFileName);
        if (f.exists()) {
            boolean error = false;
            try {
                Document doc = new Document(f);
                library = EffectsLibrary.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 EffectsLibrary();
            System.out.println("Creating new Effects Library");
        }
    }
    return library;
}
Also used : ParseException(electric.xml.ParseException) Document(electric.xml.Document) File(java.io.File) IOException(java.io.IOException) ParseException(electric.xml.ParseException)

Example 35 with Document

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

the class CodeRepositoryManager method getCodeRepositoryTreeNode.

/**
 * @param getCodeNodes
 * @return
 * @throws ParseException
 */
public static TreeNode getCodeRepositoryTreeNode(boolean getLeafNodes) throws ParseException {
    File repository = BlueSystem.getCodeRepository();
    Document doc = new Document(repository);
    Element root = doc.getRoot();
    TreeNode rootNode = getTreeNode(root, getLeafNodes);
    return rootNode;
}
Also used : TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Element(electric.xml.Element) Document(electric.xml.Document) File(java.io.File)

Aggregations

Document (electric.xml.Document)35 Element (electric.xml.Element)22 ParseException (electric.xml.ParseException)17 Vector (java.util.Vector)17 IOException (java.io.IOException)13 Elements (electric.xml.Elements)12 File (java.io.File)12 XmlRpcException (org.apache.xmlrpc.XmlRpcException)6 SoundObject (blue.soundObject.SoundObject)4 EffectOption (blue.tools.blueShare.effects.EffectOption)3 InstrumentOption (blue.tools.blueShare.instruments.InstrumentOption)3 SoundObjectOption (blue.tools.blueShare.soundObjects.SoundObjectOption)3 MissingResourceException (java.util.MissingResourceException)3 BlueData (blue.BlueData)2 UDOLibrary (blue.udo.UDOLibrary)2 FileOutputStream (java.io.FileOutputStream)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 SoundLayer (blue.SoundLayer)1 Library (blue.library.Library)1 Effect (blue.mixer.Effect)1