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.userobjects;
016:
017: import com.metaboss.applications.designstudio.Application;
018: import com.metaboss.applications.designstudio.BasePropertiesDialog;
019: import com.metaboss.applications.designstudio.BaseUserObject;
020: import com.metaboss.applications.designstudio.propertiesdialogs.EventMessageFieldPropertiesDialog;
021: import com.metaboss.applications.designstudio.propertiesview.PropertiesTableModel;
022: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
023: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
024: import com.metaboss.sdlctools.models.metabossmodel.ModelElementUtils;
025: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EnterpriseModelPackage;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Event;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventMessageField;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventMessageFieldClass;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
030:
031: /* Event message field user object */
032:
033: public class EventMessageFieldUserObject extends BaseUserObject {
034: private EventMessageField mField = null;
035:
036: public EventMessageFieldUserObject(EventMessageField pField) {
037: super (pField, Application.MESSAGE_ICON);
038: mField = pField;
039: }
040:
041: public EventMessageFieldUserObject(EventMessageField pField,
042: String pCaption, int pMode) {
043: super (pField, pCaption, pMode);
044: mField = pField;
045: }
046:
047: // create new message
048: public static void addNewField(Event pEvent) throws Exception {
049: new EventMessageFieldUserObject(null).addNewObject(
050: getObjectPackage(pEvent), pEvent.getMessageFields());
051: }
052:
053: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
054: EnterpriseModelPackage lEnterpriseModelPackage = pPackage
055: .getEnterpriseModel();
056: EventMessageFieldClass lClass = lEnterpriseModelPackage
057: .getEventMessageField();
058: return new EventMessageFieldUserObject(lClass
059: .createEventMessageField());
060: }
061:
062: public EventMessageField getField() {
063: return mField;
064: }
065:
066: // return object root node captions
067: public String getRootNodeName() {
068: return Application.getString("messagefields_node");
069: }
070:
071: // load object properties into grid control
072: public void loadObjectProperties(PropertiesTableModel pModel)
073: throws Exception {
074: super .loadObjectProperties(pModel);
075: if (pModel == null || mField == null)
076: return;
077:
078: pModel.AddProperty("Is Array", boolToString(mField.isArray()));
079: Message lMessage = mField.getMessageType();
080: pModel.AddProperty("Message Type",
081: (lMessage != null) ? lMessage.getName() : "");
082: }
083:
084: // get object editor
085: public BasePropertiesDialog getObjectEditor() {
086: return new EventMessageFieldPropertiesDialog();
087: }
088:
089: // return master collection
090: protected ModelCollectionInfo extractMasterCollection() {
091: ModelCollectionInfo lResult = new ModelCollectionInfo(null,
092: null);
093: if (mField != null) {
094: Event lEvent = mField.getEvent();
095: if (lEvent != null) {
096: lResult.mCollection = ModelElementUtils
097: .getListOfModelElementsInAlphabeticalOrder(lEvent
098: .getMessageFields());
099: lResult.mElement = lEvent;
100: }
101: }
102: return lResult;
103: }
104:
105: // can duplicate model element
106: public boolean canDuplicate() {
107: return true;
108: }
109:
110: // duplicate model element
111: public ModelElement duplicate() throws Exception {
112: EventMessageField lField = (EventMessageField) Application.sModelRepository
113: .duplicateModelElement(mField);
114: lField.setEvent(mField.getEvent());
115: return lField;
116: }
117: }
|