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 java.util.ArrayList;
018:
019: import com.metaboss.applications.designstudio.Application;
020: import com.metaboss.applications.designstudio.BasePropertiesDialog;
021: import com.metaboss.applications.designstudio.BaseUserObject;
022: import com.metaboss.applications.designstudio.propertiesdialogs.EntityPropertiesDialog;
023: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
024:
025: /* User object for Entity Generalization */
026:
027: public class EntityGeneralizationUserObject extends BaseUserObject {
028: private Entity mEntity = null;
029:
030: public EntityGeneralizationUserObject(Entity pEntity)
031: throws Exception {
032: super (pEntity, null);
033: mEntity = pEntity;
034: }
035:
036: public EntityGeneralizationUserObject() throws Exception {
037: super (null, null);
038: }
039:
040: public void setEntity(Entity pEntity) throws Exception {
041: Entity lOldSuperType = (mEntity != null) ? mEntity
042: .getSupertype() : null;
043:
044: setNewSuperType(null);
045:
046: mEntity = pEntity;
047: mObject = pEntity;
048:
049: setNewSuperType(lOldSuperType);
050: }
051:
052: public Entity getEntity() {
053: return mEntity;
054: }
055:
056: public String toString() {
057: return "";
058: }
059:
060: // fill actions list
061: public void fillActionsList(ArrayList pList) {
062: pList.add(mEditAction);
063: pList.add(mDeleteAction);
064: }
065:
066: public BasePropertiesDialog getObjectEditor() {
067: return new EntityPropertiesDialog();
068: }
069:
070: public void deleteObject() throws Exception {
071: if (mEntity != null) {
072: Application.beginTransaction();
073: try {
074: mEntity.setSupertype(null);
075: Application.commit();
076: Application.fireObjectDeleted(this );
077: } finally {
078: Application.checkAndRollback();
079: }
080: }
081: }
082:
083: public void setNewSuperType(Entity pEntity) throws Exception {
084: if (mEntity == null)
085: return;
086: EntityUserObject.setNewSuperType(mEntity, pEntity);
087: }
088:
089: public Entity getSuperType() throws Exception {
090: return (mEntity != null) ? mEntity.getSupertype() : null;
091: }
092:
093: public boolean isSuperTypeChanged(Entity pNewSuperType)
094: throws Exception {
095: Entity lOldSuperType = getSuperType();
096: return ((lOldSuperType != null && pNewSuperType != null && !lOldSuperType
097: .equals(pNewSuperType))
098: || (lOldSuperType != null && pNewSuperType == null) || (lOldSuperType == null && pNewSuperType != null));
099: }
100:
101: public boolean isEnityChanged(Entity pNewEntity) throws Exception {
102: return ((mEntity != null && pNewEntity != null && !mEntity
103: .equals(pNewEntity))
104: || (mEntity != null && pNewEntity == null) || (mEntity == null && pNewEntity != null));
105: }
106:
107: public String getDeletePromptText() {
108: return "Delete Generalization?";
109: }
110: }
|