Search in sources :

Example 6 with INodeChangeListener

use of org.freeplane.features.map.INodeChangeListener in project freeplane by freeplane.

the class StyleEditorPanel method addListeners.

private void addListeners() {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    mapController.addNodeSelectionListener(new INodeSelectionListener() {

        public void onSelect(final NodeModel node) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            if (selection.size() == 1) {
                setComponentsEnabled(true);
                setStyle(node);
            }
        }

        public void setComponentsEnabled(boolean enabled) {
            final Container panel = (Container) getComponent(0);
            for (int i = 0; i < panel.getComponentCount(); i++) {
                panel.getComponent(i).setEnabled(enabled);
            }
        }

        public void onDeselect(final NodeModel node) {
            setComponentsEnabled(false);
        }
    });
    mapController.addNodeChangeListener(new INodeChangeListener() {

        public void nodeChanged(final NodeChangeEvent event) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            final NodeModel node = event.getNode();
            if (selection.getSelected().equals(node)) {
                setStyle(node);
            }
        }
    });
    mapController.addMapChangeListener(new AMapChangeListenerAdapter() {

        @Override
        public void mapChanged(MapChangeEvent event) {
            if (!MapStyle.MAP_STYLES.equals(event.getProperty()))
                return;
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            final NodeModel node = selection.getSelected();
            setStyle(node);
        }
    });
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) IMapSelection(org.freeplane.features.map.IMapSelection) ModeController(org.freeplane.features.mode.ModeController) MapController(org.freeplane.features.map.MapController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) AMapChangeListenerAdapter(org.freeplane.features.map.AMapChangeListenerAdapter) MapController(org.freeplane.features.map.MapController) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) Container(java.awt.Container) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) MapChangeEvent(org.freeplane.features.map.MapChangeEvent)

Example 7 with INodeChangeListener

use of org.freeplane.features.map.INodeChangeListener in project freeplane by freeplane.

the class StyleEditorPanel method addListeners.

private void addListeners() {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    mapController.addNodeSelectionListener(new INodeSelectionListener() {

        public void onSelect(final NodeModel node) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            if (selection.size() == 1) {
                setStyle(node);
            }
        }

        public void onDeselect(final NodeModel node) {
        }
    });
    mapController.addNodeChangeListener(new INodeChangeListener() {

        public void nodeChanged(final NodeChangeEvent event) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            final NodeModel node = event.getNode();
            if (selection.getSelected().equals(node)) {
                setStyle(node);
            }
        }
    });
    mapController.addMapChangeListener(new AMapChangeListenerAdapter() {

        @Override
        public void mapChanged(MapChangeEvent event) {
            if (!MapStyle.MAP_STYLES.equals(event.getProperty()))
                return;
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            final NodeModel node = selection.getSelected();
            setStyle(node);
        }
    });
    final IMapViewManager mapViewManager = controller.getMapViewManager();
    mapViewManager.addMapViewChangeListener(new IMapViewChangeListener() {

        public void beforeViewChange(final Component oldView, final Component newView) {
        }

        public void afterViewCreated(final Component mapView) {
        }

        public void afterViewClose(final Component oldView) {
        }

        public void afterViewChange(final Component oldView, final Component newView) {
            final Container panel = (Container) getComponent(0);
            for (int i = 0; i < panel.getComponentCount(); i++) {
                panel.getComponent(i).setEnabled(newView != null);
            }
        }
    });
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) IMapViewChangeListener(org.freeplane.features.ui.IMapViewChangeListener) IMapSelection(org.freeplane.features.map.IMapSelection) ModeController(org.freeplane.features.mode.ModeController) EdgeController(org.freeplane.features.edge.EdgeController) MapController(org.freeplane.features.map.MapController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController) FormatController(org.freeplane.features.format.FormatController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ResourceController(org.freeplane.core.resources.ResourceController) CloudController(org.freeplane.features.cloud.CloudController) LinkController(org.freeplane.features.link.LinkController) MCloudController(org.freeplane.features.cloud.mindmapmode.MCloudController) ModeController(org.freeplane.features.mode.ModeController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) AMapChangeListenerAdapter(org.freeplane.features.map.AMapChangeListenerAdapter) MapController(org.freeplane.features.map.MapController) IMapViewManager(org.freeplane.features.ui.IMapViewManager) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) Container(java.awt.Container) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) MapChangeEvent(org.freeplane.features.map.MapChangeEvent) Component(java.awt.Component)

Example 8 with INodeChangeListener

use of org.freeplane.features.map.INodeChangeListener in project freeplane by freeplane.

the class TimeManagement method showDialog.

void showDialog() {
    if (TimeManagement.sCurrentlyOpenTimeManagement != null) {
        TimeManagement.sCurrentlyOpenTimeManagement.dialog.getContentPane().setVisible(true);
        return;
    }
    TimeManagement.sCurrentlyOpenTimeManagement = this;
    dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), false);
    final JTimePanel timePanel = createTimePanel(dialog, true, 4);
    nodeSelectionListener = new INodeSelectionListener() {

        public void onSelect(NodeModel node) {
            timePanel.update(node);
        }

        public void onDeselect(NodeModel node) {
        }
    };
    getMindMapController().getMapController().addNodeSelectionListener(nodeSelectionListener);
    nodeChangeListener = new INodeChangeListener() {

        public void nodeChanged(NodeChangeEvent event) {
            final NodeModel node = event.getNode();
            if (event.getProperty().equals(ReminderExtension.class) && node.equals(getMindMapController().getMapController().getSelectedNode()))
                timePanel.update(node);
        }
    };
    getMindMapController().getMapController().addNodeChangeListener(nodeChangeListener);
    dialog.setTitle(getResourceString("plugins/TimeManagement.xml_WindowTitle"));
    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent event) {
            disposeDialog();
        }
    });
    final Action action = new AbstractAction() {

        /**
         */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent arg0) {
            disposeDialog();
        }
    };
    UITools.addEscapeActionToDialog(dialog, action);
    dialog.setContentPane(timePanel);
    dialog.pack();
    UITools.setBounds(dialog, -1, -1, dialog.getWidth(), dialog.getHeight());
    dialog.setVisible(true);
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) AbstractAction(javax.swing.AbstractAction) JDialog(javax.swing.JDialog)

Aggregations

INodeChangeListener (org.freeplane.features.map.INodeChangeListener)8 NodeChangeEvent (org.freeplane.features.map.NodeChangeEvent)8 NodeModel (org.freeplane.features.map.NodeModel)8 INodeSelectionListener (org.freeplane.features.map.INodeSelectionListener)5 MapChangeEvent (org.freeplane.features.map.MapChangeEvent)4 MapController (org.freeplane.features.map.MapController)4 ModeController (org.freeplane.features.mode.ModeController)4 IMapSelection (org.freeplane.features.map.IMapSelection)3 Controller (org.freeplane.features.mode.Controller)3 Container (java.awt.Container)2 JScrollPane (javax.swing.JScrollPane)2 ResourceController (org.freeplane.core.resources.ResourceController)2 CloudController (org.freeplane.features.cloud.CloudController)2 MCloudController (org.freeplane.features.cloud.mindmapmode.MCloudController)2 EdgeController (org.freeplane.features.edge.EdgeController)2 MEdgeController (org.freeplane.features.edge.mindmapmode.MEdgeController)2 FormatController (org.freeplane.features.format.FormatController)2 LinkController (org.freeplane.features.link.LinkController)2 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)2 AMapChangeListenerAdapter (org.freeplane.features.map.AMapChangeListenerAdapter)2