use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class MFileManager method templateFile.
private File templateFile(final String userDefinedTemplateFilePath) {
final ResourceController resourceController = ResourceController.getResourceController();
final File userDefinedTemplateFile = new File(userDefinedTemplateFilePath);
if (userDefinedTemplateFile.isAbsolute() && userDefinedTemplateFile.exists() && !userDefinedTemplateFile.isDirectory()) {
return userDefinedTemplateFile;
}
for (final String filePath : new String[] { userDefinedTemplateFilePath, resourceController.getDefaultProperty(STANDARD_TEMPLATE) }) {
for (final File userTemplates : new File[] { defaultUserTemplateDir(), defaultStandardTemplateDir() }) {
if (userTemplates.isDirectory()) {
final File userStandard = new File(userTemplates, filePath);
if (userStandard.exists() && !userStandard.isDirectory()) {
if (!filePath.equals(userDefinedTemplateFilePath))
resourceController.setProperty(STANDARD_TEMPLATE, filePath);
return userStandard;
}
}
}
}
return null;
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class AddOnsController method registerInstalledAddOn.
public void registerInstalledAddOn(final AddOnProperties addOn) {
installedAddOns.add(addOn);
final ResourceController resourceController = ResourceController.getResourceController();
if (addOn.getDefaultProperties() != null)
resourceController.addDefaults(addOn.getDefaultProperties());
if (addOn.getTranslations() != null)
registerAddOnResources(addOn, resourceController);
if (addOn.getPreferencesXml() != null) {
final ModeController modeController = Controller.getCurrentModeController();
if (modeController instanceof MModeController) {
((MModeController) modeController).getOptionPanelBuilder().load(new StringReader(addOn.getPreferencesXml()));
}
}
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class UIComponentVisibilityDispatcher method setProperty.
public void setProperty(final boolean visible) {
final ResourceController resourceController = ResourceController.getResourceController();
resourceController.setProperty(getPropertyName(), visible);
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class ManualBugReporter method openBugTracker.
private void openBugTracker(final String log, final String hash) {
final String option = showBugReportDialog(log, hash);
if (!BugReportDialogManager.ALLOWED.equals(option)) {
return;
}
try {
final ResourceController resourceController = ResourceController.getResourceController();
final String location = resourceController.getProperty("bugTrackerLocation");
final Controller controller = Controller.getCurrentController();
controller.getViewController().openDocument(new URL(location));
} catch (final MalformedURLException ex) {
UITools.errorMessage(TextUtils.getText("url_error") + "\n" + ex);
LogUtils.warn(ex);
} catch (final Exception ex) {
UITools.errorMessage(ex);
LogUtils.warn(ex);
}
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class ExportWithXSLT method transformMapWithXslt.
private boolean transformMapWithXslt(final String xsltFileName, final File saveFile, final String areaCode, final Mode mode, String[] parameters) throws IOException, TransformerFactoryConfigurationError {
final String map = getMapXml(mode);
final StringReader reader = new StringReader(map);
ResourceController resourceController = ResourceController.getResourceController();
final URL xsltUrl = resourceController.getResource(xsltFileName);
if (xsltUrl == null) {
LogUtils.severe("Can't find " + xsltFileName + " as resource.");
throw new IllegalArgumentException("Can't find " + xsltFileName + " as resource.");
}
final InputStream xsltFile = new BufferedInputStream(xsltUrl.openStream());
final Source xsltSource = new StreamSource(xsltFile);
final Result result = new StreamResult(saveFile);
try {
final TransformerFactory transFact = TransformerFactory.newInstance();
final Transformer trans = transFact.newTransformer(xsltSource);
trans.setParameter("file_ref", saveFile.getAbsoluteFile().toURI().toString());
final String fileName = saveFile.getName();
final String fileNameEncoded = toRelativeUri(fileName);
trans.setParameter("destination_dir", fileNameEncoded + "_files/");
trans.setParameter("area_code", areaCode);
trans.setParameter("folding_type", resourceController.getProperty("html_export_folding"));
StringBuilder sb = new StringBuilder();
for (String p : parameters) {
String value = resourceController.getProperty(p, null);
if (value != null && !value.equals(resourceController.getDefaultProperty(p))) {
sb.append(p);
sb.append('=');
sb.append(value);
sb.append("$$$");
}
}
trans.setParameter("propertyList", sb.toString());
trans.transform(new StreamSource(reader), result);
} catch (final Exception e) {
LogUtils.warn(e);
return false;
} finally {
FileUtils.silentlyClose(xsltFile);
}
return true;
}
Aggregations