use of org.freeplane.features.styles.IStyle 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.styles.IStyle in project freeplane by freeplane.
the class RedefineStyleAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final NodeModel node = Controller.getCurrentController().getSelection().getSelected();
final IStyle style = LogicalStyleController.getController().getFirstStyle(node);
final MapStyleModel extension = MapStyleModel.getExtension(node.getMap());
final NodeModel styleNode = extension.getStyleNode(style);
if (styleNode == null)
return;
Controller.getCurrentModeController().undoableCopyExtensions(LogicalStyleKeys.NODE_STYLE, node, styleNode);
Controller.getCurrentModeController().undoableRemoveExtensions(LogicalStyleKeys.NODE_STYLE, node, node);
LogicalStyleController.getController().refreshMap(node.getMap());
}
use of org.freeplane.features.styles.IStyle in project freeplane by freeplane.
the class AssignStyleAction method setSelected.
@Override
public void setSelected() {
IMapSelection selection = Controller.getCurrentController().getSelection();
if (selection != null) {
NodeModel node = selection.getSelected();
final IStyle style = LogicalStyleModel.getStyle(node);
setSelected(this.style == style || this.style != null && this.style.equals(style));
} else
setSelected(false);
}
use of org.freeplane.features.styles.IStyle in project freeplane by freeplane.
the class LinkController method formatNodeAsHyperlink.
public boolean formatNodeAsHyperlink(final NodeModel node) {
String text = node.getText();
if (text.isEmpty() || HtmlUtils.isHtmlNode(text))
return false;
final Boolean ownFlag = ownFormatNodeAsHyperlink(node);
if (ownFlag != null)
return ownFlag;
Collection<IStyle> collection = LogicalStyleController.getController(modeController).getStyles(node);
final MapStyleModel mapStyles = MapStyleModel.getExtension(node.getMap());
for (IStyle styleKey : collection) {
final NodeModel styleNode = mapStyles.getStyleNode(styleKey);
if (styleNode == null) {
continue;
}
final Boolean styleFlag = ownFormatNodeAsHyperlink(styleNode);
if (styleFlag != null)
return styleFlag;
}
return false;
}
use of org.freeplane.features.styles.IStyle in project freeplane by freeplane.
the class CopyStyleExtensionsAction method actionPerformed.
@Override
protected void actionPerformed(ActionEvent e, NodeModel node) {
final MLogicalStyleController controller = MLogicalStyleController.getController();
final IStyle firstStyle = controller.getFirstStyle(node);
controller.copyStyleExtensions(firstStyle, node);
}
Aggregations