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.JCheckBox;
20: import javax.swing.JTextArea;
21:
22: import com.metaboss.applications.designstudio.Application;
23: import com.metaboss.applications.designstudio.messagesfield.MessagesBox;
24: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
25: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.AbstractMessageField;
26: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
27: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System;
28:
29: /* BOOutputMessage object properties tuning dialog */
30:
31: public abstract class AbstractMessageFieldPropertiesDialog extends
32: ModelElementPropertiesDialog {
33: private MessagesBox mMessageField = new MessagesBox("Message");
34: private JCheckBox mIsArrayCheckBox = new JCheckBox();
35: private JTextArea mDescriptionField = new JTextArea(8, 40);
36:
37: public AbstractMessageFieldPropertiesDialog(String pCaption) {
38: super (pCaption, new Dimension(400, 310));
39:
40: addComplexFieldWithEdit(mPropertiesPanel, mMessageField, 2,
41: true);
42: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
43: addCheckBox(mPropertiesPanel, "- is array", mIsArrayCheckBox,
44: 3, false);
45: addTextArea(mPropertiesPanel, "Description: ",
46: mDescriptionField, 4, false);
47:
48: mMessageField.addItemListener(new NameElementChangeListener());
49: }
50:
51: // load service module properties
52: public void loadProperties(ModelElement pObject) throws Exception {
53: if (pObject != null && pObject instanceof AbstractMessageField) {
54: AbstractMessageField lMessage = (AbstractMessageField) pObject;
55:
56: mMessageField.setSystem(getSystem(lMessage));
57:
58: mNameField.setText(lMessage.getName());
59: mIsArrayCheckBox.setSelected(lMessage.isArray());
60: mMessageField.setSelectedMessage(lMessage.getMessageType());
61: mDescriptionField.setText(lMessage.getDescription());
62: }
63: super .loadProperties(pObject);
64: }
65:
66: protected abstract System getSystem(AbstractMessageField pMessage);
67:
68: // save service module proeprties
69: public void saveProperties(ModelElement pObject) throws Exception {
70: super .saveProperties(pObject);
71: if (pObject != null && pObject instanceof AbstractMessageField) {
72: AbstractMessageField lMessage = (AbstractMessageField) pObject;
73: lMessage.setMessageType(mMessageField.getSelectedMessage());
74: lMessage.setName(mNameField.getText());
75: lMessage.setArray(mIsArrayCheckBox.isSelected());
76: lMessage.setDescription(mDescriptionField.getText());
77: }
78: }
79:
80: // check fields data
81: public boolean checkProperties() {
82: if (mNameField.getText().length() == 0) {
83: Application.showError("Name field could not be blank!");
84: return false;
85: }
86: return super .checkProperties();
87: }
88:
89: protected ModelElement getNameElement() {
90: Message lResult = null;
91: try {
92: lResult = mMessageField.getSelectedMessage();
93: } catch (Exception e) {
94: lResult = null;
95: }
96: return lResult;
97: }
98: }
|