use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class MTextController method edit.
public void edit(final NodeModel nodeModel, final NodeModel prevSelectedModel, final boolean isNewNode, final boolean parentFolded, final boolean editLong) {
if (nodeModel == null || mCurrentEditDialog != null) {
return;
}
final Controller controller = Controller.getCurrentController();
if (controller.getMap() != nodeModel.getMap()) {
return;
}
final IMapViewManager viewController = controller.getMapViewManager();
final Component map = viewController.getMapViewComponent();
map.validate();
map.invalidate();
final Component node = viewController.getComponent(nodeModel);
if (node == null) {
return;
}
node.requestFocus();
stopEditing();
if (isNewNode && !eventQueue.isActive() && !ResourceController.getResourceController().getBooleanProperty("display_inline_editor_for_all_new_nodes")) {
keyEventDispatcher = new EditEventDispatcher(Controller.getCurrentModeController(), nodeModel, prevSelectedModel, isNewNode, parentFolded, editLong);
keyEventDispatcher.install();
return;
}
;
final IEditControl editControl = new IEditControl() {
public void cancel() {
if (isNewNode && nodeModel.getMap().equals(controller.getMap())) {
if (nodeModel.getParentNode() != null) {
controller.getSelection().selectAsTheOnlyOneSelected(nodeModel);
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
modeController.undo();
modeController.resetRedo();
}
final MapController mapController = Controller.getCurrentModeController().getMapController();
mapController.select(prevSelectedModel);
if (parentFolded) {
mapController.setFolded(prevSelectedModel, true);
}
}
stop();
}
private void stop() {
Controller.getCurrentModeController().setBlocked(false);
viewController.obtainFocusForSelected();
mCurrentEditDialog = null;
}
public void ok(final String text) {
String processedText = makePlainIfNoFormattingFound(text);
setGuessedNodeObject(nodeModel, processedText);
stop();
}
public void split(final String newText, final int position) {
splitNode(nodeModel, position, newText);
viewController.obtainFocusForSelected();
stop();
}
public boolean canSplit() {
return true;
}
public EditedComponent getEditType() {
return EditedComponent.TEXT;
}
};
mCurrentEditDialog = createEditor(nodeModel, editControl, nodeModel.getText(), isNewNode, editLong, true);
final JFrame frame = controller.getViewController().getJFrame();
mCurrentEditDialog.show(frame);
}
use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class NodeList method selectMap.
private void selectMap(final MapModel map) {
if (map.equals(Controller.getCurrentController().getMap())) {
return;
}
final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
final Map<String, MapModel> maps = mapViewManager.getMaps(MModeController.MODENAME);
for (final Map.Entry<String, MapModel> entry : maps.entrySet()) {
if (map.equals(entry.getValue())) {
mapViewManager.tryToChangeToMapView(entry.getKey());
}
}
}
use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class UserInputListenerFactory method updateMapList.
private void updateMapList(final String mapsMenuPosition) {
if (!getMenuBuilder(MenuBuilder.class).contains(mapsMenuPosition))
return;
getMenuBuilder(MenuBuilder.class).removeChildElements(mapsMenuPosition);
final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
final List<? extends Component> mapViewVector = mapViewManager.getMapViewVector();
if (mapViewVector == null) {
return;
}
final ButtonGroup group = new ButtonGroup();
int i = 0;
for (final Component mapView : mapViewVector) {
final String displayName = mapView.getName();
final JRadioButtonMenuItem newItem = new JRadioButtonMenuItem(displayName);
newItem.setSelected(false);
group.add(newItem);
newItem.addActionListener(mapsMenuActionListener);
if (displayName.length() > 0) {
newItem.setMnemonic(displayName.charAt(0));
}
final MapView currentMapView = (MapView) mapViewManager.getMapViewComponent();
if (currentMapView != null) {
if (mapView == currentMapView) {
newItem.setSelected(true);
}
}
getMenuBuilder(MenuBuilder.class).addMenuItem(mapsMenuPosition, newItem, mapsMenuPosition + '-' + i++, UIBuilder.AS_CHILD);
}
}
use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class UserInputListenerFactory method updateMenus.
public void updateMenus(String menuStructureResource, Set<String> plugins) {
mapsPopupMenu = new JPopupMenu();
getMenuBuilder(MenuBuilder.class).addPopupMenu(mapsPopupMenu, FreeplaneMenuBar.MAP_POPUP_MENU);
getMenuBuilder(MenuBuilder.class).addPopupMenu(getNodePopupMenu(), UserInputListenerFactory.NODE_POPUP);
final URL popupStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "popup.xml"));
loadStructure(plugins, popupStructure);
if (useRibbonMenu()) {
final URL ribbonStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "ribbon.xml"));
if (ribbonStructure != null) {
getMenuBuilder(RibbonBuilder.class).updateRibbon(ribbonStructure);
}
} else {
final FreeplaneMenuBar menuBar = getMenuBar();
getMenuBuilder(MenuBuilder.class).addMenuBar(menuBar, FreeplaneMenuBar.MENU_BAR_PREFIX);
getMenuBuilder(MenuBuilder.class).addToolbar((JToolBar) getToolBar("/main_toolbar"), "/main_toolbar");
final URL menuStructure = ResourceController.getResourceController().getResource(menuStructureResource);
loadStructure(plugins, menuStructure);
final URL toolbarStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "toolbar.xml"));
loadStructure(plugins, toolbarStructure);
final IMapViewManager viewController = Controller.getCurrentController().getMapViewManager();
viewController.updateMenus(getMenuBuilder(MenuBuilder.class));
}
mapsPopupMenu.setName(TextUtils.getText("mindmaps"));
}
use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.
the class EditNodeTextField method hideMe.
private void hideMe() {
if (textfield == null) {
return;
}
textfield.getDocument().removeDocumentListener(documentListener);
final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
mapViewManager.removeMapViewChangeListener(mapViewChangeListener);
mapViewChangeListener = null;
parent.setPreferredSize(null);
if (SwingUtilities.getAncestorOfClass(MapView.class, nodeView) != null)
nodeView.update();
if (nodeView.isRoot() && parent instanceof MainView)
parent.setHorizontalAlignment(JLabel.CENTER);
final Dimension textFieldSize = textfield.getSize();
final Point textFieldCoordinate = new Point();
final MapView mapView = nodeView.getMap();
UITools.convertPointToAncestor(textfield, textFieldCoordinate, mapView);
textfield.getParent().remove(textfield);
parent.revalidate();
parent.repaint();
mapView.repaint(textFieldCoordinate.x, textFieldCoordinate.y, textFieldSize.width, textFieldSize.height);
textfield = null;
}
Aggregations