use of org.freeplane.features.text.mindmapmode.EditNodeBase.IEditControl 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);
}
Aggregations