01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.applications.designstudio.propertiesdialogs;
16:
17: import java.awt.Dimension;
18:
19: import javax.swing.JComboBox;
20: import javax.swing.JTextArea;
21:
22: import com.metaboss.applications.designstudio.userobjects.StateItem;
23: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
24: import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.Transition;
25:
26: /* StateTransition properties dialog */
27:
28: public class StateTransitionPropertiesDialog extends
29: ModelElementPropertiesDialog {
30: private JComboBox mStartStateField = new JComboBox();
31: private JComboBox mStopStateField = new JComboBox();
32: private JTextArea mDescriptionField = new JTextArea(8, 40);
33:
34: public StateTransitionPropertiesDialog() {
35: super ("Transition", new Dimension(400, 320));
36:
37: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
38: addComboBox(mPropertiesPanel, "Start State: ",
39: mStartStateField, 2, false);
40: addComboBox(mPropertiesPanel, "End State: ", mStopStateField,
41: 3, false);
42: addTextArea(mPropertiesPanel, "Description: ",
43: mDescriptionField, 4, false);
44: }
45:
46: // load state transition properties
47: public void loadProperties(ModelElement pObject) throws Exception {
48: if (pObject != null && pObject instanceof Transition) {
49: Transition lTransition = (Transition) pObject;
50:
51: StateItem.loadBoxWithStates(mStartStateField, lTransition
52: .getStateMachine(), false);
53: StateItem.loadBoxWithStates(mStopStateField, lTransition
54: .getStateMachine(), false);
55:
56: mNameField.setText(lTransition.getName());
57: mStartStateField.setSelectedIndex(StateItem
58: .findStateItemIndex(mStartStateField, lTransition
59: .getStartState()));
60: mStopStateField.setSelectedIndex(StateItem
61: .findStateItemIndex(mStopStateField, lTransition
62: .getEndState()));
63: mDescriptionField.setText(lTransition.getDescription());
64: }
65: super .loadProperties(pObject);
66: }
67:
68: // save state transition proeprties
69: public void saveProperties(ModelElement pObject) throws Exception {
70: super .saveProperties(pObject);
71: if (pObject != null && pObject instanceof Transition) {
72: Transition lTransition = (Transition) pObject;
73:
74: lTransition.setName(mNameField.getText());
75: lTransition.setDescription(mDescriptionField.getText());
76:
77: StateItem lItem = (StateItem) mStartStateField
78: .getSelectedItem();
79: if (lItem != null)
80: lTransition.setStartState(lItem.mState);
81: else
82: lTransition.setStartState(null);
83: lItem = (StateItem) mStopStateField.getSelectedItem();
84: if (lItem != null)
85: lTransition.setEndState(lItem.mState);
86: else
87: lTransition.setEndState(null);
88: }
89: }
90: }
|