Search in sources :

Example 26 with Document

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

the class BlueShareRemoteCaller method getLatestTenEffects.

public static EffectOption[] getLatestTenEffects() throws XmlRpcException, IOException, ParseException {
    String result = (String) xrpc.execute("blueShare.getLatestTenEffects", new Vector());
    Document doc = new Document(result);
    Element root = doc.getRoot();
    Elements instruments = root.getElements("effect");
    EffectOption[] effectOptions = new EffectOption[instruments.size()];
    int i = 0;
    int effectId;
    String screenName, name, description, category;
    Element temp;
    while (instruments.hasMoreElements()) {
        temp = instruments.next();
        effectId = Integer.parseInt(temp.getAttribute("effectId").getValue());
        screenName = temp.getElement("screenName").getTextString();
        name = temp.getElement("name").getTextString();
        description = temp.getElement("description").getTextString();
        category = temp.getElement("category").getTextString();
        effectOptions[i] = new EffectOption(effectId, checkNullString(screenName), checkNullString(name), checkNullString(description), checkNullString(category));
        i++;
    }
    return effectOptions;
}
Also used : Element(electric.xml.Element) Document(electric.xml.Document) Elements(electric.xml.Elements) EffectOption(blue.tools.blueShare.effects.EffectOption) Vector(java.util.Vector)

Example 27 with Document

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

the class BlueShareRemoteCaller method getInstrumentOptionsForUser.

public static InstrumentOption[] getInstrumentOptionsForUser(String username, String password) throws IOException, XmlRpcException, ParseException {
    Vector v = new Vector();
    String result;
    Document doc;
    v.add(username);
    v.add(password);
    result = (String) xrpc.execute("blueShare.getInstrumentListForUser", v);
    doc = new Document(result);
    Element root = doc.getRoot();
    Elements instruments = root.getElements("instrument");
    InstrumentOption[] iOptions = new InstrumentOption[instruments.size()];
    int i = 0;
    int instrumentId;
    String screenName, name, type, description, category;
    Element temp;
    while (instruments.hasMoreElements()) {
        temp = instruments.next();
        instrumentId = Integer.parseInt(temp.getAttribute("instrumentId").getValue());
        screenName = temp.getElement("screenName").getTextString();
        name = temp.getElement("name").getTextString();
        type = temp.getElement("type").getTextString();
        description = temp.getElement("description").getTextString();
        category = temp.getElement("category").getTextString();
        iOptions[i] = new InstrumentOption(instrumentId, checkNullString(screenName), checkNullString(name), checkNullString(type), checkNullString(description), checkNullString(category));
        i++;
    }
    return iOptions;
}
Also used : InstrumentOption(blue.tools.blueShare.instruments.InstrumentOption) Element(electric.xml.Element) Document(electric.xml.Document) Elements(electric.xml.Elements) Vector(java.util.Vector)

Example 28 with Document

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

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

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

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