public void run(IAction action) {
StructuredSelection ss = (StructuredSelection) iSelection;
LocalVariableEditPart editPart = (LocalVariableEditPart) ss
.getFirstElement();
org.eclipse.emf.common.command.Command cmd = null;
EObject eObj = editPart.resolveSemanticElement();
if (eObj instanceof LocalVariable) {
LocalVariable lv = (LocalVariable) editPart
.resolveSemanticElement();
PrimitiveTypeReference ptr = ReferencesFactory.eINSTANCE
.createPrimitiveTypeReference();
if (action.getId().contains("AnyTypeID"))
ptr.setPrimitiveType(TypesFactory.eINSTANCE.createAny());
if (action.getId().contains("StringTypeID"))
ptr.setPrimitiveType(TypesFactory.eINSTANCE.createString());
if (action.getId().contains("BooleanTypeID"))
ptr.setPrimitiveType(TypesFactory.eINSTANCE.createBoolean());
if (action.getId().contains("IntegerTypeID"))
ptr.setPrimitiveType(TypesFactory.eINSTANCE.createInteger());
if (action.getId().contains("RealTypeID"))
ptr.setPrimitiveType(TypesFactory.eINSTANCE.createReal());
cmd = SetCommand.create(
editPart.getEditingDomain(),
eObj,
(EStructuralFeature) eObj.eClass().getEStructuralFeature(
"typeReference"), ptr);
editPart.getEditingDomain().getCommandStack().execute(cmd);
}
}