001package org.biopax.paxtools.command;
002
003import org.biopax.paxtools.controller.PropertyEditor;
004import org.biopax.paxtools.model.BioPAXElement;
005
006public class PropertyAddCommand extends AbstractPropertyCommand
007{
008
009        PropertyAddCommand(BioPAXElement bpe, PropertyEditor editor, Object value)
010        {
011                super(bpe, editor, value);
012                if (!editor.isMultipleCardinality())
013                {
014                        throw new IllegalArgumentException();
015                }
016        }
017
018
019
020        @Override
021        protected void undoAction()
022        {
023                editor.removeValueFromBean(value, bpe);
024        }
025
026        public boolean canUndo()
027        {
028                return bpe != null;
029        }
030
031
032        @Override
033        protected void redoAction()
034        {
035                editor.setValueToBean(value, bpe);
036        }
037
038        public boolean canRedo()
039        {
040                return bpe != null && value != null;
041        }
042
043        public boolean isSignificant()
044        {
045                return value != null;
046        }
047
048        public String getPresentationName()
049        {
050                return "Add " + value + " to " + editor.getProperty() + "s of " + bpe;
051        }
052
053        public String getUndoPresentationName()
054        {
055                return "Remove" + value + "from" + editor.getProperty() + "s of " + bpe;
056        }
057
058        public String getRedoPresentationName()
059        {
060                return "Re-Add " + value + " to " + editor.getProperty() + "s of " + bpe;
061        }
062}