use of org.freeplane.core.ui.ControllerPopupMenuListener in project freeplane by freeplane.
the class DefaultMapMouseListener method handlePopup.
protected void handlePopup(final MouseEvent e) {
if (e.isPopupTrigger()) {
Component popup = null;
final Component popupForModel;
final MapView mapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
final ModeController modeController = Controller.getCurrentController().getModeController();
if (mapView != null) {
final java.lang.Object obj = mapView.detectCollision(e.getPoint());
popupForModel = LinkController.getController(modeController).getPopupForModel(obj);
} else {
popupForModel = null;
}
if (popupForModel != null) {
final ControllerPopupMenuListener popupListener = new ControllerPopupMenuListener();
popupForModel.addHierarchyListener(popupListener);
popup = popupForModel;
} else {
popup = modeController.getUserInputListenerFactory().getMapPopup();
}
Component component = e.getComponent();
if (popup instanceof JPopupMenu) {
((JPopupMenu) popup).show(component, e.getX(), e.getY());
} else {
Point locationOnScreen = component.getLocationOnScreen();
final Component window;
if (popup instanceof Window) {
window = popup;
} else {
final Frame frame = UITools.getFrame();
final JDialog d = new JDialog(frame, popup.getName());
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.setModal(false);
d.add(popup);
d.pack();
d.addWindowFocusListener(new WindowFocusListener() {
public void windowLostFocus(WindowEvent e) {
}
public void windowGainedFocus(WindowEvent e) {
frame.addWindowFocusListener(new WindowFocusListener() {
public void windowLostFocus(WindowEvent e) {
}
public void windowGainedFocus(WindowEvent e) {
d.setVisible(false);
frame.removeWindowFocusListener(this);
}
});
d.removeWindowFocusListener(this);
}
});
window = d;
}
window.setLocation(locationOnScreen.x + e.getX(), locationOnScreen.y + e.getY());
window.setVisible(true);
}
}
}
use of org.freeplane.core.ui.ControllerPopupMenuListener 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());
}
}
}
Aggregations