use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class Slide method applySelection.
private void applySelection() {
if (selectedNodeIds.isEmpty())
return;
ArrayList<NodeModel> selectedNodes = getSelectedNodes(true);
final boolean displaysAllSlideNodes = displaysAllSlideNodes();
final boolean selectsAllVisibleNodes = displaysAllSlideNodes && showsOnlySpecificNodes && mapViewManager.isSpotlightEnabled();
final boolean replacesSelectionBySelectedNodes = !(selectsAllVisibleNodes || showsOnlySpecificNodes || selectedNodes.isEmpty());
if (!replacesSelectionBySelectedNodes && !foldsNodes() && displaysAllSlideNodes) {
for (NodeModel node : selectedNodes) {
displayOnCurrentView(node);
if (showsDescendants)
displayDescendantsOnCurrentView(node);
}
}
final IMapSelection selection = Controller.getCurrentController().getSelection();
if (replacesSelectionBySelectedNodes) {
NodeModel[] nodes = selectedNodes.toArray(new NodeModel[] {});
selection.replaceSelection(nodes);
}
if (showsOnlySpecificNodes) {
final NodeModel firstNode = selectedNodes.get(0);
selection.selectAsTheOnlyOneSelected(firstNode);
}
if (selectsAllVisibleNodes) {
if (showsAncestors) {
final NodeModel rootNode = selection.getSelected().getMap().getRootNode();
selection.selectBranch(rootNode, true);
} else
for (NodeModel node : selectedNodes) selection.selectBranch(node, true);
}
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class Slide method placeSelectedNode.
private void placeSelectedNode() {
if (placedNodeId != null) {
NodeModel placedNode = getCurrentPlacedNode();
final IMapSelection selection = Controller.getCurrentController().getSelection();
if (placedNode != null && placedNode != selection.getSelected()) {
displayOnCurrentView(placedNode);
}
final boolean slowMotion = ResourceController.getResourceController().getBooleanProperty(PRESENTATION_SLOW_MOTION_KEY, false);
if (slowMotion)
selection.slowlyMoveNodeTo(placedNode, placedNodePosition);
else
selection.moveNodeTo(placedNode, placedNodePosition);
}
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class SlideEditorController method createPlacesSelectedNodeToggleButton.
private JToggleButton createPlacesSelectedNodeToggleButton() {
final JToggleButton checkBoxOnlySpecificNodes = createToggleButtonWithIconAndLabel("PlaceSelectedNodeOnSlide.icon", "slide.placenode");
checkBoxOnlySpecificNodes.setAlignmentX(Component.CENTER_ALIGNMENT);
checkBoxOnlySpecificNodes.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String centeredNodeId = slide.getPlacedNodeId();
final IMapSelection selection = Controller.getCurrentController().getSelection();
if (centeredNodeId == null) {
final NodeModel selected = selection.getSelected();
if (selected != null) {
UndoableSlide.of(slide).setPlacedNodeId(selected.getID());
setNodePlacementControlsEnabled(true, slide.getPlacedNodePosition());
} else {
UndoableSlide.of(slide).setPlacedNodeId(null);
setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
}
} else {
UndoableSlide.of(slide).setPlacedNodeId(null);
setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
final MapModel map = Controller.getCurrentController().getMap();
final NodeModel node = map.getNodeForID(centeredNodeId);
if (node != null)
selection.selectAsTheOnlyOneSelected(node);
}
checkBoxOnlySpecificNodes.setSelected(slide.getPlacedNodeId() != null);
}
});
return checkBoxOnlySpecificNodes;
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class MoveToRootAction method actionPerformed.
public void actionPerformed(final ActionEvent event) {
Controller ctrl = Controller.getCurrentController();
final IMapSelection selection = ctrl.getSelection();
if (selection != null) {
final NodeView selectedComponent = (NodeView) ctrl.getMapViewManager().getSelectedComponent();
if (!selectedComponent.focused() && java.awt.EventQueue.getCurrentEvent() instanceof KeyEvent)
selectedComponent.requestFocusInWindow();
else
selection.selectRoot();
}
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class PersistentNodeHook method getSelectedNodes.
protected NodeModel[] getSelectedNodes() {
final IMapSelection mapSelection = Controller.getCurrentController().getSelection();
if (mapSelection != null) {
final Collection<NodeModel> selection = mapSelection.getSelection();
final int size = selection.size();
final NodeModel[] nodes = new NodeModel[size];
final Iterator<NodeModel> iterator = selection.iterator();
int i = 0;
while (iterator.hasNext()) {
nodes[i++] = iterator.next();
}
return nodes;
} else
return new NodeModel[] {};
}
Aggregations