1 11 package org.eclipse.ui.internal.cheatsheets.data; 12 13 import org.eclipse.core.runtime.IStatus; 14 import org.eclipse.osgi.util.NLS; 15 import org.eclipse.ui.internal.cheatsheets.ActionRunner; 16 import org.eclipse.ui.internal.cheatsheets.Messages; 17 import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; 18 import org.w3c.dom.Node ; 19 20 24 public class Action extends AbstractExecutable { 25 private String actionClass; 26 private String pluginID; 27 private boolean hasClassAttr = false; 28 private boolean hasPluginId = false; 29 30 public Action() { 31 super(); 32 } 33 34 35 39 public String getActionClass() { 40 return actionClass; 41 } 42 43 47 public String getPluginID() { 48 return pluginID; 49 } 50 51 56 public void setClass(String aclass) { 57 this.actionClass = aclass; 58 } 59 60 64 public void setPluginID(String pluginId) { 65 this.pluginID = pluginId; 66 } 67 68 public boolean handleAttribute(Node attribute) { 69 if (attribute.getNodeName().equals(IParserTags.PLUGINID)) { 70 hasPluginId = true; 71 setPluginID(attribute.getNodeValue()); 72 return true; 73 } else if (attribute.getNodeName().equals(IParserTags.CLASS)) { 74 hasClassAttr = true; 75 setClass(attribute.getNodeValue()); 76 return true; 77 } 78 return false; 79 } 80 81 public String checkAttributes(Node node) { 82 if(!hasClassAttr) { 83 return NLS.bind(Messages.ERROR_PARSING_NO_CLASS, (new Object [] {node.getNodeName()})); 84 } 85 if(!hasPluginId) { 86 return NLS.bind(Messages.ERROR_PARSING_NO_PLUGINID, (new Object [] {node.getNodeName()})); 87 } 88 if(isConfirm() && !isRequired()) { 89 return NLS.bind(Messages.ERROR_PARSING_REQUIRED_CONFIRM, (new Object [] {node.getNodeName()})); 90 } 91 return null; 92 } 93 94 public boolean isCheatSheetManagerUsed() { 95 return true; 96 } 97 98 99 public IStatus execute(CheatSheetManager csm) { 100 return new ActionRunner().runAction(this, csm); 101 } 102 103 public boolean hasParams() { 104 return true; 105 } 106 107 } 108 | Popular Tags |