use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class DefaultNodeMouseMotionListener method mouseClicked.
public void mouseClicked(final MouseEvent e) {
final ModeController mc = Controller.getCurrentController().getModeController();
if (Compat.isMacOsX()) {
final JPopupMenu popupmenu = mc.getUserInputListenerFactory().getNodePopupMenu();
if (popupmenu.isShowing()) {
return;
}
}
final MainView component = (MainView) e.getComponent();
NodeView nodeView = component.getNodeView();
if (nodeView == null)
return;
final NodeModel node = nodeView.getModel();
final boolean plainEvent = Compat.isPlainEvent(e);
final boolean inside = nodeSelector.isInside(e);
final MapController mapController = mc.getMapController();
if (e.getButton() == 1) {
if (plainEvent) {
if (component.isInFollowLinkRegion(e.getX())) {
LinkController.getController(mc).loadURL(node, e);
e.consume();
return;
}
final String link = component.getLink(e.getPoint());
if (link != null) {
doubleClickTimer.start(new Runnable() {
public void run() {
loadLink(link);
}
});
e.consume();
return;
}
if (inside && e.getClickCount() == 1 && ResourceController.getResourceController().getBooleanProperty(FOLD_ON_CLICK_INSIDE)) {
final boolean fold = FoldingMark.UNFOLDED.equals(component.foldingMarkType(mapController, node)) && !mapController.hasHiddenChildren(node);
if (!nodeSelector.shouldSelectOnClick(e)) {
doubleClickTimer.start(new Runnable() {
public void run() {
mapController.setFolded(node, fold);
}
});
}
}
} else if (Compat.isShiftEvent(e)) {
if (isInFoldingRegion(e)) {
if (!mapController.showNextChild(node))
mapController.setFolded(node, true);
e.consume();
}
}
}
final boolean inFoldingRegion = isInFoldingRegion(e);
if ((plainEvent && inFoldingRegion || (inFoldingRegion || inside) && Compat.isCtrlShiftEvent(e)) && !nodeSelector.shouldSelectOnClick(e)) {
boolean fold = FoldingMark.UNFOLDED.equals(component.foldingMarkType(mapController, node)) && !mapController.hasHiddenChildren(node);
doubleClickTimer.cancel();
mapController.setFolded(node, fold);
e.consume();
return;
}
if (inside && e.getButton() == 1 && !e.isAltDown())
nodeSelector.extendSelection(e);
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class NodePopupMenuDisplayer method showNodePopupMenu.
public void showNodePopupMenu(final MouseEvent e) {
if (e.isPopupTrigger()) {
ModeController mc = Controller.getCurrentController().getModeController();
final NodeView nodeView = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, e.getComponent());
if (nodeView == null)
return;
if (!nodeView.isSelected()) {
Controller.getCurrentController().getSelection().selectAsTheOnlyOneSelected(nodeView.getModel());
}
final JPopupMenu popupmenu = mc.getUserInputListenerFactory().getNodePopupMenu();
new NodePopupMenuDisplayer().showMenuAndConsumeEvent(popupmenu, e);
}
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class DefaultNodeKeyListener method keyPressed.
public void keyPressed(final KeyEvent e) {
final boolean checkForScrollMap = e.isShiftDown() && e.isControlDown() && e.isAltDown();
final MapView mapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
if (mapView == null || SwingUtilities.isDescendingFrom(mapView, e.getComponent()))
return;
if (checkForScrollMap) {
switch(e.getKeyCode()) {
case KeyEvent.VK_UP:
mapView.scrollBy(0, -10);
e.consume();
return;
case KeyEvent.VK_DOWN:
mapView.scrollBy(0, 10);
e.consume();
return;
case KeyEvent.VK_LEFT:
mapView.scrollBy(-10, 0);
e.consume();
return;
case KeyEvent.VK_RIGHT:
mapView.scrollBy(10, 0);
e.consume();
}
return;
}
if ((e.isAltDown() || e.isControlDown() || e.isMetaDown())) {
return;
}
switch(e.getKeyCode()) {
case KeyEvent.VK_ENTER:
case KeyEvent.VK_ESCAPE:
case KeyEvent.VK_SHIFT:
case KeyEvent.VK_DELETE:
case KeyEvent.VK_SPACE:
case KeyEvent.VK_INSERT:
case KeyEvent.VK_TAB:
return;
}
final boolean continious = e.isShiftDown();
switch(e.getKeyCode()) {
case KeyEvent.VK_UP:
if (mapView.selectUp(continious))
e.consume();
return;
case KeyEvent.VK_DOWN:
if (mapView.selectDown(continious))
e.consume();
return;
case KeyEvent.VK_LEFT:
if (mapView.selectLeft(continious))
e.consume();
return;
case KeyEvent.VK_RIGHT:
if (mapView.selectRight(continious))
e.consume();
return;
case KeyEvent.VK_PAGE_UP:
if (mapView.selectPageUp(continious))
e.consume();
return;
case KeyEvent.VK_PAGE_DOWN:
if (mapView.selectPageDown(continious))
e.consume();
return;
case KeyEvent.VK_HOME:
case KeyEvent.VK_END:
case KeyEvent.VK_BACK_SPACE:
if (editHandler != null) {
editHandler.edit(e, FirstAction.EDIT_CURRENT, false);
}
return;
case KeyEvent.VK_CONTEXT_MENU:
final ModeController modeController = Controller.getCurrentModeController();
final NodeModel node = Controller.getCurrentModeController().getMapController().getSelectedNode();
final NodeView nodeView = mapView.getNodeView(node);
final JPopupMenu popupmenu = modeController.getUserInputListenerFactory().getNodePopupMenu();
if (popupmenu != null) {
popupmenu.addHierarchyListener(new ControllerPopupMenuListener());
final MainView mainView = nodeView.getMainView();
popupmenu.show(mainView, mainView.getX(), mainView.getY());
}
}
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class NodeSelector method extendSelection.
public void extendSelection(final MouseEvent e) {
final Controller controller = Controller.getCurrentController();
final NodeView nodeView = getRelatedNodeView(e);
final NodeModel newlySelectedNode = nodeView.getModel();
final boolean extend = Compat.isMacOsX() ? e.isMetaDown() : e.isControlDown();
final boolean range = e.isShiftDown();
final IMapSelection selection = controller.getSelection();
if (range && !extend) {
selection.selectContinuous(newlySelectedNode);
} else if (extend && !range) {
selection.toggleSelected(newlySelectedNode);
}
if (extend == range) {
if (selection.isSelected(newlySelectedNode) && selection.size() == 1 && FocusManager.getCurrentManager().getFocusOwner() instanceof MainView)
return;
else {
selection.selectAsTheOnlyOneSelected(newlySelectedNode);
}
e.consume();
}
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class ConnectorView method getModeController.
private ModeController getModeController() {
NodeView nodeView = source;
if (source == null) {
nodeView = target;
}
final MapView mapView = nodeView.getMap();
return mapView.getModeController();
}
Aggregations