Search in sources :

Example 1 with ResourceController

use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.

the class ActionAcceleratorManager method loadDefaultAccelerators.

private void loadDefaultAccelerators(String resource) {
    final ResourceController resourceController = ResourceController.getResourceController();
    final URL resourceUrl = resourceController.getResource(resource);
    if (resourceUrl == null)
        return;
    try (final InputStream resourceStream = new BufferedInputStream(resourceUrl.openStream())) {
        overwritttenDefaultProps.load(resourceStream);
    } catch (Exception e) {
        LogUtils.warn(e);
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ResourceController(org.freeplane.core.resources.ResourceController) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) URL(java.net.URL) IOException(java.io.IOException)

Example 2 with ResourceController

use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.

the class MClipboardController method getFlavorHandler.

private IDataFlavorHandler getFlavorHandler(final Transferable t) {
    if (t.isDataFlavorSupported(MindMapNodesSelection.mindMapNodesFlavor)) {
        try {
            final String textFromClipboard = t.getTransferData(MindMapNodesSelection.mindMapNodesFlavor).toString();
            return new MindMapNodesFlavorHandler(textFromClipboard);
        } catch (final UnsupportedFlavorException e) {
        } catch (final IOException e) {
        }
    }
    final ResourceController resourceController = ResourceController.getResourceController();
    DataFlavor supportedHtmlFlavor = getSupportedHtmlFlavor(t);
    if (supportedHtmlFlavor != null) {
        try {
            final String textFromClipboard = t.getTransferData(supportedHtmlFlavor).toString();
            if (textFromClipboard.charAt(0) != 65533) {
                if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                    final MTextController textController = (MTextController) TextController.getController();
                    final boolean richText = textController.useRichTextInEditor(RESOURCES_REMIND_USE_RICH_TEXT_IN_NEW_NODES);
                    if (richText) {
                        final boolean structuredHtmlImport = resourceController.getBooleanProperty("structured_html_import");
                        final IDataFlavorHandler htmlFlavorHandler;
                        if (structuredHtmlImport) {
                            htmlFlavorHandler = new StructuredHtmlFlavorHandler(textFromClipboard);
                        } else {
                            htmlFlavorHandler = new DirectHtmlFlavorHandler(textFromClipboard);
                        }
                        return htmlFlavorHandler;
                    }
                }
            }
        } catch (final UnsupportedFlavorException e) {
        } catch (final IOException e) {
        }
    }
    if (t.isDataFlavorSupported(MindMapNodesSelection.fileListFlavor)) {
        try {
            final List<File> fileList = castToFileList(t.getTransferData(MindMapNodesSelection.fileListFlavor));
            if (!shouldIgnoreFileListFlavor(fileList))
                return new FileListFlavorHandler(fileList);
        } catch (final UnsupportedFlavorException e) {
        } catch (final IOException e) {
        }
    }
    if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        try {
            final String plainTextFromClipboard = t.getTransferData(DataFlavor.stringFlavor).toString();
            return new StringFlavorHandler(plainTextFromClipboard);
        } catch (final UnsupportedFlavorException e) {
        } catch (final IOException e) {
        }
    }
    if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
        try {
            Image image = (Image) t.getTransferData(DataFlavor.imageFlavor);
            return new ImageFlavorHandler(image);
        } catch (final UnsupportedFlavorException e) {
        } catch (final IOException e) {
        }
    }
    return null;
}
Also used : IOException(java.io.IOException) Image(java.awt.Image) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) DataFlavor(java.awt.datatransfer.DataFlavor) ResourceController(org.freeplane.core.resources.ResourceController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) File(java.io.File)

Example 3 with ResourceController

use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.

the class FormatController method getDefaultNumberFormat.

public DecimalFormat getDefaultNumberFormat() {
    if (defaultNumberFormat != null)
        return defaultNumberFormat;
    final ResourceController resourceController = ResourceController.getResourceController();
    // an empty number format does not make sense!
    fixEmptyDataFormatProperty(resourceController, RESOURCES_NUMBER_FORMAT, "#0.####");
    defaultNumberFormat = getDecimalFormat(resourceController.getProperty(RESOURCES_NUMBER_FORMAT));
    return defaultNumberFormat;
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController)

Example 4 with ResourceController

use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.

the class FormatController method getDefaultDateFormat.

public SimpleDateFormat getDefaultDateFormat() {
    if (defaultDateFormat != null)
        return defaultDateFormat;
    final ResourceController resourceController = ResourceController.getResourceController();
    // DateFormatParser cannot handle empty date format!
    fixEmptyDataFormatProperty(resourceController, RESOURCES_DATE_FORMAT, "SHORT");
    String datePattern = resourceController.getProperty(RESOURCES_DATE_FORMAT);
    defaultDateFormat = createDateFormat(datePattern);
    return defaultDateFormat;
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController)

Example 5 with ResourceController

use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.

the class PresentationKeyEventDispatcher method of.

static PresentationKeyEventDispatcher of(KeyEventDispatcher upDownKeyEventDispatcher, String propertyName) {
    ResourceController resourceController = ResourceController.getResourceController();
    final boolean processKeys = ResourceController.getResourceController().getBooleanProperty(propertyName);
    final PresentationKeyEventDispatcher presentationKeyEventDispatcher = new PresentationKeyEventDispatcher(propertyName, upDownKeyEventDispatcher, processKeys);
    resourceController.addPropertyChangeListener(presentationKeyEventDispatcher);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(presentationKeyEventDispatcher);
    resourceController.addPropertyChangeListener(presentationKeyEventDispatcher);
    return presentationKeyEventDispatcher;
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController)

Aggregations

ResourceController (org.freeplane.core.resources.ResourceController)31 File (java.io.File)8 IOException (java.io.IOException)7 URL (java.net.URL)6 MalformedURLException (java.net.MalformedURLException)4 URISyntaxException (java.net.URISyntaxException)3 Point (java.awt.Point)2 BufferedInputStream (java.io.BufferedInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 StringReader (java.io.StringReader)2 Box (javax.swing.Box)2 Controller (org.freeplane.features.mode.Controller)2 ModeController (org.freeplane.features.mode.ModeController)2 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)2 FileUserDictionary (com.inet.jortho.FileUserDictionary)1 LanguageChangeEvent (com.inet.jortho.LanguageChangeEvent)1 LanguageChangeListener (com.inet.jortho.LanguageChangeListener)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1