Search in sources :

Example 1 with IFreeplanePropertyListener

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

the class MapView method createPropertyChangeListener.

private static void createPropertyChangeListener() {
    MapView.propertyChangeListener = new IFreeplanePropertyListener() {

        public void propertyChanged(final String propertyName, final String newValue, final String oldValue) {
            final Component c = Controller.getCurrentController().getMapViewManager().getMapViewComponent();
            if (!(c instanceof MapView)) {
                return;
            }
            final MapView mapView = (MapView) c;
            if (propertyName.equals(RESOURCES_SELECTED_NODE_COLOR)) {
                MapView.standardSelectColor = ColorUtils.stringToColor(newValue);
                mapView.repaintSelecteds();
                return;
            }
            if (propertyName.equals(RESOURCES_SELECTED_NODE_RECTANGLE_COLOR)) {
                MapView.standardSelectRectangleColor = ColorUtils.stringToColor(newValue);
                mapView.repaintSelecteds();
                return;
            }
            if (propertyName.equals(ResourceController.RESOURCE_DRAW_RECTANGLE_FOR_SELECTION)) {
                MapView.standardDrawRectangleForSelection = TreeXmlReader.xmlToBoolean(newValue);
                mapView.repaintSelecteds();
                return;
            }
            if (propertyName.equals("printonwhitebackground")) {
                MapView.printOnWhiteBackground = TreeXmlReader.xmlToBoolean(newValue);
                return;
            }
            if (propertyName.equals(SPOTLIGHT_BACKGROUND_COLOR)) {
                MapView.spotlightBackgroundColor = ColorUtils.stringToColor(newValue);
                mapView.repaint();
                return;
            }
            if (propertyName.equals(HIDE_SINGLE_END_CONNECTORS)) {
                MapView.hideSingleEndConnectors = ResourceController.getResourceController().getBooleanProperty(HIDE_SINGLE_END_CONNECTORS);
                mapView.repaint();
                return;
            }
            if (propertyName.equals(SHOW_CONNECTORS_PROPERTY)) {
                MapView.showConnectors = ResourceController.getResourceController().getProperty(SHOW_CONNECTORS_PROPERTY).intern();
                mapView.repaint();
                return;
            }
            if (propertyName.equals(SHOW_ICONS_PROPERTY)) {
                MapView.showIcons = ResourceController.getResourceController().getBooleanProperty(SHOW_ICONS_PROPERTY);
                mapView.updateIconsRecursively(mapView.getRoot());
                mapView.repaint();
                return;
            }
            if (propertyName.equals(OUTLINE_HGAP_PROPERTY)) {
                MapView.outlineHGap = ResourceController.getResourceController().getLengthProperty(OUTLINE_HGAP_PROPERTY);
                if (mapView.isOutlineLayoutSet()) {
                    mapView.getRoot().updateAll();
                    mapView.repaint();
                }
                return;
            }
            if (propertyName.equals(OUTLINE_VIEW_FITS_WINDOW_WIDTH)) {
                outlineViewFitsWindowWidth = ResourceController.getResourceController().getBooleanProperty(OUTLINE_VIEW_FITS_WINDOW_WIDTH);
                if (mapView.isOutlineLayoutSet()) {
                    mapView.getRoot().updateAll();
                    mapView.repaint();
                }
                return;
            }
        }
    };
    ResourceController.getResourceController().addPropertyChangeListener(MapView.propertyChangeListener);
}
Also used : IFreeplanePropertyListener(org.freeplane.core.resources.IFreeplanePropertyListener) Component(java.awt.Component) ScalableComponent(org.freeplane.view.swing.features.filepreview.ScalableComponent) JComponent(javax.swing.JComponent)

Example 2 with IFreeplanePropertyListener

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

the class NodeTooltipManager method getSharedInstance.

public static NodeTooltipManager getSharedInstance(ModeController modeController) {
    {
        final NodeTooltipManager instance = modeController.getExtension(NodeTooltipManager.class);
        if (instance != null) {
            return instance;
        }
    }
    final NodeTooltipManager instance = new NodeTooltipManager();
    setTooltipDelays(instance);
    UIManager.put("PopupMenu.consumeEventOnClose", Boolean.FALSE);
    ResourceController.getResourceController().addPropertyChangeListener(new IFreeplanePropertyListener() {

        public void propertyChanged(final String propertyName, final String newValue, final String oldValue) {
            if (propertyName.startsWith(TOOL_TIP_MANAGER)) {
                setTooltipDelays(instance);
            }
        }
    });
    IMapChangeListener mapChangeListener = new AMapChangeListenerAdapter() {

        @Override
        public void onNodeDeleted(NodeDeletionEvent nodeDeletionEvent) {
            instance.hideTipWindow();
        }

        @Override
        public void onNodeInserted(NodeModel parent, NodeModel child, int newIndex) {
            instance.hideTipWindow();
        }

        @Override
        public void onNodeMoved(NodeMoveEvent nodeMoveEvent) {
            instance.hideTipWindow();
        }
    };
    MapController mapController = modeController.getMapController();
    mapController.addMapChangeListener(mapChangeListener);
    INodeSelectionListener nodeSelectionListener = new INodeSelectionListener() {

        public void onSelect(NodeModel node) {
            NodeView view = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, instance.insideComponent);
            if (view != null && node.equals(view.getModel()))
                return;
            instance.hideTipWindow();
        }

        public void onDeselect(NodeModel node) {
        }
    };
    mapController.addNodeSelectionListener(nodeSelectionListener);
    modeController.addExtension(NodeTooltipManager.class, instance);
    return instance;
}
Also used : NodeMoveEvent(org.freeplane.features.map.NodeMoveEvent) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) NodeDeletionEvent(org.freeplane.features.map.NodeDeletionEvent) IFreeplanePropertyListener(org.freeplane.core.resources.IFreeplanePropertyListener) IMapChangeListener(org.freeplane.features.map.IMapChangeListener) AMapChangeListenerAdapter(org.freeplane.features.map.AMapChangeListenerAdapter) MapController(org.freeplane.features.map.MapController)

Example 3 with IFreeplanePropertyListener

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

the class SpellCheckerController method init.

private void init() {
    if (spellCheckerInitialized == true) {
        return;
    }
    spellCheckerInitialized = true;
    final ResourceController resourceController = ResourceController.getResourceController();
    final File orthoDir = new File(resourceController.getResourceBaseDir(), "ortho");
    registerDictionaries(orthoDir);
    final File userOrthoDir = new File(resourceController.getFreeplaneUserDirectory(), "ortho");
    registerDictionaries(userOrthoDir);
    if (!spellCheckerEnabled) {
        return;
    }
    setSpellCheckOptions(resourceController);
    resourceController.addPropertyChangeListener(new IFreeplanePropertyListener() {

        public void propertyChanged(final String propertyName, final String newValue, final String oldValue) {
            if (propertyName.startsWith("spelling_opt")) {
                setSpellCheckOptions(resourceController);
            }
        }
    });
    String spellingLanguage = resourceController.getProperty(SPELLING_LANGUAGE, null);
    if (spellingLanguage == null) {
        spellingLanguage = resourceController.getLanguageCode();
    }
    if (!spellingLanguage.equals("disabled")) {
        SpellChecker.setLanguage(spellingLanguage);
    }
    languageChangeListener = new LanguageChangeListener() {

        public void languageChanged(final LanguageChangeEvent ev) {
            EventQueue.invokeLater(new Runnable() {

                public void run() {
                    final Locale currentLocale = ev.getCurrentLocale();
                    if (currentLocale == null) {
                        resourceController.setProperty(SPELLING_LANGUAGE, "disabled");
                        return;
                    }
                    resourceController.setProperty(SPELLING_LANGUAGE, currentLocale.getLanguage());
                }
            });
        }
    };
    SpellChecker.addLanguageChangeLister(languageChangeListener);
}
Also used : Locale(java.util.Locale) IFreeplanePropertyListener(org.freeplane.core.resources.IFreeplanePropertyListener) LanguageChangeListener(com.inet.jortho.LanguageChangeListener) LanguageChangeEvent(com.inet.jortho.LanguageChangeEvent) ResourceController(org.freeplane.core.resources.ResourceController) File(java.io.File)

Aggregations

IFreeplanePropertyListener (org.freeplane.core.resources.IFreeplanePropertyListener)3 LanguageChangeEvent (com.inet.jortho.LanguageChangeEvent)1 LanguageChangeListener (com.inet.jortho.LanguageChangeListener)1 Component (java.awt.Component)1 File (java.io.File)1 Locale (java.util.Locale)1 JComponent (javax.swing.JComponent)1 ResourceController (org.freeplane.core.resources.ResourceController)1 AMapChangeListenerAdapter (org.freeplane.features.map.AMapChangeListenerAdapter)1 IMapChangeListener (org.freeplane.features.map.IMapChangeListener)1 INodeSelectionListener (org.freeplane.features.map.INodeSelectionListener)1 MapController (org.freeplane.features.map.MapController)1 NodeDeletionEvent (org.freeplane.features.map.NodeDeletionEvent)1 NodeModel (org.freeplane.features.map.NodeModel)1 NodeMoveEvent (org.freeplane.features.map.NodeMoveEvent)1 ScalableComponent (org.freeplane.view.swing.features.filepreview.ScalableComponent)1