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.BorderLayout;
018: import java.awt.Dimension;
019:
020: import javax.swing.JCheckBox;
021: import javax.swing.JComboBox;
022: import javax.swing.JPanel;
023: import javax.swing.JScrollPane;
024: import javax.swing.JTextArea;
025: import javax.swing.JTextField;
026:
027: import com.metaboss.applications.designstudio.Application;
028: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Selector;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorCardinality;
031: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorCardinalityEnum;
032:
033: /* BOSelector object properties tuning dialog */
034:
035: public class SelectorPropertiesDialog extends
036: ModelElementPropertiesDialog {
037: //UI
038: private JPanel mSQLPanel = new JPanel();
039: //proeprties
040: private JTextField mNameField = new JTextField();
041: private JComboBox mCardinalityField = new JComboBox();
042: private JCheckBox mIsImplicitCheckBox = new JCheckBox();
043: private JTextArea mDescriptionField = new JTextArea(8, 40);
044: //sql
045: private JTextArea mSQLField = new JTextArea();
046:
047: public SelectorPropertiesDialog() {
048: super ("Selector", new Dimension(400, 310));
049:
050: mSQLPanel.setLayout(new BorderLayout());
051:
052: mCardinalityField.addItem(SelectorCardinalityEnum.ZERO_OR_ONE);
053: mCardinalityField.addItem(SelectorCardinalityEnum.ZERO_TO_MANY);
054:
055: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
056: addComboBox(mPropertiesPanel, "Cardinality: ",
057: mCardinalityField, 2, false);
058: addCheckBox(mPropertiesPanel, "- implicit",
059: mIsImplicitCheckBox, 3, false);
060: addTextArea(mPropertiesPanel, "Description: ",
061: mDescriptionField, 4, false);
062:
063: mSQLPanel.setBorder(createEditorBorder());
064: mSQLField.setFont(Application.EDITOR_FONT);
065: mSQLPanel.add(new JScrollPane(mSQLField));
066:
067: mTabControl.insertTab("SQL", null, mSQLPanel, null, 1);
068: }
069:
070: // load service module properties
071: public void loadProperties(ModelElement pObject) throws Exception {
072: if (pObject != null && pObject instanceof Selector) {
073: Selector lSelector = (Selector) pObject;
074: mNameField.setText(lSelector.getName());
075: mCardinalityField
076: .setSelectedIndex(findCardinalityItemIndex(lSelector
077: .getCardinality()));
078: mIsImplicitCheckBox.setSelected(lSelector.isImplicit());
079: mDescriptionField.setText(lSelector.getDescription());
080: mSQLField.setText(lSelector.getTextOfSqlSelect());
081: }
082: super .loadProperties(pObject);
083: }
084:
085: // save service module proeprties
086: public void saveProperties(ModelElement pObject) throws Exception {
087: super .saveProperties(pObject);
088: if (pObject != null && pObject instanceof Selector) {
089: Selector lSelector = (Selector) pObject;
090: lSelector.setName(mNameField.getText());
091: lSelector
092: .setCardinality((SelectorCardinality) mCardinalityField
093: .getSelectedItem());
094: lSelector.setImplicit(mIsImplicitCheckBox.isSelected());
095: lSelector.setDescription(mDescriptionField.getText());
096: lSelector.setTextOfSqlSelect(mSQLField.getText());
097: }
098: }
099:
100: // check fields data
101: public boolean checkProperties() {
102: if (mNameField.getText().length() == 0) {
103: Application.showError("Name field could not be blank!");
104: return false;
105: }
106: return super .checkProperties();
107: }
108:
109: // find message type index
110: private int findCardinalityItemIndex(
111: SelectorCardinality lCardinality) {
112: for (int i = 0; i < mCardinalityField.getItemCount(); i++) {
113: SelectorCardinality lItem = (SelectorCardinality) mCardinalityField
114: .getItemAt(i);
115: if (lItem == lCardinality)
116: return i;
117: }
118: return -1;
119: }
120: }
|