Search in sources :

Example 1 with ConditionalContentTransformer

use of org.freeplane.features.text.mindmapmode.ConditionalContentTransformer in project freeplane by freeplane.

the class Activator method registerMindMapModeExtension.

private void registerMindMapModeExtension(final BundleContext context) {
    final Hashtable<String, String[]> props = new Hashtable<String, String[]>();
    props.put("mode", new String[] { MModeController.MODENAME, SModeController.MODENAME });
    context.registerService(IModeControllerExtensionProvider.class.getName(), new IModeControllerExtensionProvider() {

        public void installExtension(final ModeController modeController) {
            // LattexNodeHook -> Menu insert
            final LatexNodeHook nodeHook = new LatexNodeHook();
            // 
            modeController.getExtension(TextController.class).addTextTransformer(new ConditionalContentTransformer(new LatexRenderer(), Activator.TOGGLE_PARSE_LATEX));
            modeController.getController().getExtension(FormatController.class).addPatternFormat(new LatexFormat());
            modeController.getController().getExtension(FormatController.class).addPatternFormat(new UnparsedLatexFormat());
            if (modeController.getModeName().equals("MindMap")) {
                modeController.addAction(new InsertLatexAction(nodeHook));
                modeController.addAction(new EditLatexAction(nodeHook));
                modeController.addAction(new DeleteLatexAction(nodeHook));
                addPreferencesToOptionPanel();
            }
        }

        private void addPreferencesToOptionPanel() {
            final URL preferences = this.getClass().getResource(PREFERENCES_RESOURCE);
            if (preferences == null)
                throw new RuntimeException("cannot open preferences");
            final Controller controller = Controller.getCurrentController();
            MModeController modeController = (MModeController) controller.getModeController();
            modeController.getOptionPanelBuilder().load(preferences);
        }
    }, props);
}
Also used : Hashtable(java.util.Hashtable) SModeController(org.freeplane.main.mindmapmode.stylemode.SModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController) IModeControllerExtensionProvider(org.freeplane.main.osgi.IModeControllerExtensionProvider) SModeController(org.freeplane.main.mindmapmode.stylemode.SModeController) Controller(org.freeplane.features.mode.Controller) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) TextController(org.freeplane.features.text.TextController) ModeController(org.freeplane.features.mode.ModeController) FormatController(org.freeplane.features.format.FormatController) URL(java.net.URL) ConditionalContentTransformer(org.freeplane.features.text.mindmapmode.ConditionalContentTransformer) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Aggregations

URL (java.net.URL)1 Hashtable (java.util.Hashtable)1 FormatController (org.freeplane.features.format.FormatController)1 Controller (org.freeplane.features.mode.Controller)1 ModeController (org.freeplane.features.mode.ModeController)1 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)1 TextController (org.freeplane.features.text.TextController)1 ConditionalContentTransformer (org.freeplane.features.text.mindmapmode.ConditionalContentTransformer)1 SModeController (org.freeplane.main.mindmapmode.stylemode.SModeController)1 IModeControllerExtensionProvider (org.freeplane.main.osgi.IModeControllerExtensionProvider)1