Search in sources :

Example 6 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MAttributeController method performSetValueAt.

@Override
public void performSetValueAt(final NodeAttributeTableModel model, final Object o, final int row, final int col) {
    final Attribute attribute = model.getAttribute(row);
    final MapModel map = model.getNode().getMap();
    final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
    switch(col) {
        case 0:
            {
                final String name = o.toString().trim();
                final String oldName = attribute.getName();
                if (oldName.equals(name)) {
                    return;
                }
                final IActor nameActor = new SetAttributeNameActor(model, name, oldName, row);
                Controller.getCurrentModeController().execute(nameActor, map);
                try {
                    final AttributeRegistryElement element = registry.getElement(name);
                    final String value = model.getValueAt(row, 1).toString();
                    final int index = element.getValues().getIndexOf(value);
                    if (index == -1) {
                        final IActor valueActor = new SetAttributeValueActor(model, row, element.getValues().firstElement());
                        Controller.getCurrentModeController().execute(valueActor, map);
                    }
                } catch (final NoSuchElementException ex) {
                    final IActor registryActor = new RegistryAttributeActor(name, false, false, registry, map);
                    Controller.getCurrentModeController().execute(registryActor, map);
                }
                break;
            }
        case 1:
            {
                if (attribute.getValue().equals(o)) {
                    return;
                }
                final IActor actor = new SetAttributeValueActor(model, row, o);
                Controller.getCurrentModeController().execute(actor, map);
                final String name = model.getValueAt(row, 0).toString();
                final AttributeRegistryElement element = registry.getElement(name);
                final int index = element.getValues().getIndexOf(o);
                if (index == -1) {
                    final IActor registryActor = new RegistryAttributeValueActor(element, o, false);
                    Controller.getCurrentModeController().execute(registryActor, map);
                }
                break;
            }
    }
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) AttributeRegistryElement(org.freeplane.features.attribute.AttributeRegistryElement) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) NoSuchElementException(java.util.NoSuchElementException)

Example 7 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MAttributeController method performRegistryAttribute.

@Override
public void performRegistryAttribute(final String name) {
    if (name.equals("")) {
        return;
    }
    final MapModel map = Controller.getCurrentModeController().getController().getMap();
    final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
    try {
        attributeRegistry.getElement(name);
    } catch (final NoSuchElementException ex) {
        final IActor actor = new RegistryAttributeActor(name, true, false, attributeRegistry, map);
        Controller.getCurrentModeController().execute(actor, map);
        return;
    }
}
Also used : AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) NoSuchElementException(java.util.NoSuchElementException)

Example 8 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MAttributeController method performRemoveRow.

@Override
public Attribute performRemoveRow(final NodeAttributeTableModel model, final int row) {
    final Vector<Attribute> attributes = model.getAttributes();
    final Object o = attributes.elementAt(row);
    final IActor actor = new RemoveAttributeActor(model, row);
    Controller.getCurrentModeController().execute(actor, model.getNode().getMap());
    return (Attribute) o;
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) IActor(org.freeplane.core.undo.IActor)

Example 9 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MCloudController method setColor.

public void setColor(final NodeModel node, final Color color) {
    setCloud(node, true);
    final ModeController modeController = Controller.getCurrentModeController();
    final Color oldColor = CloudModel.getModel(node).getColor();
    if (color == oldColor || color != null && color.equals(oldColor)) {
        return;
    }
    final IActor actor = new IActor() {

        public void act() {
            CloudModel.getModel(node).setColor(color);
            modeController.getMapController().nodeChanged(node);
        }

        public String getDescription() {
            return "setColor";
        }

        public void undo() {
            CloudModel.getModel(node).setColor(oldColor);
            modeController.getMapController().nodeChanged(node);
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : Color(java.awt.Color) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Example 10 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MCloudController method setShape.

public void setShape(final NodeModel node, final CloudModel.Shape shape) {
    setCloud(node, true);
    final ModeController modeController = Controller.getCurrentModeController();
    final CloudModel.Shape oldShape = CloudModel.getModel(node).getShape();
    if (shape == oldShape || shape != null && shape.equals(oldShape)) {
        return;
    }
    final IActor actor = new IActor() {

        public void act() {
            CloudModel.getModel(node).setShape(shape);
            modeController.getMapController().nodeChanged(node);
        }

        public String getDescription() {
            return "setShape";
        }

        public void undo() {
            CloudModel.getModel(node).setShape(oldShape);
            modeController.getMapController().nodeChanged(node);
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : Shape(org.freeplane.features.cloud.CloudModel.Shape) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) CloudModel(org.freeplane.features.cloud.CloudModel)

Aggregations

IActor (org.freeplane.core.undo.IActor)123 NodeModel (org.freeplane.features.map.NodeModel)30 ModeController (org.freeplane.features.mode.ModeController)28 MapModel (org.freeplane.features.map.MapModel)27 MapController (org.freeplane.features.map.MapController)11 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)10 Color (java.awt.Color)8 Point (java.awt.Point)6 MMapController (org.freeplane.features.map.mindmapmode.MMapController)6 NodeStyleModel (org.freeplane.features.nodestyle.NodeStyleModel)6 Controller (org.freeplane.features.mode.Controller)5 IStyle (org.freeplane.features.styles.IStyle)5 MapStyleModel (org.freeplane.features.styles.MapStyleModel)5 NoSuchElementException (java.util.NoSuchElementException)4 LengthUnits (org.freeplane.core.ui.LengthUnits)4 AttributeRegistryElement (org.freeplane.features.attribute.AttributeRegistryElement)4 Date (java.util.Date)3 IExtension (org.freeplane.core.extension.IExtension)3 IUndoHandler (org.freeplane.core.undo.IUndoHandler)3 EdgeModel (org.freeplane.features.edge.EdgeModel)3