001: /*******************************************************************************
002: * Copyright (c) 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.core.text.cheatsheet.simple;
011:
012: import java.util.ArrayList;
013: import java.util.List;
014:
015: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSAction;
016: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModel;
017:
018: /**
019: * SimpleCSAction
020: *
021: */
022: public class SimpleCSAction extends SimpleCSRunObject implements
023: ISimpleCSAction {
024:
025: private static final long serialVersionUID = 1L;
026:
027: private static final int F_MAX_PARAMS = 9;
028:
029: // TODO: MP: TEO: MED: Verify translate of paramaters on write is okay - no translate before
030:
031: /**
032: * @param model
033: */
034: public SimpleCSAction(ISimpleCSModel model) {
035: super (model, ELEMENT_ACTION);
036: }
037:
038: /* (non-Javadoc)
039: * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSAction#getClazz()
040: */
041: public String getClazz() {
042: return getXMLAttributeValue(ATTRIBUTE_CLASS);
043: }
044:
045: /* (non-Javadoc)
046: * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSAction#getParam(int)
047: */
048: public String getParam(int index) {
049: // Ensure in valid range
050: if ((index < 1) || (index > F_MAX_PARAMS)) {
051: return null;
052: }
053: StringBuffer buffer = new StringBuffer(ATTRIBUTE_PARAM);
054: buffer.append(index);
055: // Get paramN
056: return getXMLAttributeValue(buffer.toString());
057: }
058:
059: /* (non-Javadoc)
060: * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSAction#getParams()
061: */
062: public String[] getParams() {
063: ArrayList list = new ArrayList();
064: // Get all set parameters
065: for (int i = 1; i <= F_MAX_PARAMS; i++) {
066: String parameter = getParam(i);
067: if (parameter == null) {
068: break;
069: }
070: list.add(parameter);
071: }
072: return (String[]) list.toArray(new String[list.size()]);
073: }
074:
075: /* (non-Javadoc)
076: * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSAction#getPluginId()
077: */
078: public String getPluginId() {
079: return getXMLAttributeValue(ATTRIBUTE_PLUGINID);
080: }
081:
082: /* (non-Javadoc)
083: * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSAction#setClazz(java.lang.String)
084: */
085: public void setClazz(String clazz) {
086: setXMLAttribute(ATTRIBUTE_CLASS, clazz);
087: }
088:
089: /* (non-Javadoc)
090: * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSAction#setParam(java.lang.String, int)
091: */
092: public void setParam(String param, int index) {
093: // Ensure proper index
094: if ((index < 1) || (index > F_MAX_PARAMS)) {
095: return;
096: }
097: StringBuffer buffer = new StringBuffer(ATTRIBUTE_PARAM);
098: buffer.append(index);
099: setXMLAttribute(buffer.toString(), param);
100: }
101:
102: /* (non-Javadoc)
103: * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSAction#setPluginId(java.lang.String)
104: */
105: public void setPluginId(String pluginId) {
106: setXMLAttribute(ATTRIBUTE_PLUGINID, pluginId);
107: }
108:
109: /* (non-Javadoc)
110: * @see org.eclipse.pde.internal.core.text.cheatsheet.simple.SimpleCSObject#getChildren()
111: */
112: public List getChildren() {
113: return new ArrayList();
114: }
115:
116: /* (non-Javadoc)
117: * @see org.eclipse.pde.internal.core.text.cheatsheet.simple.SimpleCSObject#getName()
118: */
119: public String getName() {
120: // Leave as is. Not a separate node in tree view
121: return ELEMENT_ACTION;
122: }
123:
124: /* (non-Javadoc)
125: * @see org.eclipse.pde.internal.core.text.cheatsheet.simple.SimpleCSObject#getType()
126: */
127: public int getType() {
128: return TYPE_ACTION;
129: }
130:
131: /* (non-Javadoc)
132: * @see org.eclipse.pde.internal.core.text.plugin.PluginDocumentNode#isLeafNode()
133: */
134: public boolean isLeafNode() {
135: return true;
136: }
137:
138: }
|