01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.applications.designstudio.userobjects;
16:
17: import com.metaboss.applications.designstudio.Application;
18: import com.metaboss.applications.designstudio.BaseUserObject;
19: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
20: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
21: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionaryModelPackage;
22: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
23: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.StructureField;
24: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.StructureFieldClass;
25:
26: /* Structure Field user object */
27:
28: public class StructureFieldUserObject extends
29: AbstractDataFieldUserObject {
30: private StructureField mField = null;
31:
32: public StructureFieldUserObject(StructureField pField) {
33: super (pField);
34: mField = pField;
35: }
36:
37: // create new service module
38: public static void addNewStructureField(Structure pStructure)
39: throws Exception {
40: new StructureFieldUserObject(null).addNewObject(
41: getObjectPackage(pStructure), pStructure.getFields());
42: }
43:
44: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
45: DataDictionaryModelPackage lDataDictionaryModelPackage = pPackage
46: .getDataDictionaryModel();
47: StructureFieldClass lClass = lDataDictionaryModelPackage
48: .getStructureField();
49: return new StructureFieldUserObject(lClass
50: .createStructureField());
51: }
52:
53: public StructureField getField() {
54: return mField;
55: }
56:
57: // return master collection
58: protected ModelCollectionInfo extractMasterCollection() {
59: ModelCollectionInfo lResult = new ModelCollectionInfo(null,
60: null);
61: if (mField != null) {
62: Structure lStructure = mField.getOwnerStructure();
63: if (lStructure != null) {
64: lResult.mCollection = lStructure.getFields();
65: lResult.mElement = lStructure;
66: }
67: }
68: return lResult;
69: }
70:
71: // duplicate model element
72: public ModelElement duplicate() throws Exception {
73: StructureField lStructureField = (StructureField) Application.sModelRepository
74: .duplicateModelElement(mField);
75: lStructureField.setOwnerStructure(mField.getOwnerStructure());
76: return lStructureField;
77: }
78: }
|