KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > cheatsheets > data > AbstractExecutable


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.cheatsheets.data;
13
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager;
16 import org.w3c.dom.Node JavaDoc;
17
18 /**
19  * The common base class for all of the cheatsheet elements which have
20  * executable behavior, i.e. Action, Command and Linkable
21  */

22
23 public abstract class AbstractExecutable {
24     
25     private String JavaDoc[] params;
26     private boolean confirm = false;
27     private String JavaDoc when;
28     private boolean required = true;
29     
30     /**
31      * This method returns an array of parameters specified to be passed to the action class
32      * when it is run in the cheat sheet.
33      * @return an array of string parameters that are passed to the action class when it is run
34      */

35     public String JavaDoc[] getParams() {
36         return params;
37     }
38
39     /**
40      * This method returns the expression to be used when determining if this action should used.
41      * @return the when expression to be used for this action
42      */

43     public String JavaDoc getWhen() {
44         return when;
45     }
46
47     /**
48      * Returns whether this action needs to be manually confirmed by the user.
49      * @return <code>true</code> when the action needs to be confirmed and <code>false</code> otherwise.
50      */

51     public boolean isConfirm() {
52         return confirm;
53     }
54     
55     /**
56      * @return true if this step or substep can only be completed by performing
57      * this executable.
58      */

59     public boolean isRequired() {
60         return required;
61     }
62
63     /**
64      * This method allows you to set the string parameters to be passed to the action class on running it
65      * in the cheat sheet.
66      * @param params an array of strings that is passed to the action class on running the action
67      */

68     public void setParams(String JavaDoc[] params) {
69         this.params = params;
70     }
71
72     /**
73      * Set whether this action needs to be manually confirmed by the user.
74      * @param value The new value of the confirm state.
75      */

76     public void setConfirm(boolean value) {
77         this.confirm = value;
78     }
79     
80     /**
81      * Set whether this executable can be by passed.
82      * @param required if true this action must be performed to complete this
83      * step or substep.
84      */

85     public void setRequired(boolean required) {
86         this.required = required;
87     }
88
89     /**
90      * Indicates this action is to be used if and only if the value of the condition attribute
91      * of the containing <perform-when> element matches this string value. This attribute is
92      * ignored if the <action> element is not a child of a <perform-when> element.
93      * @param when The expression to use when determine if this action should be used.
94      */

95     public void setWhen(String JavaDoc when) {
96         this.when = when;
97     }
98
99     /**
100      * Handle an attribute specific to this type of AbstractExecutable
101      * @param attribute
102      * @return true if this parameter is valid for this type of executable
103      */

104     public abstract boolean handleAttribute(Node JavaDoc attribute);
105
106     /**
107      * Check to see if all required attributes are present and are valid.
108      * This method is called after any calls to handleAttributes have been made
109      * @param node the node for this executable.
110      * @return null if the parameters are valid or an error message if the
111      * parameters are invalid or incomplete.
112      */

113     public abstract String JavaDoc checkAttributes(Node JavaDoc node);
114     
115     /**
116      * @return true if calls to execute require a non-null CheatsheetManager
117      */

118     public abstract boolean isCheatSheetManagerUsed();
119     
120     /**
121      * Execute and return a status
122      * @param csm A cheatsheet manager if this object uses a cheatsheet manager,
123      * otherwise null.
124      * @return OK status if the operation succeeds, warning status if an action
125      * completes with a failure result, error status if an exception was thrown
126      * or the executable could not be initiated.
127      */

128     public abstract IStatus execute(CheatSheetManager csm);
129
130     /**
131      * @return true if this executable can have parameters
132      */

133     public abstract boolean hasParams();
134
135 }
136
Popular Tags