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: /*
043: * File : MethodChangeFacility.java
044: * Created on : Nov 20, 2003
045: * Author : Aztec
046: */
047: package org.netbeans.modules.uml.core.roundtripframework;
048:
049: import org.netbeans.modules.uml.core.metamodel.core.foundation.IMultiplicity;
050: import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IClassifier;
051: import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation;
052: import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IParameter;
053: import org.netbeans.modules.uml.core.support.umlutils.ETList;
054:
055: /**
056: * @author Aztec
057: */
058: public class MethodChangeFacility extends RequestFacility implements
059: IMethodChangeFacility {
060:
061: /* (non-Javadoc)
062: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#added(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation)
063: */
064: public void added(IOperation pOp) {
065: // Stubbed in C++ code.
066:
067: }
068:
069: /* (non-Javadoc)
070: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#addOperation(java.lang.String, java.lang.String)
071: */
072: public IOperation addOperation(String sName, String sReturnType,
073: ETList<IParameter> pParameters, IClassifier pClassifier) {
074: if (sName == null || pClassifier == null)
075: return null;
076: // Create the new Operation
077: IOperation op = pClassifier.createOperation(sReturnType, sName);
078:
079: if (op != null) {
080: if (pParameters != null) {
081: // Add the parameters to the operation
082: op.setParameters(pParameters);
083: }
084:
085: // Add the Operation to the classifier
086: addOperationToClassifier(op, pClassifier);
087: added(op);
088: }
089: return op;
090: }
091:
092: /* (non-Javadoc)
093: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#addOperationToClassifier(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation, org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IClassifier)
094: */
095: public void addOperationToClassifier(IOperation pOperation,
096: IClassifier pClassifier) {
097: if (pOperation == null || pClassifier == null)
098: return;
099:
100: new RoundTripModeRestorer(RTMode.RTM_OFF);
101: pClassifier.addOperation(pOperation);
102:
103: added(pOperation);
104:
105: }
106:
107: /* (non-Javadoc)
108: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#changeName(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation, java.lang.String)
109: */
110: public void changeName(IOperation pOp, String sNewName,
111: boolean rtOffCreate, boolean rtOffPostProcessing) {
112: if (pOp == null)
113: return;
114:
115: RoundTripModeRestorer restorer = new RoundTripModeRestorer(
116: RoundTripUtils.getRTModeFromTurnOffFlag(rtOffCreate));
117:
118: pOp.setName(sNewName);
119:
120: restorer.setMode(RoundTripUtils
121: .getRTModeFromTurnOffFlag(rtOffPostProcessing));
122:
123: nameChanged(pOp);
124:
125: restorer.restoreOriginalMode();
126: }
127:
128: /* (non-Javadoc)
129: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#changeParameterMultiplicity(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IParameter, org.netbeans.modules.uml.core.metamodel.core.foundation.IMultiplicity, boolean, boolean)
130: */
131: public void changeParameterMultiplicity(IParameter pParameter,
132: IMultiplicity pMultiplicity, boolean rtOffWhileChanging,
133: boolean rtOffPostProcessing) {
134: if (pParameter == null || pMultiplicity == null)
135: return;
136:
137: RoundTripModeRestorer restorer = new RoundTripModeRestorer(
138: RoundTripUtils
139: .getRTModeFromTurnOffFlag(rtOffWhileChanging));
140:
141: RoundTripUtils.setParameterMultiplicity(pParameter,
142: pMultiplicity);
143:
144: restorer.restoreOriginalMode();
145:
146: }
147:
148: /* (non-Javadoc)
149: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#changeReturnTypeMultiplicity(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation, org.netbeans.modules.uml.core.metamodel.core.foundation.IMultiplicity, boolean, boolean)
150: */
151: public void changeReturnTypeMultiplicity(IOperation pOperation,
152: IMultiplicity pMultiplicity, boolean rtOffWhileChanging,
153: boolean rtOffPostProcessing) {
154: if (pOperation == null || pMultiplicity == null)
155: return;
156:
157: RoundTripModeRestorer restorer = new RoundTripModeRestorer(
158: RoundTripUtils
159: .getRTModeFromTurnOffFlag(rtOffWhileChanging));
160:
161: RoundTripUtils.setOperationReturnTypeMultiplicity(pOperation,
162: pMultiplicity);
163:
164: restorer.restoreOriginalMode();
165: }
166:
167: /* (non-Javadoc)
168: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#changeType(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation, java.lang.String)
169: */
170: public void changeType(IOperation pOp, String sNewType,
171: boolean rtOffWhileChanging, boolean rtOffPostProcessing) {
172: RoundTripModeRestorer restorer = new RoundTripModeRestorer(
173: RoundTripUtils
174: .getRTModeFromTurnOffFlag(rtOffWhileChanging));
175:
176: pOp.setReturnType2(sNewType);
177:
178: restorer.setMode(RoundTripUtils
179: .getRTModeFromTurnOffFlag(rtOffPostProcessing));
180: typeChanged(pOp);
181:
182: restorer.restoreOriginalMode();
183: }
184:
185: /* (non-Javadoc)
186: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#delete(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation)
187: */
188: public void delete(IOperation pOp) {
189: RoundTripModeRestorer restorer = new RoundTripModeRestorer(
190: RTMode.RTM_OFF);
191:
192: IClassifier pClassifier = pOp.getFeaturingClassifier();
193:
194: if (pClassifier != null) {
195: pClassifier.removeFeature(pOp);
196: }
197: pOp.delete();
198:
199: restorer.restoreOriginalMode();
200: }
201:
202: /* (non-Javadoc)
203: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#deleted(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation, org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IClassifier)
204: */
205: public void deleted(IOperation pOp, IClassifier pClassifier) {
206: // Stubbed in C++ code.
207: }
208:
209: /* (non-Javadoc)
210: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#nameChanged(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation)
211: */
212: public void nameChanged(IOperation pOp) {
213: // Stubbed in C++ code.
214: }
215:
216: /* (non-Javadoc)
217: * @see org.netbeans.modules.uml.core.roundtripframework.IMethodChangeFacility#typeChanged(org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IOperation)
218: */
219: public void typeChanged(IOperation pOp) {
220: // Stubbed in C++ code.
221: }
222:
223: }
|