public Property buildAttribute2(final Object handle, final Object type) { if (!(handle instanceof Type)) { throw new IllegalArgumentException("handle must be instance of Type."); // $NON-NLS-1$ } if (type != null && !(type instanceof Type)) { throw new IllegalArgumentException("type must be instance of Type."); // $NON-NLS-1$ } if (UMLUtil.getOwnedAttributes((Type) handle) == null) { throw new UnsupportedOperationException( "The type " + handle.getClass() // $NON-NLS-1$ + " does not support owning attributes."); //$NON-NLS-1$ } RunnableClass run = new RunnableClass() { public void run() { Property property = createAttribute(); UMLUtil.getOwnedAttributes((Type) handle).add(property); if (type != null) { property.setType((Type) type); } property.setName("newAttr"); getParams().add(property); } }; ChangeCommand cmd = new ChangeCommand(modelImpl, run, "Create the attribute # of the type #"); editingDomain.getCommandStack().execute(cmd); cmd.setObjects(run.getParams().get(0), handle); return (Property) run.getParams().get(0); }