001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.uml.core.metamodel.diagrams;
043:
044: public class DiagramValidation implements IDiagramValidation {
045: private boolean[] validationKinds = null;
046: private boolean[] validationResponse = null;
047: private boolean validateLinks = false;
048: private boolean validateNodes = false;
049:
050: public DiagramValidation() {
051: validationKinds = new boolean[7];
052: validationResponse = new boolean[7];
053: }
054:
055: /* (non-Javadoc)
056: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#addValidationKind(int)
057: */
058: public void addValidationKind(int nKind) {
059: if (nKind < validationKinds.length) {
060: validationKinds[nKind] = true;
061: }
062: }
063:
064: /* (non-Javadoc)
065: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#addValidationResponse(int)
066: */
067: public void addValidationResponse(int nResponse) {
068: if (nResponse < validationResponse.length) {
069: validationResponse[nResponse] = true;
070: }
071: }
072:
073: /* (non-Javadoc)
074: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#createGraphObjectValidation()
075: */
076: public IGraphObjectValidation createGraphObjectValidation() {
077: IGraphObjectValidation pLocal = new GraphObjectValidation();
078:
079: pLocal
080: .addValidationKind(IDiagramValidateKind.DVK_VALIDATE_DRAWENGINE);
081: pLocal
082: .addValidationKind(IDiagramValidateKind.DVK_VALIDATE_LINKENDS);
083: pLocal
084: .addValidationKind(IDiagramValidateKind.DVK_VALIDATE_CONNECTIONTOELEMENT);
085: pLocal
086: .addValidationKind(IDiagramValidateKind.DVK_VALIDATE_BRIDGES);
087: pLocal
088: .addValidationKind(IDiagramValidateKind.DVK_VALIDATE_RESYNC_DEEP);
089: pLocal.addValidationKind(IDiagramValidateKind.DVK_VALIDATE_ALL);
090: pLocal
091: .addValidationKind(IDiagramValidateKind.DVK_VALIDATE_NONE);
092:
093: return pLocal;
094: }
095:
096: /* (non-Javadoc)
097: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#getValidateLinks()
098: */
099: public boolean getValidateLinks() {
100: return validateLinks;
101: }
102:
103: /* (non-Javadoc)
104: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#getValidateNodes()
105: */
106: public boolean getValidateNodes() {
107: return validateNodes;
108: }
109:
110: /* (non-Javadoc)
111: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#getValidationKind(int)
112: */
113: public boolean getValidationKind(int nKind) {
114: if (!validationKinds[IDiagramValidateKind.DVK_VALIDATE_ALL]) {
115: return validationKinds[nKind];
116: }
117: return true;
118: }
119:
120: /* (non-Javadoc)
121: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#getValidationResponse(int)
122: */
123: public boolean getValidationResponse(int nKind) {
124: if (!validationResponse[IDiagramValidateResponse.DVRSP_VALIDATE_ALL]) {
125: return validationResponse[nKind];
126: }
127: return true;
128: }
129:
130: /* (non-Javadoc)
131: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#removeValidationKind(int)
132: */
133: public void removeValidationKind(int nKind) {
134: if (nKind < validationKinds.length) {
135: if (nKind == IDiagramValidateKind.DVK_VALIDATE_ALL) {
136: validationKinds = new boolean[7];
137: } else if (nKind != IDiagramValidateKind.DVK_VALIDATE_NONE) {
138: validationKinds[IDiagramValidateKind.DVK_VALIDATE_ALL] = false;
139: validationKinds[nKind] = false;
140: }
141: }
142: }
143:
144: /* (non-Javadoc)
145: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#removeValidationResponse(int)
146: */
147: public void removeValidationResponse(int nKind) {
148: if (nKind < validationKinds.length) {
149: validationResponse[nKind] = false;
150: }
151: }
152:
153: /* (non-Javadoc)
154: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#reset()
155: */
156: public void reset() {
157: validationKinds = new boolean[7];
158: validationResponse = new boolean[7];
159: validateLinks = false;
160: validateNodes = false;
161:
162: }
163:
164: /* (non-Javadoc)
165: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#setValidateLinks(boolean)
166: */
167: public void setValidateLinks(boolean value) {
168: validateLinks = value;
169: }
170:
171: /* (non-Javadoc)
172: * @see org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramValidation#setValidateNodes(boolean)
173: */
174: public void setValidateNodes(boolean value) {
175: validateNodes = value;
176: }
177:
178: }
|