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