use of org.freeplane.view.swing.map.MainView 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.MainView in project freeplane by freeplane.
the class GlassPaneNodeSelector method mouseClicked.
public void mouseClicked(MouseEvent e) {
if (e.getButton() != 1) {
return;
}
final Component component = findMapComponent(e);
if (!(component instanceof MainView)) {
return;
}
MainView mainView = (MainView) component;
final NodeModel model = mainView.getNodeView().getModel();
switch(e.getClickCount()) {
case 1:
final MapController mapController = Controller.getCurrentModeController().getMapController();
mapController.setFolded(model, !model.isFolded());
break;
case 2:
nodeSelector.nodeSelected(model);
break;
}
}
use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.
the class GlassPaneNodeSelector method findMapComponent.
// A basic implementation of redispatching events.
private Component findMapComponent(MouseEvent e) {
final Component glassPane = e.getComponent();
final Point glassPanePoint = e.getPoint();
final Container container = SwingUtilities.getRootPane(glassPane).getContentPane();
Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, container);
Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);
if (component instanceof MainView || component instanceof MapView || component instanceof JScrollBar) {
return component;
}
return SwingUtilities.getAncestorOfClass(MapView.class, component);
}
use of org.freeplane.view.swing.map.MainView 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.MainView 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();
}
}
Aggregations