1 11 12 package org.eclipse.ui.internal.cheatsheets.data; 13 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.ui.internal.cheatsheets.CommandRunner; 17 import org.eclipse.ui.internal.cheatsheets.Messages; 18 import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; 19 import org.w3c.dom.Node ; 20 21 24 25 public class CheatSheetCommand extends AbstractExecutable { 26 27 private String serialization; 28 private String returns; 29 private boolean serializationFound; 30 31 public void setSerialization(String serialization) { 32 this.serialization = serialization; 33 } 34 35 public String getSerialization() { 36 return serialization; 37 } 38 39 public boolean isCheatSheetManagerUsed() { 40 return true; 41 } 42 43 public IStatus execute(CheatSheetManager csm) { 44 return new CommandRunner().executeCommand(this, csm); 45 } 46 47 public boolean hasParams() { 48 return false; 49 } 50 51 public boolean handleAttribute(Node attribute) { 52 if (IParserTags.SERIALIZATION.equals(attribute.getNodeName())) { 53 setSerialization(attribute.getNodeValue()); 54 serializationFound = true; 55 return true; 56 } else if (IParserTags.RETURNS.equals(attribute.getNodeName())) { 57 setReturns(attribute.getNodeValue()); 58 return true; 59 } 60 return false; 61 } 62 63 public String checkAttributes(Node node) { 64 if(!serializationFound) { 65 return NLS.bind(Messages.ERROR_PARSING_NO_SERIALIZATION, (new Object [] {node.getNodeName()})); 66 } 67 if(isConfirm() && !isRequired()) { 68 return NLS.bind(Messages.ERROR_PARSING_REQUIRED_CONFIRM, (new Object [] {node.getNodeName()})); 69 } 70 return null; 71 } 72 73 public void setReturns(String returns) { 74 this.returns = returns; 75 } 76 77 public String getReturns() { 78 return returns; 79 } 80 81 } 82 | Popular Tags |