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();
}
}
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);
}
}
}
}
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);
}
}
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;
}
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;
}
Aggregations