use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class MMapController method setFoldingState.
@Override
protected void setFoldingState(final NodeModel node, final boolean folded) {
final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
final boolean wasFolded = mapViewManager.isFoldedOnCurrentView(node);
if (wasFolded == folded && mapViewManager.getComponent(node) == null)
return;
if (isFoldingPersistent()) {
IActor foldingActor = new IActor() {
@Override
public void undo() {
unfoldHiddenChildren(node);
MMapController.super.setFoldingState(node, wasFolded);
}
@Override
public String getDescription() {
return "setFoldingState";
}
@Override
public void act() {
unfoldHiddenChildren(node);
MMapController.super.setFoldingState(node, folded);
}
};
getMModeController().execute(foldingActor, node.getMap());
} else
super.setFoldingState(node, folded);
}
use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class LastOpenedList method afterViewChange.
public void afterViewChange(final Component oldView, final Component newView) {
if (newView == null) {
updateMenus();
return;
}
final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
final MapModel map = mapViewManager.getModel(newView);
final String restoreString = getRestoreable(map);
updateList(map, restoreString);
}
use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class ImportLinkedBranchAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final MapModel map = Controller.getCurrentController().getMap();
final ModeController modeController = Controller.getCurrentModeController();
final NodeModel selected = modeController.getMapController().getSelectedNode();
final IMapViewManager viewController = Controller.getCurrentController().getMapViewManager();
if (selected == null || NodeLinks.getLink(selected) == null) {
JOptionPane.showMessageDialog((viewController.getMapViewComponent()), TextUtils.getText("import_linked_branch_no_link"));
return;
}
final URI uri = NodeLinks.getLink(selected);
try {
final File file = uri.isAbsolute() && !uri.isOpaque() ? new File(uri) : new File(new URL(map.getURL(), uri.getPath()).getFile());
final NodeModel node = ((MFileManager) UrlManager.getController()).loadTree(map, file);
PersistentNodeHook.removeMapExtensions(node);
((MMapController) modeController.getMapController()).insertNode(node, selected);
((MLinkController) LinkController.getController()).setLink(selected, (URI) null, LinkController.LINK_ABSOLUTE);
((MLinkController) LinkController.getController()).setLink(node, (URI) null, LinkController.LINK_ABSOLUTE);
} catch (final MalformedURLException ex) {
UITools.errorMessage(TextUtils.format("invalid_url_msg", uri.toString()));
LogUtils.warn(ex);
return;
} catch (final IllegalArgumentException ex) {
UITools.errorMessage(TextUtils.format("invalid_file_msg", uri.toString()));
LogUtils.warn(ex);
return;
} catch (final Exception ex) {
UrlManager.getController().handleLoadingException(ex);
}
}
use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class MapProxy method close.
// Map: R/W
public boolean close(boolean force, boolean allowInteraction) {
if (!getDelegate().isSaved() && !force && !allowInteraction)
throw new RuntimeException("will not close an unsaved map without being told so");
final IMapViewManager mapViewManager = getMapViewManager();
changeToThisMap(mapViewManager);
return mapViewManager.close(force);
}
use of org.freeplane.features.ui.IMapViewManager 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);
}
}
});
}
Aggregations