use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class UrlManager method loadURL.
/**
*@deprecated -- use LinkController
*/
@Deprecated
public void loadURL(URI uri) {
final String uriString = uri.toString();
if (uriString.startsWith("#")) {
final String target = uri.getFragment();
try {
final ModeController modeController = Controller.getCurrentModeController();
final MapController mapController = modeController.getMapController();
final NodeModel node = mapController.getNodeFromID(target);
if (node != null) {
mapController.select(node);
}
} catch (final Exception e) {
LogUtils.warn("link " + target + " not found", e);
UITools.errorMessage(TextUtils.format("link_not_found", target));
}
return;
}
try {
final String extension = FileUtils.getExtension(uri.getRawPath());
if (!uri.isAbsolute()) {
URI absoluteUri = getAbsoluteUri(uri);
if (absoluteUri == null) {
final MapModel map = Controller.getCurrentController().getMap();
if (map.getURL() == null)
UITools.errorMessage(TextUtils.getText("map_not_saved"));
else
UITools.errorMessage(TextUtils.format("link_not_found", String.valueOf(uri)));
return;
}
uri = absoluteUri;
}
// DOCEAR: mindmaps can be linked in a mindmap --> therefore project-relative-paths are possible
if (!asList(FILE_SCHEME, SMB_SCHEME, FREEPLANE_SCHEME).contains(uri.getScheme())) {
try {
uri = uri.toURL().openConnection().getURL().toURI().normalize();
} catch (Exception e) {
LogUtils.warn("link " + uri + " not found", e);
UITools.errorMessage(TextUtils.format("link_not_found", uri.toString()));
}
}
try {
if ((extension != null) && extension.equals(UrlManager.FREEPLANE_FILE_EXTENSION_WITHOUT_DOT)) {
FreeplaneUriConverter freeplaneUriConverter = new FreeplaneUriConverter();
final URL url = freeplaneUriConverter.freeplaneUrl(uri);
final ModeController modeController = Controller.getCurrentModeController();
modeController.getMapController().newMap(url);
final String ref = uri.getFragment();
if (ref != null) {
final ModeController newModeController = Controller.getCurrentModeController();
final MapController newMapController = newModeController.getMapController();
newMapController.select(newMapController.getNodeFromID(ref));
}
return;
}
Controller.getCurrentController().getViewController().openDocument(uri);
} catch (final Exception e) {
LogUtils.warn("link " + uri + " not found", e);
UITools.errorMessage(TextUtils.format("link_not_found", uri.toString()));
}
return;
} catch (final MalformedURLException ex) {
LogUtils.warn("URL " + uriString + " not found", ex);
UITools.errorMessage(TextUtils.format("link_not_found", uriString));
}
}
use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class NextPresentationItemAction method actionPerformed.
/**
*/
public void actionPerformed(final ActionEvent e) {
final FilterController filterController = FilterController.getCurrentFilterController();
final NodeModel start = Controller.getCurrentController().getSelection().getSelected();
final NodeModel next = filterController.findNext(start, null, Direction.FORWARD_N_FOLD, null);
if (next != null) {
final MapController mapController = Controller.getCurrentModeController().getMapController();
if (!next.isVisible()) {
next.getFilterInfo().reset();
mapController.nodeRefresh(next);
}
final NodeModel[] path = next.getPathToRoot();
for (int i = 1; i < path.length; i++) {
final NodeModel nodeOnPath = path[i];
final NodeModel parentNode = nodeOnPath.getParentNode();
while (parentNode.isFolded() || nodeOnPath.containsExtension(HideChildSubtree.class)) mapController.showNextChild(parentNode);
}
Controller.getCurrentController().getSelection().selectAsTheOnlyOneSelected(next);
}
}
use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class MCloudController method setCloud.
public void setCloud(final NodeModel node, final boolean enable) {
final CloudModel cloud = CloudModel.getModel(node);
if ((cloud != null) == enable) {
return;
}
final Color color = cloud != null ? cloud.getColor() : CloudController.getStandardColor();
final ModeController modeController = Controller.getCurrentModeController();
final IActor actor = new IActor() {
public void act() {
if (enable) {
enable();
} else {
disable();
}
}
private void disable() {
final MapController mapController = modeController.getMapController();
CloudModel.setModel(node, null);
mapController.nodeChanged(node);
}
private void enable() {
final CloudModel cloud = new CloudModel();
cloud.setColor(color);
final MapController mapController = modeController.getMapController();
CloudModel.setModel(node, cloud);
mapController.nodeChanged(node);
}
public String getDescription() {
return "setCloud";
}
public void undo() {
if (enable) {
disable();
} else {
enable();
}
}
};
modeController.execute(actor, node.getMap());
}
use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class MLogicalStyleController method initM.
public void initM() {
final ModeController modeController = Controller.getCurrentModeController();
modeController.getMapController().addNodeChangeListener(new StyleRemover());
modeController.registerExtensionCopier(new ExtensionCopier());
modeController.addAction(new RedefineStyleAction());
modeController.addAction(new NewUserStyleAction());
modeController.addAction(new ManageMapConditionalStylesAction());
modeController.addAction(new ManageNodeConditionalStylesAction());
modeController.addAction(new CopyStyleExtensionsAction());
if (modeController.getModeName().equals("MindMap")) {
modeController.addAction(new MapBackgroundColorAction());
modeController.addAction(new MapBackgroundImageAction());
modeController.addAction(new MapBackgroundClearAction());
modeController.addAction(new SetBooleanMapPropertyAction(MapStyle.FIT_TO_VIEWPORT));
modeController.addAction(new CopyMapStylesAction());
}
if (!modeController.getController().getViewController().isHeadless()) {
final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
final MenuBuilder menuBuilder = userInputListenerFactory.getMenuBuilder(MenuBuilder.class);
// TODO RIBBONS - apply to ribbons as well
Controller.getCurrentController().getMapViewManager().addMapSelectionListener(new IMapSelectionListener() {
public void beforeMapChange(final MapModel oldMap, final MapModel newMap) {
removeStyleMenu(menuBuilder, "main_menu_styles");
removeStyleMenu(menuBuilder, "node_popup_styles");
}
public void afterMapChange(final MapModel oldMap, final MapModel newMap) {
addStyleMenu(menuBuilder, "main_menu_styles", newMap);
addStyleMenu(menuBuilder, "node_popup_styles", newMap);
}
});
final MapController mapController = modeController.getMapController();
mapController.addMapChangeListener(new IMapChangeListener() {
public void onPreNodeMoved(final NodeModel oldParent, final int oldIndex, final NodeModel newParent, final NodeModel child, final int newIndex) {
}
public void onPreNodeDelete(final NodeModel oldParent, final NodeModel selectedNode, final int index) {
}
public void onNodeMoved(final NodeModel oldParent, final int oldIndex, final NodeModel newParent, final NodeModel child, final int newIndex) {
}
public void onNodeInserted(final NodeModel parent, final NodeModel child, final int newIndex) {
}
public void onNodeDeleted(final NodeModel parent, final NodeModel child, final int index) {
}
public void mapChanged(final MapChangeEvent event) {
if (event.getProperty().equals(MapStyle.MAP_STYLES)) {
removeStyleMenu(menuBuilder, "main_menu_styles");
addStyleMenu(menuBuilder, "main_menu_styles", event.getMap());
removeStyleMenu(menuBuilder, "node_popup_styles");
addStyleMenu(menuBuilder, "node_popup_styles", event.getMap());
}
}
});
mapController.addNodeSelectionListener(new INodeSelectionListener() {
public void onSelect(final NodeModel node) {
selectActions();
}
public void onDeselect(final NodeModel node) {
}
});
}
}
use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class MTextController method joinNodes.
public void joinNodes(final List<NodeModel> selectedNodes) {
if (selectedNodes.isEmpty())
return;
final NodeModel selectedNode = selectedNodes.get(0);
final NodeModel parentNode = selectedNode.getParentNode();
for (final NodeModel node : selectedNodes) {
if (node.getParentNode() != parentNode) {
UITools.errorMessage(TextUtils.getText("cannot_add_parent_diff_parents"));
return;
}
}
String joinedContent = "";
final Controller controller = Controller.getCurrentController();
boolean isHtml = false;
final LinkedHashSet<MindIcon> icons = new LinkedHashSet<MindIcon>();
for (final NodeModel node : selectedNodes) {
final String nodeContent = node.getText();
icons.addAll(node.getIcons());
final boolean isHtmlNode = HtmlUtils.isHtmlNode(nodeContent);
joinedContent = addContent(joinedContent, isHtml, nodeContent, isHtmlNode);
if (node != selectedNode) {
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
for (final NodeModel child : node.getChildren().toArray(new NodeModel[] {})) {
mapController.moveNode(child, selectedNode, selectedNode.getChildCount());
}
mapController.deleteNode(node);
}
isHtml = isHtml || isHtmlNode;
}
controller.getSelection().selectAsTheOnlyOneSelected(selectedNode);
setNodeText(selectedNode, joinedContent);
final MIconController iconController = (MIconController) IconController.getController();
iconController.removeAllIcons(selectedNode);
for (final MindIcon icon : icons) {
iconController.addIcon(selectedNode, icon);
}
}
Aggregations