use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class WindowConfigurationStorage method unmarschall.
protected XMLElement unmarschall(final String marshalled, final JDialog dialog) {
if (marshalled != null) {
final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
final IXMLReader xmlReader = new StdXMLReader(new StringReader(marshalled));
parser.setReader(xmlReader);
try {
final XMLElement storage = (XMLElement) parser.parse();
if (storage != null) {
x = Integer.parseInt(storage.getAttribute("x", "-1"));
y = Integer.parseInt(storage.getAttribute("y", "-1"));
width = Integer.parseInt(storage.getAttribute("width", "-1"));
height = Integer.parseInt(storage.getAttribute("height", "-1"));
UITools.setBounds(dialog, x, y, width, height);
return storage;
}
} catch (final NumberFormatException e) {
LogUtils.severe(e);
} catch (final XMLException e) {
LogUtils.severe(e);
}
}
UITools.setBounds(dialog, -1, -1, -1, -1);
return null;
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class TimeWindowConfigurationStorage method decorateDialog.
public static TimeWindowConfigurationStorage decorateDialog(final String marshalled, final JDialog dialog) {
final TimeWindowConfigurationStorage storage = new TimeWindowConfigurationStorage();
final XMLElement xml = storage.unmarschall(marshalled, dialog);
if (xml != null) {
final Iterator<XMLElement> iterator = xml.getChildren().iterator();
while (iterator.hasNext()) {
storage.addTimeWindowColumnSetting(TimeWindowColumnSetting.create(iterator.next()));
}
return storage;
}
return null;
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class AddOnProperties method addDeinstallationRulesAsChild.
private void addDeinstallationRulesAsChild(XMLElement parent) {
final XMLElement xmlElement = new XMLElement("deinstall");
for (String[] rule : deinstallationRules) {
final XMLElement ruleElement = new XMLElement(rule[0]);
ruleElement.setContent(rule[1]);
xmlElement.addChild(ruleElement);
}
parent.addChild(xmlElement);
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class AddOnProperties method addTranslationsAsChild.
private void addTranslationsAsChild(XMLElement parent) {
final XMLElement translationsElement = new XMLElement("translations");
for (Entry<String, Map<String, String>> localeEntry : translations.entrySet()) {
final XMLElement localeElement = new XMLElement("locale");
localeElement.setAttribute("name", localeEntry.getKey());
for (Entry<String, String> translationEntry : localeEntry.getValue().entrySet()) {
final XMLElement translationElement = new XMLElement("entry");
translationElement.setAttribute("key", translationEntry.getKey());
translationElement.setContent(StringEscapeUtils.escapeJava(translationEntry.getValue()));
localeElement.addChild(translationElement);
}
translationsElement.addChild(localeElement);
}
parent.addChild(translationsElement);
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class AddOnsController method registerPlugins.
private void registerPlugins() {
final File addOnsDir = getAddOnsDir();
// in applets the addOnsDir will be null
if (addOnsDir == null)
return;
File[] addonXmlFiles = addOnsDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".plugin.xml");
}
});
final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
for (File file : addonXmlFiles) {
BufferedInputStream inputStream = null;
try {
inputStream = new BufferedInputStream(new FileInputStream(file));
final IXMLReader reader = new StdXMLReader(inputStream);
parser.setReader(reader);
registerInstalledAddOn(new AddOnProperties(AddOnType.PLUGIN, (XMLElement) parser.parse()));
} catch (final Exception e) {
LogUtils.warn("error parsing " + file, e);
} finally {
FileUtils.silentlyClose(inputStream);
}
}
}
Aggregations