use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class LogicalStyleController method createBuilder.
private void createBuilder() {
ModeController modeController = Controller.getCurrentModeController();
final MapController mapController = modeController.getMapController();
final ReadManager readManager = mapController.getReadManager();
readManager.addAttributeHandler(NodeBuilder.XML_NODE, "STYLE_REF", new IAttributeHandler() {
public void setAttribute(final Object node, final String value) {
final LogicalStyleModel extension = LogicalStyleModel.createExtension((NodeModel) node);
extension.setStyle(StyleFactory.create(value));
}
});
readManager.addAttributeHandler(NodeBuilder.XML_NODE, "LOCALIZED_STYLE_REF", new IAttributeHandler() {
public void setAttribute(final Object node, final String value) {
final LogicalStyleModel extension = LogicalStyleModel.createExtension((NodeModel) node);
extension.setStyle(StyleFactory.create(NamedObject.format(value)));
}
});
final WriteManager writeManager = mapController.getWriteManager();
writeManager.addAttributeWriter(NodeBuilder.XML_NODE, new IAttributeWriter() {
public void writeAttributes(final ITreeWriter writer, final Object node, final String tag) {
if (!NodeWriter.shouldWriteSharedContent(writer))
return;
final LogicalStyleModel extension = LogicalStyleModel.getExtension((NodeModel) node);
if (extension == null) {
return;
}
final IStyle style = extension.getStyle();
if (style == null) {
return;
}
final String value = StyleNamedObject.toKeyString(style);
if (style instanceof StyleNamedObject) {
writer.addAttribute("LOCALIZED_STYLE_REF", value);
} else {
writer.addAttribute("STYLE_REF", value);
}
}
});
}
use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class LogicalStyleController method registerChangeListener.
private void registerChangeListener() {
ModeController modeController = Controller.getCurrentModeController();
final MapController mapController = modeController.getMapController();
mapController.addMapChangeListener(new IMapChangeListener() {
public void onPreNodeMoved(NodeModel oldParent, int oldIndex, NodeModel newParent, NodeModel child, int newIndex) {
clearCache();
}
public void onPreNodeDelete(NodeModel oldParent, NodeModel selectedNode, int index) {
clearCache();
}
public void onNodeMoved(NodeModel oldParent, int oldIndex, NodeModel newParent, NodeModel child, int newIndex) {
clearCache();
}
public void onNodeInserted(NodeModel parent, NodeModel child, int newIndex) {
clearCache();
}
public void onNodeDeleted(NodeModel parent, NodeModel child, int index) {
clearCache();
}
public void mapChanged(MapChangeEvent event) {
clearCache();
}
});
mapController.addNodeChangeListener(new INodeChangeListener() {
public void nodeChanged(NodeChangeEvent event) {
clearCache();
}
});
}
use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class MNodeStyleController method setMaxNodeWidth.
public void setMaxNodeWidth(final NodeModel node, final int maxNodeWidth) {
final NodeSizeModel sizeModel = createOwnSizeModel(node);
final int oldValue = NodeSizeModel.getNodeMaxNodeWidth(node);
final IActor actor = new IActor() {
public void act() {
sizeModel.setMaxNodeWidth(maxNodeWidth);
final MapController mapController = getModeController().getMapController();
mapController.nodeChanged(node);
}
public String getDescription() {
return "setMaxNodeWidth";
}
public void undo() {
sizeModel.setMaxNodeWidth(oldValue);
final MapController mapController = getModeController().getMapController();
mapController.nodeChanged(node);
}
};
getModeController().execute(actor, node.getMap());
final int minNodeWidth = getMinWidth(node);
if (maxNodeWidth < minNodeWidth) {
setMinNodeWidth(node, maxNodeWidth);
}
}
use of org.freeplane.features.map.MapController in project freeplane by freeplane.
the class MNodeStyleController method setNodeNumbering.
public void setNodeNumbering(final NodeModel node, final Boolean enableNodeNumbering) {
final ModeController modeController = Controller.getCurrentModeController();
final Boolean oldValue = NodeStyleModel.getNodeNumbering(node);
final IActor actor = new IActor() {
public void act() {
NodeStyleModel.setNodeNumbering(node, enableNodeNumbering);
final MapController mapController = modeController.getMapController();
mapController.setSaved(node.getMap(), false);
mapController.delayedNodeRefresh(node, NodeStyleController.NODE_NUMBERING, oldValue, enableNodeNumbering);
}
public String getDescription() {
return "setNodeNumbering";
}
public void undo() {
NodeStyleModel.setNodeNumbering(node, oldValue);
final MapController mapController = modeController.getMapController();
mapController.setSaved(node.getMap(), false);
modeController.getMapController().delayedNodeRefresh(node, NodeStyleController.NODE_NUMBERING, enableNodeNumbering, oldValue);
}
};
modeController.execute(actor, node.getMap());
}
use of org.freeplane.features.map.MapController 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