use of electric.xml.Document in project blue by kunstmusik.
the class ImportSoundObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
ScoreTimeCanvas sCanvas = (ScoreTimeCanvas) lGroupPanel;
List<File> retVal = FileChooserManager.getDefault().showOpenDialog(IMPORT_DIALOG, WindowManager.getDefault().getMainWindow());
if (!retVal.isEmpty()) {
File f = retVal.get(0);
Document doc;
try {
doc = new Document(f);
Element root = doc.getRoot();
if (root.getName().equals("soundObject")) {
SoundObject tempSobj = (SoundObject) ObjectUtilities.loadFromXML(root, null);
int start = p.x;
Layer layer = scorePath.getGlobalLayerForY(p.y);
if (timeState.isSnapEnabled()) {
int snapPixels = (int) (timeState.getSnapValue() * timeState.getPixelSecond());
start = start - (start % snapPixels);
}
float startTime = (float) start / timeState.getPixelSecond();
tempSobj.setStartTime(startTime);
((SoundLayer) layer).add(tempSobj);
AddScoreObjectEdit edit = new AddScoreObjectEdit((ScoreObjectLayer) layer, tempSobj);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(edit);
} else {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: File did not contain Sound Object", "Error", JOptionPane.ERROR_MESSAGE);
}
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: Could not read Sound Object from file", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
use of electric.xml.Document in project blue by kunstmusik.
the class BlueShare method selectServer.
private static String selectServer() {
String retVal = null;
// get server list from disk
try {
Document doc = new Document(new File(BlueSystem.getConfDir() + File.separator + "blueShare.xml"));
Element root = doc.getRoot();
Elements servers = root.getElements("server");
Object[] serverOptions = new Object[servers.size()];
int i = 0;
while (servers.hasMoreElements()) {
serverOptions[i] = servers.next().getTextString();
i++;
}
Object serverObj = JOptionPane.showInputDialog(null, BlueSystem.getString("blueShare.selectServer.message"), BlueSystem.getString("blueShare.selectServer.title"), JOptionPane.PLAIN_MESSAGE, null, serverOptions, serverOptions[0]);
if (serverObj != null) {
retVal = serverObj.toString();
}
} catch (ParseException | HeadlessException e) {
e.printStackTrace();
}
return retVal;
}
use of electric.xml.Document in project blue by kunstmusik.
the class BlueShareRemoteCaller method getLatestTenInstruments.
public static InstrumentOption[] getLatestTenInstruments() throws XmlRpcException, IOException, ParseException {
String result = (String) xrpc.execute("blueShare.getLatestTen", new Vector());
Document 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;
}
use of electric.xml.Document in project blue by kunstmusik.
the class BlueShareRemoteCaller method getEffectOptionsForUser.
public static EffectOption[] getEffectOptionsForUser(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.getEffectListForUser", v);
doc = new Document(result);
Element root = doc.getRoot();
Elements instruments = root.getElements("effect");
EffectOption[] iOptions = 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();
iOptions[i] = new EffectOption(effectId, checkNullString(screenName), checkNullString(name), checkNullString(description), checkNullString(category));
i++;
}
return iOptions;
}
use of electric.xml.Document in project blue by kunstmusik.
the class BlueShareRemoteCaller method getInstrument.
public static Instrument getInstrument(InstrumentOption iOption) throws IOException, XmlRpcException, ParseException {
Vector v = new Vector();
String result;
v.add(new Integer(iOption.getInstrumentId()));
result = (String) xrpc.execute("blueShare.getInstrument", v);
Instrument instrument = null;
try {
Document d = new Document(result);
instrument = (Instrument) ObjectUtilities.loadFromXML(d.getRoot());
} catch (Exception e) {
}
return instrument;
}
Aggregations