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:
019: import javax.swing.JComboBox;
020: import javax.swing.JTextArea;
021:
022: import com.metaboss.applications.designstudio.userobjects.StorageTechnologyItem;
023: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
024: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
025: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.DomainRelationalStorageDefinition;
026: import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.RelationalStorageTechnology;
027:
028: /* DomainRelationalStorageDefinition properties dialog */
029:
030: public class RelationalStorageDefinitionPropertiesDialog extends
031: ModelElementPropertiesDialog {
032: private Object[] mTechnologies = null;
033: //UI
034: private JComboBox mTechField = new JComboBox();
035: private JTextArea mDescriptionField = new JTextArea(8, 40);
036:
037: public RelationalStorageDefinitionPropertiesDialog() {
038: super ("Domain Relational Storage Definition", new Dimension(
039: 400, 300));
040:
041: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
042: addComboBox(mPropertiesPanel, "Technology: ", mTechField, 2,
043: true);
044: addTextArea(mPropertiesPanel, "Description: ",
045: mDescriptionField, 3, false);
046:
047: mTechField.addItemListener(new NameElementChangeListener());
048: }
049:
050: // load entity properties
051: public void loadProperties(ModelElement pObject) throws Exception {
052: DomainRelationalStorageDefinition lDefinition = (DomainRelationalStorageDefinition) pObject;
053: if (lDefinition != null) {
054: mTechnologies = loadDataTypes(lDefinition.getDomain()
055: .getSystem().getEnterprise());
056:
057: mNameField.setText(lDefinition.getName());
058: mTechField.setSelectedIndex(StorageTechnologyItem
059: .findStorageTechnologyItemIndex(lDefinition
060: .getTechnology(), mTechField));
061: mDescriptionField.setText(lDefinition.getDescription());
062: }
063: super .loadProperties(pObject);
064: }
065:
066: // save entity proeprties
067: public void saveProperties(ModelElement pObject) throws Exception {
068: super .saveProperties(pObject);
069: if (pObject != null
070: && pObject instanceof DomainRelationalStorageDefinition) {
071: DomainRelationalStorageDefinition lDefinition = (DomainRelationalStorageDefinition) pObject;
072:
073: lDefinition.setName(mNameField.getText());
074: lDefinition.setDescription(mDescriptionField.getText());
075:
076: StorageTechnologyItem lItem = (StorageTechnologyItem) mTechField
077: .getSelectedItem();
078: if (lItem != null)
079: lDefinition.setTechnology(lItem.mStorageTechnology);
080: else
081: lDefinition.setTechnology(null);
082: }
083: }
084:
085: // load Technologies ComboBox
086: private Object[] loadDataTypes(Enterprise pEnterprise) {
087: Object[] lTechnologies = StorageTechnologyItem
088: .preloadStorageTechnologies(pEnterprise
089: .getTechnologyLibrary(), false);
090: StorageTechnologyItem.loadBoxWithStorageTechnolgies(mTechField,
091: lTechnologies);
092: return lTechnologies;
093: }
094:
095: protected ModelElement getNameElement() {
096: RelationalStorageTechnology lResult = null;
097: try {
098: lResult = ((StorageTechnologyItem) mTechField
099: .getSelectedItem()).mStorageTechnology;
100: } catch (Exception e) {
101: lResult = null;
102: }
103: return lResult;
104: }
105: }
|