use of org.freeplane.features.text.DetailTextModel in project freeplane by freeplane.
the class MTextController method setDetailsHidden.
@Override
public void setDetailsHidden(final NodeModel node, final boolean isHidden) {
stopEditing();
DetailTextModel details = node.getExtension(DetailTextModel.class);
if (details == null || details.isHidden() == isHidden) {
return;
}
final IActor actor = new IActor() {
@Override
public void act() {
setHidden(isHidden);
}
@Override
public String getDescription() {
return "setDetailsHidden";
}
private void setHidden(final boolean isHidden) {
final DetailTextModel details = DetailTextModel.createDetailText(node);
details.setHidden(isHidden);
node.addExtension(details);
final NodeChangeEvent nodeChangeEvent = new NodeChangeEvent(node, DETAILS_HIDDEN, !isHidden, isHidden, true, false);
Controller.getCurrentModeController().getMapController().nodeRefresh(nodeChangeEvent);
}
@Override
public void undo() {
setHidden(!isHidden);
}
};
Controller.getCurrentModeController().execute(actor, node.getMap());
}
use of org.freeplane.features.text.DetailTextModel in project freeplane by freeplane.
the class MTextController method setDetails.
public void setDetails(final NodeModel node, final String newText) {
final String oldText = DetailTextModel.getDetailTextText(node);
if (oldText == newText || null != oldText && oldText.equals(newText)) {
return;
}
final IActor actor = new IActor() {
boolean hidden = false;
@Override
public void act() {
setText(newText);
}
@Override
public String getDescription() {
return "setDetailText";
}
private void setText(final String text) {
final boolean containsDetails = !(text == null || text.equals(""));
if (containsDetails) {
final DetailTextModel details = DetailTextModel.createDetailText(node);
details.setHtml(text);
details.setHidden(hidden);
node.addExtension(details);
} else {
final DetailTextModel details = node.getExtension(DetailTextModel.class);
if (null != details) {
hidden = details.isHidden();
node.removeExtension(DetailTextModel.class);
}
}
Controller.getCurrentModeController().getMapController().nodeChanged(node, DetailTextModel.class, oldText, text);
}
@Override
public void undo() {
setText(oldText);
}
};
Controller.getCurrentModeController().execute(actor, node.getMap());
}
use of org.freeplane.features.text.DetailTextModel in project freeplane by freeplane.
the class DeleteDetailsAction method actionPerformed.
@Override
protected void actionPerformed(final ActionEvent e, final NodeModel node) {
final DetailTextModel detailText = DetailTextModel.getDetailText(node);
if (detailText == null) {
return;
}
final IMapSelection selection = Controller.getCurrentController().getSelection();
selection.keepNodePosition(selection.getSelected(), 0.0f, 0.0f);
final MTextController controller = MTextController.getController();
controller.setDetailsHidden(node, false);
controller.setDetails(node, null);
}
use of org.freeplane.features.text.DetailTextModel in project freeplane by freeplane.
the class NodeViewFactory method updateDetails.
void updateDetails(NodeView nodeView, int minNodeWidth, int maxNodeWidth) {
final DetailTextModel detailText = DetailTextModel.getDetailText(nodeView.getModel());
if (detailText == null) {
nodeView.removeContent(NodeView.DETAIL_VIEWER_POSITION);
return;
}
DetailsView detailContent = (DetailsView) nodeView.getContent(NodeView.DETAIL_VIEWER_POSITION);
if (detailContent == null) {
detailContent = createDetailView();
nodeView.addContent(detailContent, NodeView.DETAIL_VIEWER_POSITION);
}
final MapView map = nodeView.getMap();
if (detailText.isHidden()) {
final ArrowIcon icon = new ArrowIcon(nodeView, true);
detailContent.setIcon(icon);
detailContent.updateText("");
} else {
detailContent.setFont(map.getDetailFont());
detailContent.setHorizontalAlignment(map.getDetailHorizontalAlignment());
detailContent.setIcon(new ArrowIcon(nodeView, false));
detailContent.updateText(detailText.getHtml());
}
detailContent.setForeground(map.getDetailForeground());
detailContent.setBackground(map.getDetailBackground());
detailContent.setMinimumWidth(minNodeWidth);
detailContent.setMaximumWidth(maxNodeWidth);
detailContent.revalidate();
map.repaint();
}
Aggregations