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.OutputMessagePropertiesDialog;
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.enterprisemodel.AbstractOperation;
025: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EnterpriseModelPackage;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationOutputMessage;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationOutputMessageClass;
029:
030: /* BOOutputMessage user object class */
031:
032: public class OperationOutputMessageUserObject extends BaseUserObject {
033: private OperationOutputMessage mMessage = null;
034:
035: public OperationOutputMessageUserObject(
036: OperationOutputMessage pMessage) {
037: super (pMessage, Application.OUTMESSAGE_ICON);
038: mMessage = pMessage;
039: }
040:
041: public OperationOutputMessageUserObject(
042: OperationOutputMessage pMessage, String pCaption, int pMode) {
043: super (pMessage, pCaption, pMode);
044: mMessage = pMessage;
045: }
046:
047: // create new message
048: public static void addNewMessage(AbstractOperation pOperation)
049: throws Exception {
050: new OperationOutputMessageUserObject(null).addNewObject(
051: getObjectPackage(pOperation), pOperation
052: .getOutputMessages());
053: }
054:
055: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
056: EnterpriseModelPackage lEnterpriseModelPackage = pPackage
057: .getEnterpriseModel();
058: OperationOutputMessageClass lClass = lEnterpriseModelPackage
059: .getOperationOutputMessage();
060: OperationOutputMessage lOperationOutputMessage = lClass
061: .createOperationOutputMessage();
062: lOperationOutputMessage.setArray(false);
063: return new OperationOutputMessageUserObject(
064: lOperationOutputMessage);
065: }
066:
067: public OperationOutputMessage getMessage() {
068: return mMessage;
069: }
070:
071: // return object root node captions
072: public String getRootNodeName() {
073: return Application.getString("outputmessages_node");
074: }
075:
076: // load object properties into grid control
077: public void loadObjectProperties(PropertiesTableModel pModel)
078: throws Exception {
079: super .loadObjectProperties(pModel);
080: if (pModel == null || mMessage == null)
081: return;
082:
083: pModel
084: .AddProperty("Is Array", boolToString(mMessage
085: .isArray()));
086: Message lMessage = mMessage.getMessageType();
087: pModel.AddProperty("Message Type",
088: (lMessage != null) ? lMessage.getName() : "");
089: }
090:
091: // get object editor
092: public BasePropertiesDialog getObjectEditor() {
093: return new OutputMessagePropertiesDialog();
094: }
095:
096: // return master collection
097: protected ModelCollectionInfo extractMasterCollection() {
098: ModelCollectionInfo lResult = new ModelCollectionInfo(null,
099: null);
100: if (mMessage != null) {
101: AbstractOperation lOperation = mMessage.getOperation();
102: if (lOperation != null) {
103: lResult.mCollection = lOperation.getOutputMessages();
104: lResult.mElement = lOperation;
105: }
106: }
107: return lResult;
108: }
109:
110: // can duplicate model element
111: public boolean canDuplicate() {
112: return true;
113: }
114:
115: // duplicate model element
116: public ModelElement duplicate() throws Exception {
117: OperationOutputMessage lMessage = (OperationOutputMessage) Application.sModelRepository
118: .duplicateModelElement(mMessage);
119: lMessage.setOperation(mMessage.getOperation());
120: return lMessage;
121: }
122: }
|