use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class Filter method selectVisibleNode.
private void selectVisibleNode() {
final IMapSelection mapSelection = Controller.getCurrentController().getSelection();
final Collection<NodeModel> selectedNodes = mapSelection.getSelection();
final NodeModel[] array = new NodeModel[selectedNodes.size()];
boolean next = false;
for (NodeModel node : selectedNodes.toArray(array)) {
if (next) {
if (!node.isVisible()) {
mapSelection.toggleSelected(node);
}
} else
next = true;
}
NodeModel selected = mapSelection.getSelected();
if (!selected.isVisible()) {
if (mapSelection.getSelection().size() > 1) {
mapSelection.toggleSelected(selected);
} else
mapSelection.selectAsTheOnlyOneSelected(selected.getVisibleAncestorOrSelf());
}
mapSelection.setSiblingMaxLevel(mapSelection.getSelected().getNodeLevel(false));
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class FindAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final IMapSelection selection = Controller.getCurrentController().getSelection();
if (selection == null) {
return;
}
final NodeModel start = selection.getSelected();
if (editor == null) {
editor = new FilterConditionEditor(FilterController.getCurrentFilterController());
editor.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(5, 0, 5, 0)));
} else {
editor.mapChanged(start.getMap());
}
editor.addAncestorListener(new AncestorListener() {
public void ancestorAdded(final AncestorEvent event) {
final Component component = event.getComponent();
final Window windowAncestor = SwingUtilities.getWindowAncestor(component);
if (windowAncestor.isFocused())
editor.focusInputField(true);
else {
windowAncestor.addWindowFocusListener(new WindowFocusListener() {
public void windowLostFocus(WindowEvent e) {
}
public void windowGainedFocus(WindowEvent e) {
windowAncestor.removeWindowFocusListener(this);
editor.focusInputField(true);
}
});
windowAncestor.toFront();
}
editor.removeAncestorListener(this);
}
public void ancestorMoved(final AncestorEvent event) {
}
public void ancestorRemoved(final AncestorEvent event) {
}
});
final int run = UITools.showConfirmDialog(start, editor, TextUtils.getText("FindAction.text"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
final Container parent = editor.getParent();
if (parent != null) {
parent.remove(editor);
}
if (run != JOptionPane.OK_OPTION) {
return;
}
final ASelectableCondition condition = editor.getCondition();
findFirst(condition);
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class QuickFindAllAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ASelectableCondition condition = filterEditor.getCondition();
if (condition == null) {
return;
}
final IMapSelection selection = Controller.getCurrentController().getSelection();
final MapController mapController = Controller.getCurrentModeController().getMapController();
final NodeModel selected = selection.getSelected();
final NodeModel rootNode = selected.getMap().getRootNode();
boolean nodeFound = condition.checkNode(rootNode);
if (nodeFound) {
selection.selectAsTheOnlyOneSelected(rootNode);
}
NodeModel next = rootNode;
for (; ; ) {
next = filterController.findNext(next, rootNode, Direction.FORWARD, condition);
if (next == null) {
break;
}
mapController.displayNode(next);
if (nodeFound) {
selection.toggleSelected(next);
} else {
selection.selectAsTheOnlyOneSelected(next);
nodeFound = true;
}
}
if (condition.checkNode(selected))
selection.makeTheSelected(selected);
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class QuickFindAction method executeAction.
public void executeAction(final boolean reFocusSearchInputField) {
final ASelectableCondition condition = filterEditor.getCondition();
if (condition == null) {
return;
}
final IMapSelection selection = Controller.getCurrentController().getSelection();
if (selection == null) {
return;
}
final NodeModel selected = selection.getSelected();
final NodeModel next;
try {
filterEditor.setSearchingBusyCursor();
next = filterController.findNext(selected, null, direction, condition);
} finally {
filterEditor.setSearchingDefaultCursor();
}
if (next != null) {
final MapController mapController = Controller.getCurrentModeController().getMapController();
mapController.displayNode(next);
selection.selectAsTheOnlyOneSelected(next);
if (reFocusSearchInputField) {
// this is called by Enter key listener in FilterConditionEditor
// => we want to re-focus the search term input field so that one can hit enter
// again to find the next search result!
filterEditor.focusInputField(false);
}
}
}
use of org.freeplane.features.map.IMapSelection 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