001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.applications.designstudio.propertiesdialogs;
016:
017: import java.awt.Dimension;
018: import java.util.HashMap;
019:
020: import javax.swing.JComboBox;
021: import javax.swing.JTextArea;
022: import javax.swing.JTextField;
023:
024: import com.metaboss.applications.designstudio.Application;
025: import com.metaboss.applications.designstudio.fieldstable.FieldsEditPanel;
026: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.MessageType;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.MessageTypeEnum;
030:
031: /* BOMessage proeprties tuning dialog class */
032:
033: public class MessagePropertiesDialog extends
034: ModelElementPropertiesDialog {
035: private HashMap mOptions = new HashMap();
036: // UI constrols
037: private FieldsEditPanel mFieldsPanel = new FieldsEditPanel();
038: // properties
039: private JComboBox mTypeField = new JComboBox();
040: private JTextField mDefaultTextField = new JTextField();
041: private JTextArea mDescriptionField = new JTextArea(8, 40);
042:
043: public MessagePropertiesDialog() {
044: super ("Message", new Dimension(450, 320));
045:
046: mTypeField.addItem(MessageTypeEnum.ERROR);
047: mTypeField.addItem(MessageTypeEnum.FAILURE);
048: mTypeField.addItem(MessageTypeEnum.INFORMATION);
049: mTypeField.addItem(MessageTypeEnum.WARNING);
050:
051: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
052: addComboBox(mPropertiesPanel, "Type: ", mTypeField, 2, false);
053: addTextField(mPropertiesPanel, "Default Text: ",
054: mDefaultTextField, 3, false);
055: addTextArea(mPropertiesPanel, "Description: ",
056: mDescriptionField, 4, false);
057:
058: mTabControl.insertTab("Fields", null, mFieldsPanel, null, 1);
059:
060: mClient.add(mTabControl);
061: }
062:
063: // load service module properties
064: public void loadProperties(ModelElement pObject) throws Exception {
065: if (pObject != null && pObject instanceof Message) {
066: Message lMessage = (Message) pObject;
067:
068: mNameField.setText(lMessage.getName());
069: mTypeField.setSelectedIndex(findItemIndex(lMessage
070: .getType()));
071: mDefaultTextField.setText(lMessage.getDefaultText());
072: mDescriptionField.setText(lMessage.getDescription());
073:
074: mFieldsPanel.loadFields(lMessage);
075: }
076: super .loadProperties(pObject);
077: }
078:
079: // save service module proeprties
080: public void saveProperties(ModelElement pObject) throws Exception {
081: super .saveProperties(pObject);
082: if (pObject != null && pObject instanceof Message) {
083: Message lModule = (Message) pObject;
084: lModule.setName(mNameField.getText());
085: lModule.setDefaultText(mDefaultTextField.getText());
086: lModule.setType((MessageType) mTypeField.getSelectedItem());
087: lModule.setDescription(mDescriptionField.getText());
088: }
089: }
090:
091: // check fields data
092: public boolean checkProperties() {
093: if (mNameField.getText().length() == 0) {
094: Application.showError("Name field could not be blank!");
095: return false;
096: }
097: return super .checkProperties();
098: }
099:
100: // find message type index
101: private int findItemIndex(MessageType lMessageType) {
102: for (int i = 0; i < mTypeField.getItemCount(); i++) {
103: MessageType lItem = (MessageType) mTypeField.getItemAt(i);
104: if (lItem == lMessageType)
105: return i;
106: }
107: return -1;
108: }
109: }
|