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.attributestable;
016:
017: import com.metaboss.applications.designstudio.BaseUserObject;
018: import com.metaboss.applications.designstudio.components.FieldsModel;
019: import com.metaboss.applications.designstudio.userobjects.AttributeUserObject;
020: import com.metaboss.applications.designstudio.userobjects.ReportEntityAttributeUserObject;
021: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
022: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
023: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
024: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ReportOutputEntity;
025:
026: /* Attributes table model */
027:
028: public class AttributesTableModel extends FieldsModel {
029: private ModelElement mEntity = null;
030:
031: public void loadAttributes(Entity pEntity, Object[] pAttributeList) {
032: this .loadAttributes(pAttributeList);
033: mEntity = pEntity;
034: }
035:
036: public void loadAttributes(ReportOutputEntity pEntity,
037: Object[] pAttributeList) {
038: this .loadAttributes(pAttributeList);
039: mEntity = pEntity;
040: }
041:
042: public void loadAttributes(Object[] pAttributeList) {
043: mFields.clear();
044: if (pAttributeList != null) {
045: for (int i = 0; i < pAttributeList.length; i++)
046: mFields.add(new AttributeUserObject(
047: (Attribute) pAttributeList[i]));
048: }
049: fireTableDataChanged();
050: }
051:
052: public AttributeUserObject getAttribute(int pIndex) {
053: return (AttributeUserObject) mFields.get(pIndex);
054: }
055:
056: public Object getValueAt(int r, int c) {
057: AttributeUserObject lAttribute = null;
058: try {
059: lAttribute = (AttributeUserObject) mFields.get(r);
060: } catch (Exception e) {
061: lAttribute = null;
062: }
063: if (lAttribute != null) {
064: try {
065: switch (c) {
066: case 0:
067: return lAttribute.getIcon();
068: case 1:
069: return lAttribute.toString();
070: case 2:
071: return lAttribute.getAttribute().getStereotype()
072: .toString();
073: case 3:
074: return lAttribute.getToolTip();
075: }
076: } catch (Exception e) {
077: e.printStackTrace();
078: }
079: }
080: return null;
081: }
082:
083: public String getColumnName(int c) {
084: switch (c) {
085: case 0:
086: return "..";
087: case 1:
088: return "Attribute";
089: case 2:
090: return "Stereotype";
091: case 3:
092: return "Description";
093: }
094: return null;
095: }
096:
097: protected void processObjectInserted(BaseUserObject pObject) {
098: if (pObject instanceof AttributeUserObject) {
099: Attribute lAttribute = ((AttributeUserObject) pObject)
100: .getAttribute();
101: if (lAttribute != null
102: && mEntity.equals(lAttribute.getEntity())) {
103: mFields.add(pObject);
104: fireTableDataChanged();
105: }
106: } else if (pObject instanceof ReportEntityAttributeUserObject) {
107: Attribute lAttribute = ((ReportEntityAttributeUserObject) pObject)
108: .getAttribute();
109: if (lAttribute != null
110: && mEntity.equals(lAttribute.getEntity())) {
111: mFields.add(pObject);
112: fireTableDataChanged();
113: }
114: }
115: }
116: }
|