use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class MTextController method joinNodes.
public void joinNodes(final List<NodeModel> selectedNodes, final String separator) {
if (selectedNodes.isEmpty())
return;
final NodeModel selectedNode = selectedNodes.get(0);
for (final NodeModel node : selectedNodes) {
if (node != selectedNode && node.subtreeContainsCloneOf(selectedNode)) {
UITools.errorMessage(TextUtils.getText("cannot_move_into_child_node"));
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, separator);
if (node != selectedNode) {
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
mapController.moveNodes(node.getChildren(), 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);
}
}
use of org.freeplane.features.mode.Controller 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.mode.Controller in project freeplane by freeplane.
the class FilterController method install.
public static void install() {
final Controller controller = Controller.getCurrentController();
final FilterController extension = new FilterController();
controller.addExtension(FilterController.class, extension);
controller.getExtension(HighlightController.class).addNodeHighlighter(new NodeHighlighter() {
@Override
public boolean isNodeHighlighted(NodeModel node, boolean isPrinting) {
return !isPrinting && FilterController.getController(controller).isNodeHighlighted(node);
}
@Override
public void configure(Graphics2D g, boolean isPrinting) {
g.setColor(Color.MAGENTA);
}
});
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class MapViewDockingWindows method selectMap.
private void selectMap(final int tabIndexChange) {
final Controller controller = Controller.getCurrentController();
MapView mapView = (MapView) controller.getMapViewManager().getMapViewComponent();
if (mapView != null) {
AbstractTabWindow tabWindow = (AbstractTabWindow) SwingUtilities.getAncestorOfClass(AbstractTabWindow.class, mapView);
if (tabWindow != null) {
final DockingWindow selectedWindow = tabWindow.getSelectedWindow();
final int childWindowIndex = tabWindow.getChildWindowIndex(selectedWindow);
final int childWindowCount = tabWindow.getChildWindowCount();
final int nextWindowIndex = (childWindowIndex + childWindowCount + tabIndexChange) % childWindowCount;
final View nextWindow = (View) tabWindow.getChildWindow(nextWindowIndex);
final Component nextMapView = getContainedMapView(nextWindow);
Controller.getCurrentController().getMapViewManager().changeToMapView(nextMapView);
}
}
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class BModeControllerFactory method createModeController.
public static BModeController createModeController() {
final Controller controller = Controller.getCurrentController();
modeController = new BModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MapController(modeController);
new IconController(modeController).install(modeController);
UrlManager.install(new UrlManager());
MapIO.install(modeController);
AttributeController.install(new AttributeController(modeController));
NodeStyleController.install(new NodeStyleController(modeController));
EdgeController.install(new EdgeController(modeController));
CloudController.install(new CloudController(modeController));
NoteController.install(new NoteController());
new TextController(modeController).install(modeController);
LinkController.install(new LinkController(modeController));
LogicalStyleController.install(new LogicalStyleController(modeController));
try {
ClipboardController.install(new ClipboardController());
} catch (final AccessControlException e) {
LogUtils.warn("can not access system clipboard, clipboard controller disabled");
}
LocationController.install(new LocationController());
SummaryNode.install();
FreeNode.install();
MapStyle.install(true);
final BToolbarContributor toolbarContributor = new BToolbarContributor();
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_url", toolbarContributor);
controller.getMapViewManager().addMapViewChangeListener(toolbarContributor);
userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getController(controller).getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
FoldingController.install(new FoldingController());
new ViewerController();
EncryptionController.install(new EncryptionController(modeController));
new AutomaticLayoutController();
return modeController;
}
Aggregations