Search in sources :

Example 1 with DetailTextModel

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());
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) DetailTextModel(org.freeplane.features.text.DetailTextModel) IActor(org.freeplane.core.undo.IActor)

Example 2 with DetailTextModel

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());
}
Also used : DetailTextModel(org.freeplane.features.text.DetailTextModel) IActor(org.freeplane.core.undo.IActor)

Example 3 with DetailTextModel

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);
}
Also used : DetailTextModel(org.freeplane.features.text.DetailTextModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Example 4 with DetailTextModel

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();
}
Also used : DetailTextModel(org.freeplane.features.text.DetailTextModel)

Aggregations

DetailTextModel (org.freeplane.features.text.DetailTextModel)4 IActor (org.freeplane.core.undo.IActor)2 IMapSelection (org.freeplane.features.map.IMapSelection)1 NodeChangeEvent (org.freeplane.features.map.NodeChangeEvent)1