01: package org.osbl.agent.gui;
02:
03: import java.util.List;
04:
05: import org.osbl.agent.model.Condition;
06:
07: /**
08: * The class ConditionPanel represents the ability to visually manipulate a Condition in the
09: * RuleEditorPanel.
10: *
11: * It shows a list of available Condition(Controllers) and its correspoding parameters.
12: *
13: * @author Sebastian Nozzi.
14: */
15: public class ConditionPanel extends OperationPanel {
16:
17: /**
18: * Instantiates a new ConditionPanel in the given Rule Editor.
19: *
20: * @param ruleEditorPanel the RuleEditorPanel this panel will be used in.
21: */
22: public ConditionPanel(RuleEditorPanel ruleEditorPanel) {
23: this (ruleEditorPanel, null);
24: }
25:
26: /**
27: * Instantiates a new ActionPanel, setting the given ActionController
28: * as the selected item.
29: *
30: * @param ruleEditorPanel the RuleEditorPanel to which this panel belongs.
31: * @param preferredController the ActionController to be used as the selected item.
32: */
33: public ConditionPanel(RuleEditorPanel ruleEditorPanel,
34: ConditionController preferredController) {
35: super (ruleEditorPanel, preferredController);
36: }
37:
38: /**
39: * Get an Condition instance corresponding to the selected ConditionController and
40: * the state of its parameters.
41: *
42: * @return the Condition instance currently reflected by this panel.
43: */
44: public Condition getCondition() {
45: // Ask the currently selected (in the UI) ConditionController for its
46: // corresponding Condition and return it.
47: return ((ConditionController) controllerCombo.getSelectedItem())
48: .getCondition();
49: }
50:
51: /* (non-Javadoc)
52: * @see org.osbl.agent.gui.OperationPanel#getControllers()
53: */
54: protected List<OperationController> getControllers() {
55: return ruleEditorPanel.getDesignContext()
56: .getConditionControllers();
57: }
58:
59: }
|