/** * Build a returnparameter. Removes all current return parameters from the operation and adds the * supplied parameter. The directionkind of the parameter will be return. The name will be equal * to the name of the last found return parameter or the default value "return" if no return * parameter was present in the operation. * * @param operation * @param newReturnParameter */ public void setReturnParameter(MOperation operation, MParameter newReturnParameter) { Iterator params = operation.getParameters().iterator(); String name = "return"; while (params.hasNext()) { MParameter parameter = (MParameter) params.next(); if ((parameter.getKind()).equals(MParameterDirectionKind.RETURN)) { operation.removeParameter(parameter); if (parameter.getName() != null || parameter.getName() == "") { name = parameter.getName(); } } } newReturnParameter.setName(name); newReturnParameter.setKind(MParameterDirectionKind.RETURN); operation.addParameter(0, newReturnParameter); // we set the listeners to the figs here too // it would be better to do that in the figs themselves Project p = ProjectBrowser.TheInstance.getProject(); Iterator it = p.findFigsForMember(operation).iterator(); while (it.hasNext()) { MElementListener listener = (MElementListener) it.next(); // UmlModelEventPump.getPump().removeModelEventListener(listener, newReturnParameter); UmlModelEventPump.getPump().addModelEventListener(listener, newReturnParameter); } }