use of org.freeplane.features.map.MapController 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);
}
}
});
}
use of org.freeplane.features.map.MapController 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.features.map.MapController 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.features.map.MapController in project freeplane by freeplane.
the class BModeControllerFactory method createModeController.
public static BModeController createModeController() {
final Controller controller = Controller.getCurrentController();
modeController = new BModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController, false);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MapController(modeController);
IconController.install(new IconController(modeController));
UrlManager.install(new UrlManager());
MapIO.install(modeController);
AttributeController.install(new AttributeController(modeController));
NodeStyleController.install(new NodeStyleController(modeController));
EdgeController.install(new EdgeController(modeController));
CloudController.install(new CloudController(modeController));
NoteController.install(new NoteController());
TextController.install(new TextController(modeController));
LinkController.install(new LinkController());
LogicalStyleController.install(new LogicalStyleController(modeController));
try {
ClipboardController.install(new ClipboardController());
} catch (final AccessControlException e) {
LogUtils.warn("can not access system clipboard, clipboard controller disabled");
}
LocationController.install(new LocationController());
SummaryNode.install();
FreeNode.install();
MapStyle.install(true);
final BToolbarContributor toolbarContributor = new BToolbarContributor();
modeController.addMenuContributor(toolbarContributor);
controller.getMapViewManager().addMapViewChangeListener(toolbarContributor);
userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
userInputListenerFactory.addToolBar("/filter_toolbar", ViewController.BOTTOM, FilterController.getController(controller).getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
FoldingController.install(new FoldingController());
new ViewerController();
EncryptionController.install(new EncryptionController(modeController));
new AutomaticLayoutController();
new CloneStateIconSupplier().registerStateIconProvider();
return modeController;
}
use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class AddExternalImageAction method actionPerformed.
public void actionPerformed(final ActionEvent event) {
final ProgressUtilities progUtil = new ProgressUtilities();
final MapController mapController = Controller.getCurrentModeController().getMapController();
final Collection<NodeModel> nodes = mapController.getSelectedNodes();
final ViewerController vc = Controller.getCurrentController().getModeController().getExtension(ViewerController.class);
final NodeModel selectedNode = mapController.getSelectedNode();
if (selectedNode == null)
return;
final ExternalResource extRes = (ExternalResource) vc.createExtension(selectedNode);
if (extRes == null)
return;
URI absoluteUri = extRes.getAbsoluteUri(selectedNode.getMap());
if (absoluteUri == null)
return;
for (final NodeModel node : nodes) {
if (!progUtil.hasExternalResource(node)) {
vc.paste(absoluteUri, node, node.isLeft());
}
}
}
Aggregations