0001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
0002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
0003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
0005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
0006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
0008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
0011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
0012: // POSSIBILITY OF SUCH DAMAGE.
0013: //
0014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
0015: package com.metaboss.applications.designstudio.designtree;
0016:
0017: import java.util.ArrayList;
0018: import java.util.Collection;
0019: import java.util.Iterator;
0020: import java.util.List;
0021: import java.util.StringTokenizer;
0022:
0023: import javax.swing.JTree;
0024: import javax.swing.tree.DefaultMutableTreeNode;
0025: import javax.swing.tree.DefaultTreeModel;
0026: import javax.swing.tree.MutableTreeNode;
0027: import javax.swing.tree.TreeNode;
0028: import javax.swing.tree.TreePath;
0029:
0030: import com.metaboss.applications.designstudio.Application;
0031: import com.metaboss.applications.designstudio.BaseUserObject;
0032: import com.metaboss.applications.designstudio.userobjects.AbstractNamespaceUserObject;
0033: import com.metaboss.applications.designstudio.userobjects.ActorsUserObject;
0034: import com.metaboss.applications.designstudio.userobjects.AssociationRoleUserObject;
0035: import com.metaboss.applications.designstudio.userobjects.AssociationUserObject;
0036: import com.metaboss.applications.designstudio.userobjects.AttributeUserObject;
0037: import com.metaboss.applications.designstudio.userobjects.DataDictionaryUserObject;
0038: import com.metaboss.applications.designstudio.userobjects.DataTypeUserObject;
0039: import com.metaboss.applications.designstudio.userobjects.DesignLibUserObject;
0040: import com.metaboss.applications.designstudio.userobjects.DomainEntitiesDiagramUserObject;
0041: import com.metaboss.applications.designstudio.userobjects.DomainUserObject;
0042: import com.metaboss.applications.designstudio.userobjects.EnterpriseSystemsDiagramUserObject;
0043: import com.metaboss.applications.designstudio.userobjects.EnterpriseUserObject;
0044: import com.metaboss.applications.designstudio.userobjects.EntityStateDiagramUserObject;
0045: import com.metaboss.applications.designstudio.userobjects.EntityUserObject;
0046: import com.metaboss.applications.designstudio.userobjects.EventDataFieldUserObject;
0047: import com.metaboss.applications.designstudio.userobjects.EventMessageFieldUserObject;
0048: import com.metaboss.applications.designstudio.userobjects.EventSubscriptionOperationUserObject;
0049: import com.metaboss.applications.designstudio.userobjects.EventSubscriptionUserObject;
0050: import com.metaboss.applications.designstudio.userobjects.EventUserObject;
0051: import com.metaboss.applications.designstudio.userobjects.MessageFieldUserObject;
0052: import com.metaboss.applications.designstudio.userobjects.MessageUserObject;
0053: import com.metaboss.applications.designstudio.userobjects.ModelElementConstraintUserObject;
0054: import com.metaboss.applications.designstudio.userobjects.ModelUserObject;
0055: import com.metaboss.applications.designstudio.userobjects.NamespaceUserObject;
0056: import com.metaboss.applications.designstudio.userobjects.OperationInputFieldUserObject;
0057: import com.metaboss.applications.designstudio.userobjects.OperationOutputFieldUserObject;
0058: import com.metaboss.applications.designstudio.userobjects.OperationOutputMessageUserObject;
0059: import com.metaboss.applications.designstudio.userobjects.OperationUserObject;
0060: import com.metaboss.applications.designstudio.userobjects.OutputElementUserObject;
0061: import com.metaboss.applications.designstudio.userobjects.PackageNodeUserObject;
0062: import com.metaboss.applications.designstudio.userobjects.PrimaryKeyElementUserObject;
0063: import com.metaboss.applications.designstudio.userobjects.PropertyDescriptorUserObject;
0064: import com.metaboss.applications.designstudio.userobjects.PropertyUserObject;
0065: import com.metaboss.applications.designstudio.userobjects.RelationalAssociationTableUserObject;
0066: import com.metaboss.applications.designstudio.userobjects.RelationalEntityTableAttributeColumnUserObject;
0067: import com.metaboss.applications.designstudio.userobjects.RelationalEntityTableReferenceColumnUserObject;
0068: import com.metaboss.applications.designstudio.userobjects.RelationalEntityTableUserObject;
0069: import com.metaboss.applications.designstudio.userobjects.RelationalReferenceTableUserObject;
0070: import com.metaboss.applications.designstudio.userobjects.RelationalStorageDefinitionUserObject;
0071: import com.metaboss.applications.designstudio.userobjects.RelationalStorageTechnologyUserObject;
0072: import com.metaboss.applications.designstudio.userobjects.ReportEntityAttributeUserObject;
0073: import com.metaboss.applications.designstudio.userobjects.ReportEntityUserObject;
0074: import com.metaboss.applications.designstudio.userobjects.ReportInputFieldUserObject;
0075: import com.metaboss.applications.designstudio.userobjects.ReportOutputFieldUserObject;
0076: import com.metaboss.applications.designstudio.userobjects.ReportUserObject;
0077: import com.metaboss.applications.designstudio.userobjects.SelectorInputFieldUserObject;
0078: import com.metaboss.applications.designstudio.userobjects.SelectorUserObject;
0079: import com.metaboss.applications.designstudio.userobjects.ServiceImplementationUserObject;
0080: import com.metaboss.applications.designstudio.userobjects.ServiceUserObject;
0081: import com.metaboss.applications.designstudio.userobjects.ServicemoduleStructuresDiagramUserObject;
0082: import com.metaboss.applications.designstudio.userobjects.ServicemoduleUserObject;
0083: import com.metaboss.applications.designstudio.userobjects.StateMachineUserObject;
0084: import com.metaboss.applications.designstudio.userobjects.StateUserObject;
0085: import com.metaboss.applications.designstudio.userobjects.StructureFieldUserObject;
0086: import com.metaboss.applications.designstudio.userobjects.StructureUserObject;
0087: import com.metaboss.applications.designstudio.userobjects.SystemUseCasesDiagramUserObject;
0088: import com.metaboss.applications.designstudio.userobjects.SystemUserObject;
0089: import com.metaboss.applications.designstudio.userobjects.TechLibUserObject;
0090: import com.metaboss.applications.designstudio.userobjects.TransitionUserObject;
0091: import com.metaboss.applications.designstudio.userobjects.TypeTemplateUserObject;
0092: import com.metaboss.applications.designstudio.userobjects.UseCaseUserObject;
0093: import com.metaboss.applications.designstudio.userobjects.UserObjectFactory;
0094: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
0095: import com.metaboss.sdlctools.models.metabossmodel.ModelElementConstraint;
0096: import com.metaboss.sdlctools.models.metabossmodel.ModelElementUtils;
0097: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
0098: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
0099: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Namespace;
0100: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Property;
0101: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.PropertyDescriptor;
0102: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
0103: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.StructureField;
0104: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.TypeTemplate;
0105: import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
0106: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
0107: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Event;
0108: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventDataField;
0109: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventMessageField;
0110: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventSubscription;
0111: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventSubscriptionOperation;
0112: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
0113: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.MessageField;
0114: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Operation;
0115: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationInputField;
0116: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationOutputField;
0117: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationOutputMessage;
0118: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
0119: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
0120: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System;
0121: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Association;
0122: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
0123: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
0124: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
0125: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
0126: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.PrimaryKeyElement;
0127: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Report;
0128: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ReportInputField;
0129: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ReportOutputElement;
0130: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ReportOutputEntity;
0131: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ReportOutputField;
0132: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Selector;
0133: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorInputField;
0134: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ServiceImplementation;
0135: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.DomainRelationalStorageDefinition;
0136: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalAssociationTable;
0137: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTable;
0138: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTableAttributeColumn;
0139: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTableReferenceColumn;
0140: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalReferenceTable;
0141: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.Actor;
0142: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.UsageSpecification;
0143: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.UseCase;
0144: import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.State;
0145: import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.StateMachine;
0146: import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.Transition;
0147: import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.RelationalStorageTechnology;
0148: import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.TechnologyLibrary;
0149: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.DomainEntitiesDiagram;
0150: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.EnterpriseSystemsDiagram;
0151: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.EntityStateDiagram;
0152: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.ServicemoduleStructuresDiagram;
0153: import com.metaboss.sdlctools.models.metabossmodel.visualmodel.SystemUseCasesDiagram;
0154:
0155: /* Design Tree Model */
0156:
0157: public class MetaBossPackageTreeModel extends DefaultTreeModel {
0158: protected ModelUserObject mPackage = null;
0159: protected ModelUserObject mDesignLib = null;
0160: protected ModelUserObject mTechLib = null;
0161: protected boolean mIgnoreExpanded = false;
0162:
0163: public MetaBossPackageTreeModel() {
0164: super (null);
0165: }
0166:
0167: // load MetaBoss model
0168: public void loadModel(ModelUserObject pPackage) {
0169: if (root != null)
0170: ((DefaultMutableTreeNode) root).removeAllChildren();
0171:
0172: mPackage = pPackage;
0173: try {
0174: ModelElement lElement = mPackage.getRootElement();
0175: if (lElement instanceof Enterprise) {
0176: Enterprise lEnterprise = (Enterprise) lElement;
0177: root = new DefaultMutableTreeNode(
0178: new EnterpriseUserObject(lEnterprise), true);
0179: addEnterpriseNodes(((DefaultMutableTreeNode) root),
0180: lEnterprise);
0181: } else if (lElement instanceof DesignLibrary) {
0182: DesignLibrary lDesignLibrary = (DesignLibrary) lElement;
0183: root = new DefaultMutableTreeNode(
0184: new DesignLibUserObject(lDesignLibrary), true);
0185: addDesignLibraryNodes(((DefaultMutableTreeNode) root),
0186: lDesignLibrary);
0187: } else if (lElement instanceof TechnologyLibrary) {
0188: TechnologyLibrary lTechnologyLibrary = (TechnologyLibrary) lElement;
0189: root = new DefaultMutableTreeNode(
0190: new TechLibUserObject(lTechnologyLibrary), true);
0191: addTechLibraryNodes(((DefaultMutableTreeNode) root),
0192: lTechnologyLibrary);
0193: }
0194: } catch (Exception e) {
0195: e.printStackTrace();
0196: }
0197: }
0198:
0199: public void loadModel(ModelUserObject pDesignLib,
0200: ModelUserObject pTechLib) {
0201: if (root != null)
0202: ((DefaultMutableTreeNode) root).removeAllChildren();
0203:
0204: mDesignLib = pDesignLib;
0205: mTechLib = pTechLib;
0206: try {
0207: root = new DefaultMutableTreeNode(
0208: new PackageNodeUserObject(null), true);
0209: if (mDesignLib != null) {
0210: DesignLibrary lDesignLibrary = (DesignLibrary) mDesignLib
0211: .getRootElement();
0212: addDesignLibraryNode((DefaultMutableTreeNode) root,
0213: lDesignLibrary, true);
0214: }
0215: if (mTechLib != null) {
0216: TechnologyLibrary lTechnologyLibrary = (TechnologyLibrary) mTechLib
0217: .getRootElement();
0218: addTechLibraryNode((DefaultMutableTreeNode) root,
0219: lTechnologyLibrary, true);
0220: }
0221: } catch (Exception e) {
0222: e.printStackTrace();
0223: }
0224: }
0225:
0226: public void loadModel(TypeTemplate pTypeTemplate) {
0227: if (root != null)
0228: ((DefaultMutableTreeNode) root).removeAllChildren();
0229: try {
0230: root = new DefaultMutableTreeNode(
0231: new PackageNodeUserObject(null), true);
0232: if (pTypeTemplate != null) {
0233: Collection lProperties = sortCollection(pTypeTemplate
0234: .getPropertyDescriptors());
0235: addPropertyDescriptors((DefaultMutableTreeNode) root,
0236: lProperties, false);
0237: }
0238: } catch (Exception e) {
0239: e.printStackTrace();
0240: }
0241: }
0242:
0243: public void loadModel(DataType pDataType) {
0244: if (root != null)
0245: ((DefaultMutableTreeNode) root).removeAllChildren();
0246: try {
0247: root = new DefaultMutableTreeNode(
0248: new PackageNodeUserObject(null), true);
0249: if (pDataType != null) {
0250: //SortedSet lProperties = ModelElementUtils.getSetOfModelElementsInAlphabeticalOrder(pDataType.getTypetemplateProperties());
0251: //Object[] lProperties = pDataType.getTypetemplateProperties().toArray();
0252:
0253: // causes elements removal from the result list
0254: Collection lProperties = sortCollection(pDataType
0255: .getTypetemplateProperties());
0256: addDataTypeProperties((DefaultMutableTreeNode) root,
0257: lProperties, false);
0258: }
0259: } catch (Exception e) {
0260: e.printStackTrace();
0261: }
0262: }
0263:
0264: // load model again
0265: public void reLoadModel() {
0266: if (mPackage != null)
0267: loadModel(mPackage);
0268: else
0269: loadModel(mDesignLib, mTechLib);
0270: reload();
0271: }
0272:
0273: public int getChildCount() {
0274: return getRootNode().getChildCount();
0275: }
0276:
0277: public DefaultMutableTreeNode getRootNode() {
0278: return (DefaultMutableTreeNode) root;
0279: }
0280:
0281: // find child node by caption
0282: public TreeNode findChildNodeByCaption(String pCaption,
0283: boolean pReverse) {
0284: return findChildNodeByCaption(getRootNode(), pCaption, pReverse);
0285: }
0286:
0287: public TreeNode findChildNodeByCaption(TreeNode pParentNode,
0288: String pCaption, boolean pReverse) {
0289: if (pCaption != null && pParentNode != null) {
0290: if (pParentNode.toString() != null
0291: && pCaption.compareTo(pParentNode.toString()) == 0)
0292: return pParentNode;
0293:
0294: for (int i = 0; i < pParentNode.getChildCount(); i++) {
0295: TreeNode lNode = pParentNode.getChildAt(i);
0296: String lCaption = lNode.toString();
0297: if (lCaption != null
0298: && lCaption.compareTo(pCaption) == 0)
0299: return lNode;
0300: if (pReverse) {
0301: lNode = findChildNodeByCaption(lNode, pCaption,
0302: pReverse);
0303: if (lNode != null)
0304: return lNode;
0305: }
0306: }
0307: }
0308: return null;
0309: }
0310:
0311: // add new object to the tree
0312: public void addNewObject(BaseUserObject pObject, JTree pTree) {
0313: if (pObject == null || pObject.getBOObject() == null
0314: || !pObject.addToTree())
0315: return;
0316:
0317: ModelElement lMaster = pObject.getMasterElement();
0318: DefaultMutableTreeNode lMasterNode = (lMaster != null) ? findChildNodeByModelElement(lMaster)
0319: : null;
0320: String lRootNodeName = pObject.getRootNodeName();
0321:
0322: if (lMasterNode == null)
0323: lMasterNode = getRootNode();
0324:
0325: /*
0326: if (lRootNodeName!=null && lRootNodeName.length()>0)
0327: {
0328: DefaultMutableTreeNode lRootNode = createRootNodes(lMaster, lRootNodeName, lMasterNode, pTree);
0329: addNewNode(pObject, lRootNode, pTree);
0330: }
0331: else
0332: addNewNode(pObject, lMasterNode, pTree);*/
0333:
0334: if (lRootNodeName != null && lRootNodeName.length() > 0) {
0335: DefaultMutableTreeNode lRootNode = createRootNodes(lMaster,
0336: lRootNodeName, lMasterNode, pTree);
0337: lMasterNode = lRootNode;
0338: }
0339: // special rulles for Property
0340: if (pObject instanceof PropertyUserObject) {
0341: PropertyUserObject lPropertyUserObject = (PropertyUserObject) pObject;
0342: DefaultMutableTreeNode lNode = createParentNodeForProperty(
0343: lPropertyUserObject.getProperty(), lMasterNode);
0344: if (lNode != null)
0345: addNewNode(lNode, lMasterNode, pTree);
0346: lMasterNode = getParentNodeForProperty(lPropertyUserObject
0347: .getProperty(), lMasterNode);
0348: }
0349: addNewNode(pObject, lMasterNode, pTree);
0350: }
0351:
0352: // add node to the tree
0353: public void addNewNode(TreeNode pNode, TreeNode pParentNode,
0354: JTree pTree) {
0355: insertNodeInto((MutableTreeNode) pNode,
0356: (MutableTreeNode) pParentNode, pParentNode
0357: .getChildCount());
0358: checkParentNode(pNode, pTree);
0359: }
0360:
0361: public void addNewNode(BaseUserObject pObject,
0362: TreeNode pParentNode, JTree pTree) {
0363: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
0364: pObject, true);
0365: addNewNode(lNode, pParentNode, pTree);
0366: }
0367:
0368: // check parent node
0369: public void checkParentNode(TreeNode pNode, JTree pTree) {
0370: TreeNode lParentNode = pNode.getParent();
0371: if (lParentNode != null
0372: && (pTree.isExpanded(new TreePath(
0373: getPathToRoot(lParentNode))) || mIgnoreExpanded)) {
0374: TreeNode[] nodes = getPathToRoot(pNode);
0375: TreePath path = new TreePath(nodes);
0376: pTree.scrollPathToVisible(path);
0377: pTree.setSelectionPath(path);
0378: }
0379: }
0380:
0381: // remove tree node
0382: public void removeNode(BaseUserObject pObject) {
0383: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) findChildNodeByObject(
0384: (DefaultMutableTreeNode) root, pObject);
0385: removeNode(lNode);
0386: }
0387:
0388: public void removeNode(String pID) {
0389: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) findChildNodeByID(
0390: (DefaultMutableTreeNode) root, pID);
0391: removeNode(lNode);
0392: }
0393:
0394: public void removeNode(DefaultMutableTreeNode pNode) {
0395: if (pNode == null)
0396: return;
0397:
0398: DefaultMutableTreeNode lParentNode = (DefaultMutableTreeNode) pNode
0399: .getParent();
0400: removeNodeFromParent(pNode);
0401: if (lParentNode != null && lParentNode.getChildCount() == 0
0402: && !lParentNode.equals(getRootNode())) {
0403: Object lObject = lParentNode.getUserObject();
0404: if (lObject == null
0405: || (lObject instanceof BaseUserObject && ((BaseUserObject) lObject)
0406: .getMode() > 0)
0407: || lObject instanceof PackageNodeUserObject) {
0408: //???removeNode(lParentNode);
0409: removeNodeFromParent(lParentNode);
0410: }
0411: }
0412: }
0413:
0414: // select object's node
0415: public void selectNode(BaseUserObject pObject, JTree pTree) {
0416: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) findChildNodeByObject(
0417: (DefaultMutableTreeNode) root, pObject);
0418: if (lNode != null)
0419: selectNode(lNode, pTree);
0420: }
0421:
0422: public void selectNode(DefaultMutableTreeNode pNode, JTree pTree) {
0423: if (pNode != null) {
0424: TreeNode[] nodes = getPathToRoot(pNode);
0425: TreePath path = new TreePath(nodes);
0426: pTree.scrollPathToVisible(path);
0427: pTree.setSelectionPath(path);
0428: } else {
0429: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) pTree
0430: .getLastSelectedPathComponent();
0431: if (lNode != null) {
0432: TreeNode[] nodes = getPathToRoot(lNode);
0433: TreePath path = new TreePath(nodes);
0434: pTree.removeSelectionPath(path);
0435: }
0436: }
0437: }
0438:
0439: // find child node by user object
0440: public DefaultMutableTreeNode findChildNodeByObject(
0441: BaseUserObject pObject) {
0442: return findChildNodeByObject((DefaultMutableTreeNode) root,
0443: pObject);
0444: }
0445:
0446: public DefaultMutableTreeNode findChildNodeByObject(
0447: DefaultMutableTreeNode pParentNode, BaseUserObject pObject) {
0448: if (pObject != null) {
0449: if (pObject.equals(pParentNode.getUserObject()))
0450: return pParentNode;
0451:
0452: for (int i = 0; i < pParentNode.getChildCount(); i++) {
0453: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) pParentNode
0454: .getChildAt(i);
0455: if (lNode.getUserObject().equals(pObject))
0456: return lNode;
0457: lNode = findChildNodeByObject(lNode, pObject);
0458: if (lNode != null)
0459: return lNode;
0460: }
0461: }
0462: return null;
0463: }
0464:
0465: // find child node by ID
0466: public DefaultMutableTreeNode findChildNodeByID(String pID) {
0467: return findChildNodeByID((DefaultMutableTreeNode) root, pID);
0468: }
0469:
0470: public DefaultMutableTreeNode findChildNodeByID(
0471: DefaultMutableTreeNode pParentNode, String pID) {
0472: if (pID.equals(((BaseUserObject) pParentNode.getUserObject())
0473: .getID()))
0474: return pParentNode;
0475:
0476: for (int i = 0; i < pParentNode.getChildCount(); i++) {
0477: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) pParentNode
0478: .getChildAt(i);
0479: if (((BaseUserObject) lNode.getUserObject()).getID()
0480: .equals(pID))
0481: return lNode;
0482: lNode = findChildNodeByID(lNode, pID);
0483: if (lNode != null)
0484: return lNode;
0485: }
0486: return null;
0487: }
0488:
0489: // find child node by ref
0490: public DefaultMutableTreeNode findChildNodeByRef(String pRef) {
0491: return findChildNodeByRef((DefaultMutableTreeNode) root, pRef);
0492: }
0493:
0494: public DefaultMutableTreeNode findChildNodeByRef(
0495: DefaultMutableTreeNode pParentNode, String pRef) {
0496: if (pRef.equals(((BaseUserObject) pParentNode.getUserObject())
0497: .getRef()))
0498: return pParentNode;
0499:
0500: for (int i = 0; i < pParentNode.getChildCount(); i++) {
0501: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) pParentNode
0502: .getChildAt(i);
0503: if (((BaseUserObject) lNode.getUserObject()).getRef()
0504: .equals(pRef))
0505: return lNode;
0506: lNode = findChildNodeByRef(lNode, pRef);
0507: if (lNode != null)
0508: return lNode;
0509: }
0510: return null;
0511: }
0512:
0513: // find child node by wrapped model element
0514: public DefaultMutableTreeNode findChildNodeByModelElement(
0515: ModelElement pElement) {
0516: return findChildNodeByModelElement(
0517: (DefaultMutableTreeNode) root, pElement);
0518: }
0519:
0520: public DefaultMutableTreeNode findChildNodeByModelElement(
0521: DefaultMutableTreeNode pParentNode, ModelElement pElement) {
0522: Object lObject = pParentNode.getUserObject();
0523: if (lObject != null
0524: && lObject instanceof BaseUserObject
0525: && pElement.equals(((BaseUserObject) lObject)
0526: .getBOObject()))
0527: return pParentNode;
0528:
0529: for (int i = 0; i < pParentNode.getChildCount(); i++) {
0530: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) pParentNode
0531: .getChildAt(i);
0532: lObject = lNode.getUserObject();
0533: if (lObject != null
0534: && lObject instanceof BaseUserObject
0535: && pElement.equals(((BaseUserObject) lObject)
0536: .getBOObject()))
0537: return lNode;
0538: lNode = findChildNodeByModelElement(lNode, pElement);
0539: if (lNode != null)
0540: return lNode;
0541: }
0542: return null;
0543: }
0544:
0545: // make first tree level visible
0546: public void makeFirstLevelVisisble(JTree pTree) {
0547: if (pTree == null)
0548: return;
0549:
0550: for (int i = 0; i < getRootNode().getChildCount(); i++) {
0551: TreeNode mEnterpriseNode = getRootNode().getChildAt(i);
0552: TreeNode[] nodes = getPathToRoot(mEnterpriseNode);
0553: TreePath path = new TreePath(nodes);
0554: pTree.expandPath(path);
0555: }
0556: }
0557:
0558: // expand all treeitems
0559: public void expandAll(JTree pTree) {
0560: if (pTree == null)
0561: return;
0562: expandAll(pTree, getRootNode());
0563: }
0564:
0565: public void expandAll(JTree pTree,
0566: DefaultMutableTreeNode pParentNode) {
0567: if (pParentNode == null || pTree == null)
0568: return;
0569:
0570: for (int i = 0; i < pParentNode.getChildCount(); i++) {
0571: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) pParentNode
0572: .getChildAt(i);
0573: if (lNode != null) {
0574: TreeNode[] nodes = getPathToRoot(lNode);
0575: TreePath path = new TreePath(nodes);
0576: pTree.expandPath(path);
0577:
0578: expandAll(pTree, lNode);
0579: }
0580: }
0581: }
0582:
0583: // collapse all treeitems
0584: public void collapseAll(JTree pTree) {
0585: if (pTree == null)
0586: return;
0587: collapseAll(pTree, getRootNode());
0588: }
0589:
0590: public void collapseAll(JTree pTree,
0591: DefaultMutableTreeNode pParentNode) {
0592: if (pParentNode == null || pTree == null)
0593: return;
0594:
0595: for (int i = 0; i < pParentNode.getChildCount(); i++) {
0596: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) pParentNode
0597: .getChildAt(i);
0598: if (lNode != null) {
0599: collapseAll(pTree, lNode);
0600:
0601: TreeNode[] nodes = getPathToRoot(lNode);
0602: TreePath path = new TreePath(nodes);
0603: pTree.collapsePath(path);
0604: }
0605: }
0606: }
0607:
0608: // fill warning items
0609: public void fillWarnings(boolean pÑlear) {
0610: if (!pÑlear)
0611: fillWarnings(getRootNode(), true);
0612: fillWarnings(getRootNode(), pÑlear);
0613: }
0614:
0615: public void fillWarnings(DefaultMutableTreeNode pParentNode,
0616: boolean pClear) {
0617: for (int i = 0; i < pParentNode.getChildCount(); i++) {
0618: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) pParentNode
0619: .getChildAt(i);
0620: if (lNode != null) {
0621: Object lObject = lNode.getUserObject();
0622: if (lObject != null
0623: && lObject instanceof BaseUserObject) {
0624: BaseUserObject lUserObject = (BaseUserObject) lObject;
0625: if (pClear)
0626: lUserObject.mWarningCount = 0;
0627: else if (Application.isErrorElementID(lUserObject
0628: .getID()))
0629: incrementWarnings(lNode);
0630: }
0631: fillWarnings(lNode, pClear);
0632: }
0633: }
0634: }
0635:
0636: protected void incrementWarnings(DefaultMutableTreeNode pNode) {
0637: if (pNode != null) {
0638: DefaultMutableTreeNode lParentNode = (DefaultMutableTreeNode) pNode
0639: .getParent();
0640: while (lParentNode != null) {
0641: Object lObject = lParentNode.getUserObject();
0642: if (lObject != null
0643: && lObject instanceof BaseUserObject)
0644: ((BaseUserObject) lObject).mWarningCount++;
0645:
0646: lParentNode = (DefaultMutableTreeNode) lParentNode
0647: .getParent();
0648: }
0649: }
0650: }
0651:
0652: /* Helper. Adds enterprise nodes */
0653: protected void addEnterpriseNodes(
0654: DefaultMutableTreeNode pParentNode, Enterprise pEnterprise) {
0655: // systems
0656: Collection lSystems = sortCollection(pEnterprise.getSystems());
0657: DefaultMutableTreeNode lSystemsNode = new DefaultMutableTreeNode(
0658: new EnterpriseUserObject(pEnterprise, Application
0659: .getString("systems_node"),
0660: EnterpriseUserObject.SYSTEMS_ACTION), true);
0661: pParentNode.add(lSystemsNode);
0662: if (lSystems.size() > 0)
0663: addSystemNodes(lSystemsNode, lSystems);
0664:
0665: // design library
0666: DesignLibrary lDesignLibrary = pEnterprise.getDesignLibrary();
0667: if (lDesignLibrary != null)
0668: addDesignLibraryNode(pParentNode, lDesignLibrary, true);
0669:
0670: // technology lubrary
0671: TechnologyLibrary lTechLibrary = pEnterprise
0672: .getTechnologyLibrary();
0673: if (lTechLibrary != null)
0674: addTechLibraryNode(pParentNode, lTechLibrary, true);
0675:
0676: // add diagrams
0677: Collection lDiagrams = sortCollection(pEnterprise
0678: .getEnterpriseSystemsDiagrams());
0679: if (lDiagrams.size() > 0) {
0680: DefaultMutableTreeNode lDiagramsNode = new DefaultMutableTreeNode(
0681: new EnterpriseUserObject(pEnterprise, Application
0682: .getString("diagrams_node"),
0683: EnterpriseUserObject.ADD_DIAGRAM), true);
0684: pParentNode.add(lDiagramsNode);
0685: addEnterpriseSystemsDiagrams(lDiagramsNode, lDiagrams);
0686: }
0687: }
0688:
0689: // add System object nodes
0690: protected void addSystemNodes(DefaultMutableTreeNode pParentNode,
0691: Collection pSystems) {
0692: for (Iterator lIterator = pSystems.iterator(); lIterator
0693: .hasNext();) {
0694: System lSystem = (System) lIterator.next();
0695: DefaultMutableTreeNode lSystemNode = new DefaultMutableTreeNode(
0696: new SystemUserObject(lSystem), true);
0697: pParentNode.add(lSystemNode);
0698:
0699: // usage specification
0700: UsageSpecification lUsageSpecification = lSystem
0701: .getUsageSpecification();
0702: if (lUsageSpecification != null)
0703: addUsageSpecificationNodes(lSystemNode,
0704: lUsageSpecification);
0705:
0706: // public interfaces
0707: DefaultMutableTreeNode lPublicInterfacesNode = new DefaultMutableTreeNode(
0708: new SystemUserObject(lSystem, Application
0709: .getString("publicinterfaces_node"),
0710: SystemUserObject.PUBLICINTERFACES_ACTION),
0711: true);
0712: lSystemNode.add(lPublicInterfacesNode);
0713:
0714: // add system services tree
0715: Collection lServiceModules = sortCollection(lSystem
0716: .getServicemodules());
0717: if (lServiceModules.size() > 0) {
0718: DefaultMutableTreeNode lServiceModulesNode = new DefaultMutableTreeNode(
0719: new SystemUserObject(lSystem, Application
0720: .getString("servicemodules_node"),
0721: SystemUserObject.SERVICEMODULE_ACTION),
0722: true);
0723: lPublicInterfacesNode.add(lServiceModulesNode);
0724: addServiceModulesNodes(lServiceModulesNode,
0725: lServiceModules);
0726: }
0727:
0728: // data dictionary
0729: DataDictionary lDictionary = lSystem.getDataDictionary();
0730: if (lDictionary != null)
0731: addDataDictionaryNodes(lPublicInterfacesNode,
0732: lDictionary);
0733:
0734: // system implementation
0735: DefaultMutableTreeNode lImplementationNode = new DefaultMutableTreeNode(
0736: new SystemUserObject(
0737: lSystem,
0738: Application
0739: .getString("implemetationcomponents_node"),
0740: SystemUserObject.IMPLEMETATIONCOMPONENTS_ACTION),
0741: true);
0742: lSystemNode.add(lImplementationNode);
0743:
0744: // Add domains tree
0745: Collection lDomains = sortCollection(lSystem.getDomains());
0746: if (lDomains.size() > 0) {
0747: DefaultMutableTreeNode lDomainsNode = new DefaultMutableTreeNode(
0748: new SystemUserObject(lSystem, Application
0749: .getString("domains_node"),
0750: SystemUserObject.DOMAIN_ACTION), true);
0751: lImplementationNode.add(lDomainsNode);
0752: addDomainNodes(lDomainsNode, lDomains);
0753: }
0754: }
0755: }
0756:
0757: // add DataDictionary object nodes
0758: protected void addDataDictionaryNodes(
0759: DefaultMutableTreeNode pParentNode,
0760: DataDictionary pDictionary) {
0761: DefaultMutableTreeNode lDictionaryNode = new DefaultMutableTreeNode(
0762: new DataDictionaryUserObject(pDictionary), true);
0763: pParentNode.add(lDictionaryNode);
0764:
0765: // namespaces
0766: Collection lNameSpaces = sortCollection(pDictionary
0767: .getSubNamespaces());
0768: if (lNameSpaces.size() > 0) {
0769: DefaultMutableTreeNode lNameSpacesNode = new DefaultMutableTreeNode(
0770: new DataDictionaryUserObject(pDictionary,
0771: Application.getString("namespaces_node"),
0772: DataDictionaryUserObject.NAMESPACE_ACTION),
0773: true);
0774: lDictionaryNode.add(lNameSpacesNode);
0775: addNameSpacesNodes(lNameSpacesNode, lNameSpaces);
0776: }
0777: // typetemplates
0778: Collection lTypeTemplates = sortCollection(pDictionary
0779: .getTypeTemplates());
0780: if (lTypeTemplates.size() > 0) {
0781: DefaultMutableTreeNode lTypetemplatesNode = new DefaultMutableTreeNode(
0782: new DataDictionaryUserObject(
0783: pDictionary,
0784: Application.getString("typetemplates_node"),
0785: DataDictionaryUserObject.TYPETEMPLATE_ACTION),
0786: true);
0787: lDictionaryNode.add(lTypetemplatesNode);
0788: addTypetemplatesNodes(lTypetemplatesNode, lTypeTemplates);
0789: }
0790: // datatypes
0791: Collection lDataTypes = sortCollection(pDictionary
0792: .getDataTypes());
0793: if (lDataTypes.size() > 0) {
0794: DefaultMutableTreeNode lDatatypesNode = new DefaultMutableTreeNode(
0795: new DataDictionaryUserObject(pDictionary,
0796: Application.getString("datatypes_node"),
0797: DataDictionaryUserObject.DATATYPE_ACTION),
0798: true);
0799: lDictionaryNode.add(lDatatypesNode);
0800: addDatatypeNodes(lDatatypesNode, lDataTypes);
0801: }
0802: // structures
0803: Collection lStructures = sortCollection(pDictionary
0804: .getStructures());
0805: if (lStructures.size() > 0) {
0806: DefaultMutableTreeNode lStructuresNode = new DefaultMutableTreeNode(
0807: new DataDictionaryUserObject(pDictionary,
0808: Application.getString("structures_node"),
0809: DataDictionaryUserObject.STRUCTURE_ACTION),
0810: true);
0811: lDictionaryNode.add(lStructuresNode);
0812: addStructuresNodes(lStructuresNode, lStructures);
0813: }
0814: // messages
0815: Collection lMessages = sortCollection(pDictionary.getMessages());
0816: if (lMessages.size() > 0) {
0817: DefaultMutableTreeNode lMessagesNode = new DefaultMutableTreeNode(
0818: new DataDictionaryUserObject(pDictionary,
0819: Application.getString("messages_node"),
0820: DataDictionaryUserObject.MESSAGES_ACTION),
0821: true);
0822: lDictionaryNode.add(lMessagesNode);
0823: addMessagesNodes(lMessagesNode, lMessages);
0824: }
0825: }
0826:
0827: protected void addDataDictionaryNodes(
0828: DefaultMutableTreeNode pParentNode, Collection pDictionaries) {
0829: for (Iterator lIterator = pDictionaries.iterator(); lIterator
0830: .hasNext();) {
0831: DataDictionary lDictionary = (DataDictionary) lIterator
0832: .next();
0833: addDataDictionaryNodes(pParentNode, lDictionary);
0834: }
0835: }
0836:
0837: // add NameSpaces nodes
0838: protected void addNameSpacesNodes(
0839: DefaultMutableTreeNode pParentNode, Collection pNameSpaces) {
0840: for (Iterator lIterator = pNameSpaces.iterator(); lIterator
0841: .hasNext();) {
0842: Namespace lNameSpace = (Namespace) lIterator.next();
0843: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
0844: new NamespaceUserObject(lNameSpace), true);
0845: pParentNode.add(lNode);
0846:
0847: // namespaces
0848: Collection lNameSpaces = sortCollection(lNameSpace
0849: .getSubNamespaces());
0850: if (lNameSpaces.size() > 0) {
0851: DefaultMutableTreeNode lNameSpacesNode = new DefaultMutableTreeNode(
0852: new NamespaceUserObject(lNameSpace, Application
0853: .getString("namespaces_node"),
0854: NamespaceUserObject.NAMESPACE_ACTION),
0855: true);
0856: lNode.add(lNameSpacesNode);
0857: addNameSpacesNodes(lNameSpacesNode, lNameSpaces);
0858: }
0859: // typetemplates
0860: Collection lTypeTemplates = sortCollection(lNameSpace
0861: .getTypeTemplates());
0862: if (lTypeTemplates.size() > 0) {
0863: DefaultMutableTreeNode lTypetemplatesNode = new DefaultMutableTreeNode(
0864: new NamespaceUserObject(lNameSpace, Application
0865: .getString("typetemplates_node"),
0866: NamespaceUserObject.TYPETEMPLATE_ACTION),
0867: true);
0868: lNode.add(lTypetemplatesNode);
0869: addTypetemplatesNodes(lTypetemplatesNode,
0870: lTypeTemplates);
0871: }
0872: // datatypes
0873: Collection lDataTypes = sortCollection(lNameSpace
0874: .getDataTypes());
0875: if (lDataTypes.size() > 0) {
0876: DefaultMutableTreeNode lDatatypesNode = new DefaultMutableTreeNode(
0877: new NamespaceUserObject(lNameSpace, Application
0878: .getString("datatypes_node"),
0879: NamespaceUserObject.DATATYPE_ACTION),
0880: true);
0881: lNode.add(lDatatypesNode);
0882: addDatatypeNodes(lDatatypesNode, lDataTypes);
0883: }
0884: // structures
0885: Collection lStructures = sortCollection(lNameSpace
0886: .getStructures());
0887: if (lStructures.size() > 0) {
0888: DefaultMutableTreeNode lStructuresNode = new DefaultMutableTreeNode(
0889: new NamespaceUserObject(lNameSpace, Application
0890: .getString("structures_node"),
0891: NamespaceUserObject.STRUCTURES_ACTION),
0892: true);
0893: lNode.add(lStructuresNode);
0894: addStructuresNodes(lStructuresNode, lStructures);
0895: }
0896: // messages
0897: Collection lMessages = sortCollection(lNameSpace
0898: .getMessages());
0899: if (lMessages.size() > 0) {
0900: DefaultMutableTreeNode lMessagesNode = new DefaultMutableTreeNode(
0901: new NamespaceUserObject(lNameSpace, Application
0902: .getString("messages_node"),
0903: NamespaceUserObject.MESSAGES_ACTION),
0904: true);
0905: lNode.add(lMessagesNode);
0906: addMessagesNodes(lMessagesNode, lMessages);
0907: }
0908: }
0909: }
0910:
0911: // add usage specification nodes
0912: protected void addUsageSpecificationNodes(
0913: DefaultMutableTreeNode pParentNode,
0914: UsageSpecification pUsageSpecification) {
0915: addAbstractNamespace(pParentNode, pUsageSpecification); //new UsageSpecificationUserObject(pUsageSpecification)
0916: }
0917:
0918: // add abstract namespces collection
0919: protected void addAbstractNamespaces(
0920: DefaultMutableTreeNode pParentNode, Collection pNameSpaces) {
0921: for (Iterator lIterator = pNameSpaces.iterator(); lIterator
0922: .hasNext();) {
0923: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.Namespace lNameSpace = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.Namespace) lIterator
0924: .next();
0925: addAbstractNamespace(pParentNode, lNameSpace); //new AbstractNamespaceUserObject(lNameSpace)
0926: }
0927: }
0928:
0929: // add abstract namespce
0930: protected void addAbstractNamespace(
0931: DefaultMutableTreeNode pParentNode,
0932: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemusagemodel.AbstractNamespace pNameSpace) {
0933: if (pNameSpace == null || pParentNode == null)
0934: return;
0935:
0936: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
0937: UserObjectFactory.createUserObject(pNameSpace), true);
0938: pParentNode.add(lNode);
0939:
0940: // namespaces
0941: Collection lNameSpaces = sortCollection(pNameSpace
0942: .getSubNamespaces());
0943: if (lNameSpaces.size() > 0) {
0944: DefaultMutableTreeNode lNameSpacesNode = new DefaultMutableTreeNode(
0945: new AbstractNamespaceUserObject(pNameSpace,
0946: Application.getString("namespaces_node"),
0947: AbstractNamespaceUserObject.ADD_NAMESPACE),
0948: true);
0949: lNode.add(lNameSpacesNode);
0950: addAbstractNamespaces(lNameSpacesNode, lNameSpaces);
0951: }
0952: //actors
0953: Collection lActors = sortCollection(pNameSpace.getActors());
0954: if (lActors.size() > 0) {
0955: DefaultMutableTreeNode lActorsNode = new DefaultMutableTreeNode(
0956: new AbstractNamespaceUserObject(pNameSpace,
0957: Application.getString("actors_node"),
0958: AbstractNamespaceUserObject.ADD_ACTORS),
0959: true);
0960: lNode.add(lActorsNode);
0961: addActorsNodes(lActorsNode, lActors);
0962: }
0963: // use cases
0964: Collection lUseCases = sortCollection(pNameSpace.getUseCases());
0965: if (lActors.size() > 0) {
0966: DefaultMutableTreeNode lUseCasesNode = new DefaultMutableTreeNode(
0967: new AbstractNamespaceUserObject(pNameSpace,
0968: Application.getString("usecases_node"),
0969: AbstractNamespaceUserObject.ADD_USECASE),
0970: true);
0971: lNode.add(lUseCasesNode);
0972: addUseCasesNodes(lUseCasesNode, lUseCases);
0973: }
0974: // diagrams
0975: Collection lDiagrams = sortCollection(pNameSpace
0976: .getUseCaseDiagrams());
0977: if (lDiagrams.size() > 0) {
0978: DefaultMutableTreeNode lDiagramsNode = new DefaultMutableTreeNode(
0979: new AbstractNamespaceUserObject(pNameSpace,
0980: Application.getString("diagrams_node"),
0981: ServicemoduleUserObject.ADD_DIAGRAM), true);
0982: lNode.add(lDiagramsNode);
0983: addUseCaseDiagrams(lDiagramsNode, lDiagrams);
0984: }
0985: }
0986:
0987: // add actors nodes
0988: protected void addActorsNodes(DefaultMutableTreeNode pParentNode,
0989: Collection pActors) {
0990: for (Iterator lIterator = pActors.iterator(); lIterator
0991: .hasNext();) {
0992: Actor lActor = (Actor) lIterator.next();
0993: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
0994: new ActorsUserObject(lActor), true);
0995: pParentNode.add(lNode);
0996: }
0997: }
0998:
0999: // add use cases nodes
1000: protected void addUseCasesNodes(DefaultMutableTreeNode pParentNode,
1001: Collection pUseCases) {
1002: for (Iterator lIterator = pUseCases.iterator(); lIterator
1003: .hasNext();) {
1004: UseCase lUseCase = (UseCase) lIterator.next();
1005: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1006: new UseCaseUserObject(lUseCase), true);
1007: pParentNode.add(lNode);
1008: }
1009: }
1010:
1011: /* Helper. Add application nodes */
1012: protected void addApplicationNodes(
1013: DefaultMutableTreeNode pParentNode, Object[] pApplications)
1014: throws Exception {
1015: /*for (int i = 0; i < aApplications.length; i++)
1016: {
1017: BOApplication xApplication = aApplications[i];
1018: DefaultMutableTreeNode xNode = new DefaultMutableTreeNode(new ApplicationNodeUserObject(xApplication), true);
1019: aParentNode.add(xNode);
1020: }*/
1021: }
1022:
1023: /* Helper. Adds domain nodes */
1024: protected void addDomainNodes(DefaultMutableTreeNode pParentNode,
1025: Collection pDomains) {
1026: for (Iterator lIterator = pDomains.iterator(); lIterator
1027: .hasNext();) {
1028: Domain lDomain = (Domain) lIterator.next();
1029: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1030: new DomainUserObject(lDomain), true);
1031: pParentNode.add(lNode);
1032:
1033: // add associations
1034: Collection lAssociations = sortCollection(lDomain
1035: .getAssociations());
1036: if (lAssociations.size() > 0) {
1037: DefaultMutableTreeNode lAssNode = new DefaultMutableTreeNode(
1038: new DomainUserObject(lDomain, Application
1039: .getString("associations_node"),
1040: DomainUserObject.ADD_ASSOCIATION), true);
1041: lNode.add(lAssNode);
1042: addAssociationsNodes(lAssNode, lAssociations);
1043: }
1044: // add entities
1045: Collection lEntities = sortCollection(lDomain.getEntities());
1046: if (lEntities.size() > 0) {
1047: DefaultMutableTreeNode lEntityNode = new DefaultMutableTreeNode(
1048: new DomainUserObject(lDomain, Application
1049: .getString("entities_node"),
1050: DomainUserObject.ADD_ENTITY), true);
1051: lNode.add(lEntityNode);
1052: addEntitiesNode(lEntityNode, lEntities);
1053: }
1054: // add reports tree
1055: Collection lReports = sortCollection(lDomain.getReports());
1056: if (lReports.size() > 0) {
1057: DefaultMutableTreeNode lReportsNode = new DefaultMutableTreeNode(
1058: new DomainUserObject(lDomain, Application
1059: .getString("reports_node"),
1060: DomainUserObject.ADD_REPORT), true);
1061: lNode.add(lReportsNode);
1062: addReportsNode(lReportsNode, lReports);
1063: }
1064: // add relational implementations
1065: Collection lRelationalImplementations = sortCollection(lDomain
1066: .getRelationalImplementations());
1067: if (lRelationalImplementations.size() > 0) {
1068: DefaultMutableTreeNode lRelationalImplementationsNode = new DefaultMutableTreeNode(
1069: new DomainUserObject(
1070: lDomain,
1071: Application
1072: .getString("domainimplementations_node"),
1073: DomainUserObject.ADD_RELATIONALIMPLEMENTATION),
1074: true);
1075: lNode.add(lRelationalImplementationsNode);
1076: addDomainImplementations(
1077: lRelationalImplementationsNode,
1078: lRelationalImplementations);
1079: }
1080: // add diagrams
1081: Collection lDiagrams = sortCollection(lDomain
1082: .getEntityClassDiagrams());
1083: if (lDiagrams.size() > 0) {
1084: DefaultMutableTreeNode lDiagramsNode = new DefaultMutableTreeNode(
1085: new DomainUserObject(lDomain, Application
1086: .getString("diagrams_node"),
1087: DomainUserObject.ADD_DIAGRAM), true);
1088: lNode.add(lDiagramsNode);
1089: addDomainEntitiesDiagrams(lDiagramsNode, lDiagrams);
1090: }
1091: }
1092: }
1093:
1094: /* Helper. Adds Service Modules nodes */
1095: protected void addServiceModulesNodes(
1096: DefaultMutableTreeNode pParentNode,
1097: Collection pServiceModules) {
1098: for (Iterator lIterator = pServiceModules.iterator(); lIterator
1099: .hasNext();) {
1100: Servicemodule lServicemodule = (Servicemodule) lIterator
1101: .next();
1102: DefaultMutableTreeNode lServicemoduleNode = new DefaultMutableTreeNode(
1103: new ServicemoduleUserObject(lServicemodule), true);
1104: pParentNode.add(lServicemoduleNode);
1105:
1106: // message
1107: Collection lMessages = sortCollection(lServicemodule
1108: .getMessages());
1109: if (lMessages.size() > 0) {
1110: DefaultMutableTreeNode lMessagesNode = new DefaultMutableTreeNode(
1111: new ServicemoduleUserObject(lServicemodule,
1112: Application.getString("messages_node"),
1113: ServicemoduleUserObject.ADD_MESSAGE),
1114: true);
1115: lServicemoduleNode.add(lMessagesNode);
1116: addMessagesNodes(lMessagesNode, lMessages);
1117: }
1118: //services
1119: Collection lServices = sortCollection(lServicemodule
1120: .getServices());
1121: if (lServices.size() > 0) {
1122: DefaultMutableTreeNode lServicesNode = new DefaultMutableTreeNode(
1123: new ServicemoduleUserObject(lServicemodule,
1124: Application.getString("services_node"),
1125: ServicemoduleUserObject.ADD_SERVICE),
1126: true);
1127: lServicemoduleNode.add(lServicesNode);
1128: addServicesNodes(lServicesNode, lServices);
1129: }
1130: // structures
1131: Collection lStructures = sortCollection(lServicemodule
1132: .getStructures());
1133: if (lStructures.size() > 0) {
1134: DefaultMutableTreeNode lStructuresNode = new DefaultMutableTreeNode(
1135: new ServicemoduleUserObject(lServicemodule,
1136: Application
1137: .getString("structures_node"),
1138: ServicemoduleUserObject.ADD_STRUCTURE),
1139: true);
1140: lServicemoduleNode.add(lStructuresNode);
1141: addStructuresNodes(lStructuresNode, lStructures);
1142: }
1143: // event subscriptions
1144: Collection lEventSubscriptions = sortCollection(lServicemodule
1145: .getEventSubscriptions());
1146: if (lEventSubscriptions.size() > 0) {
1147: DefaultMutableTreeNode lEventNode = new DefaultMutableTreeNode(
1148: new ServicemoduleUserObject(
1149: lServicemodule,
1150: Application
1151: .getString("eventsubscriptions_node"),
1152: ServicemoduleUserObject.ADD_EVENTESUBSCRIPTION),
1153: true);
1154: lServicemoduleNode.add(lEventNode);
1155: addEventSubscriptionsNodes(lEventNode,
1156: lEventSubscriptions);
1157: }
1158: // diagrams
1159: Collection lDiagrams = sortCollection(lServicemodule
1160: .getServicemoduleStructuresDiagrams());
1161: if (lDiagrams.size() > 0) {
1162: DefaultMutableTreeNode lDiagramsNode = new DefaultMutableTreeNode(
1163: new ServicemoduleUserObject(lServicemodule,
1164: Application.getString("diagrams_node"),
1165: ServicemoduleUserObject.ADD_DIAGRAM),
1166: true);
1167: lServicemoduleNode.add(lDiagramsNode);
1168: addServicemoduleStructuresDiagrams(lDiagramsNode,
1169: lDiagrams);
1170: }
1171: }
1172: }
1173:
1174: /* Helper. Add Service Modules Messages tree */
1175: protected void addMessagesNodes(DefaultMutableTreeNode aParentNode,
1176: Collection pMessages) {
1177: for (Iterator lIterator = pMessages.iterator(); lIterator
1178: .hasNext();)
1179: aParentNode.add(addMessageNode((Message) lIterator.next()));
1180: }
1181:
1182: /* Helper. Add Message node */
1183: protected DefaultMutableTreeNode addMessageNode(Message pMessage) {
1184: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1185: new MessageUserObject(pMessage), true);
1186:
1187: Collection lMessageFields = sortCollection(pMessage.getFields());
1188: if (lMessageFields.size() > 0) {
1189: DefaultMutableTreeNode lFieldsNode = new DefaultMutableTreeNode(
1190: new MessageUserObject(pMessage, Application
1191: .getString("fields_node"),
1192: MessageUserObject.ADD_FIELD), true);
1193: lNode.add(lFieldsNode);
1194: addMessagesFieldsNodes(lFieldsNode, lMessageFields);
1195: }
1196:
1197: return lNode;
1198: }
1199:
1200: /* Helper. Add Services tree */
1201: protected void addServicesNodes(DefaultMutableTreeNode pParentNode,
1202: Collection pServices) {
1203: for (Iterator lIterator = pServices.iterator(); lIterator
1204: .hasNext();) {
1205: Service lService = (Service) lIterator.next();
1206: pParentNode.add(addServiceNode(lService));
1207: }
1208: }
1209:
1210: // add BOServicemodule node
1211: protected DefaultMutableTreeNode addServiceNode(Service pService) {
1212: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1213: new ServiceUserObject(pService), true);
1214:
1215: // add implementation list
1216: Collection lImplementations = sortCollection(pService
1217: .getImplementations());
1218: if (lImplementations.size() > 0) {
1219: DefaultMutableTreeNode lImplNode = new DefaultMutableTreeNode(
1220: new ServiceUserObject(pService, Application
1221: .getString("implementations_node"),
1222: ServiceUserObject.ADD_IMPLEMENTATION), true);
1223: lNode.add(lImplNode);
1224: addServiceImplementationNodes(lImplNode, lImplementations);
1225: }
1226: // add operations
1227: Collection lOperations = sortCollection(pService
1228: .getOperations());
1229: if (lOperations.size() > 0) {
1230: DefaultMutableTreeNode lOperNode = new DefaultMutableTreeNode(
1231: new ServiceUserObject(pService, Application
1232: .getString("operations_node"),
1233: ServiceUserObject.ADD_OPERATION), true);
1234: lNode.add(lOperNode);
1235: addOperationsNodes(lOperNode, lOperations);
1236: }
1237: return lNode;
1238: }
1239:
1240: /* Helper. Add Structures tree */
1241: protected void addStructuresNodes(
1242: DefaultMutableTreeNode pParentNode, Collection pStructures) {
1243: for (Iterator lIterator = pStructures.iterator(); lIterator
1244: .hasNext();) {
1245: Structure lStructure = (Structure) lIterator.next();
1246: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1247: new StructureUserObject(lStructure), true);
1248: pParentNode.add(lNode);
1249:
1250: // add fields
1251: Collection lFields = sortCollection(lStructure.getFields());
1252: if (lFields.size() > 0) {
1253: DefaultMutableTreeNode lFieldsNode = new DefaultMutableTreeNode(
1254: new StructureUserObject(lStructure, Application
1255: .getString("fields_node"),
1256: StructureUserObject.ADD_FIELD), true);
1257: lNode.add(lFieldsNode);
1258: addStructureFields(lFieldsNode, lFields);
1259: }
1260:
1261: // add constraints
1262: //Collection lConstraints = sortCollection(lStructure.getConstraints());
1263: Collection lConstraints = lStructure.getConstraints();
1264: if (lConstraints.size() > 0) {
1265: DefaultMutableTreeNode lConstraintsNode = new DefaultMutableTreeNode(
1266: new StructureUserObject(lStructure, Application
1267: .getString("constraints_node"),
1268: StructureUserObject.ADD_CONSTRAINT),
1269: true);
1270: lNode.add(lConstraintsNode);
1271: addConstraintsNodes(lConstraintsNode, lConstraints);
1272: }
1273: }
1274: }
1275:
1276: protected void addEventSubscriptionsNodes(
1277: DefaultMutableTreeNode pParentNode,
1278: Collection pEventSubscriptions) {
1279: for (Iterator lIterator = pEventSubscriptions.iterator(); lIterator
1280: .hasNext();) {
1281: EventSubscription lEventSubscription = (EventSubscription) lIterator
1282: .next();
1283: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1284: new EventSubscriptionUserObject(lEventSubscription),
1285: true);
1286: pParentNode.add(lNode);
1287:
1288: //subscription operation
1289: EventSubscriptionOperation lOperation = lEventSubscription
1290: .getSubscriptionOperation();
1291: if (lOperation != null)
1292: addEventSubscriptionOperationNodes(lNode, lOperation);
1293:
1294: // update events
1295: Collection lEvents = sortCollection(lEventSubscription
1296: .getEvents());
1297: if (lEvents.size() > 0) {
1298: DefaultMutableTreeNode lEventsNode = new DefaultMutableTreeNode(
1299: new EventSubscriptionUserObject(
1300: lEventSubscription,
1301: Application
1302: .getString("updateevents_node"),
1303: EventSubscriptionUserObject.ADD_UPDATEEVENT),
1304: true);
1305: lNode.add(lEventsNode);
1306: addEventsNodes(lEventsNode, lEvents);
1307: }
1308: }
1309: }
1310:
1311: // add subscription
1312: protected void addEventSubscriptionOperationNodes(
1313: DefaultMutableTreeNode pParentNode,
1314: EventSubscriptionOperation pOperation) {
1315: if (pOperation == null || pParentNode == null)
1316: return;
1317:
1318: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1319: UserObjectFactory.createUserObject(pOperation), true);
1320: pParentNode.add(lNode);
1321:
1322: //input fields
1323: Collection lFields = sortCollection(pOperation.getInputFields());
1324: if (lFields.size() > 0) {
1325: DefaultMutableTreeNode lInFieldsNode = new DefaultMutableTreeNode(
1326: new EventSubscriptionOperationUserObject(
1327: pOperation,
1328: Application.getString("inputfields_node"),
1329: EventSubscriptionOperationUserObject.ADD_INPUTFIELD),
1330: true);
1331: lNode.add(lInFieldsNode);
1332: addEventSubscriptionOperationInputFields(lInFieldsNode,
1333: lFields);
1334: }
1335: //input constraints
1336: Collection lConstraints = pOperation.getInputConstraints();
1337: if (lConstraints.size() > 0) {
1338: DefaultMutableTreeNode lConstraintsNode = new DefaultMutableTreeNode(
1339: new EventSubscriptionOperationUserObject(
1340: pOperation,
1341: Application
1342: .getString("inputconstraints_node"),
1343: EventSubscriptionOperationUserObject.ADD_CONSTRAINT),
1344: true);
1345: lNode.add(lConstraintsNode);
1346: addConstraintsNodes(lConstraintsNode, lConstraints);
1347: }
1348: //output fields
1349: lFields = sortCollection(pOperation.getOutputFields());
1350: if (lFields.size() > 0) {
1351: DefaultMutableTreeNode lOutFieldsNode = new DefaultMutableTreeNode(
1352: new EventSubscriptionOperationUserObject(
1353: pOperation,
1354: Application.getString("outputfields_node"),
1355: EventSubscriptionOperationUserObject.ADD_OUTPUTFIELD),
1356: true);
1357: lNode.add(lOutFieldsNode);
1358: addEventSubscriptionOperationOutputFields(lOutFieldsNode,
1359: lFields);
1360: }
1361: // output messages
1362: Collection lOutputMessages = sortCollection(pOperation
1363: .getOutputMessages());
1364: if (lOutputMessages.size() > 0) {
1365: DefaultMutableTreeNode lOutMessagesNode = new DefaultMutableTreeNode(
1366: new EventSubscriptionOperationUserObject(
1367: pOperation,
1368: Application
1369: .getString("outputmessages_node"),
1370: EventSubscriptionOperationUserObject.ADD_OUTPUTMESSAGE),
1371: true);
1372: lNode.add(lOutMessagesNode);
1373: addEventSubscriptionOutMessagesNodes(lOutMessagesNode,
1374: lOutputMessages);
1375: }
1376: }
1377:
1378: /* Helper. Add Operation Input Fields Tree */
1379: protected void addEventSubscriptionOperationInputFields(
1380: DefaultMutableTreeNode pParentNode, Collection pFields) {
1381: for (Iterator lIterator = pFields.iterator(); lIterator
1382: .hasNext();) {
1383: OperationInputField lField = (OperationInputField) lIterator
1384: .next();
1385: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1386: new OperationInputFieldUserObject(lField), false);
1387: pParentNode.add(lNode);
1388: }
1389: }
1390:
1391: /* Helper. Add Operation Input Fields Tree */
1392: protected void addEventSubscriptionOperationOutputFields(
1393: DefaultMutableTreeNode pParentNode, Collection pFields) {
1394: for (Iterator lIterator = pFields.iterator(); lIterator
1395: .hasNext();) {
1396: OperationOutputField lField = (OperationOutputField) lIterator
1397: .next();
1398: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1399: new OperationOutputFieldUserObject(lField), false);
1400: pParentNode.add(lNode);
1401: }
1402: }
1403:
1404: /* Helper. Add Output messages tree */
1405: protected void addEventSubscriptionOutMessagesNodes(
1406: DefaultMutableTreeNode pParentNode, Collection pMessages) {
1407: for (Iterator lIterator = pMessages.iterator(); lIterator
1408: .hasNext();) {
1409: OperationOutputMessage lMessage = (OperationOutputMessage) lIterator
1410: .next();
1411: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1412: new OperationOutputMessageUserObject(lMessage),
1413: false);
1414: pParentNode.add(lNode);
1415: }
1416: }
1417:
1418: // add update events nodes
1419: protected void addEventsNodes(DefaultMutableTreeNode pParentNode,
1420: Collection pUpdateEvents) {
1421: for (Iterator lIterator = pUpdateEvents.iterator(); lIterator
1422: .hasNext();) {
1423: Event lEvent = (Event) lIterator.next();
1424: addEventNodes(pParentNode, lEvent);
1425: }
1426: }
1427:
1428: // add event to the tree
1429: protected void addEventNodes(DefaultMutableTreeNode pParentNode,
1430: Event pEvent) {
1431: if (pEvent == null)
1432: return;
1433:
1434: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1435: UserObjectFactory.createUserObject(pEvent), true);
1436: pParentNode.add(lNode);
1437:
1438: //data fields
1439: Collection lDataFields = sortCollection(pEvent.getDataFields());
1440: if (lDataFields.size() > 0) {
1441: DefaultMutableTreeNode lDataFieldsNode = new DefaultMutableTreeNode(
1442: new EventUserObject(pEvent, Application
1443: .getString("datafields_node"),
1444: EventUserObject.ADD_DATAFIELD), true);
1445: lNode.add(lDataFieldsNode);
1446: addEventDataFieldNodes(lDataFieldsNode, lDataFields);
1447: }
1448:
1449: //message fields
1450: Collection lMessageFields = sortCollection(pEvent
1451: .getMessageFields());
1452: if (lMessageFields.size() > 0) {
1453: DefaultMutableTreeNode lDataFieldsNode = new DefaultMutableTreeNode(
1454: new EventUserObject(pEvent, Application
1455: .getString("messagefields_node"),
1456: EventUserObject.ADD_MESSAGEFIELD), true);
1457: lNode.add(lDataFieldsNode);
1458: addEventMessageFieldNodes(lDataFieldsNode, lMessageFields);
1459: }
1460: }
1461:
1462: // add event data field nodes
1463: protected void addEventDataFieldNodes(
1464: DefaultMutableTreeNode pParentNode, Collection pFields) {
1465: for (Iterator lIterator = pFields.iterator(); lIterator
1466: .hasNext();) {
1467: EventDataField lField = (EventDataField) lIterator.next();
1468: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1469: new EventDataFieldUserObject(lField), false);
1470: pParentNode.add(lNode);
1471: }
1472: }
1473:
1474: // add event message field nodes
1475: protected void addEventMessageFieldNodes(
1476: DefaultMutableTreeNode pParentNode, Collection pFields) {
1477: for (Iterator lIterator = pFields.iterator(); lIterator
1478: .hasNext();) {
1479: EventMessageField lField = (EventMessageField) lIterator
1480: .next();
1481: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1482: new EventMessageFieldUserObject(lField), false);
1483: pParentNode.add(lNode);
1484: }
1485: }
1486:
1487: /* Helper. Add Structure Fields Tree */
1488: protected void addStructureFields(
1489: DefaultMutableTreeNode pParentNode, Collection pFields) {
1490: for (Iterator lIterator = pFields.iterator(); lIterator
1491: .hasNext();) {
1492: StructureField lField = (StructureField) lIterator.next();
1493: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1494: new StructureFieldUserObject(lField), false);
1495: pParentNode.add(lNode);
1496: }
1497: }
1498:
1499: /* Helper. Add Messages Fields Tree */
1500: protected void addMessagesFieldsNodes(
1501: DefaultMutableTreeNode pParentNode, Collection pFields) {
1502: for (Iterator lIterator = pFields.iterator(); lIterator
1503: .hasNext();) {
1504: MessageField lField = (MessageField) lIterator.next();
1505: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1506: new MessageFieldUserObject(lField), false);
1507: pParentNode.add(lNode);
1508: }
1509: }
1510:
1511: /* Helper. Add Service Implementations */
1512: protected void addServiceImplementationNodes(
1513: DefaultMutableTreeNode pParentNode,
1514: Collection pImplementations) {
1515: for (Iterator lIterator = pImplementations.iterator(); lIterator
1516: .hasNext();) {
1517: ServiceImplementation lImplementation = (ServiceImplementation) lIterator
1518: .next();
1519: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1520: new ServiceImplementationUserObject(lImplementation),
1521: false);
1522: pParentNode.add(lNode);
1523: }
1524: }
1525:
1526: /* Helper. Add Operations */
1527: protected void addOperationsNodes(
1528: DefaultMutableTreeNode pParentNode, Collection pOperations) {
1529: for (Iterator lIterator = pOperations.iterator(); lIterator
1530: .hasNext();) {
1531: Operation lOperation = (Operation) lIterator.next();
1532: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1533: new OperationUserObject(lOperation), true);
1534: pParentNode.add(lNode);
1535:
1536: //input fields
1537: Collection lFields = sortCollection(lOperation
1538: .getInputFields());
1539: if (lFields.size() > 0) {
1540: DefaultMutableTreeNode lInFieldsNode = new DefaultMutableTreeNode(
1541: new OperationUserObject(lOperation, Application
1542: .getString("inputfields_node"),
1543: OperationUserObject.ADD_INPUTFIELD),
1544: true);
1545: lNode.add(lInFieldsNode);
1546: addOperationInputFields(lInFieldsNode, lFields);
1547: }
1548: //input constraints
1549: //Collection lConstraints = sortCollection(lOperation.getInputConstraints());
1550: Collection lConstraints = lOperation.getInputConstraints();
1551: if (lConstraints.size() > 0) {
1552: DefaultMutableTreeNode lConstraintsNode = new DefaultMutableTreeNode(
1553: new OperationUserObject(lOperation, Application
1554: .getString("inputconstraints_node"),
1555: OperationUserObject.ADD_CONSTRAINT),
1556: true);
1557: lNode.add(lConstraintsNode);
1558: addConstraintsNodes(lConstraintsNode, lConstraints);
1559: }
1560: //output fields
1561: lFields = sortCollection(lOperation.getOutputFields());
1562: if (lFields.size() > 0) {
1563: DefaultMutableTreeNode lOutFieldsNode = new DefaultMutableTreeNode(
1564: new OperationUserObject(lOperation, Application
1565: .getString("outputfields_node"),
1566: OperationUserObject.ADD_OUTPUTFIELD),
1567: true);
1568: lNode.add(lOutFieldsNode);
1569: addOperationOutputFields(lOutFieldsNode, lFields);
1570: }
1571: // output messages
1572: Collection lOutputMessages = sortCollection(lOperation
1573: .getOutputMessages());
1574: if (lOutputMessages.size() > 0) {
1575: DefaultMutableTreeNode lOutMessagesNode = new DefaultMutableTreeNode(
1576: new OperationUserObject(lOperation, Application
1577: .getString("outputmessages_node"),
1578: OperationUserObject.ADD_OUTPUTMESSAGE),
1579: true);
1580: lNode.add(lOutMessagesNode);
1581: addOutMessagesNodes(lOutMessagesNode, lOutputMessages);
1582: }
1583: }
1584: }
1585:
1586: /* Helper. Add Operation Input Fields Tree */
1587: protected void addOperationInputFields(
1588: DefaultMutableTreeNode pParentNode, Collection pFields) {
1589: for (Iterator lIterator = pFields.iterator(); lIterator
1590: .hasNext();) {
1591: OperationInputField lField = (OperationInputField) lIterator
1592: .next();
1593: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1594: new OperationInputFieldUserObject(lField), false);
1595: pParentNode.add(lNode);
1596: }
1597: }
1598:
1599: /* Helper. Add Operation Input Fields Tree */
1600: protected void addOperationOutputFields(
1601: DefaultMutableTreeNode pParentNode, Collection pFields) {
1602: for (Iterator lIterator = pFields.iterator(); lIterator
1603: .hasNext();) {
1604: OperationOutputField lField = (OperationOutputField) lIterator
1605: .next();
1606: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1607: new OperationOutputFieldUserObject(lField), false);
1608: pParentNode.add(lNode);
1609: }
1610: }
1611:
1612: /* Helper. Add Output messages tree */
1613: protected void addOutMessagesNodes(
1614: DefaultMutableTreeNode pParentNode, Collection pMessages) {
1615: for (Iterator lIterator = pMessages.iterator(); lIterator
1616: .hasNext();) {
1617: OperationOutputMessage lMessage = (OperationOutputMessage) lIterator
1618: .next();
1619: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1620: new OperationOutputMessageUserObject(lMessage),
1621: false);
1622: pParentNode.add(lNode);
1623: }
1624: }
1625:
1626: /* Helper. Add Associations tree */
1627: protected void addAssociationsNodes(
1628: DefaultMutableTreeNode pParentNode, Collection pAssociations) {
1629: for (Iterator lIterator = pAssociations.iterator(); lIterator
1630: .hasNext();) {
1631: Association lAssociation = (Association) lIterator.next();
1632: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1633: new AssociationUserObject(lAssociation), true);
1634: pParentNode.add(lNode);
1635:
1636: // add association roles
1637: //Object[] lAssociationRoles = lEntity.getAssociationRoles().toArray();
1638: Collection lAssociationRoles = sortCollection(lAssociation
1639: .getRoles());
1640: if (lAssociationRoles.size() > 0) {
1641: DefaultMutableTreeNode lAssRolesNode = new DefaultMutableTreeNode(
1642: new AssociationUserObject(
1643: lAssociation,
1644: Application
1645: .getString("associationsroles_node"),
1646: AssociationUserObject.ADD_ASSOCIATIOROLE),
1647: true);
1648: lNode.add(lAssRolesNode);
1649: addAssociationRolesNodes(lAssRolesNode,
1650: lAssociationRoles);
1651: }
1652: }
1653: }
1654:
1655: /* Helper. Add entites */
1656: protected void addEntitiesNode(DefaultMutableTreeNode pParentNode,
1657: Collection pEntities) {
1658: for (Iterator lIterator = pEntities.iterator(); lIterator
1659: .hasNext();) {
1660: Entity lEntity = (Entity) lIterator.next();
1661: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1662: new EntityUserObject(lEntity), true);
1663: pParentNode.add(lNode);
1664:
1665: // add attributes
1666: Collection lAttributes = sortCollection(lEntity
1667: .getAttributes());
1668: if (lAttributes.size() > 0) {
1669: DefaultMutableTreeNode lAttributesNode = new DefaultMutableTreeNode(
1670: new EntityUserObject(lEntity, Application
1671: .getString("attributes_node"),
1672: EntityUserObject.ADD_ATTRIBUTE), true);
1673: lNode.add(lAttributesNode);
1674: addAttributesNodes(lAttributesNode, lAttributes, null);
1675: }
1676: // add primary key elements
1677: // ??? îòêëþ÷åíî
1678: /*Object[] lObjects = lEntity.getPrimaryKeyElements().toArray();
1679: if (lObjects.length>0)
1680: {
1681: DefaultMutableTreeNode lPrimKeyNode = new DefaultMutableTreeNode(new EntityNodeUserObject(lEntity, Application.getString("primarykeyelements_node"), EntityNodeUserObject.ADD_PRIMARYKEY), true);
1682: lNode.add(lPrimKeyNode);
1683: addPrimaryKeyElementNodes(lPrimKeyNode, lObjects);
1684: }*/
1685:
1686: // add selectors
1687: Collection lSelectors = sortCollection(lEntity
1688: .getSelectors());
1689: if (lSelectors.size() > 0) {
1690: DefaultMutableTreeNode lSelectorsNode = new DefaultMutableTreeNode(
1691: new EntityUserObject(lEntity, Application
1692: .getString("selectors_node"),
1693: EntityUserObject.ADD_SELECTOR), true);
1694: lNode.add(lSelectorsNode);
1695: addSelectorsNodes(lSelectorsNode, lSelectors);
1696: }
1697:
1698: // add constraints
1699: //Collection lConstraints = sortCollection(lEntity.getConstraints());
1700: Collection lConstraints = lEntity.getConstraints();
1701: if (lConstraints.size() > 0) {
1702: DefaultMutableTreeNode lConstraintsNode = new DefaultMutableTreeNode(
1703: new EntityUserObject(lEntity, Application
1704: .getString("constraints_node"),
1705: EntityUserObject.ADD_CONSTRAINT), true);
1706: lNode.add(lConstraintsNode);
1707: addConstraintsNodes(lConstraintsNode, lConstraints);
1708: }
1709:
1710: // add entity states
1711: StateMachine lMachine = lEntity.getStateMachine();
1712: addStateMachine(lNode, lMachine);
1713:
1714: // diagrams
1715: Collection lDiagrams = sortCollection(lEntity
1716: .getEntityStateDiagrams());
1717: if (lDiagrams.size() > 0) {
1718: DefaultMutableTreeNode lDiagramsNode = new DefaultMutableTreeNode(
1719: new EntityUserObject(lEntity, Application
1720: .getString("diagrams_node"),
1721: EntityUserObject.ADD_DIAGRAM), true);
1722: lNode.add(lDiagramsNode);
1723: addEntityStatesDiagrams(lDiagramsNode, lDiagrams);
1724: }
1725: }
1726: }
1727:
1728: /* Helper. Add Associations roles tree */
1729: protected void addAssociationRolesNodes(
1730: DefaultMutableTreeNode pParentNode,
1731: Collection pAssociationRoles) {
1732: for (Iterator lIterator = pAssociationRoles.iterator(); lIterator
1733: .hasNext();) {
1734: AssociationRole lAssociation = (AssociationRole) lIterator
1735: .next();
1736: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1737: new AssociationRoleUserObject(lAssociation), false);
1738: pParentNode.add(lNode);
1739: }
1740: }
1741:
1742: /* Add State Machine objects */
1743: protected void addStateMachine(DefaultMutableTreeNode pParentNode,
1744: StateMachine pMachine) {
1745: if (pMachine != null) {
1746: DefaultMutableTreeNode lMachineNode = new DefaultMutableTreeNode(
1747: new StateMachineUserObject(pMachine), true);
1748: pParentNode.add(lMachineNode);
1749:
1750: // states
1751: Collection lStates = sortCollection(pMachine.getStates());
1752: if (lStates.size() > 0) {
1753: DefaultMutableTreeNode lEntityStatesNode = new DefaultMutableTreeNode(
1754: new StateMachineUserObject(pMachine,
1755: Application.getString("states_node"),
1756: StateMachineUserObject.ADD_STATE), true);
1757: lMachineNode.add(lEntityStatesNode);
1758: addStatesNodes(lEntityStatesNode, lStates);
1759: }
1760:
1761: // transitions
1762: Collection lTransitions = sortCollection(pMachine
1763: .getTransitions());
1764: if (lTransitions.size() > 0) {
1765: DefaultMutableTreeNode lTransitionsNode = new DefaultMutableTreeNode(
1766: new StateMachineUserObject(pMachine,
1767: Application
1768: .getString("transitions_node"),
1769: StateMachineUserObject.ADD_TRANSITION),
1770: true);
1771: lMachineNode.add(lTransitionsNode);
1772: addStateTransitionNodes(lTransitionsNode, lTransitions);
1773: }
1774: }
1775: }
1776:
1777: /* Helper. Add States tree */
1778: protected void addStatesNodes(DefaultMutableTreeNode pParentNode,
1779: Collection pStates) {
1780: for (Iterator lIterator = pStates.iterator(); lIterator
1781: .hasNext();) {
1782: State lState = (State) lIterator.next();
1783: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1784: new StateUserObject(lState), true);
1785: pParentNode.add(lNode);
1786: /*
1787: // add incoming state transitions
1788: Object[] lIncomingTransitions = lState.getIncomingTransitions().toArray();
1789: if (lIncomingTransitions.length>0)
1790: {
1791: DefaultMutableTreeNode lStateTransitionNode = new DefaultMutableTreeNode(new PackageNodeUserObject(Application.getString("instatetransitions_node")), true);
1792: lNode.add(lStateTransitionNode);
1793: addStateTransitionNodes(lStateTransitionNode, lIncomingTransitions);
1794: }
1795: // add ougoing state transitions
1796: Object[] lOutgoingTransitions = lState.getOutgoingTranstions().toArray();
1797: if (lOutgoingTransitions.length>0)
1798: {
1799: DefaultMutableTreeNode lStateTransitionNode = new DefaultMutableTreeNode(new PackageNodeUserObject(Application.getString("outstatetransitions_node")), true);
1800: lNode.add(lStateTransitionNode);
1801: addStateTransitionNodes(lStateTransitionNode, lOutgoingTransitions);
1802: }*/
1803: }
1804: }
1805:
1806: /* Helper. Add Selectors tree */
1807: protected void addSelectorsNodes(
1808: DefaultMutableTreeNode pParentNode, Collection pSelectors) {
1809: for (Iterator lIterator = pSelectors.iterator(); lIterator
1810: .hasNext();) {
1811: Selector lSelector = (Selector) lIterator.next();
1812: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1813: new SelectorUserObject(lSelector), true);
1814: pParentNode.add(lNode);
1815:
1816: // add input fields
1817: Collection lFields = sortCollection(lSelector
1818: .getInputFields());
1819: if (lFields.size() > 0) {
1820: DefaultMutableTreeNode lInFieldsNode = new DefaultMutableTreeNode(
1821: new SelectorUserObject(lSelector, Application
1822: .getString("inputfields_node"),
1823: SelectorUserObject.ADD_FIELD), true);
1824: lNode.add(lInFieldsNode);
1825: addSelectorInputFieldsNodes(lInFieldsNode, lFields);
1826: }
1827: }
1828: }
1829:
1830: /* Helper. Add Selector Input Fields nodes */
1831: protected void addSelectorInputFieldsNodes(
1832: DefaultMutableTreeNode pParentNode, Collection pFields) {
1833: for (Iterator lIterator = pFields.iterator(); lIterator
1834: .hasNext();) {
1835: SelectorInputField lField = (SelectorInputField) lIterator
1836: .next();
1837: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1838: new SelectorInputFieldUserObject(lField), false);
1839: pParentNode.add(lNode);
1840: }
1841: }
1842:
1843: /* Helper. Add Constraints tree */
1844: protected void addConstraintsNodes(
1845: DefaultMutableTreeNode pParentNode, Collection pConstraints) {
1846: for (Iterator lIterator = pConstraints.iterator(); lIterator
1847: .hasNext();) {
1848: ModelElementConstraint lModelElementConstraint = (ModelElementConstraint) lIterator
1849: .next();
1850: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1851: new ModelElementConstraintUserObject(
1852: lModelElementConstraint), true);
1853: pParentNode.add(lNode);
1854: }
1855: }
1856:
1857: /* Helper. Add Attributes tree */
1858: protected void addAttributesNodes(
1859: DefaultMutableTreeNode pParentNode, Collection pAttributes,
1860: ReportOutputEntity pReportEntity) {
1861: for (Iterator lIterator = pAttributes.iterator(); lIterator
1862: .hasNext();) {
1863: Attribute lAttribute = (Attribute) lIterator.next();
1864: DefaultMutableTreeNode lNode = null;
1865: if (pReportEntity != null)
1866: lNode = new DefaultMutableTreeNode(
1867: new ReportEntityAttributeUserObject(lAttribute,
1868: pReportEntity), false);
1869: else
1870: lNode = new DefaultMutableTreeNode(
1871: new AttributeUserObject(lAttribute), false);
1872: pParentNode.add(lNode);
1873: }
1874: }
1875:
1876: /* Helper. Add Primary key elements tree */
1877: protected void addPrimaryKeyElementNodes(
1878: DefaultMutableTreeNode pParentNode, Object[] pObjects) {
1879: for (int i = 0; i < pObjects.length; i++) {
1880: PrimaryKeyElement lObject = (PrimaryKeyElement) pObjects[i];
1881: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1882: new PrimaryKeyElementUserObject(lObject), false);
1883: if (lNode != null)
1884: pParentNode.add(lNode);
1885: }
1886: }
1887:
1888: /* Helper. Add Attributes tree */
1889: protected void addStateTransitionNodes(
1890: DefaultMutableTreeNode pParentNode,
1891: Collection pStateTransitions) {
1892: for (Iterator lIterator = pStateTransitions.iterator(); lIterator
1893: .hasNext();) {
1894: Transition lStateTransition = (Transition) lIterator.next();
1895: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1896: new TransitionUserObject(lStateTransition), false);
1897: pParentNode.add(lNode);
1898: }
1899: }
1900:
1901: /* Helper. Add Reports tree */
1902: protected void addReportsNode(DefaultMutableTreeNode pParentNode,
1903: Collection pReports) {
1904: for (Iterator lIterator = pReports.iterator(); lIterator
1905: .hasNext();) {
1906: Report lReport = (Report) lIterator.next();
1907: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1908: new ReportUserObject(lReport), true);
1909: pParentNode.add(lNode);
1910:
1911: //add input fields
1912: Collection lFields = sortCollection(lReport
1913: .getInputFields());
1914: if (lFields.size() > 0) {
1915: DefaultMutableTreeNode lInFieldsNode = new DefaultMutableTreeNode(
1916: new ReportUserObject(lReport, Application
1917: .getString("inputfields_node"),
1918: ReportUserObject.ADD_INPUTFIELD), true);
1919: lNode.add(lInFieldsNode);
1920: addReportInputFields(lInFieldsNode, lFields);
1921: }
1922: // add top level output element
1923: addReportOutputElementNodes(lNode, lReport
1924: .getTopLevelOutputElement());
1925: }
1926: }
1927:
1928: /* Helper. Add Report Input Fields */
1929: protected void addReportInputFields(
1930: DefaultMutableTreeNode pParentNode, Collection pFields) {
1931: for (Iterator lIterator = pFields.iterator(); lIterator
1932: .hasNext();) {
1933: ReportInputField lField = (ReportInputField) lIterator
1934: .next();
1935: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1936: new ReportInputFieldUserObject(lField), false);
1937: pParentNode.add(lNode);
1938: }
1939: }
1940:
1941: /* Helper. Add Reports Output Elements tree */
1942: protected void addReportOutputElementNodes(
1943: DefaultMutableTreeNode pParentNode,
1944: ReportOutputElement pElement) {
1945: if (pElement == null)
1946: return;
1947:
1948: DefaultMutableTreeNode lOutElementNode = new DefaultMutableTreeNode(
1949: new OutputElementUserObject(pElement), true);
1950: pParentNode.add(lOutElementNode);
1951:
1952: //add output fields
1953: Collection lFields = sortCollection(pElement.getOutputFields());
1954: if (lFields.size() > 0) {
1955: DefaultMutableTreeNode lOutFieldsNode = new DefaultMutableTreeNode(
1956: new OutputElementUserObject(pElement, Application
1957: .getString("outputfields_node"),
1958: OutputElementUserObject.ADD_OUTPUTFIELD),
1959: true);
1960: lOutElementNode.add(lOutFieldsNode);
1961: addReportOutputFieldsNodes(lOutFieldsNode, lFields);
1962: }
1963: //add report entity
1964: Collection lEntites = sortCollection(pElement
1965: .getOutputEntities());
1966: if (lEntites.size() > 0) {
1967: DefaultMutableTreeNode lEntityNode = new DefaultMutableTreeNode(
1968: new OutputElementUserObject(pElement, Application
1969: .getString("entities_node"),
1970: OutputElementUserObject.ADD_ENTITY), true);
1971: lOutElementNode.add(lEntityNode);
1972: addReportEntityNodes(lEntityNode, lEntites);
1973: }
1974: // add sub element
1975: if ((pElement.getReport() != null)
1976: && ((pElement.getLevelIndex() + 1) < pElement
1977: .getReport().getOutputLevelsCount()))
1978: addReportOutputElementNodes(lOutElementNode, pElement
1979: .getSubElement());
1980: }
1981:
1982: /* Helper. Add Report Output Fields tree */
1983: protected void addReportOutputFieldsNodes(
1984: DefaultMutableTreeNode pParentNode, Collection pFields) {
1985: for (Iterator lIterator = pFields.iterator(); lIterator
1986: .hasNext();) {
1987: ReportOutputField lField = (ReportOutputField) lIterator
1988: .next();
1989: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
1990: new ReportOutputFieldUserObject(lField), false);
1991: pParentNode.add(lNode);
1992: }
1993: }
1994:
1995: /* Helper. Add Report Entity tree */
1996: protected void addReportEntityNodes(
1997: DefaultMutableTreeNode pParentNode, Collection pEntities) {
1998: for (Iterator lIterator = pEntities.iterator(); lIterator
1999: .hasNext();) {
2000: ReportOutputEntity lEntity = (ReportOutputEntity) lIterator
2001: .next();
2002: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2003: new ReportEntityUserObject(lEntity), true);
2004: pParentNode.add(lNode);
2005:
2006: // add attributes
2007: Collection lAttributes = sortCollection(lEntity
2008: .getAttributes());
2009: if (lAttributes.size() > 0) {
2010: DefaultMutableTreeNode lAttributesNode = new DefaultMutableTreeNode(
2011: new ReportEntityUserObject(lEntity, Application
2012: .getString("attributes_node"),
2013: ReportEntityUserObject.ADD_ATTRIBUTE),
2014: true);
2015: lNode.add(lAttributesNode);
2016: addAttributesNodes(lAttributesNode, lAttributes,
2017: lEntity);
2018: }
2019: }
2020: }
2021:
2022: /* Helper. Adds query nodes */
2023: protected void addTypetemplatesNodes(
2024: DefaultMutableTreeNode pParentNode,
2025: Collection pTypeTemplates) {
2026: for (Iterator lIterator = pTypeTemplates.iterator(); lIterator
2027: .hasNext();) {
2028: TypeTemplate lTypeTemplate = (TypeTemplate) lIterator
2029: .next();
2030: addTypetemplateNodes(pParentNode, lTypeTemplate);
2031: }
2032: }
2033:
2034: protected void addTypetemplateNodes(
2035: DefaultMutableTreeNode pParentNode,
2036: TypeTemplate pTypeTemplate) {
2037: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2038: new TypeTemplateUserObject(pTypeTemplate), true);
2039: pParentNode.add(lNode);
2040:
2041: // add property descriptors
2042: Collection lProperties = sortCollection(pTypeTemplate
2043: .getPropertyDescriptors());
2044: if (lProperties.size() > 0) {
2045: DefaultMutableTreeNode lPropertiesNode = new DefaultMutableTreeNode(
2046: new TypeTemplateUserObject(
2047: pTypeTemplate,
2048: Application
2049: .getString("propertydescriptors_node"),
2050: TypeTemplateUserObject.PROPERTY_ACTION),
2051: true);
2052: lNode.add(lPropertiesNode);
2053: addPropertyDescriptors(lPropertiesNode, lProperties, true);
2054: }
2055: }
2056:
2057: /* Helper. Adds property descriptors tree */
2058: protected void addPropertyDescriptors(
2059: DefaultMutableTreeNode pParentNode,
2060: Collection pDescriptors, boolean pAddRoot) {
2061: for (Iterator lIterator = pDescriptors.iterator(); lIterator
2062: .hasNext();) {
2063: PropertyDescriptor lDescriptor = (PropertyDescriptor) lIterator
2064: .next();
2065: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2066: new PropertyDescriptorUserObject(lDescriptor), true);
2067: pParentNode.add(lNode);
2068:
2069: Collection lList = sortCollection(lDescriptor
2070: .getSubPropertyDescriptors());
2071: if (lList.size() > 0) {
2072: if (pAddRoot) {
2073: DefaultMutableTreeNode lPropertiesNode = new DefaultMutableTreeNode(
2074: new PropertyDescriptorUserObject(
2075: lDescriptor,
2076: Application
2077: .getString("propertydescriptors_node"),
2078: PropertyDescriptorUserObject.PROPERTY_ACTION),
2079: true);
2080: lNode.add(lPropertiesNode);
2081: addPropertyDescriptors(lPropertiesNode, lList,
2082: pAddRoot);
2083: } else
2084: addPropertyDescriptors(lNode, lList, pAddRoot);
2085: }
2086: }
2087: }
2088:
2089: /* Helper. Adds datatype nodes */
2090: protected void addDatatypeNodes(DefaultMutableTreeNode pParentNode,
2091: Collection pDatatypes) {
2092: for (Iterator lIterator = pDatatypes.iterator(); lIterator
2093: .hasNext();) {
2094: DataType lDataType = (DataType) lIterator.next();
2095: // Position ourselves at the package node
2096: //DefaultMutableTreeNode lPackageNode = getOrCreatePackageNode(pParentNode, getPackageArray(lDataType.getRef()));
2097: // We now have a package node we need to stick our typetemplate node in - just do it
2098: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2099: new DataTypeUserObject(lDataType), true);
2100: pParentNode.add(lNode);
2101:
2102: Collection lProperties = sortCollection(lDataType
2103: .getTypetemplateProperties());
2104: if (lProperties.size() > 0) {
2105: DefaultMutableTreeNode lPropertiesNode = new DefaultMutableTreeNode(
2106: new DataTypeUserObject(lDataType, Application
2107: .getString("properties_node"),
2108: DataTypeUserObject.PROPERTY_ACTION),
2109: true);
2110: lNode.add(lPropertiesNode);
2111: addDataTypeProperties(lPropertiesNode, lProperties,
2112: true);
2113: }
2114:
2115: /*Object[] lProperties = lDataType.getTypetemplateProperties().toArray();
2116: if (lProperties.length>0)
2117: {
2118: DefaultMutableTreeNode lPropertiesNode = new DefaultMutableTreeNode(new DataTypeUserObject(lDataType, Application.getString("properties_node"), DataTypeUserObject.PROPERTY_ACTION), true);
2119: lNode.add(lPropertiesNode);
2120: addDataTypeProperties(lPropertiesNode, lProperties, true);
2121: }*/
2122: }
2123: }
2124:
2125: // properties old style
2126: /*protected void addDataTypeProperties(DefaultMutableTreeNode pParentNode, Collection pProperties, boolean pAddRoot)
2127: {
2128: for (Iterator lIterator = pProperties.iterator(); lIterator.hasNext();)
2129: {
2130: Property lProperty = (Property)lIterator.next();
2131: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(new PropertyUserObject(lProperty), true);
2132: pParentNode.add(lNode);
2133:
2134: Collection lProperties = sortCollection(lProperty.getSubProperties());
2135: if (lProperties.size()>0)
2136: {
2137: if (pAddRoot)
2138: {
2139: DefaultMutableTreeNode lPropertiesNode = new DefaultMutableTreeNode(new PropertyUserObject(lProperty, Application.getString("properties_node"), PropertyUserObject.PROPERTY_ACTION), true);
2140: lNode.add(lPropertiesNode);
2141: addDataTypeProperties(lPropertiesNode, lProperties, pAddRoot);
2142: }
2143: else
2144: addDataTypeProperties(lNode, lProperties, pAddRoot);
2145: }
2146: }
2147: }*/
2148:
2149: // properties new style
2150: protected void addDataTypeProperties(
2151: DefaultMutableTreeNode pParentNode, Collection pProperties,
2152: boolean pAddRoot) {
2153: for (Iterator lIterator = pProperties.iterator(); lIterator
2154: .hasNext();) {
2155: Property lProperty = (Property) lIterator.next();
2156: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2157: new PropertyUserObject(lProperty), true);
2158: DefaultMutableTreeNode lParentNode = getParentNodeForProperty(
2159: lProperty, pParentNode);
2160: if (lParentNode != null)
2161: lParentNode.add(lNode);
2162:
2163: Collection lProperties = sortCollection(lProperty
2164: .getSubProperties());
2165: if (lProperties.size() > 0) {
2166: if (pAddRoot) {
2167: DefaultMutableTreeNode lPropertiesNode = new DefaultMutableTreeNode(
2168: new PropertyUserObject(
2169: lProperty,
2170: Application
2171: .getString("properties_node"),
2172: PropertyUserObject.PROPERTY_ACTION),
2173: true);
2174: lNode.add(lPropertiesNode);
2175: addDataTypeProperties(lPropertiesNode, lProperties,
2176: pAddRoot);
2177: } else
2178: addDataTypeProperties(lNode, lProperties, pAddRoot);
2179: }
2180: }
2181: }
2182:
2183: // return parent node for property
2184: protected DefaultMutableTreeNode getParentNodeForProperty(
2185: Property pProperty, DefaultMutableTreeNode pParentNode) {
2186: if (pProperty != null && pParentNode != null) {
2187: PropertyDescriptor lPropertyDescriptor = pProperty
2188: .getDescriptor();
2189: if (lPropertyDescriptor != null
2190: && lPropertyDescriptor.isArray()) {
2191: String lName = lPropertyDescriptor.getName() + "s";
2192: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) findChildNodeByCaption(
2193: pParentNode, lName, false);
2194: if (lNode == null) {
2195: BaseUserObject lBaseUserObject = new BaseUserObject(
2196: null, lName, 0) {
2197: public void fillActionsList(ArrayList pList) {
2198: // no actions for the group
2199: }
2200: };
2201: lNode = new DefaultMutableTreeNode(lBaseUserObject,
2202: true);
2203: pParentNode.add(lNode);
2204: }
2205: return lNode;
2206: }
2207: }
2208: return pParentNode;
2209: }
2210:
2211: // create parent node for property
2212: protected DefaultMutableTreeNode createParentNodeForProperty(
2213: Property pProperty, DefaultMutableTreeNode pParentNode) {
2214: if (pProperty != null && pParentNode != null) {
2215: PropertyDescriptor lPropertyDescriptor = pProperty
2216: .getDescriptor();
2217: if (lPropertyDescriptor != null
2218: && lPropertyDescriptor.isArray()) {
2219: String lName = lPropertyDescriptor.getName() + "s";
2220: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) findChildNodeByCaption(
2221: pParentNode, lName, false);
2222: if (lNode == null) {
2223: BaseUserObject lBaseUserObject = new BaseUserObject(
2224: null, lName, 0);
2225: lNode = new DefaultMutableTreeNode(lBaseUserObject,
2226: true);
2227: return lNode;
2228: }
2229: }
2230: }
2231: return null;
2232: }
2233:
2234: /* Helper. Adds design library nodes */
2235: protected void addDesignLibraryNodes(
2236: DefaultMutableTreeNode pParentNode, DesignLibrary pLibrary) {
2237: addDesignLibraryNode(pParentNode, pLibrary, false);
2238: }
2239:
2240: // add design library nodes
2241: protected void addDesignLibraryNode(
2242: DefaultMutableTreeNode pParentNode, DesignLibrary pLibrary,
2243: boolean pAddRootNode) {
2244: DefaultMutableTreeNode lNode = pParentNode;
2245: if (pAddRootNode) {
2246: lNode = new DefaultMutableTreeNode(new DesignLibUserObject(
2247: pLibrary), true);
2248: if (pParentNode != null)
2249: pParentNode.add(lNode);
2250: }
2251:
2252: Collection lDataDictionaries = sortCollection(pLibrary
2253: .getDataDictionaries());
2254: if (lDataDictionaries.size() > 0) {
2255: DefaultMutableTreeNode lDictionariesNode = new DefaultMutableTreeNode(
2256: new DesignLibUserObject(pLibrary, Application
2257: .getString("datadictionaries_node"),
2258: DesignLibUserObject.ADD_DATADICTIONARY),
2259: true);
2260: lNode.add(lDictionariesNode);
2261: addDataDictionaryNodes(lDictionariesNode, lDataDictionaries);
2262: }
2263: }
2264:
2265: // Add technology library
2266: protected void addTechLibraryNodes(
2267: DefaultMutableTreeNode pParentNode,
2268: TechnologyLibrary pLibrary) {
2269: addTechLibraryNode(pParentNode, pLibrary, false);
2270: }
2271:
2272: // add technology library
2273: protected void addTechLibraryNode(
2274: DefaultMutableTreeNode pParentNode,
2275: TechnologyLibrary pLibrary, boolean pAddRootNode) {
2276: DefaultMutableTreeNode lNode = pParentNode;
2277: if (pAddRootNode) {
2278: lNode = new DefaultMutableTreeNode(new TechLibUserObject(
2279: pLibrary), true);
2280: pParentNode.add(lNode);
2281: }
2282:
2283: Collection lStorageTechnologies = sortCollection(pLibrary
2284: .getStorageTechnologies());
2285: if (lStorageTechnologies.size() > 0) {
2286: DefaultMutableTreeNode lTechnologiesNode = new DefaultMutableTreeNode(
2287: new TechLibUserObject(pLibrary, Application
2288: .getString("storagetech_node"),
2289: TechLibUserObject.TECHLIB_ACTION), true);
2290: lNode.add(lTechnologiesNode);
2291: addStorageTechnologies(lTechnologiesNode,
2292: lStorageTechnologies);
2293: }
2294: }
2295:
2296: // add Storage Technologies
2297: protected void addStorageTechnologies(
2298: DefaultMutableTreeNode pParentNode, Collection pTechnologies) {
2299: for (Iterator lIterator = pTechnologies.iterator(); lIterator
2300: .hasNext();) {
2301: RelationalStorageTechnology lStorageTechnology = (RelationalStorageTechnology) lIterator
2302: .next();
2303: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2304: new RelationalStorageTechnologyUserObject(
2305: lStorageTechnology), true);
2306: pParentNode.add(lNode);
2307:
2308: /* ????
2309: Object[] lDomainImplementations = lStorageTechnology.getDomainImplementationsOnTechnology().toArray();
2310: if (lDomainImplementations.length>0)
2311: {
2312:
2313: DefaultMutableTreeNode lDomainImplementationsNode = new DefaultMutableTreeNode(new RelationalStorageTechnologyUserObject(lStorageTechnology, Application.getString("domainimplementations_node"), RelationalStorageTechnologyUserObject.ADD_DOMINIMP), true);
2314: lNode.add(lDomainImplementationsNode);
2315: addDomainImplementations(lDomainImplementationsNode, lDomainImplementations);
2316: }*/
2317: }
2318: }
2319:
2320: // add domain implementations
2321: protected void addDomainImplementations(
2322: DefaultMutableTreeNode pParentNode,
2323: Collection pDomainImplementations) {
2324: for (Iterator lIterator = pDomainImplementations.iterator(); lIterator
2325: .hasNext();) {
2326: DomainRelationalStorageDefinition lDomainImplementation = (DomainRelationalStorageDefinition) lIterator
2327: .next();
2328: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2329: new RelationalStorageDefinitionUserObject(
2330: lDomainImplementation), true);
2331: pParentNode.add(lNode);
2332:
2333: // association tables
2334: Collection lAssociationsTables = sortCollection(lDomainImplementation
2335: .getAssociationTables());
2336: if (lAssociationsTables.size() > 0) {
2337: DefaultMutableTreeNode lTablesNode = new DefaultMutableTreeNode(
2338: new RelationalStorageDefinitionUserObject(
2339: lDomainImplementation,
2340: Application
2341: .getString("associationtables_node"),
2342: RelationalStorageDefinitionUserObject.ADD_ASSOCIATIONTABLES),
2343: true);
2344: lNode.add(lTablesNode);
2345: addAssociationTables(lTablesNode, lAssociationsTables);
2346: }
2347:
2348: // entity tables
2349: Collection lEntityTables = sortCollection(lDomainImplementation
2350: .getEntityTables());
2351: if (lEntityTables.size() > 0) {
2352: DefaultMutableTreeNode lTablesNode = new DefaultMutableTreeNode(
2353: new RelationalStorageDefinitionUserObject(
2354: lDomainImplementation,
2355: Application
2356: .getString("entitytables_node"),
2357: RelationalStorageDefinitionUserObject.ADD_ENTITYTABLES),
2358: true);
2359: lNode.add(lTablesNode);
2360: addEntityTables(lTablesNode, lEntityTables);
2361: }
2362:
2363: // reference tables
2364: Collection lReferenceTables = sortCollection(lDomainImplementation
2365: .getReferenceTables());
2366: if (lReferenceTables.size() > 0) {
2367: DefaultMutableTreeNode lTablesNode = new DefaultMutableTreeNode(
2368: new RelationalStorageDefinitionUserObject(
2369: lDomainImplementation,
2370: Application
2371: .getString("relationaltables_node"),
2372: RelationalStorageDefinitionUserObject.ADD_RELATIONALTABLES),
2373: true);
2374: lNode.add(lTablesNode);
2375: addRelationalTables(lTablesNode, lReferenceTables);
2376: }
2377: }
2378: }
2379:
2380: // add enterprise system diagrams collection
2381: protected void addEnterpriseSystemsDiagrams(
2382: DefaultMutableTreeNode pParentNode, Collection pDiagrams) {
2383: for (Iterator lIterator = pDiagrams.iterator(); lIterator
2384: .hasNext();) {
2385: EnterpriseSystemsDiagram lDiagram = (EnterpriseSystemsDiagram) lIterator
2386: .next();
2387: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2388: new EnterpriseSystemsDiagramUserObject(lDiagram),
2389: true);
2390: pParentNode.add(lNode);
2391: }
2392: }
2393:
2394: // add entity states diagrams collection
2395: protected void addEntityStatesDiagrams(
2396: DefaultMutableTreeNode pParentNode, Collection pDiagrams) {
2397: for (Iterator lIterator = pDiagrams.iterator(); lIterator
2398: .hasNext();) {
2399: EntityStateDiagram lDiagram = (EntityStateDiagram) lIterator
2400: .next();
2401: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2402: new EntityStateDiagramUserObject(lDiagram), true);
2403: pParentNode.add(lNode);
2404: }
2405: }
2406:
2407: // add servicemodule structures diagrams collection
2408: protected void addServicemoduleStructuresDiagrams(
2409: DefaultMutableTreeNode pParentNode, Collection pDiagrams) {
2410: for (Iterator lIterator = pDiagrams.iterator(); lIterator
2411: .hasNext();) {
2412: ServicemoduleStructuresDiagram lDiagram = (ServicemoduleStructuresDiagram) lIterator
2413: .next();
2414: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2415: new ServicemoduleStructuresDiagramUserObject(
2416: lDiagram), true);
2417: pParentNode.add(lNode);
2418: }
2419: }
2420:
2421: // add domain entities diagrams collection
2422: protected void addDomainEntitiesDiagrams(
2423: DefaultMutableTreeNode pParentNode, Collection pDiagrams) {
2424: for (Iterator lIterator = pDiagrams.iterator(); lIterator
2425: .hasNext();) {
2426: DomainEntitiesDiagram lDiagram = (DomainEntitiesDiagram) lIterator
2427: .next();
2428: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2429: new DomainEntitiesDiagramUserObject(lDiagram), true);
2430: pParentNode.add(lNode);
2431: }
2432: }
2433:
2434: // add use case diagrams
2435: protected void addUseCaseDiagrams(
2436: DefaultMutableTreeNode pParentNode, Collection pDiagrams) {
2437: for (Iterator lIterator = pDiagrams.iterator(); lIterator
2438: .hasNext();) {
2439: SystemUseCasesDiagram lDiagram = (SystemUseCasesDiagram) lIterator
2440: .next();
2441: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2442: new SystemUseCasesDiagramUserObject(lDiagram), true);
2443: pParentNode.add(lNode);
2444: }
2445: }
2446:
2447: // add Association class
2448: protected void addAssociationTables(
2449: DefaultMutableTreeNode pParentNode, Collection pTables) {
2450: for (Iterator lIterator = pTables.iterator(); lIterator
2451: .hasNext();) {
2452: RelationalAssociationTable lTable = (RelationalAssociationTable) lIterator
2453: .next();
2454: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2455: new RelationalAssociationTableUserObject(lTable),
2456: true);
2457: pParentNode.add(lNode);
2458: }
2459: }
2460:
2461: // add Entity tables
2462: protected void addEntityTables(DefaultMutableTreeNode pParentNode,
2463: Collection pTables) {
2464: for (Iterator lIterator = pTables.iterator(); lIterator
2465: .hasNext();) {
2466: RelationalEntityTable lTable = (RelationalEntityTable) lIterator
2467: .next();
2468: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2469: new RelationalEntityTableUserObject(lTable), true);
2470: pParentNode.add(lNode);
2471:
2472: // attribute columns
2473: Collection lAttributeColumns = sortCollection(lTable
2474: .getAttributeColumns());
2475: if (lAttributeColumns.size() > 0) {
2476: DefaultMutableTreeNode lColumnsNode = new DefaultMutableTreeNode(
2477: new RelationalEntityTableUserObject(
2478: lTable,
2479: Application
2480: .getString("attributecolumns_node"),
2481: RelationalEntityTableUserObject.ADD_ATTRIBUTECOLUMN),
2482: true);
2483: lNode.add(lColumnsNode);
2484: addAttributesColumns(lColumnsNode, lAttributeColumns);
2485: }
2486:
2487: // reference columns
2488: Collection lReferenceColumns = sortCollection(lTable
2489: .getReferenceColumns());
2490: if (lReferenceColumns.size() > 0) {
2491: DefaultMutableTreeNode lColumnsNode = new DefaultMutableTreeNode(
2492: new RelationalEntityTableUserObject(
2493: lTable,
2494: Application
2495: .getString("referencecolumns_node"),
2496: RelationalEntityTableUserObject.ADD_REFERENCECOLUMN),
2497: true);
2498: lNode.add(lColumnsNode);
2499: addReferenceColumns(lColumnsNode, lReferenceColumns);
2500: }
2501: }
2502: }
2503:
2504: // add attributes columns
2505: protected void addAttributesColumns(
2506: DefaultMutableTreeNode pParentNode, Collection pColumns) {
2507: for (Iterator lIterator = pColumns.iterator(); lIterator
2508: .hasNext();) {
2509: RelationalEntityTableAttributeColumn lColumn = (RelationalEntityTableAttributeColumn) lIterator
2510: .next();
2511: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2512: new RelationalEntityTableAttributeColumnUserObject(
2513: lColumn), true);
2514: pParentNode.add(lNode);
2515: }
2516: }
2517:
2518: // add refernce columns
2519: protected void addReferenceColumns(
2520: DefaultMutableTreeNode pParentNode, Collection pColumns) {
2521: for (Iterator lIterator = pColumns.iterator(); lIterator
2522: .hasNext();) {
2523: RelationalEntityTableReferenceColumn lColumn = (RelationalEntityTableReferenceColumn) lIterator
2524: .next();
2525: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2526: new RelationalEntityTableReferenceColumnUserObject(
2527: lColumn), true);
2528: pParentNode.add(lNode);
2529: }
2530: }
2531:
2532: // add relational tables
2533: protected void addRelationalTables(
2534: DefaultMutableTreeNode pParentNode, Collection pTables) {
2535: for (Iterator lIterator = pTables.iterator(); lIterator
2536: .hasNext();) {
2537: RelationalReferenceTable lTable = (RelationalReferenceTable) lIterator
2538: .next();
2539: DefaultMutableTreeNode lNode = new DefaultMutableTreeNode(
2540: new RelationalReferenceTableUserObject(lTable),
2541: true);
2542: pParentNode.add(lNode);
2543: }
2544: }
2545:
2546: protected static String[] getPackageArray(String lRef) {
2547: StringTokenizer lTok = new StringTokenizer(lRef, ".", false);
2548: int lTokCount = lTok.countTokens();
2549: String[] lReturn = new String[lTokCount];
2550: for (int i = 0; i < lReturn.length; i++) {
2551: lReturn[i] = lTok.nextToken();
2552: }
2553: return lReturn;
2554: }
2555:
2556: // check and create root nodes for new object
2557: protected DefaultMutableTreeNode createRootNodes(
2558: ModelElement pMasterElement, String pRootName,
2559: DefaultMutableTreeNode pMasterNode, JTree pTree) {
2560: String[] lRootNames = getPackageArray(pRootName);
2561: DefaultMutableTreeNode lMasterNode = pMasterNode;
2562:
2563: for (int i = 0; i < lRootNames.length; i++) {
2564: DefaultMutableTreeNode lNode = (DefaultMutableTreeNode) findChildNodeByCaption(
2565: lMasterNode, lRootNames[i], false);
2566: if (lNode == null) {
2567: BaseUserObject lMasterUserObject = UserObjectFactory
2568: .createUserObject(pMasterElement);
2569: if (lMasterUserObject != null) {
2570: String lRootName = lRootNames[i];
2571: lMasterUserObject.SetCaption(lRootName);
2572: lMasterUserObject.SetMode(lMasterUserObject
2573: .convertCaptionToAction(lRootName));
2574: lMasterUserObject.LoadDefaultIcons();
2575: lNode = new DefaultMutableTreeNode(
2576: lMasterUserObject, true);
2577: addNewNode(lNode, lMasterNode, pTree);
2578: }
2579: }
2580: lMasterNode = lNode;
2581: }
2582:
2583: return lMasterNode;
2584: }
2585:
2586: // sort collection elements if needed
2587: protected Collection sortCollection(Collection pInputCollection) {
2588: if (pInputCollection != null
2589: && !(pInputCollection instanceof List))
2590: // return ModelElementUtils.getSetOfModelElementsInAlphabeticalOrder(pInputCollection);
2591: return ModelElementUtils
2592: .getListOfModelElementsInAlphabeticalOrder(pInputCollection);
2593: else
2594: return pInputCollection;
2595: }
2596: }
|