0001: /*
0002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003: *
0004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * The contents of this file are subject to the terms of either the GNU
0007: * General Public License Version 2 only ("GPL") or the Common
0008: * Development and Distribution License("CDDL") (collectively, the
0009: * "License"). You may not use this file except in compliance with the
0010: * License. You can obtain a copy of the License at
0011: * http://www.netbeans.org/cddl-gplv2.html
0012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013: * specific language governing permissions and limitations under the
0014: * License. When distributing the software, include this License Header
0015: * Notice in each file and include the License file at
0016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
0017: * particular file as subject to the "Classpath" exception as provided
0018: * by Sun in the GPL Version 2 section of the License file that
0019: * accompanied this code. If applicable, add the following below the
0020: * License Header, with the fields enclosed by brackets [] replaced by
0021: * your own identifying information:
0022: * "Portions Copyrighted [year] [name of copyright owner]"
0023: *
0024: * Contributor(s):
0025: *
0026: * The Original Software is NetBeans. The Initial Developer of the Original
0027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0028: * Microsystems, Inc. All Rights Reserved.
0029: *
0030: * If you wish your version of this file to be governed by only the CDDL
0031: * or only the GPL Version 2, indicate your decision by adding
0032: * "[Contributor] elects to include this software in this distribution
0033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034: * single choice of license, a recipient has the option to distribute
0035: * your version of this file under either the CDDL, the GPL Version 2 or
0036: * to extend the choice of license to its licensees as provided above.
0037: * However, if you add GPL Version 2 code and therefore, elected the GPL
0038: * Version 2 license, then the option applies only if the new code is
0039: * made subject to such option by the copyright holder.
0040: */
0041:
0042: /*
0043: * Created on Feb 3, 2004
0044: *
0045: */
0046: package org.netbeans.modules.uml.ui.support.applicationmanager;
0047:
0048: import java.awt.Color;
0049: import java.util.List;
0050:
0051: import org.dom4j.Document;
0052: import org.dom4j.Element;
0053: import org.dom4j.Node;
0054: import org.netbeans.modules.uml.common.generics.ETPairT;
0055: import org.netbeans.modules.uml.common.generics.ETTripleT;
0056: import org.netbeans.modules.uml.core.configstringframework.ConfigStringTranslator;
0057: import org.netbeans.modules.uml.core.configstringframework.IConfigStringTranslator;
0058: import org.netbeans.modules.uml.core.metamodel.core.foundation.ConfigManager;
0059: import org.netbeans.modules.uml.core.metamodel.core.foundation.IConfigManager;
0060: import org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramKind;
0061: import org.netbeans.modules.uml.core.support.umlsupport.StringUtilities;
0062: import org.netbeans.modules.uml.core.support.umlsupport.XMLManip;
0063: import org.netbeans.modules.uml.core.support.umlutils.ETArrayList;
0064: import org.netbeans.modules.uml.core.support.umlutils.ETList;
0065: import org.netbeans.modules.uml.ui.support.ProductHelper;
0066: import org.netbeans.modules.uml.ui.support.drawingproperties.ColorProperty;
0067: import org.netbeans.modules.uml.ui.support.drawingproperties.ETFontType;
0068: import org.netbeans.modules.uml.ui.support.drawingproperties.FontProperty;
0069: import org.netbeans.modules.uml.ui.support.drawingproperties.IColorProperty;
0070: import org.netbeans.modules.uml.ui.support.drawingproperties.IDrawingProperty;
0071: import org.netbeans.modules.uml.ui.support.drawingproperties.IFontProperty;
0072:
0073: /**
0074: * @author jingmingm
0075: *
0076: */
0077: public class PresentationResourceMgr implements
0078: IPresentationResourceMgr {
0079: public static final String TYPENAME = "type";
0080: public static final String FONT = "font";
0081: public static final String FACENAME = "facename";
0082: public static final String HEIGHT = "height";
0083: public static final String WEIGHT = "weight";
0084: public static final String COLORVALUE = "colorvalue";
0085: public static final String COLOR = "color";
0086: public static final String NAME = "name";
0087: public static final String RESOURCE = "resource";
0088: public static final String TYPE = "type";
0089: public static final String DEFAULTRESOURCE = "defaultresource";
0090: public static final String ITALIC = "italic";
0091: public static final String DRAWENGINE = "drawengine";
0092: public static final String DISPLAYNAME = "displayName";
0093: public static final String DESCRIPTION = "description";
0094: public static final String DIAGRAMTYPE = "diagramtype";
0095: public static final String ADVANCED = "advanced";
0096: public static final String STANDARDDRAWENGINE = "standarddrawengine";
0097:
0098: // The diagram types
0099: public static final String ACTIVITY_DIAGRAM = "activity";
0100: public static final String CLASS_DIAGRAM = "class";
0101: public static final String COLLABORATION_DIAGRAM = "collaboration";
0102: public static final String COMPONENT_DIAGRAM = "component";
0103: public static final String DEPLOYMENT_DIAGRAM = "deployment";
0104: public static final String SEQUENCE_DIAGRAM = "sequence";
0105: public static final String STATE_DIAGRAM = "state";
0106: public static final String USECASE_DIAGRAM = "usecase";
0107: public static final String ENTITY_DIAGRAM = "entity";
0108:
0109: protected static final String IDR_OVERRIDDENCOLORS = "OverriddenColors.htm";
0110: //"c:\\development\\uml\\gui\\support\\applicationmanager\\OverriddenColors.htm";
0111:// <?xml version="1.0"?>
0112: // <EMBT:OverriddenColors version="1.0" xmlns:EMBT="www.sun.com">
0113: // <Version>1</Version>
0114: // </EMBT:OverriddenColors>
0115:
0116: // The loaded document
0117: protected Document m_DefaultDoc = null;
0118: protected Document m_OverriddenDoc = null;
0119:
0120: // The default location of the files
0121: protected String m_DefaultResourceLoc = "";
0122: protected String m_OverriddenResourceLoc = "";
0123:
0124: protected void reset() {
0125: m_DefaultResourceLoc = "";
0126: m_OverriddenResourceLoc = "";
0127: }
0128:
0129: protected Node getOrCreateElement(String sDrawEngineName) {
0130: Node pFoundOrCreatedNode = null;
0131:
0132: boolean bIsValid = validateFiles();
0133: if (bIsValid && m_OverriddenDoc != null) {
0134: Element pRoot = m_OverriddenDoc.getRootElement();
0135: Node pRootNode = (Node) pRoot;
0136: if (pRootNode != null) {
0137: // Now see if the sDrawEngineName parent is there
0138: // Typical Entry
0139: // <drawengine type="ClassDrawEngine">
0140: // <resource type='color' name="fill" value="16777215"/>
0141: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
0142: // </drawengine>
0143: //
0144: // Do a select like follows
0145: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
0146: String query = "./drawengine[@type='" + sDrawEngineName
0147: + "']";
0148: pFoundOrCreatedNode = pRootNode.selectSingleNode(query);
0149:
0150: if (pFoundOrCreatedNode == null) {
0151: pFoundOrCreatedNode = (Node) XMLManip
0152: .createElement(pRoot, DRAWENGINE);
0153:
0154: if (pFoundOrCreatedNode != null) {
0155: XMLManip.setAttributeValue(pFoundOrCreatedNode,
0156: TYPE, sDrawEngineName);
0157: }
0158: }
0159: }
0160: }
0161:
0162: return pFoundOrCreatedNode;
0163: }
0164:
0165: protected String getResourceType(Document pDomDocument,
0166: String sDrawEngineName, String sResourceName) {
0167: String sResourceType = "";
0168:
0169: Element pRoot = pDomDocument.getRootElement();
0170: Node pRootNode = (Node) pRoot;
0171: if (pRootNode != null) {
0172: // Typical Entry
0173: // <drawengine type="ClassDrawEngine">
0174: // <resource type='color' name="fill" value="16777215"/>
0175: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
0176: // </drawengine>
0177: //
0178: // Do a select like follows
0179: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
0180:
0181: String query = "./drawengine[@type='" + sDrawEngineName
0182: + "']/resource[@name='" + sResourceName + "']";
0183: Node pNode = pRootNode.selectSingleNode(query);
0184: if (pNode != null) {
0185: sResourceType = XMLManip.getAttributeValue(pNode,
0186: TYPENAME);
0187: }
0188: }
0189: return sResourceType;
0190: }
0191:
0192: protected IDrawingProperty loadFont(String sDrawEngine,
0193: String sFontResource) {
0194: IFontProperty pFoundProperty = new FontProperty();
0195: ETFontType pETFontType = getFontResource(sDrawEngine,
0196: sFontResource);
0197: if (pETFontType != null) {
0198: pFoundProperty.initialize(null, sDrawEngine, sFontResource,
0199: pETFontType.getName(), (short) 0,
0200: (short) pETFontType.getHeight(), pETFontType
0201: .getItalic(), false, false, pETFontType
0202: .getWeight(), pETFontType.getColor());
0203:
0204: }
0205:
0206: return (IDrawingProperty) pFoundProperty;
0207: }
0208:
0209: protected IDrawingProperty loadColor(String sDrawEngine,
0210: String sColorResource) {
0211: IColorProperty pFoundProperty = new ColorProperty();
0212: int nColor = getColorResource(sDrawEngine, sColorResource);
0213: //if (nColor != -1)
0214: {
0215: pFoundProperty.initialize(null, sDrawEngine,
0216: sColorResource, nColor);
0217: }
0218: return (IDrawingProperty) pFoundProperty;
0219: }
0220:
0221: protected ETList<String> getAllDrawEngineNames(Document pDomDocument) {
0222: ETList<String> pDrawEngines = new ETArrayList<String>();
0223:
0224: Element pRoot = pDomDocument.getRootElement();
0225: Node pRootNode = (Node) pRoot;
0226: if (pRootNode != null) {
0227: // Typical Entry
0228: // <drawengine type="ClassDrawEngine">
0229: // <resource type='color' name="fill" value="16777215"/>
0230: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
0231: // </drawengine>
0232: //
0233: // Do a select like follows
0234: // ./drawengine[@type]
0235:
0236: String query = "./drawengine[@type]";
0237: List pNodes = pRootNode.selectNodes(query);
0238: if (pNodes != null) {
0239: int nLen = pNodes.size();
0240: for (int ii = 0; ii < nLen; ii++) {
0241: Node pNode = (Node) pNodes.get(ii);
0242: if (pNode != null) {
0243: String sDrawEngineName = XMLManip
0244: .getAttributeValue(pNode, TYPENAME);
0245: if (sDrawEngineName != null
0246: && sDrawEngineName.length() > 0) {
0247: boolean bAddIt = true;
0248: if (sDrawEngineName
0249: .equals("TitleBlockDrawEngine")
0250: || sDrawEngineName
0251: .equals("ERViewDrawEngine")
0252: || sDrawEngineName
0253: .equals("EREntityDrawEngine")
0254: || sDrawEngineName
0255: .equals("EREntityAssociationEdgeDrawEngine")) {
0256: bAddIt = false;
0257: }
0258:
0259: if (bAddIt) {
0260: pDrawEngines.add(sDrawEngineName);
0261: }
0262: }
0263: }
0264: }
0265: }
0266: }
0267:
0268: return pDrawEngines;
0269: }
0270:
0271: protected ETList<String> getAllResourceNames(Document pDomDocument,
0272: String sDrawEngineName) {
0273: ETList<String> pResourceNames = new ETArrayList<String>();
0274:
0275: Element pRoot = pDomDocument.getRootElement();
0276: Node pRootNode = (Node) pRoot;
0277: if (pRootNode != null) {
0278: // Typical Entry
0279: // <drawengine type="ClassDrawEngine">
0280: // <resource type='color' name="fill" value="16777215"/>
0281: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
0282: // </drawengine>
0283: //
0284: // Do a select like follows
0285: // ./drawengine[@type=sDrawEngineName]/resource
0286: String query = "./drawengine[@type='" + sDrawEngineName
0287: + "']/resource";
0288: List pNodes = pRootNode.selectNodes(query);
0289: if (pNodes != null) {
0290: int nLen = pNodes.size();
0291: for (int ii = 0; ii < nLen; ii++) {
0292: Node pNode = (Node) pNodes.get(ii);
0293: if (pNode != null) {
0294: String sResourceName = XMLManip
0295: .getAttributeValue(pNode, NAME);
0296: if (sResourceName != null
0297: && sResourceName.length() > 0) {
0298: pResourceNames.add(sResourceName);
0299: }
0300: }
0301: }
0302: }
0303: }
0304:
0305: return pResourceNames;
0306: }
0307:
0308: protected ETPairT<String, String> retrieveDefaultPresentationResourceLocation() {
0309: ETPairT<String, String> retVal = new ETPairT<String, String>();
0310:
0311: if (m_DefaultResourceLoc.length() == 0
0312: || m_OverriddenResourceLoc.length() == 0) {
0313: IProduct prod = ProductHelper.getProduct();
0314: IConfigManager config = null;
0315: if (prod != null) {
0316: config = prod.getConfigManager();
0317: } else {
0318: config = new ConfigManager();
0319: }
0320:
0321: if (config != null) {
0322: if (m_DefaultResourceLoc.length() == 0) {
0323: m_DefaultResourceLoc = config
0324: .getDefaultResourcesLocation();
0325: }
0326: if (m_OverriddenResourceLoc.length() == 0) {
0327: m_OverriddenResourceLoc = config
0328: .getOverriddenResourcesLocation();
0329: }
0330: }
0331: }
0332:
0333: retVal.setParamOne(m_DefaultResourceLoc);
0334: retVal.setParamTwo(m_OverriddenResourceLoc);
0335: return retVal;
0336: }
0337:
0338: protected ETFontType getFont(Document pDomDocument) {
0339: ETFontType retVal = null;
0340:
0341: Element pRoot = pDomDocument.getRootElement();
0342: Node pRootNode = (Node) pRoot;
0343: if (pRootNode != null) {
0344: // Typical Entry
0345: // <defaultresource type="font" facename="Arial" height="12" weight="400" colorvalue="0"/>
0346: //
0347: // Do a select like follows
0348: // ./defaultresource[@type='font']
0349:
0350: String query = "./defaultresource[@type='font']";
0351: Node pNode = pRootNode.selectSingleNode(query);
0352:
0353: if (pNode != null) {
0354: retVal = new ETFontType();
0355: retVal.setName(XMLManip.getAttributeValue(pNode,
0356: FACENAME));
0357: retVal.setHeight(XMLManip.getAttributeIntValue(pNode,
0358: HEIGHT));
0359: retVal.setWeight(XMLManip.getAttributeIntValue(pNode,
0360: WEIGHT));
0361: retVal.setItalic(XMLManip.getAttributeBooleanValue(
0362: pNode, ITALIC));
0363: retVal.setColor(readCOLORREF(pNode));
0364: }
0365: }
0366:
0367: return retVal;
0368: }
0369:
0370: protected int getColor(Document pDomDocument) {
0371: int nColor = -1;
0372:
0373: Element pRoot = pDomDocument.getRootElement();
0374: Node pRootNode = (Node) pRoot;
0375: if (pRootNode != null) {
0376: // Typical Entry
0377: // <defaultresource type="color" colorvalue="0"/>
0378: //
0379: // Do a select like follows
0380: // ./defaultresource[@type='color']
0381:
0382: String query = "./defaultresource[@type='color']";
0383: Node pNode = pRootNode.selectSingleNode(query);
0384:
0385: if (pNode != null) {
0386: nColor = readCOLORREF(pNode);
0387: }
0388: }
0389:
0390: return nColor;
0391: }
0392:
0393: protected ETFontType getFontResource(Document pDomDocument,
0394: String sDrawEngineName, String sResourceName) {
0395: ETFontType retVal = null;
0396: Element pRoot = pDomDocument.getRootElement();
0397: Node pRootNode = (Node) pRoot;
0398: if (pRootNode != null) {
0399: // Typical Entry
0400: // <drawengine type="ClassDrawEngine">
0401: // <resource type='color' name="fill" value="16777215"/>
0402: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
0403: // </drawengine>
0404: //
0405: // Do a select like follows
0406: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
0407:
0408: String query = "./drawengine[@type='" + sDrawEngineName
0409: + "']/resource[@name='" + sResourceName + "']";
0410: Node pNode = pRootNode.selectSingleNode(query);
0411: if (pNode != null) {
0412: retVal = new ETFontType();
0413: retVal.setName(XMLManip.getAttributeValue(pNode,
0414: FACENAME));
0415: retVal.setHeight(XMLManip.getAttributeIntValue(pNode,
0416: HEIGHT) + 4);
0417: retVal.setWeight(XMLManip.getAttributeIntValue(pNode,
0418: WEIGHT));
0419: retVal.setItalic(XMLManip.getAttributeBooleanValue(
0420: pNode, ITALIC));
0421: retVal.setColor(readCOLORREF(pNode));
0422: }
0423: }
0424:
0425: return retVal;
0426: }
0427:
0428: protected int getColorResource(Document pDomDocument,
0429: String sDrawEngineName, String sResourceName) {
0430: int nColor = -1;
0431:
0432: Element pRoot = pDomDocument.getRootElement();
0433: Node pRootNode = (Node) pRoot;
0434: if (pRootNode != null) {
0435: // Typical Entry
0436: // <drawengine type="ClassDrawEngine">
0437: // <resource type='color' name="fill" value="16777215"/>
0438: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
0439: // </drawengine>
0440: //
0441: // Do a select like follows
0442: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
0443:
0444: String query = "./drawengine[@type='" + sDrawEngineName
0445: + "']/resource[@name='" + sResourceName + "']";
0446: Node pNode = pRootNode.selectSingleNode(query);
0447: if (pNode != null) {
0448: nColor = readCOLORREF(pNode);
0449: }
0450: }
0451:
0452: return nColor;
0453: }
0454:
0455: public boolean validateFiles() {
0456: boolean bIsValid = false;
0457: ;
0458:
0459: try {
0460: if (m_DefaultDoc == null && m_OverriddenDoc == null) {
0461: // Open the file and see if it's valid
0462: ETPairT<String, String> retVal = this
0463: .retrieveDefaultPresentationResourceLocation();
0464: String xsDefaultResources = retVal.getParamOne();
0465: String xsOverriddenResources = retVal.getParamTwo();
0466:
0467: if (xsDefaultResources != null
0468: && xsDefaultResources.length() > 0
0469: && xsOverriddenResources != null
0470: && xsOverriddenResources.length() > 0) {
0471: // See if the file will load
0472: m_DefaultDoc = XMLManip
0473: .getDOMDocument(xsDefaultResources);
0474: m_OverriddenDoc = XMLManip
0475: .getDOMDocument(xsOverriddenResources);
0476:
0477: // If we fail to open the overridden colors file then create an empty one
0478: if (m_DefaultDoc != null && m_OverriddenDoc == null) {
0479: //String header = UMLXMLManip.retrieveXMLFragmentFromResource(getClass(), IDR_OVERRIDDENCOLORS);
0480: //m_OverriddenDoc = XMLManip.getDOMDocument(header);
0481: //m_OverriddenDoc = XMLManip.getDOMDocumentFromString("<?xml version='1.0'?><EMBT:OverriddenColors version='1.0' xmlns:EMBT='www.sun.com'><Version>1</Version></EMBT:OverriddenColors>");
0482: m_OverriddenDoc = XMLManip
0483: .loadXML("<?xml version='1.0'?><EMBT:OverriddenColors version='1.0' xmlns:EMBT='www.sun.com'><Version>1</Version></EMBT:OverriddenColors>");
0484: if (m_OverriddenDoc != null) {
0485: XMLManip.save(m_OverriddenDoc,
0486: xsOverriddenResources);
0487: }
0488: }
0489: }
0490:
0491: // Now we should be valid, otherwise we've got problems!
0492: if (m_DefaultDoc == null || m_OverriddenDoc == null) {
0493: reset();
0494: bIsValid = false;
0495: } else {
0496: bIsValid = true;
0497: }
0498: }
0499:
0500: if (m_DefaultDoc != null && m_OverriddenDoc != null) {
0501: bIsValid = true;
0502: }
0503: } catch (Exception e) {
0504: }
0505:
0506: return bIsValid;
0507: }
0508:
0509: public String getSampleDiagramFilename(int nKind) {
0510: String sDiagramETLDFile = "";
0511: String sDiagramKind = "";
0512:
0513: switch (nKind) {
0514: case IDiagramKind.DK_ACTIVITY_DIAGRAM:
0515: sDiagramKind = ACTIVITY_DIAGRAM;
0516: break;
0517: case IDiagramKind.DK_CLASS_DIAGRAM:
0518: sDiagramKind = CLASS_DIAGRAM;
0519: break;
0520: case IDiagramKind.DK_COLLABORATION_DIAGRAM:
0521: sDiagramKind = COLLABORATION_DIAGRAM;
0522: break;
0523: case IDiagramKind.DK_COMPONENT_DIAGRAM:
0524: sDiagramKind = COMPONENT_DIAGRAM;
0525: break;
0526: case IDiagramKind.DK_DEPLOYMENT_DIAGRAM:
0527: sDiagramKind = DEPLOYMENT_DIAGRAM;
0528: break;
0529: case IDiagramKind.DK_SEQUENCE_DIAGRAM:
0530: sDiagramKind = SEQUENCE_DIAGRAM;
0531: break;
0532: case IDiagramKind.DK_STATE_DIAGRAM:
0533: sDiagramKind = STATE_DIAGRAM;
0534: break;
0535: case IDiagramKind.DK_USECASE_DIAGRAM:
0536: sDiagramKind = USECASE_DIAGRAM;
0537: break;
0538: case IDiagramKind.DK_ENTITY_DIAGRAM:
0539: sDiagramKind = ENTITY_DIAGRAM;
0540: break;
0541: }
0542:
0543: if (sDiagramKind.length() > 0) {
0544: // Here's a sample diagrams table in the DefaultColors.etc file
0545: /*
0546: <SampleDiagrams>
0547: <diagram type="class" location="ClassDiagram_1074699624.etld"/>
0548: <diagram type="component" location="ComponentDiagram_1074809903.etld"/>
0549: <diagram type="sequence" location="SequenceDiagram_1074811353.etld"/>
0550: </SampleDiagrams>
0551: */
0552: boolean bIsValid = validateFiles();
0553: if (bIsValid && m_DefaultDoc != null) {
0554: Element pRoot = m_DefaultDoc.getRootElement();
0555: Node pRootNode = (Node) pRoot;
0556: if (pRootNode != null) {
0557: String query = "./SampleDiagrams/diagram[@type='"
0558: + sDiagramKind + "']";
0559: Node pNode = pRootNode.selectSingleNode(query);
0560: if (pNode != null) {
0561: sDiagramETLDFile = XMLManip.getAttributeValue(
0562: pNode, "location");
0563: }
0564: }
0565: }
0566: }
0567:
0568: return sDiagramETLDFile;
0569: }
0570:
0571: public ETList<String> getStandardDrawEngines(int nKind) {
0572: ETList<String> pStandardDrawEngines = new ETArrayList<String>();
0573:
0574: // Get the default draw engines from the table at the top of the default colors file
0575: boolean bIsValid = validateFiles();
0576: if (bIsValid && m_DefaultDoc != null) {
0577: Element pRoot = m_DefaultDoc.getRootElement();
0578: Node pRootNode = (Node) pRoot;
0579: if (pRootNode != null) {
0580: String sDiagramKind = "";
0581:
0582: switch (nKind) {
0583: case IDiagramKind.DK_ACTIVITY_DIAGRAM:
0584: sDiagramKind = ACTIVITY_DIAGRAM;
0585: break;
0586: case IDiagramKind.DK_CLASS_DIAGRAM:
0587: sDiagramKind = CLASS_DIAGRAM;
0588: break;
0589: case IDiagramKind.DK_COLLABORATION_DIAGRAM:
0590: sDiagramKind = COLLABORATION_DIAGRAM;
0591: break;
0592: case IDiagramKind.DK_COMPONENT_DIAGRAM:
0593: sDiagramKind = COMPONENT_DIAGRAM;
0594: break;
0595: case IDiagramKind.DK_DEPLOYMENT_DIAGRAM:
0596: sDiagramKind = DEPLOYMENT_DIAGRAM;
0597: break;
0598: case IDiagramKind.DK_SEQUENCE_DIAGRAM:
0599: sDiagramKind = SEQUENCE_DIAGRAM;
0600: break;
0601: case IDiagramKind.DK_STATE_DIAGRAM:
0602: sDiagramKind = STATE_DIAGRAM;
0603: break;
0604: case IDiagramKind.DK_USECASE_DIAGRAM:
0605: sDiagramKind = USECASE_DIAGRAM;
0606: break;
0607: case IDiagramKind.DK_ENTITY_DIAGRAM:
0608: sDiagramKind = ENTITY_DIAGRAM;
0609: break;
0610: }
0611:
0612: // Typical Entry <SampleDiagrams>
0613: // <SampleDiagrams>
0614: // <diagram type="class" location="ClassDiagram_1074699624.etld">
0615: // <standarddrawengine name="ClassDrawEngine"/>
0616: // </diagram>
0617: // </SampleDiagrams>
0618: //
0619: // Do a select like follows
0620: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
0621:
0622: String query = "./SampleDiagrams/diagram[@type='"
0623: + sDiagramKind + "']/standarddrawengine";
0624: List pNodes = pRootNode.selectNodes(query);
0625:
0626: if (pNodes != null) {
0627: int nLen = pNodes.size();
0628: for (int ii = 0; ii < nLen; ii++) {
0629: Node pNode = (Node) pNodes.get(ii);
0630: if (pNode != null) {
0631: String sDrawEngineName = XMLManip
0632: .getAttributeValue(pNode, NAME);
0633: if (sDrawEngineName != null
0634: && sDrawEngineName.length() > 0) {
0635: // Don't add the erstudio types if they don't belong
0636: boolean bAddIt = true;
0637: if (sDrawEngineName
0638: .equals("TitleBlockDrawEngine")
0639: || sDrawEngineName
0640: .equals("ERViewDrawEngine")
0641: || sDrawEngineName
0642: .equals("EREntityDrawEngine")
0643: || sDrawEngineName
0644: .equals("EREntityAssociationEdgeDrawEngine")) {
0645: bAddIt = false;
0646: }
0647:
0648: if (bAddIt) {
0649: pStandardDrawEngines
0650: .add(sDrawEngineName);
0651: }
0652: }
0653: }
0654: }
0655: }
0656: }
0657: }
0658:
0659: return pStandardDrawEngines;
0660: }
0661:
0662: public ETPairT<String, String> getUpgradeString(String sOldName) {
0663: ETPairT<String, String> retVal = new ETPairT<String, String>();
0664:
0665: // Here's a sample upgrade table in the DefaultColors.etc file
0666: /*
0667: <UpgradeTable>
0668: <resource type="color" oldname="ActivityEdgeBorderColor" newdrawengine="" newresource="activityedgecolor"/>
0669: <resource type="color" oldname="ActivityFinalNodeBorderColor" newdrawengine="" newresource=""/>
0670: </UpgradeTable>
0671: */
0672:
0673: // If we know how to upgrade then newname is set to a string (ie activityedgecolor) if it's
0674: // "" then we don't know how to upgrade that resource.
0675: boolean bIsValid = validateFiles();
0676: if (bIsValid && m_DefaultDoc != null) {
0677: Element pRoot = m_DefaultDoc.getRootElement();
0678: Node pRootNode = (Node) pRoot;
0679: if (pRootNode != null) {
0680: String query = "./UpgradeTable/resource[@oldname='"
0681: + sOldName + "']";
0682: Node pNode = pRootNode.selectSingleNode(query);
0683: if (pNode != null) {
0684: String sNewDrawEngine = XMLManip.getAttributeValue(
0685: pNode, "newdrawengine");
0686: String sNewResourceName = XMLManip
0687: .getAttributeValue(pNode, "newresource");
0688:
0689: if (sNewDrawEngine.length() > 0
0690: && sNewResourceName.length() > 0) {
0691: retVal.setParamOne(sNewDrawEngine);
0692: retVal.setParamTwo(sNewResourceName);
0693: }
0694: }
0695: }
0696: }
0697:
0698: return retVal;
0699: }
0700:
0701: public ETFontType getFont() {
0702: ETFontType retVal = null;
0703:
0704: boolean bIsValid = validateFiles();
0705: if (bIsValid && m_OverriddenDoc != null && m_DefaultDoc != null) {
0706: retVal = getFont(m_OverriddenDoc);
0707: if (retVal == null) {
0708: retVal = getFont(m_DefaultDoc);
0709: }
0710: }
0711:
0712: return retVal;
0713: }
0714:
0715: public int getColor() {
0716: int nColor = -1;
0717:
0718: // Get the default color resource
0719: boolean bIsValid = validateFiles();
0720: if (bIsValid && m_OverriddenDoc != null && m_DefaultDoc != null) {
0721: nColor = getColor(m_OverriddenDoc);
0722: if (nColor == -1) {
0723: nColor = getColor(m_DefaultDoc);
0724: }
0725: }
0726:
0727: return nColor;
0728: }
0729:
0730: public ETFontType getFontResource(String sDrawEngineName,
0731: String sResourceName) {
0732: ETFontType retVal = null;
0733:
0734: boolean bIsValid = validateFiles();
0735: if (bIsValid && m_DefaultDoc != null && m_OverriddenDoc != null) {
0736: retVal = getFontResource(m_OverriddenDoc, sDrawEngineName,
0737: sResourceName);
0738: if (retVal == null) {
0739: retVal = getFontResource(m_DefaultDoc, sDrawEngineName,
0740: sResourceName);
0741: }
0742: }
0743:
0744: return retVal;
0745: }
0746:
0747: public int getColorResource(String sDrawEngineName,
0748: String sResourceName) {
0749: int nColor = -1;
0750:
0751: boolean bIsValid = validateFiles();
0752: if (bIsValid && m_DefaultDoc != null && m_OverriddenDoc != null) {
0753: nColor = getColorResource(m_OverriddenDoc, sDrawEngineName,
0754: sResourceName);
0755: if (nColor == -1) {
0756: nColor = getColorResource(m_DefaultDoc,
0757: sDrawEngineName, sResourceName);
0758: }
0759: }
0760:
0761: return nColor;
0762: }
0763:
0764: public ETFontType getDefaultFontResource(String sDrawEngineName,
0765: String sResourceName) {
0766: ETFontType retVal = null;
0767: boolean bIsValid = validateFiles();
0768: if (bIsValid && m_DefaultDoc != null) {
0769: retVal = getFontResource(m_DefaultDoc, sDrawEngineName,
0770: sResourceName);
0771: }
0772:
0773: return retVal;
0774: }
0775:
0776: public int getDefaultColorResource(String sDrawEngineName,
0777: String sResourceName) {
0778: int nColor = -1;
0779: boolean bIsValid = validateFiles();
0780: if (bIsValid && m_DefaultDoc != null) {
0781: nColor = getColorResource(m_DefaultDoc, sDrawEngineName,
0782: sResourceName);
0783: }
0784:
0785: return nColor;
0786: }
0787:
0788: public ETFontType getOverriddenFontResource(String sDrawEngineName,
0789: String sResourceName) {
0790: ETFontType retVal = null;
0791: boolean bIsValid = validateFiles();
0792: if (bIsValid && m_OverriddenDoc != null) {
0793: retVal = getFontResource(m_OverriddenDoc, sDrawEngineName,
0794: sResourceName);
0795: }
0796:
0797: return retVal;
0798: }
0799:
0800: public int getOverriddenColorResource(String sDrawEngineName,
0801: String sResourceName) {
0802: int nColor = -1;
0803: boolean bIsValid = validateFiles();
0804: if (bIsValid && m_OverriddenDoc != null) {
0805: nColor = getColorResource(m_OverriddenDoc, sDrawEngineName,
0806: sResourceName);
0807: }
0808:
0809: return nColor;
0810: }
0811:
0812: public void saveOverriddenResources() {
0813: try {
0814: boolean bIsValid = validateFiles();
0815: if (bIsValid && m_OverriddenDoc != null
0816: && m_OverriddenResourceLoc.length() > 0) {
0817: XMLManip.save(m_OverriddenDoc, m_OverriddenResourceLoc);
0818: }
0819: } catch (Exception e) {
0820: }
0821: }
0822:
0823: public void removeOverriddenFontResource(String sDrawEngineName,
0824: String sResourceName) {
0825: boolean bIsValid = validateFiles();
0826: if (bIsValid && m_OverriddenDoc != null) {
0827: Element pRoot = m_OverriddenDoc.getRootElement();
0828: Node pRootNode = (Node) pRoot;
0829: if (pRootNode != null) {
0830: // Typical Entry
0831: // <drawengine type="ClassDrawEngine">
0832: // <resource type='color' name="fill" value="16777215"/>
0833: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
0834: // </drawengine>
0835: //
0836: // Do a select like follows
0837: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
0838:
0839: String query = "./drawengine[@type='" + sDrawEngineName
0840: + "']/resource[@name='" + sResourceName + "']";
0841: Node pNode = pRootNode.selectSingleNode(query);
0842: if (pNode != null) {
0843: Element parent = pNode.getParent();
0844: if (parent != null) {
0845: parent.remove(pNode);
0846: }
0847: }
0848: }
0849: }
0850: }
0851:
0852: public void removeOverriddenColorResource(String sDrawEngineName,
0853: String sResourceName) {
0854: boolean bIsValid = validateFiles();
0855: if (bIsValid && m_OverriddenDoc != null) {
0856: Element pRoot = m_OverriddenDoc.getRootElement();
0857: Node pRootNode = (Node) pRoot;
0858: if (pRootNode != null) {
0859: // Typical Entry
0860: // <drawengine type="ClassDrawEngine">
0861: // <resource type='color' name="fill" value="16777215"/>
0862: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
0863: // </drawengine>
0864: //
0865: // Do a select like follows
0866: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
0867:
0868: String query = "./drawengine[@type='" + sDrawEngineName
0869: + "']/resource[@name='" + sResourceName + "']";
0870: Node pNode = pRootNode.selectSingleNode(query);
0871: if (pNode != null) {
0872: Element parent = pNode.getParent();
0873: if (parent != null) {
0874: parent.remove(pNode);
0875: }
0876: }
0877: }
0878: }
0879: }
0880:
0881: public void saveOverriddenFontResource(String sDrawEngineName,
0882: String sResourceName, ETFontType pETFontType) {
0883: boolean bIsValid = validateFiles();
0884: if (bIsValid && m_OverriddenDoc != null) {
0885: Element pRoot = m_OverriddenDoc.getRootElement();
0886: Node pRootNode = (Node) pRoot;
0887: if (pRootNode != null) {
0888: // First delete the resource, then we can re-add it.
0889: removeOverriddenFontResource(sDrawEngineName,
0890: sResourceName);
0891:
0892: // Get or create the node
0893: Node pFoundOrCreatedNode = getOrCreateElement(sDrawEngineName);
0894: if (pFoundOrCreatedNode != null) {
0895: // Add the font child
0896: Node pCreatedNode = XMLManip.createElement(
0897: (Element) pFoundOrCreatedNode, RESOURCE);
0898: if (pCreatedNode != null) {
0899: XMLManip.setAttributeValue(pCreatedNode, TYPE,
0900: FONT);
0901: XMLManip.setAttributeValue(pCreatedNode, NAME,
0902: sResourceName);
0903: XMLManip.setAttributeValue(pCreatedNode,
0904: FACENAME, pETFontType.getName());
0905: Integer height = new Integer(pETFontType
0906: .getHeight() - 4); // It was increased by when read in
0907: XMLManip.setAttributeValue(pCreatedNode,
0908: HEIGHT, height.toString());
0909: Integer weight = new Integer(pETFontType
0910: .getWeight());
0911: XMLManip.setAttributeValue(pCreatedNode,
0912: WEIGHT, weight.toString());
0913: Boolean italict = new Boolean(pETFontType
0914: .getItalic());
0915: XMLManip.setAttributeValue(pCreatedNode,
0916: ITALIC, italict.toString());
0917: saveCOLORREF(pCreatedNode, pETFontType
0918: .getColor());
0919: }
0920: }
0921: }
0922: }
0923: }
0924:
0925: public void saveOverriddenColorResource(String sDrawEngineName,
0926: String sResourceName, int nColor) {
0927: boolean bIsValid = validateFiles();
0928: if (bIsValid && m_OverriddenDoc != null) {
0929: Element pRoot = m_OverriddenDoc.getRootElement();
0930: Node pRootNode = (Node) pRoot;
0931: if (pRootNode != null) {
0932: // First delete the resource, then we can re-add it.
0933: removeOverriddenColorResource(sDrawEngineName,
0934: sResourceName);
0935:
0936: // Get or create the node
0937: Node pFoundOrCreatedNode = getOrCreateElement(sDrawEngineName);
0938: if (pFoundOrCreatedNode != null) {
0939: // Add the color child
0940: Node pCreatedNode = XMLManip.createElement(
0941: (Element) pFoundOrCreatedNode, RESOURCE);
0942: if (pCreatedNode != null) {
0943: XMLManip.setAttributeValue(pCreatedNode, TYPE,
0944: COLOR);
0945: XMLManip.setAttributeValue(pCreatedNode, NAME,
0946: sResourceName);
0947: saveCOLORREF(pCreatedNode, nColor);
0948: }
0949: }
0950: }
0951: }
0952: }
0953:
0954: public ETList<String> getAllDrawEngineNames() {
0955: ETList<String> pDrawEngines = new ETArrayList<String>();
0956:
0957: boolean bIsValid = validateFiles();
0958: if (bIsValid && m_OverriddenDoc != null && m_DefaultDoc != null) {
0959: ETList<String> pFoundStrings = null;
0960: pFoundStrings = getAllDrawEngineNames(m_OverriddenDoc);
0961: pDrawEngines.addAll(pFoundStrings);
0962: pFoundStrings = getAllDrawEngineNames(m_DefaultDoc);
0963: pDrawEngines.addAll(pFoundStrings);
0964: }
0965:
0966: return pDrawEngines;
0967: }
0968:
0969: public ETList<String> getAllResourceNames(String sDrawEngineName) {
0970: ETList<String> pResourceNames = new ETArrayList<String>();
0971:
0972: boolean bIsValid = validateFiles();
0973: if (bIsValid && m_OverriddenDoc != null && m_DefaultDoc != null) {
0974: ETList<String> pFoundStrings = null;
0975: // pFoundStrings = getAllResourceNames(m_OverriddenDoc, sDrawEngineName);
0976: // pResourceNames.addAll(pFoundStrings);
0977: pFoundStrings = getAllResourceNames(m_DefaultDoc,
0978: sDrawEngineName);
0979: pResourceNames.addAll(pFoundStrings);
0980: }
0981:
0982: return pResourceNames;
0983: }
0984:
0985: public ETList<IDrawingProperty> getAllDrawingProperties(
0986: String sDrawEngineName) {
0987: ETList<IDrawingProperty> pProperties = new ETArrayList<IDrawingProperty>();
0988:
0989: ETList<String> pAllResourceNames = getAllResourceNames(sDrawEngineName);
0990: if (pAllResourceNames != null) {
0991: int count = pAllResourceNames.size();
0992: for (int i = 0; i < count; i++) {
0993: String sThisName = pAllResourceNames.get(i);
0994: if (sThisName != null && sThisName.length() > 0) {
0995: IDrawingProperty pProperty = getDrawingProperty(
0996: sDrawEngineName, sThisName);
0997: if (pProperty != null) {
0998: pProperties.add(pProperty);
0999: }
1000: }
1001: }
1002: }
1003:
1004: return pProperties;
1005: }
1006:
1007: public String getResourceType(String sDrawEngineName,
1008: String sResourceName) {
1009: String sResourceType = "";
1010:
1011: // Get the type of this resource in the overridden and then in the default color table
1012: boolean bIsValid = validateFiles();
1013: if (bIsValid && m_OverriddenDoc != null && m_DefaultDoc != null) {
1014: sResourceType = getResourceType(m_OverriddenDoc,
1015: sDrawEngineName, sResourceName);
1016: if (sResourceType == "") {
1017: sResourceType = getResourceType(m_DefaultDoc,
1018: sDrawEngineName, sResourceName);
1019: }
1020: }
1021:
1022: return sResourceType;
1023: }
1024:
1025: public boolean isAdvanced(String sDrawEngineName,
1026: String sResourceName) {
1027: boolean bIsAdvanced = false;
1028:
1029: // Get the advanced flag from the default document
1030: boolean bIsValid = validateFiles();
1031: if (sDrawEngineName != null && sResourceName != null
1032: && bIsValid && m_DefaultDoc != null) {
1033: Element pRoot = m_DefaultDoc.getRootElement();
1034: Node pRootNode = (Node) pRoot;
1035: if (pRootNode != null) {
1036: // Typical Entry
1037: // <drawengine type="ClassDrawEngine">
1038: // <resource type='color' name="fill" value="16777215" advanced="1"/>
1039: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
1040: // </drawengine>
1041: //
1042: // Do a select like follows
1043: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
1044:
1045: String query = "./drawengine[@type='" + sDrawEngineName
1046: + "']/resource[@name='" + sResourceName + "']";
1047: Node pNode = pRootNode.selectSingleNode(query);
1048: if (pNode != null) {
1049: int nAdvanced = XMLManip.getAttributeIntValue(
1050: pNode, ADVANCED);
1051: bIsAdvanced = nAdvanced == 0 ? false : true;
1052: }
1053: }
1054: }
1055: return bIsAdvanced;
1056: }
1057:
1058: public IDrawingProperty getDrawingProperty(String sDrawEngineName,
1059: String sResourceName) {
1060: IDrawingProperty pProperty = null;
1061:
1062: // Now we have a combination of the draw engine and resource name
1063: String sType = getResourceType(sDrawEngineName, sResourceName);
1064: if (sType.equals("font")) {
1065: pProperty = loadFont(sDrawEngineName, sResourceName);
1066: } else if (sType.equals("color")) {
1067: pProperty = loadColor(sDrawEngineName, sResourceName);
1068: }
1069:
1070: return pProperty;
1071: }
1072:
1073: public ETPairT<String, String> getDisplayName(
1074: String sDrawEngineName, String sResourceName) {
1075: ETPairT<String, String> retVal = new ETPairT<String, String>();
1076: String sDisplayName = "", sDescription = "";
1077:
1078: // Get the information from the default color document (defaultcolors.etc)
1079: boolean bIsValid = validateFiles();
1080: if (bIsValid && m_DefaultDoc != null) {
1081: Element pRoot = m_DefaultDoc.getRootElement();
1082: Node pRootNode = (Node) pRoot;
1083: if (pRootNode != null) {
1084: // Typical Entry
1085: // <drawengine type="ClassDrawEngine">
1086: // <resource type="color" name="classfill" colorvalue="65535" displayName="PSK_CLASSFILLCOLOR"/>
1087: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
1088: // </drawengine>
1089: //
1090: // Do a select like follows
1091: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
1092:
1093: String query = "";
1094: if (sResourceName != null && sResourceName.length() > 0) {
1095: // Get the resource description
1096: query = "./drawengine[@type='" + sDrawEngineName
1097: + "']/resource[@name='" + sResourceName
1098: + "']";
1099: } else {
1100: // Get the drawengine description
1101: query = "./drawengine[@type='" + sDrawEngineName
1102: + "']";
1103: }
1104:
1105: Node pNode = pRootNode.selectSingleNode(query);
1106: if (pNode != null) {
1107: String sPSKName = XMLManip.getAttributeValue(pNode,
1108: DISPLAYNAME);
1109: String sPSKDescription = XMLManip
1110: .getAttributeValue(pNode, DESCRIPTION);
1111: String sTranslatedName = "";
1112: String sTranslatedDescription = "";
1113: if (sPSKName != null && sPSKName.length() > 0
1114: || sPSKDescription != null
1115: && sPSKDescription.length() > 0) {
1116: IConfigStringTranslator pTranslator = new ConfigStringTranslator();
1117: if (pTranslator != null) {
1118: sTranslatedName = pTranslator
1119: .translateWord(sPSKName);
1120: sTranslatedDescription = pTranslator
1121: .translateWord(sPSKDescription);
1122:
1123: // if it actually got translated then return it
1124: if (!(sPSKName.equals(sTranslatedName))) {
1125: sDisplayName = sTranslatedName;
1126: }
1127: if (!(sPSKDescription
1128: .equals(sTranslatedDescription))) {
1129: sDescription = sTranslatedDescription;
1130: }
1131: }
1132: }
1133: }
1134: }
1135: }
1136:
1137: retVal.setParamOne(sDisplayName);
1138: retVal.setParamTwo(sDescription);
1139: return retVal;
1140: }
1141:
1142: public ETTripleT<String, String, Integer> getDrawEngineDisplayDetails(
1143: String sDrawEngineName) {
1144: ETTripleT<String, String, Integer> retVal = new ETTripleT<String, String, Integer>();
1145:
1146: String sDisplayName = "";
1147: String sDescription = "";
1148: int nPreferredDiagramKind = IDiagramKind.DK_UNKNOWN;
1149:
1150: // Get the information from the default color document (defaultcolors.etc)
1151: boolean bIsValid = validateFiles();
1152: if (bIsValid && m_DefaultDoc != null) {
1153: Element pRoot = m_DefaultDoc.getRootElement();
1154: Node pRootNode = (Node) pRoot;
1155: if (pRootNode != null) {
1156: // Typical Entry
1157: // <drawengine type="ClassDrawEngine" displayName="PSK_CLASSDRAWENGINE" description="PSK_CLASSDRAWENGINE_DESC" diagramtype="class">
1158: // <resource type="color" name="classfill" colorvalue="65535" displayName="PSK_CLASSFILLCOLOR"/>
1159: // <resource type='font' name="stereotype" facename="Arial" height="12" weight="700" color="16777215"/>
1160: // </drawengine>
1161: //
1162: // Do a select like follows
1163: // ./drawengine[@type='sDrawEngineName']/resource[@name='sResourceName') ]
1164:
1165: String query = "./drawengine[@type=" + sDrawEngineName
1166: + "']";
1167: Node pNode = pRootNode.selectSingleNode(query);
1168: if (pNode != null) {
1169: String sPSKName = XMLManip.getAttributeValue(pNode,
1170: DISPLAYNAME);
1171: String sPSKDescription = XMLManip
1172: .getAttributeValue(pNode, DESCRIPTION);
1173: String sPreferredDiagram = XMLManip
1174: .getAttributeValue(pNode, DIAGRAMTYPE);
1175: String sTranslatedName = "";
1176: String sTranslatedDescription = "";
1177:
1178: if (sPSKName.length() > 0
1179: || sPSKDescription.length() > 0
1180: || sPreferredDiagram.length() > 0) {
1181: IConfigStringTranslator pTranslator = new ConfigStringTranslator();
1182: if (pTranslator != null) {
1183: sTranslatedName = pTranslator
1184: .translateWord(sPSKName);
1185: sTranslatedDescription = pTranslator
1186: .translateWord(sPSKDescription);
1187:
1188: // if it actually got translated then return it
1189: if (!(sPSKName.equals(sTranslatedName))) {
1190: if (sDisplayName.length() > 0) {
1191: sDisplayName = sTranslatedName;
1192: }
1193: }
1194: if (!(sPSKDescription
1195: .equals(sTranslatedDescription))) {
1196: if (sDescription != null) {
1197: sDescription = sTranslatedDescription;
1198: }
1199: }
1200: if (sPreferredDiagram.length() > 0) {
1201: if (sPreferredDiagram
1202: .equals(ACTIVITY_DIAGRAM)) {
1203: nPreferredDiagramKind = IDiagramKind.DK_ACTIVITY_DIAGRAM;
1204: } else if (sPreferredDiagram
1205: .equals(CLASS_DIAGRAM)) {
1206: nPreferredDiagramKind = IDiagramKind.DK_CLASS_DIAGRAM;
1207: } else if (sPreferredDiagram
1208: .equals(COLLABORATION_DIAGRAM)) {
1209: nPreferredDiagramKind = IDiagramKind.DK_COLLABORATION_DIAGRAM;
1210: } else if (sPreferredDiagram
1211: .equals(COMPONENT_DIAGRAM)) {
1212: nPreferredDiagramKind = IDiagramKind.DK_COMPONENT_DIAGRAM;
1213: } else if (sPreferredDiagram
1214: .equals(DEPLOYMENT_DIAGRAM)) {
1215: nPreferredDiagramKind = IDiagramKind.DK_DEPLOYMENT_DIAGRAM;
1216: } else if (sPreferredDiagram
1217: .equals(SEQUENCE_DIAGRAM)) {
1218: nPreferredDiagramKind = IDiagramKind.DK_SEQUENCE_DIAGRAM;
1219: } else if (sPreferredDiagram
1220: .equals(STATE_DIAGRAM)) {
1221: nPreferredDiagramKind = IDiagramKind.DK_STATE_DIAGRAM;
1222: } else if (sPreferredDiagram
1223: .equals(USECASE_DIAGRAM)) {
1224: nPreferredDiagramKind = IDiagramKind.DK_USECASE_DIAGRAM;
1225: } else if (sPreferredDiagram
1226: .equals(ENTITY_DIAGRAM)) {
1227: nPreferredDiagramKind = IDiagramKind.DK_ENTITY_DIAGRAM;
1228: }
1229: }
1230: }
1231: }
1232: }
1233: }
1234: }
1235:
1236: retVal.setParamOne(sDisplayName);
1237: retVal.setParamTwo(sDescription);
1238: retVal.setParamThree(new Integer(nPreferredDiagramKind));
1239: return retVal;
1240: }
1241:
1242: public void saveCOLORREF(Node pElement, int nColorRef) {
1243: Color pColor = new Color(nColorRef);
1244: int nRed = pColor.getRed();
1245: int nGreen = pColor.getGreen();
1246: int nBlue = pColor.getBlue();
1247: String xsTemp = nRed + "," + nGreen + "," + nBlue;
1248:
1249: XMLManip.setAttributeValue(pElement, COLORVALUE, xsTemp);
1250: }
1251:
1252: public int readCOLORREF(Node pElement) {
1253: int nColor = 0;
1254:
1255: String xsTemp = XMLManip
1256: .getAttributeValue(pElement, COLORVALUE);
1257: if (xsTemp != null && xsTemp.length() > 0) {
1258: ETList<String> tokens = StringUtilities.splitOnDelimiter(
1259: xsTemp, ",");
1260: int nRed = Integer.parseInt(tokens.get(0));
1261: int nGreen = Integer.parseInt(tokens.get(1));
1262: int nBlue = Integer.parseInt(tokens.get(2));
1263:
1264: nColor = (new Color(nRed, nGreen, nBlue)).getRGB();
1265: }
1266: return nColor;
1267: }
1268: }
|