use of org.freeplane.features.map.NodeChangeEvent in project freeplane by freeplane.
the class LogicalStyleController method registerChangeListener.
private void registerChangeListener() {
ModeController modeController = Controller.getCurrentModeController();
final MapController mapController = modeController.getMapController();
mapController.addMapChangeListener(new IMapChangeListener() {
public void onPreNodeMoved(NodeMoveEvent nodeMoveEvent) {
clearCache();
}
public void onPreNodeDelete(NodeDeletionEvent nodeDeletionEvent) {
clearCache();
}
public void onNodeMoved(NodeMoveEvent nodeMoveEvent) {
clearCache();
}
public void onNodeInserted(NodeModel parent, NodeModel child, int newIndex) {
clearCache();
}
public void onNodeDeleted(NodeDeletionEvent nodeDeletionEvent) {
clearCache();
}
public void mapChanged(MapChangeEvent event) {
clearCache();
}
});
mapController.addNodeChangeListener(new INodeChangeListener() {
public void nodeChanged(NodeChangeEvent event) {
clearCache();
}
});
}
use of org.freeplane.features.map.NodeChangeEvent in project freeplane by freeplane.
the class SModeControllerFactory method createController.
Controller createController(final JDialog dialog) {
Controller currentController = Controller.getCurrentController();
final Controller controller = new Controller(ResourceController.getResourceController());
Controller.setCurrentController(controller);
final MapViewController mapViewController = new MMapViewController(controller);
final DialogController viewController = new DialogController(controller, mapViewController, dialog);
controller.setViewController(viewController);
controller.addExtension(HighlightController.class, new HighlightController());
controller.addAction(currentController.getAction("AboutAction"));
FilterController.install();
TextController.install();
controller.addAction(new ViewLayoutTypeAction(MapViewLayout.OUTLINE));
controller.addAction(new ShowSelectionAsRectangleAction());
modeController = new SModeController(controller);
controller.selectModeForBuild(modeController);
modeController.addAction(new NewUserStyleAction());
modeController.addAction(new DeleteUserStyleAction());
modeController.addAction(new NewLevelStyleAction());
modeController.addAction(new DeleteLevelStyleAction());
modeController.addAction(new SetAcceleratorOnNextClickAction());
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
userInputListenerFactory.setNodeMouseMotionListener(new DefaultNodeMouseMotionListener());
userInputListenerFactory.setNodeMouseWheelListener(new MNodeMouseWheelListener(userInputListenerFactory.getMapMouseWheelListener()));
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addExtension(ModelessAttributeController.class, new ModelessAttributeController());
new MMapController(modeController);
ModelessAttributeController.installConditions();
new MTextController(modeController).install(modeController);
SpellCheckerController.install(modeController);
new MIconController(modeController).install(modeController);
NodeStyleController.install(new MNodeStyleController(modeController));
LocationController.install(new MLocationController());
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
LinkController.install(new MLinkController(modeController));
MFileManager.install(new MFileManager());
MMapIO.install(modeController);
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
logicalStyleController.initS();
LogicalStyleController.install(logicalStyleController);
AttributeController.install(new MAttributeController(modeController));
FormatController.install(new FormatController());
IconController.installConditionControllers();
final ScannerController scannerController = new ScannerController();
ScannerController.install(scannerController);
scannerController.addParsersForStandardFormats();
modeController.addAction(new EditAttributesAction());
userInputListenerFactory.setMapMouseListener(new MMapMouseListener());
final JPopupMenu popupmenu = new JPopupMenu();
userInputListenerFactory.setNodePopupMenu(popupmenu);
final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
UIComponentVisibilityDispatcher.install(viewController, toolBar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
userInputListenerFactory.addToolBar("/icon_toolbar", ViewController.LEFT, ((MIconController) IconController.getController()).getIconToolBarScrollPane());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
modeController.addAction(new ToggleToolbarAction("ToggleLeftToolbarAction", "/icon_toolbar"));
MapStyle.install(false);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
if (extentionInstaller != null)
extentionInstaller.installExtensions(controller);
final SModeController modeController = this.modeController;
final StyleEditorPanel styleEditorPanel = new StyleEditorPanel(modeController, null, false);
modeController.addAction(new ShowFormatPanelAction());
final MapController mapController = modeController.getMapController();
mapController.addNodeSelectionListener(new INodeSelectionListener() {
@Override
public void onSelect(final NodeModel node) {
final IMapSelection selection = controller.getSelection();
if (selection == null) {
return;
}
if (selection.size() == 1 && node.depth() >= 2) {
return;
}
final NodeModel nextSelection;
if (node.depth() < 2) {
if (node.depth() == 1 && node.hasChildren()) {
nextSelection = node.getChildAt(0);
} else {
nextSelection = (node.getMap().getRootNode().getChildAt(0).getChildAt(0));
}
} else {
nextSelection = node;
}
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
selection.selectAsTheOnlyOneSelected(nextSelection);
}
});
}
@Override
public void onDeselect(final NodeModel node) {
}
});
mapController.addNodeChangeListener(new INodeChangeListener() {
@Override
public void nodeChanged(NodeChangeEvent event) {
final NodeModel node = event.getNode();
if (node.getUserObject().equals(MapStyleModel.DEFAULT_STYLE)) {
mapController.fireMapChanged(new MapChangeEvent(this, node.getMap(), MapStyle.MAP_STYLES, null, null));
}
}
});
final JScrollPane styleScrollPane = new JScrollPane(styleEditorPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
UITools.setScrollbarIncrement(styleScrollPane);
// styleEditorPanel.setPreferredSize(new Dimension(200, 200));
userInputListenerFactory.addToolBar("/format", ViewController.RIGHT, styleScrollPane);
UIComponentVisibilityDispatcher.install(viewController, styleScrollPane, "styleScrollPaneVisible");
modeController.addExtension(MUIFactory.class, new MUIFactory());
final Set<String> emptySet = Collections.emptySet();
modeController.updateMenus("/xml/stylemodemenu.xml", emptySet);
this.modeController = null;
return controller;
}
use of org.freeplane.features.map.NodeChangeEvent 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);
}
});
}
use of org.freeplane.features.map.NodeChangeEvent 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(UITools.getCurrentFrame(), 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);
}
Aggregations