use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class TextController method install.
public static void install(final TextController textController) {
final ModeController modeController = Controller.getCurrentModeController();
modeController.addExtension(TextController.class, textController);
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class TextController method registerNodeTextTooltip.
private void registerNodeTextTooltip() {
modeController.addToolTipProvider(NODE_TOOLTIP, new ITooltipProvider() {
public String getTooltip(final ModeController modeController, NodeModel node, Component view) {
if (!ShortenedTextModel.isShortened(node)) {
return null;
}
final NodeStyleController style = (NodeStyleController) modeController.getExtension(NodeStyleController.class);
final Font font = style.getFont(node);
final StringBuilder rule = new StringBuilder();
rule.append("font-family: " + font.getFamily() + ";");
rule.append("font-size: " + font.getSize() + "pt;");
rule.append("margin-top:0;");
if (font.isItalic()) {
rule.append("font-style: italic; ");
}
if (font.isBold()) {
rule.append("font-weight: bold; ");
}
final Color nodeTextColor = view.getForeground();
rule.append("color: ").append(ColorUtils.colorToString(nodeTextColor)).append(";");
final Object data = node.getUserObject();
String text;
try {
text = getTransformedText(data, node, data);
} catch (Exception e) {
text = TextUtils.format("MainView.errorUpdateText", data, e.getLocalizedMessage());
rule.append("color:red;");
}
if (!HtmlUtils.isHtmlNode(text)) {
text = HtmlUtils.plainToHTML(text);
}
final String tooltipText = text.replaceFirst("<body>", "<body><div style=\"" + rule + "\">").replaceFirst("</body>", "</div></body>");
return tooltipText;
}
});
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class MLogicalStyleController method setStyle.
public void setStyle(final NodeModel node, final IStyle style) {
final ModeController modeController = Controller.getCurrentModeController();
final IStyle oldStyle = LogicalStyleModel.getStyle(node);
if (oldStyle != null && oldStyle.equals(style) || oldStyle == style) {
modeController.getMapController().nodeChanged(node, LogicalStyleModel.class, oldStyle, style);
return;
}
final IActor actor = new IActor() {
public String getDescription() {
return "setStyle";
}
public void act() {
changeStyle(modeController, node, oldStyle, style);
}
public void undo() {
changeStyle(modeController, node, style, oldStyle);
}
private void changeStyle(final ModeController modeController, final NodeModel node, final IStyle oldStyle, final IStyle style) {
if (style != null) {
final LogicalStyleModel model = LogicalStyleModel.createExtension(node);
model.setStyle(style);
} else {
node.removeExtension(LogicalStyleModel.class);
}
modeController.getMapController().nodeChanged(node, LogicalStyleModel.class, oldStyle, style);
selectActions();
}
};
modeController.execute(actor, node.getMap());
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class FreeplaneHeadlessStarter method createFrame.
public void createFrame(final String[] args) {
Controller controller = Controller.getCurrentController();
ModeController modeController = controller.getModeController(MModeController.MODENAME);
controller.selectModeForBuild(modeController);
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class DeleteUserStyleAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentModeController();
final Controller controller = modeController.getController();
final NodeModel selected = controller.getSelection().getSelected();
if (selected.depth() < 2) {
UITools.errorMessage(TextUtils.getText("can_not_delete_style_group"));
return;
}
final MapModel map = selected.getMap();
final MapStyleModel styleModel = MapStyleModel.getExtension(map);
final NodeModel styleNodeGroup = styleModel.getStyleNodeGroup(selected);
if (!((StyleNamedObject) styleNodeGroup.getUserObject()).getObject().equals("styles.user-defined")) {
UITools.errorMessage(TextUtils.getText("can_not_delete_predefined_style"));
return;
}
final MMapController mapController = (MMapController) modeController.getMapController();
mapController.deleteNode(selected);
final IActor actor = new IActor() {
public void undo() {
styleModel.addStyleNode(selected);
}
public String getDescription() {
return "DeleteStyle";
}
public void act() {
styleModel.removeStyleNode(selected);
}
};
Controller.getCurrentModeController().execute(actor, map);
}
Aggregations